summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java32
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java29
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java121
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogicProvider.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java85
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java24
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java45
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeBusinessLogic.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java17
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java234
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java16
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByActionStatusComponentException.java58
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByResponseFormatComponentException.java44
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ComponentException.java76
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/ExceptionUtils.java28
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ExternalRefsMergeBL.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/UserValidations.java29
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java22
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/exception/ComponentExceptionMapper.java27
30 files changed, 773 insertions, 332 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
index fb7843430f..addd9d2407 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
@@ -1,10 +1,32 @@
+/*-
+ * ============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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.csar;
import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.impl.BaseBusinessLogic;
import org.openecomp.sdc.be.components.impl.CsarValidationUtils;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.NodeTypeInfo;
@@ -51,7 +73,7 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
} else if (status != StorageOperationStatus.OK) {
log.debug("Failed to validate uniqueness of CsarUUID {} for resource", csarUUID,
resource.getSystemName());
- throw new ComponentException(componentsUtils.convertFromStorageResponse(status));
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(status));
}
}
@@ -86,11 +108,11 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
private String logAndThrowComponentException(ResponseFormat responseFormat, String logMessage, String ...params) {
log.debug(logMessage, params, responseFormat);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
private ImmutablePair<String,String> throwComponentException(ResponseFormat responseFormat) {
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
private Either<ImmutablePair<String, String>, ResponseFormat> validateAndParseCsar(Resource resource, User user,
@@ -142,6 +164,6 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
private void auditAndThrowException(Resource resource, User user, AuditingActionEnum auditingAction, ActionStatus status, String... params){
ResponseFormat errorResponse = componentsUtils.getResponseFormat(status, params);
componentsUtils.auditResource(errorResponse, user, resource, auditingAction);
- throw new ComponentException(errorResponse);
+ throw new ByResponseFormatComponentException(errorResponse);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
index 53adc3c970..72efb1176f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
@@ -1,8 +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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.csar;
import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.Resource;
@@ -94,7 +115,7 @@ public class CsarInfo {
} else {
log.debug("Failed to validate complex VFC {}. Loop detected, VSP {}. ", nodeName,
getVfResourceName());
- throw new ComponentException(ActionStatus.CFVC_LOOP_DETECTED,
+ throw new ByActionStatusComponentException(ActionStatus.CFVC_LOOP_DETECTED,
getVfResourceName(), nodeName);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index e9b5baa49e..04df614b9d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -1,3 +1,24 @@
+/*-
+ * ============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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.csar;
import com.google.common.collect.Lists;
@@ -11,7 +32,7 @@ import org.openecomp.sdc.be.components.impl.AnnotationBusinessLogic;
import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic;
import org.openecomp.sdc.be.components.impl.ImportUtils;
import org.openecomp.sdc.be.components.impl.NodeFilterUploadCreator;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
@@ -845,17 +866,17 @@ public class YamlTemplateParsingHandler {
private Map<String, Object> failIfNoNodeTemplates(String fileName) {
titanDao.rollback();
- throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, fileName);
+ throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, fileName);
}
private Object failIfNotTopologyTemplate(String fileName) {
titanDao.rollback();
- throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, fileName);
+ throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, fileName);
}
private void rollbackWithException(ActionStatus actionStatus, String... params) {
titanDao.rollback();
- throw new ComponentException(actionStatus, params);
+ throw new ByActionStatusComponentException(actionStatus, params);
}
private void failOnMissingCapabilityTypes(GroupDefinition groupDefinition, List<String> missingCapTypes) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java
index 70898fbec2..3cf520d30e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java
@@ -1,8 +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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.impl;
import com.google.common.annotations.VisibleForTesting;
import fj.data.Either;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.validation.AccessValidations;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
@@ -47,7 +68,7 @@ public class ArchiveBusinessLogic {
Either<List<String>, ActionStatus> result = this.archiveOperation.archiveComponent(componentId);
if (result.isRight()){
- throw new ComponentException(result.right().value(), componentId);
+ throw new ByActionStatusComponentException(result.right().value(), componentId);
}
this.auditAction(ArchiveOperation.Action.ARCHIVE, result.left().value(), user, containerComponentType);
}
@@ -56,7 +77,7 @@ public class ArchiveBusinessLogic {
User user = accessValidations.userIsAdminOrDesigner(userId, containerComponentType + "_RESTORE");
Either<List<String>, ActionStatus> result = this.archiveOperation.restoreComponent(componentId);
if (result.isRight()){
- throw new ComponentException(result.right().value(), componentId);
+ throw new ByActionStatusComponentException(result.right().value(), componentId);
}
this.auditAction(ArchiveOperation.Action.RESTORE, result.left().value(), user, containerComponentType);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index aef13eea4c..f23057cad0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -34,7 +36,8 @@ import org.openecomp.sdc.be.components.ArtifactsResolver;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.artifact.ArtifactTypeToPayloadTypeSelector;
import org.openecomp.sdc.be.components.impl.artifact.PayloadTypeEnum;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction.LifecycleChanceActionEnum;
@@ -3637,17 +3640,25 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
User user;
try{
user = validateUserExists(userId, auditingAction.getName(), inTransaction);
- } catch(ComponentException e){
- user = new User();
- user.setUserId(userId);
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat() :
- componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
- handleAuditing(auditingAction, null, componentId, user, null, null, artifactId, responseFormat, componentType, null);
+ } catch(ByResponseFormatComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
+ handleComponentException(auditingAction, componentId, artifactId, responseFormat, componentType, userId);
+ throw e;
+ } catch(ByActionStatusComponentException e){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ handleComponentException(auditingAction, componentId, artifactId, responseFormat, componentType, userId);
throw e;
}
return Either.left(user);
}
+ private void handleComponentException(AuditingActionEnum auditingAction, String componentId, String artifactId,
+ ResponseFormat responseFormat, ComponentTypeEnum componentType, String userId){
+ User user = new User();
+ user.setUserId(userId);
+ handleAuditing(auditingAction, null, componentId, user, null, null, artifactId, responseFormat, componentType, null);
+ }
+
protected AuditingActionEnum detectAuditingType(ArtifactOperationInfo operation, String origMd5) {
AuditingActionEnum auditingAction = null;
switch (operation.getArtifactOperationEnum()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 643b9462bc..c77223ba59 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -31,7 +33,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
@@ -253,7 +255,7 @@ public abstract class BaseBusinessLogic {
private Boolean logAndThrowException(ActionStatus status, String componentId, String name){
log.debug(FAILED_TO_LOCK_COMPONENT_ERROR, componentId, status);
- throw new ComponentException(status, name);
+ throw new ByActionStatusComponentException(status, name);
}
private ResponseFormat logAndConvertError(ActionStatus status, String componentId, String name){
@@ -372,12 +374,12 @@ public abstract class BaseBusinessLogic {
if (type == ToscaPropertyType.LIST || type == ToscaPropertyType.MAP) {
if (property.getSchema() == null) {
log.debug(SCHEMA_DOESN_T_EXISTS_FOR_PROPERTY_OF_TYPE, type);
- throw new ComponentException(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE));
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE));
}
PropertyDataDefinition innerProperty = property.getSchema().getProperty();
if (innerProperty == null) {
log.debug(PROPERTY_IN_SCHEMA_DEFINITION_INSIDE_PROPERTY_OF_TYPE_DOESN_T_EXIST, type);
- throw new ComponentException(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE));
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE));
}
innerType = innerProperty.getType();
}
@@ -621,7 +623,7 @@ public abstract class BaseBusinessLogic {
}
private void failOnIllegalArgument() {
- throw new ComponentException(
+ throw new ByActionStatusComponentException(
componentsUtils.convertFromStorageResponse(
DaoStatusConverter.convertTitanStatusToStorageStatus(TitanOperationStatus.ILLEGAL_ARGUMENT)));
}
@@ -711,7 +713,7 @@ public abstract class BaseBusinessLogic {
protected void rollbackWithException(ActionStatus actionStatus, String... params) {
titanDao.rollback();
- throw new ComponentException(actionStatus, params);
+ throw new ByActionStatusComponentException(actionStatus, params);
}
public <T extends ToscaDataDefinition> Either<List<T>, ResponseFormat> declareProperties(String userId, String componentId,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java
index 773dc639a9..d2f845cc00 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -23,7 +25,7 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.model.ToscaTypeImportData;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -399,7 +401,7 @@ public class CommonImportManager {
TypeOperations<T> typeOperations) {
Map<String, Object> fieldMap = convertToFieldMap(toscaTypesYml);
if (fieldMap==null) {
- throw new ComponentException(ActionStatus.INVALID_YAML_FILE);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML_FILE);
}
List<T> elementTypes = createTypesFromToscaJsonMap(createApi, fieldMap);
return createTypesByDao(elementTypes, typeOperations);
@@ -416,7 +418,7 @@ public class CommonImportManager {
ToscaTypeMetadata typeMetaData = toscaTypeMetadata.get(toscaType);
if (typeMetaData == null) {
log.debug("failing while trying to associate metadata for type {}. type not exist", toscaType);
- throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
toscaTypeDefinition.setIcon(typeMetaData.getIcon());
toscaTypeDefinition.setName(typeMetaData.getDisplayName());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index acf28c2455..dcd0c7b7f0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -31,7 +33,8 @@ import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -119,15 +122,18 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
protected User validateUser(User user, String ecompErrorContext, Component component, AuditingActionEnum auditAction, boolean inTransaction) {
User validatedUser;
ResponseFormat responseFormat;
- try{
+ try {
validateUserNotEmpty(user, ecompErrorContext);
validatedUser = validateUserExists(user, ecompErrorContext, inTransaction);
- } catch(ComponentException e){
- if(e.getActionStatus()== ActionStatus.MISSING_INFORMATION){
+ } catch(ByActionStatusComponentException e){
+ if(e.getActionStatus() == ActionStatus.MISSING_INFORMATION){
user.setUserId("UNKNOWN");
}
- responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
- : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ componentsUtils.auditComponentAdmin(responseFormat, user, component, auditAction, component.getComponentType());
+ throw e;
+ } catch(ByResponseFormatComponentException e){
+ responseFormat = e.getResponseFormat();
componentsUtils.auditComponentAdmin(responseFormat, user, component, auditAction, component.getComponentType());
throw e;
}
@@ -139,26 +145,34 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
roles.add(Role.ADMIN);
roles.add(Role.DESIGNER);
}
- try{
+ try {
validateUserRole(user, roles);
- } catch(ComponentException e){
- String commentStr = null;
- String distrStatus = null;
- ComponentTypeEnum componentType = component.getComponentType();
- if (componentType.equals(ComponentTypeEnum.SERVICE)) {
- distrStatus = ((ServiceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition()).getDistributionStatus();
- commentStr = comment;
- }
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
- : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
- componentsUtils.auditComponent(responseFormat, user, component, auditAction, new ResourceCommonInfo(componentType.getValue()),
- ResourceVersionInfo.newBuilder().distributionStatus(distrStatus).build(),
- ResourceVersionInfo.newBuilder().distributionStatus(distrStatus).build(),
- commentStr, null, null);
+ }catch (ByActionStatusComponentException e) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ handleComponentException(component, comment, responseFormat, user, auditAction);
+ throw e;
+ }catch (ByResponseFormatComponentException e) {
+ ResponseFormat responseFormat = e.getResponseFormat();
+ handleComponentException(component, comment, responseFormat, user, auditAction);
throw e;
}
}
+ private void handleComponentException(Component component, String comment, ResponseFormat responseFormat,
+ User user, AuditingActionEnum auditAction){
+ String commentStr = null;
+ String distrStatus = null;
+ ComponentTypeEnum componentType = component.getComponentType();
+ if (componentType.equals(ComponentTypeEnum.SERVICE)) {
+ distrStatus = ((ServiceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition()).getDistributionStatus();
+ commentStr = comment;
+ }
+ componentsUtils.auditComponent(responseFormat, user, component, auditAction, new ResourceCommonInfo(componentType.getValue()),
+ ResourceVersionInfo.newBuilder().distributionStatus(distrStatus).build(),
+ ResourceVersionInfo.newBuilder().distributionStatus(distrStatus).build(),
+ commentStr, null, null);
+ }
+
protected void validateComponentName(User user, Component component, AuditingActionEnum actionEnum) {
ComponentTypeEnum type = component.getComponentType();
String componentName = component.getName();
@@ -166,21 +180,21 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.debug("component name is empty");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_COMPONENT_NAME, type.getValue());
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
- throw new ComponentException(ActionStatus.MISSING_COMPONENT_NAME, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.MISSING_COMPONENT_NAME, type.getValue());
}
if (!ValidationUtils.validateComponentNameLength(componentName)) {
log.debug("Component name exceeds max length {} ", ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, type.getValue(), "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
- throw new ComponentException(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT,type.getValue(), "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT,type.getValue(), "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
}
if (!validateTagPattern(componentName)) {
log.debug("Component name {} has invalid format", componentName);
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_COMPONENT_NAME, type.getValue());
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
- throw new ComponentException(ActionStatus.INVALID_COMPONENT_NAME, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_COMPONENT_NAME, type.getValue());
}
component.setNormalizedName(ValidationUtils.normaliseComponentName(componentName));
component.setSystemName(ValidationUtils.convertToSystemName(componentName));
@@ -192,15 +206,18 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
if (!ValidationUtils.validateStringNotEmpty(description)) {
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_DESCRIPTION, type.getValue());
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_DESCRIPTION, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_DESCRIPTION, type.getValue());
}
description = cleanUpText(description);
- try{
+ try {
validateComponentDescription(description, type);
- } catch(ComponentException e){
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
- : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ } catch(ByActionStatusComponentException e){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ componentsUtils.auditComponentAdmin(responseFormat, user, component, actionEnum, type);
+ throw e;
+ } catch(ByResponseFormatComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
componentsUtils.auditComponentAdmin(responseFormat, user, component, actionEnum, type);
throw e;
}
@@ -210,11 +227,11 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
private void validateComponentDescription(String description, ComponentTypeEnum type) {
if (description != null) {
if (!ValidationUtils.validateDescriptionLength(description)) {
- throw new ComponentException(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, type.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, type.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
}
if (!ValidationUtils.validateIsEnglish(description)) {
- throw new ComponentException(ActionStatus.COMPONENT_INVALID_DESCRIPTION, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_INVALID_DESCRIPTION, type.getValue());
}
}
}
@@ -254,7 +271,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.info("contact is missing.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_CONTACT, type.getValue());
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_CONTACT, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_CONTACT, type.getValue());
}
validateContactId(contactId, user, component, actionEnum, type);
}
@@ -264,7 +281,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.info("contact is invalid.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INVALID_CONTACT, type.getValue());
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
- throw new ComponentException(ActionStatus.COMPONENT_INVALID_CONTACT, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_INVALID_CONTACT, type.getValue());
}
}
@@ -317,13 +334,16 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.info("icon is missing.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_ICON, type.getValue());
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_ICON, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_ICON, type.getValue());
}
try {
validateIcon(icon, type);
- } catch(ComponentException e){
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
- : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ } catch(ByActionStatusComponentException e){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ componentsUtils.auditComponentAdmin(responseFormat, user, component, actionEnum, type);
+ throw e;
+ } catch(ByResponseFormatComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
componentsUtils.auditComponentAdmin(responseFormat, user, component, actionEnum, type);
throw e;
}
@@ -333,12 +353,12 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
if (icon != null) {
if (!ValidationUtils.validateIconLength(icon)) {
log.debug("icon exceeds max length");
- throw new ComponentException(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, type.getValue(), "" + ValidationUtils.ICON_MAX_LENGTH);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, type.getValue(), "" + ValidationUtils.ICON_MAX_LENGTH);
}
if (!ValidationUtils.validateIcon(icon)) {
log.info("icon is invalid.");
- throw new ComponentException(ActionStatus.COMPONENT_INVALID_ICON, type.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_INVALID_ICON, type.getValue());
}
}
}
@@ -347,9 +367,12 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
List<String> tagsList = component.getTags();
try {
validateComponentTags(tagsList, component.getName(), component.getComponentType(), user, component, actionEnum);
- } catch(ComponentException e){
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
- : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ } catch(ByActionStatusComponentException e){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ componentsUtils.auditComponentAdmin(responseFormat, user, component, actionEnum, component.getComponentType());
+ throw e;
+ } catch(ByResponseFormatComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
componentsUtils.auditComponentAdmin(responseFormat, user, component, actionEnum, component.getComponentType());
throw e;
}
@@ -367,7 +390,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.debug("tag length exceeds limit {}", ValidationUtils.TAG_MAX_LENGTH);
responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT, "" + ValidationUtils.TAG_MAX_LENGTH);
componentsUtils.auditComponentAdmin(responseFormat, user, component, action, componentType);
- throw new ComponentException(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT, "" + ValidationUtils.TAG_MAX_LENGTH);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT, "" + ValidationUtils.TAG_MAX_LENGTH);
}
if (validateTagPattern(tag)) {
if (!includesComponentName) {
@@ -377,7 +400,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.debug("invalid tag {}", tag);
responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_FIELD_FORMAT, componentType.getValue(), TAG_FIELD_LABEL);
componentsUtils.auditComponentAdmin(responseFormat, user, component, action, componentType);
- throw new ComponentException(ActionStatus.INVALID_FIELD_FORMAT, componentType.getValue(), TAG_FIELD_LABEL);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_FIELD_FORMAT, componentType.getValue(), TAG_FIELD_LABEL);
}
tagListSize += tag.length() + 1;
}
@@ -389,18 +412,18 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.debug("tags must include component name");
responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
componentsUtils.auditComponentAdmin(responseFormat, user, component, action, componentType);
- throw new ComponentException(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
}
if (!ValidationUtils.validateTagListLength(tagListSize)) {
log.debug("overall tags length exceeds limit {}", ValidationUtils.TAG_LIST_MAX_LENGTH);
responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
componentsUtils.auditComponentAdmin(responseFormat, user, component, action, componentType);
- throw new ComponentException(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
}
} else {
responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_TAGS);
componentsUtils.auditComponentAdmin(responseFormat, user, component, action, componentType);
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_TAGS);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_TAGS);
}
}
@@ -831,7 +854,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
Either<Resource, ResponseFormat> genericTypeEither = this.genericTypeBusinessLogic.fetchDerivedFromGenericType(component);
if(genericTypeEither.isRight()){
log.debug("Failed to fetch latest generic type for component {} of type", component.getName(), component.assetType());
- throw new ComponentException(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType());
+ throw new ByActionStatusComponentException(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType());
}
Resource genericTypeResource = genericTypeEither.left().value();
component.setDerivedFromGenericInfo(genericTypeResource);
@@ -1095,7 +1118,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
public List<GroupDefinition> throwComponentException(ResponseFormat responseFormat) {
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogicProvider.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogicProvider.java
index 3025084239..8255de63d6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogicProvider.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogicProvider.java
@@ -1,6 +1,27 @@
+/*-
+ * ============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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.impl;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -30,7 +51,7 @@ public class ComponentBusinessLogicProvider {
return resourceBusinessLogic;
default:
BeEcompErrorManager.getInstance().logBeSystemError("getComponentBL");
- throw new ComponentException(ActionStatus.INVALID_CONTENT_PARAM, componentTypeEnum.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT_PARAM, componentTypeEnum.getValue());
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java
index 7f17d44f57..4e7f86aed6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CompositionBusinessLogic.java
@@ -16,12 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -75,7 +77,7 @@ public class CompositionBusinessLogic {
}
private List<ComponentInstance> throwComponentException(ResponseFormat responseFormat) {
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
private void setRelativePosition(Entry<ImmutablePair<Double, Double>, ComponentInstance> entry) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
index 8e9f65fce1..746f4e9c27 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -24,6 +26,8 @@ import fj.data.Either;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
@@ -393,13 +397,15 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
User user;
try{
user = validateUserExists(userId, "createSubCategory", false);
- } catch(ComponentException e){
- log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat() :
- componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
- user = new User();
- user.setUserId(userId);
- handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction, componentType);
+ } catch(ByActionStatusComponentException e){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ handleComponentException(userId, auditingAction, componentType, parentCategoryName, origSubCategoryName,
+ responseFormat);
+ throw e;
+ } catch(ByResponseFormatComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
+ handleComponentException(userId, auditingAction, componentType, parentCategoryName, origSubCategoryName,
+ responseFormat);
throw e;
}
if (componentTypeEnum == null) {
@@ -512,6 +518,35 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
return Either.left(subCategoryCreated);
}
+ private void handleComponentException(String userId, AuditingActionEnum auditingAction, String componentType,
+ String parentCategoryName, String origSubCategoryName, ResponseFormat responseFormat) {
+ User user;
+ log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
+ user = new User();
+ user.setUserId(userId);
+ handleCategoryAuditing(responseFormat, user, parentCategoryName, origSubCategoryName, auditingAction,
+ componentType);
+ }
+
+ private void handleComponentException(GroupingDefinition grouping, String userId, AuditingActionEnum auditingAction,
+ String componentType, String parentCategoryName, String parentSubCategoryName, ResponseFormat responseFormat) {
+ User user;
+ log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
+ user = new User();
+ user.setUserId(userId);
+ String groupingNameForAudit = grouping == null ? null : grouping.getName();
+ handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, groupingNameForAudit,
+ auditingAction, componentType);
+ }
+
+ private void handleComponentException(String componentType, String userId, ResponseFormat responseFormat) {
+ User user;
+ user = new User();
+ user.setUserId(userId);
+ log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
+ componentsUtils.auditGetCategoryHierarchy(user, componentType, responseFormat);
+ }
+
public Either<GroupingDefinition, ResponseFormat> createGrouping(GroupingDefinition grouping, String componentTypeParamName, String grandParentCategoryId, String parentSubCategoryId, String userId) {
AuditingActionEnum auditingAction = AuditingActionEnum.ADD_GROUPING;
@@ -525,14 +560,16 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
User user;
try{
user = validateUserExists(userId, "create Grouping", false);
- } catch(ComponentException e){
- log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat() :
- componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
- user = new User();
- user.setUserId(userId);
- String groupingNameForAudit = grouping == null ? null : grouping.getName();
- handleCategoryAuditing(responseFormat, user, parentCategoryName, parentSubCategoryName, groupingNameForAudit, auditingAction, componentType);
+ } catch(ByResponseFormatComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
+ handleComponentException(grouping, userId, auditingAction, componentType, parentCategoryName,
+ parentSubCategoryName,
+ responseFormat);
+ throw e;
+ } catch(ByActionStatusComponentException e){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ handleComponentException(grouping, userId, auditingAction, componentType, parentCategoryName,
+ parentSubCategoryName, responseFormat);
throw e;
}
@@ -672,6 +709,8 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
return Either.left(groupingCreated);
}
+
+
public Either<List<CategoryDefinition>, ResponseFormat> getAllCategories(String componentType, String userId) {
ResponseFormat responseFormat;
User user = new User();
@@ -683,13 +722,13 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
}
try {
user = validateUserExists(userId, "get All Categories", false);
- } catch (ComponentException e){
- user = new User();
- user.setUserId(userId);
- log.debug(VALIDATION_OF_USER_FAILED_USER_ID, userId);
- responseFormat = e.getResponseFormat() != null ? e.getResponseFormat():
- componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
- componentsUtils.auditGetCategoryHierarchy(user, componentType, responseFormat);
+ } catch (ByActionStatusComponentException e){
+ responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ handleComponentException(componentType, userId, responseFormat);
+ throw e;
+ } catch (ByResponseFormatComponentException e){
+ responseFormat = e.getResponseFormat();
+ handleComponentException(componentType, userId, responseFormat);
throw e;
}
ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
@@ -713,6 +752,8 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
return Either.left(categories);
}
+
+
public Either<UiCategories, ResponseFormat> getAllCategories(String userId) {
ResponseFormat responseFormat;
UiCategories categories = new UiCategories();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index c8266efd42..9bab155cdf 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -27,6 +29,8 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.lock.LockingTransactional;
import org.openecomp.sdc.be.components.impl.policy.PolicyTargetsUpdateHandler;
@@ -1028,7 +1032,7 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
private void validateGroupTypePerComponent(String groupType, Component component) {
String specificType = component.getComponentMetadataDefinition().getMetadataDataDefinition().getActualComponentType();
if (!component.isTopologyTemplate()) {
- throw new ComponentException(ActionStatus.GROUP_TYPE_ILLEGAL_PER_COMPONENT, groupType,
+ throw new ByActionStatusComponentException(ActionStatus.GROUP_TYPE_ILLEGAL_PER_COMPONENT, groupType,
specificType);
}
Map<String, Set<String>> excludedGroupTypesMap = ConfigurationManager.getConfigurationManager().getConfiguration()
@@ -1037,7 +1041,7 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
if (MapUtils.isNotEmpty(excludedGroupTypesMap) && StringUtils.isNotEmpty(specificType)) {
Set<String> excludedGroupTypesPerComponent = excludedGroupTypesMap.get(specificType);
if (excludedGroupTypesPerComponent!=null && excludedGroupTypesPerComponent.contains(groupType)) {
- throw new ComponentException(ActionStatus.GROUP_TYPE_ILLEGAL_PER_COMPONENT, groupType, specificType);
+ throw new ByActionStatusComponentException(ActionStatus.GROUP_TYPE_ILLEGAL_PER_COMPONENT, groupType, specificType);
}
}
}
@@ -1077,13 +1081,13 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
private void assertNewNameIsValidAndUnique(String currentGroupName, String updatedGroupName, Component component) {
if (!ValidationUtils.validateResourceInstanceNameLength(updatedGroupName)) {
- throw new ComponentException(ActionStatus.EXCEEDS_LIMIT, "Group Name", ValidationUtils.RSI_NAME_MAX_LENGTH.toString());
+ throw new ByActionStatusComponentException(ActionStatus.EXCEEDS_LIMIT, "Group Name", ValidationUtils.RSI_NAME_MAX_LENGTH.toString());
}
if (!ValidationUtils.validateResourceInstanceName(updatedGroupName)) {
- throw new ComponentException(ActionStatus.INVALID_VF_MODULE_NAME, updatedGroupName);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_VF_MODULE_NAME, updatedGroupName);
}
if (!ComponentValidations.validateNameIsUniqueInComponent(currentGroupName, updatedGroupName, component)) {
- throw new ComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, "Group", updatedGroupName);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, "Group", updatedGroupName);
}
}
@@ -1106,21 +1110,21 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
private List<GroupDefinition> onFailedGroupDBOperation(ResponseFormat responseFormat) {
titanDao.rollback();
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
private GroupDefinition onFailedUpdateGroupDBOperation(ResponseFormat responseFormat) {
titanDao.rollback();
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
private GroupDefinition onGroupNotFoundInComponentError(Component component, String groupId) {
- throw new ComponentException(ActionStatus.GROUP_IS_MISSING, groupId,
+ throw new ByActionStatusComponentException(ActionStatus.GROUP_IS_MISSING, groupId,
component.getSystemName(), getComponentTypeForResponse(component));
}
private GroupTypeDefinition onGroupTypeNotFound(Component component) {
- throw new ComponentException(ActionStatus.GROUP_TYPE_IS_INVALID, component.getSystemName(),
+ throw new ByActionStatusComponentException(ActionStatus.GROUP_TYPE_IS_INVALID, component.getSystemName(),
component.getComponentType().toString());
}
@@ -1129,7 +1133,7 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
ActionStatus actionStatus = policyTargetsUpdateHandler.removePoliciesTargets(component, groupId, PolicyTargetType.GROUPS);
if (ActionStatus.OK != actionStatus) {
titanDao.rollback();
- throw new ComponentException(actionStatus, groupId);
+ throw new ByActionStatusComponentException(actionStatus, groupId);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java
index 855e55c415..b234bb6bd6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java
@@ -1,10 +1,31 @@
+/*-
+ * ============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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.impl;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.lock.LockingTransactional;
import org.openecomp.sdc.be.components.validation.AccessValidations;
import org.openecomp.sdc.be.components.validation.ComponentValidations;
@@ -81,24 +102,24 @@ public class GroupBusinessLogicNew {
private ComponentInstance getComponentInstance(Component component, String memberUniqueId) {
return componentValidations.getComponentInstance(component, memberUniqueId)
- .orElseThrow(() -> new ComponentException(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER,
+ .orElseThrow(() -> new ByActionStatusComponentException(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER,
memberUniqueId, "",
component.getActualComponentType(), component.getSystemName()));
}
private GroupDefinition getGroup(Component component, String groupUniqueId) {
return component.getGroupById(groupUniqueId)
- .orElseThrow(() -> new ComponentException(ActionStatus.GROUP_IS_MISSING,
+ .orElseThrow(() -> new ByActionStatusComponentException(ActionStatus.GROUP_IS_MISSING,
component.getSystemName(), component.getActualComponentType()));
}
private void validateUpdatedPropertiesAndSetEmptyValues(GroupDefinition originalGroup, List<GroupProperty> groupPropertiesToUpdate) {
if (CollectionUtils.isEmpty(groupPropertiesToUpdate)) {
- throw new ComponentException(ActionStatus.PROPERTY_NOT_FOUND, StringUtils.EMPTY);
+ throw new ByActionStatusComponentException(ActionStatus.PROPERTY_NOT_FOUND, StringUtils.EMPTY);
}
if (CollectionUtils.isEmpty(originalGroup.getProperties())) {
- throw new ComponentException(ActionStatus.PROPERTY_NOT_FOUND, groupPropertiesToUpdate.get(NumberUtils.INTEGER_ZERO).getName());
+ throw new ByActionStatusComponentException(ActionStatus.PROPERTY_NOT_FOUND, groupPropertiesToUpdate.get(NumberUtils.INTEGER_ZERO).getName());
}
Map<String, GroupProperty> originalProperties = originalGroup.convertToGroupProperties()
.stream()
@@ -108,10 +129,10 @@ public class GroupBusinessLogicNew {
for (GroupProperty gp : groupPropertiesToUpdate) {
String updatedPropertyName = gp.getName();
if (!originalProperties.containsKey(updatedPropertyName)) {
- throw new ComponentException(ActionStatus.PROPERTY_NOT_FOUND, updatedPropertyName);
+ throw new ByActionStatusComponentException(ActionStatus.PROPERTY_NOT_FOUND, updatedPropertyName);
}
if (!isOnlyGroupPropertyValueChanged(gp, originalProperties.get(updatedPropertyName))) {
- throw new ComponentException(ActionStatus.INVALID_PROPERTY, updatedPropertyName);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY, updatedPropertyName);
}
if (StringUtils.isEmpty(gp.getValue())) {
gp.setValue(originalProperties.get(updatedPropertyName).getDefaultValue());
@@ -175,15 +196,15 @@ public class GroupBusinessLogicNew {
if (isPropertyChanged(newValues, parentValues, PropertyDefinition.PropertyNames.INITIAL_COUNT)
&& (latestInitialCount > latestMaxInstances || latestInitialCount < latestMinInstances)) {
- throw new ComponentException(ActionStatus.INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE, PropertyDefinition.PropertyNames.INITIAL_COUNT.getPropertyName(), String.valueOf(latestMinInstances), String.valueOf(latestMaxInstances));
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE, PropertyDefinition.PropertyNames.INITIAL_COUNT.getPropertyName(), String.valueOf(latestMinInstances), String.valueOf(latestMaxInstances));
}
if (isPropertyChanged(newValues, parentValues, PropertyDefinition.PropertyNames.MAX_INSTANCES) &&
latestMaxInstances < latestInitialCount) {
- throw new ComponentException(ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER, PropertyDefinition.PropertyNames.MAX_INSTANCES.getPropertyName(), "higher", String.valueOf(latestInitialCount));
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER, PropertyDefinition.PropertyNames.MAX_INSTANCES.getPropertyName(), "higher", String.valueOf(latestInitialCount));
}
if (isPropertyChanged(newValues, parentValues, PropertyDefinition.PropertyNames.MIN_INSTANCES) &&
latestMinInstances > latestInitialCount) {
- throw new ComponentException(ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER, PropertyDefinition.PropertyNames.MIN_INSTANCES.getPropertyName(), "lower", String.valueOf(latestInitialCount));
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER, PropertyDefinition.PropertyNames.MIN_INSTANCES.getPropertyName(), "lower", String.valueOf(latestInitialCount));
}
}
@@ -218,11 +239,11 @@ public class GroupBusinessLogicNew {
final String groupTypeValue = groupPropertyToUpdate.getValue();
if (!org.apache.commons.lang3.StringUtils.isEmpty(groupTypeValue)) {
if (!ValidationUtils.validateDescriptionLength(groupTypeValue)) {
- throw new ComponentException(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
NodeTypeEnum.Property.getName(),
String.valueOf(ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH));
} else if (!ValidationUtils.validateIsEnglish(groupTypeValue)) {
- throw new ComponentException(ActionStatus.COMPONENT_INVALID_DESCRIPTION,
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_INVALID_DESCRIPTION,
NodeTypeEnum.Property.getName());
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeBusinessLogic.java
index 99c4e9e181..5bc0e5e3c3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeBusinessLogic.java
@@ -1,7 +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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.impl;
import org.apache.commons.lang3.StringUtils;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -62,9 +83,9 @@ public class GroupTypeBusinessLogic {
private GroupTypeDefinition failOnGetGroupType(StorageOperationStatus status, String groupType) {
titanDao.rollback();
if (status == StorageOperationStatus.NOT_FOUND) {
- throw new ComponentException(ActionStatus.GROUP_TYPE_IS_INVALID, groupType);
+ throw new ByActionStatusComponentException(ActionStatus.GROUP_TYPE_IS_INVALID, groupType);
} else {
- throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index a98694626f..0936472bb7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -36,6 +38,7 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.property.PropertyDeclarationOrchestrator;
import org.openecomp.sdc.be.components.validation.ComponentValidations;
@@ -430,7 +433,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
return result;
- } catch (ComponentException e) {
+ } catch (ByResponseFormatComponentException e) {
log.error("#createMultipleInputs: Exception thrown: ", e);
result = Either.right(e.getResponseFormat());
return result;
@@ -491,7 +494,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
toscaOperationFacade.addDataTypesToComponent(dataTypesMap, componentId);
if (dataTypeResult.isRight()) {
log.debug("#createListInput: DataType creation failed.");
- throw new ComponentException(componentsUtils.getResponseFormat(dataTypeResult.right().value()));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(dataTypeResult.right().value()));
}
// create list input
@@ -504,7 +507,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
result = createListInputsInGraph(listInputMap, dataTypesMap, component);
if (result.isRight()) {
log.debug("#createListInput: createListInputsInGraph failed.");
- throw new ComponentException(result.right().value());
+ throw new ByResponseFormatComponentException(result.right().value());
}
// update properties
@@ -517,7 +520,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
return result;
- } catch (ComponentException e) {
+ } catch (ByResponseFormatComponentException e) {
log.error("#createListInput: Exception thrown", e);
result = Either.right(e.getResponseFormat());
return result;
@@ -569,7 +572,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
return Either.left(component);
}).left().bind(component -> validateCanWorkOnComponent(component, userId).left().map(result -> component));
if (componentEither.isRight()) {
- throw new ComponentException(componentEither.right().value());
+ throw new ByResponseFormatComponentException(componentEither.right().value());
}
return componentEither.left().value();
}
@@ -578,14 +581,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
// Confirm if type is list
if (StringUtils.isEmpty(input.getType()) || !input.getType().equals(ToscaPropertyType.LIST.getType())) {
log.debug("#prepareDataTypeForListInput: Type of input is not list.");
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_TYPE));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_TYPE));
}
// Confirm schema type is not empty
String desiredTypeName = input.getSchemaType();
if (StringUtils.isEmpty(desiredTypeName)) {
log.debug("#prepareDataTypeForListInput: Schema type of list input is empty.");
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE));
}
DataTypeDefinition dataType = new DataTypeDefinition();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java
index 8b22d60ce6..30a9f799fe 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java
@@ -16,11 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datamodel.api.CategoryTypeEnum;
@@ -272,11 +275,11 @@ public class ProductBusinessLogic extends ComponentBusinessLogic {
try{
contactUser = validateUserExists(contact, CREATE_PRODUCT, false);
validateUserRole(contactUser, contactsRoles);
- } catch(ComponentException e){
+ } catch(ByActionStatusComponentException e){
log.debug("Cannot set contact with userId {} as product contact, error: {}", contact, e.getActionStatus());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_PRODUCT_CONTACT, contact);
componentsUtils.auditComponentAdmin(responseFormat, user, product, actionEnum, ComponentTypeEnum.PRODUCT);
- throw new ComponentException(e.getActionStatus(), e.getParams());
+ throw new ByActionStatusComponentException(e.getActionStatus(), e.getParams());
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 78e56ac1c9..0968e157e4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -60,6 +62,8 @@ import org.openecomp.sdc.be.components.csar.CsarInfo;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.utils.CINodeFilterUtils;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
@@ -380,7 +384,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_CSAR_UUID,
resource.getName());
componentsUtils.auditResource(errorResponse, user, resource, AuditingActionEnum.CREATE_RESOURCE);
- throw new ComponentException(ActionStatus.MISSING_CSAR_UUID, resource.getName());
+ throw new ByActionStatusComponentException(ActionStatus.MISSING_CSAR_UUID, resource.getName());
}
return updatedResource;
}
@@ -406,7 +410,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.VSP_ALREADY_EXISTS, csarUUID,
resourceLinkedToCsarRes.left().value().getName());
componentsUtils.auditResource(errorResponse, user, resource, AuditingActionEnum.UPDATE_RESOURCE_METADATA);
- throw new ComponentException(ActionStatus.VSP_ALREADY_EXISTS, csarUUID,
+ throw new ByActionStatusComponentException(ActionStatus.VSP_ALREADY_EXISTS, csarUUID,
resourceLinkedToCsarRes.left().value().getName());
}
}
@@ -425,7 +429,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat errorResponse = componentsUtils.getResponseFormat(
ActionStatus.RESOURCE_LINKED_TO_DIFFERENT_VSP, resource.getName(), csarUUID, oldCsarUUID);
componentsUtils.auditResource(errorResponse, user, resource, AuditingActionEnum.UPDATE_RESOURCE_METADATA);
- throw new ComponentException(ActionStatus.RESOURCE_LINKED_TO_DIFFERENT_VSP, resource.getName(), csarUUID, oldCsarUUID);
+ throw new ByActionStatusComponentException(ActionStatus.RESOURCE_LINKED_TO_DIFFERENT_VSP, resource.getName(), csarUUID, oldCsarUUID);
}
}
@@ -458,7 +462,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<Boolean, ResponseFormat> lockResult = lockComponent(lockedResourceId, oldResource,
"update Resource From Csar");
if (lockResult.isRight()) {
- throw new ComponentException(lockResult.right().value());
+ throw new ByResponseFormatComponentException(lockResult.right().value());
}
Map<String, NodeTypeInfo> nodeTypesInfo = csarInfo.extractNodeTypesInfo();
@@ -468,7 +472,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (findNodeTypesArtifactsToHandleRes.isRight()) {
log.debug("failed to find node types for update with artifacts during import csar {}. ",
csarInfo.getCsarUUID());
- throw new ComponentException(findNodeTypesArtifactsToHandleRes.right().value());
+ throw new ByResponseFormatComponentException(findNodeTypesArtifactsToHandleRes.right().value());
}
Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = findNodeTypesArtifactsToHandleRes
.left().value();
@@ -496,7 +500,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
!oldResource.getLastUpdaterUserId().equals(user.getUserId())) {
log.debug("#validateLifecycleState - Current user is not last updater, last updater userId: {}, current user userId: {}",
oldResource.getLastUpdaterUserId(), user.getUserId());
- throw new ComponentException(ActionStatus.RESTRICTED_OPERATION);
+ throw new ByActionStatusComponentException(ActionStatus.RESTRICTED_OPERATION);
}
}
@@ -529,7 +533,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
uploadComponentInstanceInfoMap = csarBusinessLogic.getParsedToscaYamlInfo(yamlFileContent, yamlFileName, nodeTypesInfo, csarInfo, nodeName);
Map<String, UploadComponentInstanceInfo> instances = uploadComponentInstanceInfoMap.getInstances();
if (MapUtils.isEmpty(instances) && newRresource.getResourceType() != ResourceTypeEnum.PNF) {
- throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlFileName);
+ throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlFileName);
}
preparedResource = updateExistingResourceByImport(newRresource, oldRresource, csarInfo.getModifier(),
inTransaction, shouldLock, isNested).left;
@@ -540,8 +544,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
preparedResource = createInputsOnResource(preparedResource, uploadComponentInstanceInfoMap.getInputs());
preparedResource = createResourceInstances(yamlFileName, preparedResource, instances, csarInfo.getCreatedNodes());
preparedResource = createResourceInstancesRelations(csarInfo.getModifier(), yamlFileName, preparedResource, instances);
- } catch (ComponentException e) {
- ResponseFormat responseFormat = e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
+ } catch (ByResponseFormatComponentException e) {
+ ResponseFormat responseFormat = e.getResponseFormat();
+ log.debug("#updateResourceFromYaml - failed to update resource from yaml {} .The error is {}", yamlFileName, responseFormat);
+ componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), preparedResource == null ? oldRresource : preparedResource, actionEnum);
+ throw e;
+ } catch (ByActionStatusComponentException e) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
log.debug("#updateResourceFromYaml - failed to update resource from yaml {} .The error is {}", yamlFileName, responseFormat);
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), preparedResource == null ? oldRresource : preparedResource, actionEnum);
throw e;
@@ -556,7 +565,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
preparedResource.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
- throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
+ throw new ByResponseFormatComponentException(validateUpdateVfGroupNamesRes.right().value());
}
// add groups to resource
Map<String, GroupDefinition> groups;
@@ -575,7 +584,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
csarInfo, preparedResource, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
if (updateArtifactsEither.isRight()) {
log.debug("failed to update artifacts {}", updateArtifactsEither.right().value());
- throw new ComponentException(updateArtifactsEither.right().value());
+ throw new ByResponseFormatComponentException(updateArtifactsEither.right().value());
}
preparedResource = getResourceWithGroups(updateArtifactsEither.left().value().getUniqueId());
@@ -583,7 +592,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (mergingPropsAndInputsStatus != ActionStatus.OK) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(mergingPropsAndInputsStatus,
preparedResource);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
compositionBusinessLogic.setPositionsForComponentInstances(preparedResource, csarInfo.getModifier().getUserId());
return preparedResource;
@@ -688,7 +697,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("Error occured during fetching node type with tosca name {}, error: {}", currVfcToscaName, status);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), csarInfo.getCsarUUID());
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.CREATE_RESOURCE);
- throw new ComponentException(componentsUtils.convertFromStorageResponse(status), csarInfo.getCsarUUID());
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(status), csarInfo.getCsarUUID());
} else if (StringUtils.isNotEmpty(currVfcToscaName)) {
return (Resource)toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName)
.left()
@@ -710,7 +719,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
nodeTypeArtifactsToHandle = putFoundArtifacts(artifactsToUpload, artifactsToUpdate, artifactsToDelete);
} catch (Exception e) {
log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage(), e);
- throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
return nodeTypeArtifactsToHandle;
}
@@ -753,7 +762,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
artifactsToUpload.remove(currNewArtifact);
} else {
log.debug("Can't upload two artifact with the same name {}.", currNewArtifact.getArtifactName());
- throw new ComponentException(ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR,
+ throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR,
currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(),
foundArtifact.get().getArtifactType());
}
@@ -937,7 +946,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (findNodeTypesArtifactsToHandleRes.isRight()) {
log.debug("failed to find node types for update with artifacts during import csar {}. ",
csarInfo.getCsarUUID());
- throw new ComponentException(findNodeTypesArtifactsToHandleRes.right().value());
+ throw new ByResponseFormatComponentException(findNodeTypesArtifactsToHandleRes.right().value());
}
Resource vfResource = createResourceFromYaml(resource, csarInfo.getMainTemplateContent(), csarInfo.getMainTemplateName(),
nodeTypesInfo, csarInfo, findNodeTypesArtifactsToHandleRes.left().value(), true, false,
@@ -972,15 +981,19 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
try{
ParsedToscaYamlInfo parsedToscaYamlInfo = csarBusinessLogic.getParsedToscaYamlInfo(topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, nodeName);
if (MapUtils.isEmpty(parsedToscaYamlInfo.getInstances()) && resource.getResourceType() != ResourceTypeEnum.PNF) {
- throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
log.debug("#createResourceFromYaml - Going to create resource {} and RIs ", resource.getName());
createdResource = createResourceAndRIsFromYaml(yamlName, resource,
parsedToscaYamlInfo, AuditingActionEnum.IMPORT_RESOURCE, false, createdArtifacts, topologyTemplateYaml,
nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeName);
log.debug("#createResourceFromYaml - The resource {} has been created ", resource.getName());
- } catch (ComponentException e) {
- ResponseFormat responseFormat = e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
+ } catch (ByActionStatusComponentException e) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
+ throw e;
+ } catch (ByResponseFormatComponentException e) {
+ ResponseFormat responseFormat = e.getResponseFormat();
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
throw e;
} catch (StorageException e){
@@ -1000,7 +1013,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<String, ResultStatusEnum> toscaVersion = findFirstToscaStringElement(mappedToscaTemplate,
TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
if (toscaVersion.isRight()) {
- throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE);
}
Map<String, Object> mapToConvert = new HashMap<>();
mapToConvert.put(TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION.getElementName(), toscaVersion.left().value());
@@ -1084,7 +1097,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() != StorageOperationStatus.NOT_FOUND) {
log.debug("Failed to fetch previous complex VFC by tosca resource name {}. Status is {}. ",
newComplexVfc.getToscaResourceName(), oldComplexVfcRes.right().value());
- throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
} else if (oldComplexVfcRes.isLeft()) {
log.debug(VALIDATE_DERIVED_BEFORE_UPDATE);
Either<Boolean, ResponseFormat> eitherValidation = validateNestedDerivedFromDuringUpdate(
@@ -1202,7 +1215,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private ImmutablePair<Resource,ActionStatus> failOnCertification(ResponseFormat error) {
- throw new ComponentException(error);
+ throw new ByResponseFormatComponentException(error);
}
private UploadResourceInfo fillResourceMetadata(String yamlName, Resource resourceVf,
@@ -1213,7 +1226,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (!nodeName.startsWith(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX)) {
log.debug("invalid nodeName:{} does not start with {}.", nodeName,
Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
- throw new ComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
yamlName, resourceMetaData.getName(), nodeName);
}
@@ -1231,7 +1244,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (!ResourceTypeEnum.containsName(resourceType.toUpperCase())) {
log.debug("invalid resourceType:{} the type is not one of the valide types:{}.", resourceType.toUpperCase(),
ResourceTypeEnum.values());
- throw new ComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
yamlName, resourceMetaData.getName(), nodeName);
}
@@ -1331,7 +1344,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
CREATE_RESOURCE);
if (lockResult.isRight()) {
rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
- throw new ComponentException(lockResult.right().value());
+ throw new ByResponseFormatComponentException(lockResult.right().value());
}
log.debug("name is locked {} status = {}", resource.getSystemName(), lockResult);
}
@@ -1362,7 +1375,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), resource.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
- throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
+ throw new ByResponseFormatComponentException(validateUpdateVfGroupNamesRes.right().value());
}
// add groups to resource
Map<String, GroupDefinition> groups;
@@ -1378,7 +1391,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
groups);
if (createGroupsOnResource.isRight()) {
rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
- throw new ComponentException(createGroupsOnResource.right().value());
+ throw new ByResponseFormatComponentException(createGroupsOnResource.right().value());
}
resource = createGroupsOnResource.left().value();
log.trace("************* Finished to add groups from yaml {}", yamlName);
@@ -1392,7 +1405,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
csarInfo, resource, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
if (createArtifactsEither.isRight()) {
rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
- throw new ComponentException(createArtifactsEither.right().value());
+ throw new ByResponseFormatComponentException(createArtifactsEither.right().value());
}
resource = getResourceWithGroups(createArtifactsEither.left().value().getUniqueId());
@@ -1524,7 +1537,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<Resource, StorageOperationStatus> updatedResource = toscaOperationFacade
.getToscaElement(resource.getUniqueId());
if (updatedResource.isRight()) {
- throw new ComponentException(componentsUtils.getResponseFormatByResource(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource));
}
return updatedResource.left().value();
@@ -1601,7 +1614,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<List<InputDefinition>, ResponseFormat> createInputs = inputsBusinessLogic.createInputsInGraph(inputs,
resource);
if (createInputs.isRight()) {
- throw new ComponentException(createInputs.right().value());
+ throw new ByResponseFormatComponentException(createInputs.right().value());
}
} else {
return resource;
@@ -1609,7 +1622,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<Resource, StorageOperationStatus> updatedResource = toscaOperationFacade
.getToscaElement(resource.getUniqueId());
if (updatedResource.isRight()) {
- throw new ComponentException(componentsUtils.getResponseFormatByResource(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource));
}
return updatedResource.left().value();
@@ -1623,7 +1636,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (groups != null) {
Either<Boolean, ResponseFormat> validateCyclicGroupsDependencies = validateCyclicGroupsDependencies(groups);
if (validateCyclicGroupsDependencies.isRight()) {
- throw new ComponentException(validateCyclicGroupsDependencies.right().value());
+ throw new ByResponseFormatComponentException(validateCyclicGroupsDependencies.right().value());
}
for (Entry<String, GroupDefinition> entry : groups.entrySet()) {
String groupName = entry.getKey();
@@ -1647,7 +1660,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String membersAstString = compInstancesNames.stream().collect(joining(","));
log.debug("The members: {}, in group: {}, cannot be found in component {}. There are no component instances.",
membersAstString, groupName, component.getNormalizedName());
- throw new ComponentException(componentsUtils.getResponseFormat(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(
ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
component.getNormalizedName(), getComponentTypeForResponse(component)));
}
@@ -1669,7 +1682,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String membersAstString = compInstancesNames.stream().collect(joining(","));
log.debug("The members: {}, in group: {}, cannot be found in component: {}", membersAstString,
groupName, component.getNormalizedName());
- throw new ComponentException(componentsUtils.getResponseFormat(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(
ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
component.getNormalizedName(), getComponentTypeForResponse(component)));
}
@@ -1836,9 +1849,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
createResourcesFromYamlNodeTypesList(yamlName, resource, mappedToscaTemplate, needLock, nodeTypesArtifactsToHandle,
nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo);
- } catch(ComponentException e){
- ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
- : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ } catch(ByActionStatusComponentException e){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
+ throw e;
+ } catch(ByResponseFormatComponentException e){
+ ResponseFormat responseFormat = e.getResponseFormat();
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
throw e;
} catch (StorageException e){
@@ -2152,7 +2168,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.getResourceType() != ResourceTypeEnum.PNF)) { // PNF can have no resource instances
log.debug("#createResourceInstancesRelations - No instances found in the resource {} is empty, yaml template file name {}, ", resource.getUniqueId(), yamlName);
BeEcompErrorManager.getInstance().logInternalDataError("createResourceInstancesRelations", "No instances found in a resource or nn yaml template. ", ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName));
}
Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities = new HashMap<>();
@@ -2170,7 +2186,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
TitanOperationStatus status = allDataTypes.right().value();
BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
"Failed to update property value on instance. Status is " + status, ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(
DaoStatusConverter.convertTitanStatusToStorageStatus(status)), yamlName));
}
@@ -2197,7 +2213,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<Resource, StorageOperationStatus> eitherGetResource = toscaOperationFacade.getToscaElement(resource.getUniqueId());
log.debug("************* in create relations, getResource end");
if (eitherGetResource.isRight()) {
- throw new ComponentException(componentsUtils.getResponseFormatByResource(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource));
}
return eitherGetResource.left().value();
@@ -2220,7 +2236,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate instances of resource {} status is {}", resource.getUniqueId(),
addArtToInst);
- throw new ComponentException(componentsUtils
+ throw new ByResponseFormatComponentException(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
@@ -2243,7 +2259,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate attributes of resource {} status is {}", resource.getUniqueId(),
addArtToInst);
- throw new ComponentException(componentsUtils
+ throw new ByResponseFormatComponentException(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
@@ -2255,7 +2271,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate cap and req of resource {} status is {}", resource.getUniqueId(),
addArtToInst);
- throw new ComponentException(componentsUtils
+ throw new ByResponseFormatComponentException(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
@@ -2266,7 +2282,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
addArtToInst = toscaOperationFacade.associateArtifactsToInstances(instArtifacts, resource.getUniqueId());
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
- throw new ComponentException(componentsUtils
+ throw new ByResponseFormatComponentException(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
@@ -2276,7 +2292,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource.getUniqueId(), user);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
- throw new ComponentException(componentsUtils
+ throw new ByResponseFormatComponentException(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
@@ -2288,7 +2304,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (addInputToInst.isRight()) {
log.debug("failed to associate inputs value of resource {} status is {}", resource.getUniqueId(),
addInputToInst.right().value());
- throw new ComponentException(componentsUtils.getResponseFormat(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(
componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName));
}
}
@@ -2300,7 +2316,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (addPropToInst.isRight()) {
log.debug("failed to associate properties of resource {} status is {}", resource.getUniqueId(),
addPropToInst.right().value());
- throw new ComponentException(componentsUtils.getResponseFormat(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(
componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
}
}
@@ -2311,14 +2327,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (getResourceRes.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), resource);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
getResourceRes = updateCalculatedCapReqWithSubstitutionMappings(getResourceRes.left().value(),
uploadResInstancesMap);
if (getResourceRes.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), resource);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
}
}
@@ -2343,12 +2359,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.getUniqueId(), ErrorSeverity.ERROR);
ResponseFormat responseFormat = componentsUtils
.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
ResponseFormat addRelationToRiRes = addRelationToRI(yamlName, resource, entry.getValue(), relations);
if (addRelationToRiRes.getStatus() != 200) {
- throw new ComponentException(addRelationToRiRes);
+ throw new ByResponseFormatComponentException(addRelationToRiRes);
}
}
}
@@ -2365,7 +2381,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.getUniqueId(), ErrorSeverity.ERROR);
ResponseFormat responseFormat = componentsUtils
.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
ComponentInstance currentCompInstance = currentCompInstanceOpt.get();
String resourceInstanceId = currentCompInstance.getUniqueId();
@@ -2390,7 +2406,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource,
originResource, currentCompInstance, instProperties, allDataTypes.left().value());
if (addPropertiesValueToRiRes.getStatus() != 200) {
- throw new ComponentException(addPropertiesValueToRiRes);
+ throw new ByResponseFormatComponentException(addPropertiesValueToRiRes);
}
} else {
addInputsValuesToRi(uploadComponentInstanceInfo, resource,
@@ -2409,7 +2425,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
getOriginResourceRes);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(
componentsUtils.convertFromStorageResponse(getOriginResourceRes.right().value()), yamlName);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
originResource = getOriginResourceRes.left().value();
originCompMap.put(originResource.getUniqueId(), originResource);
@@ -2692,7 +2708,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (CollectionUtils.isEmpty( originResource.getInputs())) {
log.debug("failed to find properties ");
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND));
}
originResource.getInputs().forEach(p->addInput(currPropertiesMap, p));
for (List<UploadPropInfo> propertyList : propMap.values()) {
@@ -2708,7 +2724,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String propName = propertyInfo.getName();
if (!currPropertiesMap.containsKey(propName)) {
log.debug("failed to find property {} ", propName);
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND,
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND,
propName));
}
InputDefinition curPropertyDef = currPropertiesMap.get(propName);
@@ -2742,7 +2758,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (CollectionUtils.isEmpty(inputs)) {
log.debug("Failed to add property {} to resource instance {}. Inputs list is empty ",
property, currentCompInstance.getUniqueId());
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
}
Optional<InputDefinition> optional = inputs.stream()
@@ -2750,7 +2766,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (!optional.isPresent()) {
log.debug("Failed to find input {} ", getInput.getInputName());
// @@TODO error message
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
}
InputDefinition input = optional.get();
getInput.setInputId(input.getUniqueId());
@@ -2774,7 +2790,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (!optional.isPresent()) {
log.debug("Failed to find input {} ", getInputIndex.getInputName());
// @@TODO error message
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
}
InputDefinition inputIndex = optional.get();
getInputIndex.setInputId(inputIndex.getUniqueId());
@@ -3029,7 +3045,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("createResourceInstances is {} - going to create resource instanse from CSAR", yamlName);
if (isEmpty(uploadResInstancesMap) && resource.getResourceType() != ResourceTypeEnum.PNF) { // PNF can have no resource instances
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
Map<String, Resource> existingNodeTypeMap = new HashMap<>();
if (MapUtils.isNotEmpty(nodeNamespaceMap)) {
@@ -3048,7 +3064,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat responseFormat = componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(status));
eitherResource = Either.right(responseFormat);
- throw new ComponentException(eitherResource.right().value());
+ throw new ByResponseFormatComponentException(eitherResource.right().value());
}
}
log.debug("*************Going to get resource {}", resource.getUniqueId());
@@ -3058,14 +3074,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (eitherGetResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
if (CollectionUtils.isEmpty(eitherGetResource.left().value().getComponentInstances()) &&
resource.getResourceType() != ResourceTypeEnum.PNF) { // PNF can have no resource instances
log.debug("Error when create resource instance from csar. ComponentInstances list empty");
BeEcompErrorManager.getInstance().logBeDaoSystemError(
"Error when create resource instance from csar. ComponentInstances list empty");
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
}
return eitherGetResource.left().value();
}
@@ -3114,7 +3130,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE,
yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
Resource origResource = existingnodeTypeMap.get(uploadComponentInstanceInfo.getType());
componentInstance.setName(uploadComponentInstanceInfo.getName());
@@ -3170,7 +3186,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(
componentsUtils.convertFromStorageResponse(findResourceEither.right().value()));
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
refResource = findResourceEither.left().value();
nodeNamespaceMap.put(refResource.getToscaResourceName(), refResource);
@@ -3182,14 +3198,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
refResource.getName(), componentState);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE,
refResource.getComponentType().getValue(), refResource.getName(), componentState);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
if (!ModelConverter.isAtomicComponent(refResource) && refResource.getResourceType() != ResourceTypeEnum.CVFC) {
log.debug("validateResourceInstanceBeforeCreate - ref resource type is ", refResource.getResourceType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE,
yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
return refResource;
}
@@ -3484,7 +3500,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.state(oldResource.getLifecycleState().name())
.version(oldResource.getVersion())
.build());
- throw new ComponentException(response);
+ throw new ByResponseFormatComponentException(response);
}
public Resource validateResourceBeforeCreate(Resource resource, User user, AuditingActionEnum actionEnum, boolean inTransaction, CsarInfo csarInfo) {
@@ -3691,7 +3707,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (lockResult.isRight()) {
ResponseFormat responseFormat = lockResult.right().value();
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
log.debug("name is locked {} status = {}", resource.getSystemName(), lockResult);
@@ -3705,8 +3721,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
componentsUtils.auditResource(componentsUtils.getResponseFormat(ActionStatus.CREATED), user,
createdResource, actionEnum);
ASDCKpiApi.countCreatedResourcesKPI();
- } catch(ComponentException e) {
- ResponseFormat responseFormat = e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
+ } catch(ByActionStatusComponentException e) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
+ throw e;
+ } catch(ByResponseFormatComponentException e) {
+ ResponseFormat responseFormat = e.getResponseFormat();
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw e;
} catch (StorageException e){
@@ -3734,13 +3754,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
eitherValidation.right().value());
ResponseFormat errorResponse = componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(eitherValidation.right().value()));
- throw new ComponentException(errorResponse);
+ throw new ByResponseFormatComponentException(errorResponse);
}
if (eitherValidation.left().value()) {
log.debug("resource with name: {}, already exists", resource.getName());
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,
ComponentTypeEnum.RESOURCE.getValue(), resource.getName());
- throw new ComponentException(errorResponse);
+ throw new ByResponseFormatComponentException(errorResponse);
}
log.debug("send resource {} to dao for create", resource.getName());
@@ -3764,7 +3784,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
private Resource throwComponentExceptionByResource(StorageOperationStatus status, Resource resource) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(status), resource);
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
private void createArtifactsPlaceHolderData(Resource resource, User user) {
@@ -4019,7 +4039,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<Resource, StorageOperationStatus> storageStatus = toscaOperationFacade
.getToscaElement(resourceIdToUpdate);
if (storageStatus.isRight()) {
- throw new ComponentException(componentsUtils.getResponseFormatByResource(
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(storageStatus.right().value()), ""));
}
@@ -4028,7 +4048,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// verify that resource is checked-out and the user is the last
// updater
if (!ComponentValidationUtils.canWorkOnResource(currentResource, user.getUserId())) {
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
// lock resource
@@ -4040,7 +4060,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("Failed to lock resource: {}, error - {}", resourceIdToUpdate, lockResult);
ResponseFormat responseFormat = componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(lockResult));
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
needToUnlock = true;
@@ -4064,7 +4084,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (dataModelResponse.isRight()) {
log.debug("failed to update resource metadata!!!");
rollbackNeeded = true;
- throw new ComponentException(dataModelResponse.right().value());
+ throw new ByResponseFormatComponentException(dataModelResponse.right().value());
}
log.debug("Resource metadata updated successfully!!!");
@@ -4368,7 +4388,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
} else {
log.info("Resource name: {}, cannot be updated once the resource has been certified once.",
resourceNameUpdated);
- throw new ComponentException(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED);
+ throw new ByActionStatusComponentException(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED);
}
}
}
@@ -4381,7 +4401,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
validateIcon(null, updateInfoResource, null);
} else {
log.info("Icon {} cannot be updated once the resource has been certified once.", iconUpdated);
- throw new ComponentException(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED);
+ throw new ByActionStatusComponentException(ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED);
}
}
}
@@ -4497,12 +4517,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus), resource);
log.trace("audit before sending response");
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(componentsUtils.convertFromStorageResponse(storageStatus));
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(storageStatus));
} else if (!dataModelResponse.left().value()) {
log.info("resource template with name: {}, does not exists", templateName);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.PARENT_RESOURCE_NOT_FOUND);
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.PARENT_RESOURCE_NOT_FOUND);
+ throw new ByActionStatusComponentException(ActionStatus.PARENT_RESOURCE_NOT_FOUND);
}
}
@@ -4547,7 +4567,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.getResponseFormat(ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
+ throw new ByActionStatusComponentException(ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
}
}
@@ -4558,7 +4578,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.getComponentType());
if (resourceOperationResponse.isLeft() && resourceOperationResponse.left().value()) {
log.debug("resource with name: {}, already exists", resource.getName());
- throw new ComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
resource.getName());
} else if(resourceOperationResponse.isRight()){
log.debug("error while validateResourceNameExists for resource: {}", resource.getName());
@@ -4576,22 +4596,22 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY,
ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY,
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY,
ComponentTypeEnum.RESOURCE.getValue());
}
if (categories.size() > 1) {
log.debug("Must be only one category for resource");
- throw new ComponentException(ActionStatus.COMPONENT_TOO_MUCH_CATEGORIES, ComponentTypeEnum.RESOURCE.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_TOO_MUCH_CATEGORIES, ComponentTypeEnum.RESOURCE.getValue());
}
CategoryDefinition category = categories.get(0);
List<SubCategoryDefinition> subcategories = category.getSubcategories();
if (CollectionUtils.isEmpty(subcategories)) {
log.debug("Missinig subcategory for resource");
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_SUBCATEGORY);
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_SUBCATEGORY);
}
if (subcategories.size() > 1) {
log.debug("Must be only one sub category for resource");
- throw new ComponentException(ActionStatus.RESOURCE_TOO_MUCH_SUBCATEGORIES);
+ throw new ByActionStatusComponentException(ActionStatus.RESOURCE_TOO_MUCH_SUBCATEGORIES);
}
SubCategoryDefinition subcategory = subcategories.get(0);
@@ -4601,7 +4621,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY,
ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY,
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY,
ComponentTypeEnum.RESOURCE.getValue());
}
if (!ValidationUtils.validateStringNotEmpty(subcategory.getName())) {
@@ -4609,7 +4629,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(
ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue());
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue());
}
validateCategoryListed(category, subcategory, user, resource, actionEnum, inTransaction);
@@ -4626,7 +4646,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("failed to retrieve resource categories from Titan");
responseFormat = componentsUtils.getResponseFormat(categories.right().value());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(categories.right().value());
+ throw new ByActionStatusComponentException(categories.right().value());
}
List<CategoryDefinition> categoryList = categories.left().value();
Optional<CategoryDefinition> foundCategory = categoryList.stream()
@@ -4655,7 +4675,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INVALID_CATEGORY,
ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.COMPONENT_INVALID_CATEGORY,
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_INVALID_CATEGORY,
ComponentTypeEnum.RESOURCE.getValue());
}
@@ -4666,7 +4686,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.info("vendor relese name is missing.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_VENDOR_RELEASE);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.MISSING_VENDOR_RELEASE);
+ throw new ByActionStatusComponentException(ActionStatus.MISSING_VENDOR_RELEASE);
}
validateVendorReleaseName(vendorRelease, user, resource, actionEnum);
@@ -4679,14 +4699,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat errorResponse = componentsUtils.getResponseFormat(
ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
+ throw new ByActionStatusComponentException(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
}
if (!ValidationUtils.validateVendorRelease(vendorRelease)) {
log.info("vendor release is not valid.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_VENDOR_RELEASE);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.INVALID_VENDOR_RELEASE);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_VENDOR_RELEASE);
}
}
}
@@ -4698,7 +4718,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.info("vendor name is missing.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_VENDOR_NAME);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.MISSING_VENDOR_NAME);
+ throw new ByActionStatusComponentException(ActionStatus.MISSING_VENDOR_NAME);
}
validateVendorName(vendorName, user, resource, actionEnum);
}
@@ -4711,7 +4731,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
"" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
+ throw new ByActionStatusComponentException(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
"" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
}
@@ -4719,7 +4739,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.info("vendor name is not valid.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_VENDOR_NAME);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.INVALID_VENDOR_NAME);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_VENDOR_NAME);
}
}
}
@@ -4733,7 +4753,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
"" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
+ throw new ByActionStatusComponentException(ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
"" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
}
// resource vendor model number is currently validated as vendor
@@ -4743,7 +4763,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat errorResponse = componentsUtils
.getResponseFormat(ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
- throw new ComponentException(ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER);
}
}
}
@@ -4754,7 +4774,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (cost != null) {
if (!ValidationUtils.validateCost(cost)) {
log.debug("resource cost is invalid.");
- throw new ComponentException(ActionStatus.INVALID_CONTENT);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
}
}
}
@@ -4773,7 +4793,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// In update case, no audit is required
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
}
- throw new ComponentException(ActionStatus.INVALID_CONTENT);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
}
}
}
@@ -5001,7 +5021,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
validCapabilityList.add(defaultCapability);
validCapabilitiesMap.put(key, validCapabilityList);
} else {
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, capabilityType));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, capabilityType));
}
}
@@ -5013,7 +5033,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug(
"Failed to update capability property values. Property list of fetched capability {} is empty. ",
defaultCapability.getName());
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, resourceId));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, resourceId));
} else if (isNotEmpty(capabilities.get(0).getProperties())) {
validateUniquenessUpdateUploadedComponentInstanceCapability(defaultCapability, capabilities.get(0));
}
@@ -5029,7 +5049,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (getFullComponentRes.isRight()) {
log.debug("Failed to get full component {}. Status is {}. ", resourceId,
getFullComponentRes.right().value());
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_NOT_FOUND,
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_NOT_FOUND,
resourceId));
}
defaultCapability = getFullComponentRes.left().value().getCapabilities().get(capabilityType).get(0);
@@ -5048,7 +5068,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String propertyType = property.getType();
ComponentInstanceProperty validProperty;
if (defaultProperties.containsKey(propertyName) && propertTypeEqualsTo(defaultProperties, propertyName, propertyType)) {
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NAME_ALREADY_EXISTS,
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NAME_ALREADY_EXISTS,
propertyName));
}
validProperty = new ComponentInstanceProperty();
@@ -5197,7 +5217,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
} catch (Exception e) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
log.debug("Exception occured when buildNestedToscaResourceName, error is:{}", e.getMessage(), e);
- throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE, vfResourceName);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE, vfResourceName);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 4d72f87289..cd9be0fe72 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -264,9 +266,8 @@ public class ResourceImportManager {
}
catch (ComponentException e) {
- ResponseFormat responseFormat = e.getResponseFormat() != null?
- e.getResponseFormat() : getResponseFormatManager().getResponseFormat(e.getActionStatus(), e.getParams());
- response = Either.right(handleImportResourceException(resourceMetaData, creator, false, e, responseFormat));
+ response = Either.right(handleImportResourceException(resourceMetaData, creator, false, e,
+ e.getResponseFormat()));
}
catch (RuntimeException e) {
response = Either.right(handleImportResourceException(resourceMetaData, creator, false, e, null));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index cad9a92ab3..6c41985c9a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
@@ -61,6 +63,8 @@ import org.openecomp.sdc.be.components.distribution.engine.IDistributionEngine;
import org.openecomp.sdc.be.components.distribution.engine.INotificationData;
import org.openecomp.sdc.be.components.distribution.engine.VfModuleArtifactPayload;
import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.utils.NodeFilterConstraintAction;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
@@ -963,7 +967,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
Either<Boolean, ResponseFormat> serviceNameUniquenessValidation = validateComponentNameUnique(user, service, actionEnum);
if (serviceNameUniquenessValidation.isRight()) {
- throw new ComponentException(serviceNameUniquenessValidation.right().value());
+ throw new ByResponseFormatComponentException(serviceNameUniquenessValidation.right().value());
}
Either<Boolean, ResponseFormat> categoryValidation = validateServiceCategory(user, service, actionEnum);
if (categoryValidation.isRight()) {
@@ -1462,7 +1466,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
String serviceType = ((Service)component).getServiceType();
if (serviceType == null) {
log.info("service type is not valid.");
- throw new ComponentException(ActionStatus.INVALID_SERVICE_TYPE);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_SERVICE_TYPE);
}
serviceType = cleanUpText(serviceType);
validateServiceType(serviceType);
@@ -1475,11 +1479,11 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
if (!ValidationUtils.validateServiceTypeLength(serviceType)) {
log.info("service type exceeds limit.");
- throw new ComponentException(ActionStatus.SERVICE_TYPE_EXCEEDS_LIMIT, "" + ValidationUtils.SERVICE_TYPE_MAX_LENGTH);
+ throw new ByActionStatusComponentException(ActionStatus.SERVICE_TYPE_EXCEEDS_LIMIT, "" + ValidationUtils.SERVICE_TYPE_MAX_LENGTH);
}
if (!ValidationUtils.validateIsEnglish(serviceType)) {
log.info("service type is not valid.");
- throw new ComponentException(ActionStatus.INVALID_SERVICE_TYPE);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_SERVICE_TYPE);
}
}
@@ -2378,7 +2382,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
log.debug("validateRoleForDeploy method - user is not listed. userId= {}", user.getUserId());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.USER_NOT_FOUND, user.getUserId());
auditDeployError(did, user, auditAction, service, ActionStatus.USER_NOT_FOUND);
- throw new ComponentException(ActionStatus.USER_NOT_FOUND, user.getUserId());
+ throw new ByActionStatusComponentException(ActionStatus.USER_NOT_FOUND, user.getUserId());
}
user = eitherCreator.left().value();
log.debug("validate user role");
@@ -2387,7 +2391,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
roles.add(Role.OPS);
try{
validateUserRole(user, service, roles, auditAction, null);
- } catch (ComponentException e){
+ } catch (ByActionStatusComponentException e){
log.info("role {} is not allowed to perform this action", user.getRole());
auditDeployError(did, user, auditAction, service, e.getActionStatus());
throw e;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByActionStatusComponentException.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByActionStatusComponentException.java
new file mode 100644
index 0000000000..4a19fdaf06
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByActionStatusComponentException.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.sdc.be.components.impl.exceptions;
+
+import java.util.Arrays;
+import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+public class ByActionStatusComponentException extends ComponentException {
+
+ private final ActionStatus actionStatus;
+ private final String[] params;
+
+ public ByActionStatusComponentException(ActionStatus actionStatus, String... params) {
+ this.actionStatus = actionStatus;
+ this.params = params.clone();
+ }
+
+ public ActionStatus getActionStatus() {
+ return actionStatus;
+ }
+
+ public String[] getParams() {
+ return params.clone();
+ }
+
+ @Override
+ public ResponseFormat getResponseFormat() {
+ return ResponseFormatManager.getInstance().getResponseFormat(getActionStatus(), getParams());
+ }
+
+ @Override
+ public String toString() {
+ return "ComponentException{" +
+ "actionStatus=" + actionStatus +
+ ", params=" + Arrays.toString(params) +
+ '}';
+ }
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByResponseFormatComponentException.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByResponseFormatComponentException.java
new file mode 100644
index 0000000000..0737c45d49
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ByResponseFormatComponentException.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.sdc.be.components.impl.exceptions;
+
+import org.openecomp.sdc.exception.ResponseFormat;
+
+public class ByResponseFormatComponentException extends ComponentException {
+
+ private final transient ResponseFormat responseFormat;
+
+ public ByResponseFormatComponentException(ResponseFormat responseFormat) {
+ this.responseFormat = responseFormat;
+ }
+
+ @Override
+ public ResponseFormat getResponseFormat() {
+ return responseFormat;
+ }
+
+ @Override
+ public String toString() {
+ return "ComponentException{" +
+ "responseFormat=" + responseFormat +
+ '}';
+ }
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ComponentException.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ComponentException.java
index 72d54873d2..bedb299163 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ComponentException.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ComponentException.java
@@ -1,61 +1,37 @@
+/*-
+ * ============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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.impl.exceptions;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.Arrays;
+/**
+ * This class will be initialized either by action status and params or by ResponseFormat
+ */
+public abstract class ComponentException extends RuntimeException {
-public class ComponentException extends RuntimeException {
-
- /**
- * This class will be initialized either by action status and params or by ResponseFormat
- */
-
- private final transient ResponseFormat responseFormat;
- private final ActionStatus actionStatus;
- private final String[] params;
-
- public ComponentException(ResponseFormat responseFormat) {
- this(responseFormat, ActionStatus.OK);
- }
-
- public ComponentException(ActionStatus actionStatus, String... params) {
- this(null, actionStatus, params);
- }
-
- private ComponentException(ResponseFormat responseFormat, ActionStatus actionStatus, String... params) {
- this.actionStatus = actionStatus;
- this.params = params.clone();
- this.responseFormat = responseFormat;
- }
-
- public ResponseFormat getResponseFormat() {
- return responseFormat;
- }
-
- public ActionStatus getActionStatus() {
- return actionStatus;
- }
-
- public String[] getParams() {
- return params.clone();
- }
+ public abstract ResponseFormat getResponseFormat();
@Override
public String getMessage() {
return this.toString();
}
-
- @Override
- public String toString() {
- return "ComponentException{" +
- "responseFormat=" + responseFormat +
- ", actionStatus=" + actionStatus +
- ", params=" + Arrays.toString(params) +
- '}';
- }
-
-
-
-
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/ExceptionUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/ExceptionUtils.java
index e48d21cb77..2d6f354139 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/ExceptionUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/ExceptionUtils.java
@@ -1,6 +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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.impl.utils;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
@@ -20,12 +42,12 @@ public class ExceptionUtils {
public <T> T rollBackAndThrow(ActionStatus actionStatus, String ... params) {
titanDao.rollback();
- throw new ComponentException(actionStatus, params);
+ throw new ByActionStatusComponentException(actionStatus, params);
}
public <T> T rollBackAndThrow(ResponseFormat responseFormat) {
titanDao.rollback();
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
public <T> T rollBackAndThrow(StorageOperationStatus status, String ... params) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java
index b0247a26e2..981f0bdff2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.lifecycle;
@@ -24,7 +26,7 @@ import fj.data.Either;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
import org.openecomp.sdc.be.components.impl.*;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction.LifecycleChanceActionEnum;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
@@ -314,7 +316,7 @@ public class LifecycleBusinessLogic {
lastName = fullName[1];
}
}
- throw new ComponentException(ActionStatus.COMPONENT_ALREADY_CERTIFIED,
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_ALREADY_CERTIFIED,
component.getName(),
component.getComponentType().name().toLowerCase(),
firstName,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ExternalRefsMergeBL.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ExternalRefsMergeBL.java
index e9c4364181..68a8333e31 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ExternalRefsMergeBL.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ExternalRefsMergeBL.java
@@ -1,7 +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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.merge.instance;
import fj.data.Either;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -36,7 +57,7 @@ public class ExternalRefsMergeBL implements ComponentInstanceMergeInterface {
public Either<Component, ResponseFormat> mergeDataAfterCreate(User user, DataForMergeHolder dataHolder, Component updatedContainerComponent, String newInstanceId) {
Optional<ComponentInstance> componentInstance = updatedContainerComponent.getComponentInstanceById(newInstanceId);
if (!componentInstance.isPresent()) {
- throw new ComponentException(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND,
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND,
newInstanceId);
}
Map<String, List<String>> savedExternalRefs = dataHolder.getOrigCompInstExternalRefs();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java
index d5a94c038a..9dbf012653 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ComponentValidations.java
@@ -16,12 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.validation;
import org.apache.commons.collections.CollectionUtils;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
@@ -108,7 +110,7 @@ public class ComponentValidations {
void validateComponentIsCheckedOutByUser(Component component, String userId) {
if (!ComponentValidationUtils.canWorkOnComponent(component, userId)) {
- throw new ComponentException(ActionStatus.ILLEGAL_COMPONENT_STATE, component.getComponentType().name(), component.getName(), component.getLifecycleState().name());
+ throw new ByActionStatusComponentException(ActionStatus.ILLEGAL_COMPONENT_STATE, component.getComponentType().name(), component.getName(), component.getLifecycleState().name());
}
}
Component validateComponentIsCheckedOutByUser(String componentId, ComponentTypeEnum componentTypeEnum, String userId) {
@@ -129,7 +131,7 @@ public class ComponentValidations {
private void validateComponentType(Component component, ComponentTypeEnum componentType) {
if (componentType!=component.getComponentType()) {
- throw new ComponentException(ActionStatus.INVALID_RESOURCE_TYPE);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_RESOURCE_TYPE);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/UserValidations.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/UserValidations.java
index 18fe51d3d4..dd65627738 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/UserValidations.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/UserValidations.java
@@ -1,8 +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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.components.validation;
import fj.data.Either;
import org.apache.commons.lang3.StringUtils;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -38,7 +59,7 @@ public class UserValidations {
}
log.debug("User is not listed. userId {}", userId);
BeEcompErrorManager.getInstance().logBeUserMissingError(ecompErrorContext, userId);
- throw new ComponentException(status);
+ throw new ByActionStatusComponentException(status);
}
return eitherCreator.left().value();
}
@@ -48,7 +69,7 @@ public class UserValidations {
if (roles != null) {
if (!roles.contains(userRole)) {
log.debug("user is not in appropriate role to perform action");
- throw new ComponentException(ActionStatus.RESTRICTED_OPERATION);
+ throw new ByActionStatusComponentException(ActionStatus.RESTRICTED_OPERATION);
}
}
}
@@ -74,7 +95,7 @@ public class UserValidations {
if (StringUtils.isEmpty(userId)) {
log.debug("User header is missing ");
BeEcompErrorManager.getInstance().logBeUserMissingError(ecompErrorContext, user.getUserId());
- throw new ComponentException(ActionStatus.MISSING_INFORMATION);
+ throw new ByActionStatusComponentException(ActionStatus.MISSING_INFORMATION);
}
return user;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
index 9f6fb9fe89..0d9e21a66a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.impl;
@@ -41,6 +43,8 @@ import org.openecomp.sdc.be.auditing.impl.usersadmin.AuditUserAdminEventFactory;
import org.openecomp.sdc.be.components.impl.ImportUtils;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -1516,15 +1520,21 @@ public class ComponentsUtils {
}
return result;
}
-
-
+
public ResponseFormat getResponseFormat(ComponentException exception) {
- ResponseFormat responseFormat = exception.getResponseFormat();
- if (responseFormat != null) {
- return responseFormat;
- }
+ return exception instanceof ByResponseFormatComponentException ?
+ getResponseFormat((ByResponseFormatComponentException) exception):
+ getResponseFormat((ByActionStatusComponentException) exception);
+ }
+
+ public ResponseFormat getResponseFormat(ByResponseFormatComponentException exception) {
+ return exception.getResponseFormat();
+ }
+
+ public ResponseFormat getResponseFormat(ByActionStatusComponentException exception) {
return getResponseFormat(exception.getActionStatus(), exception.getParams());
}
+
public ActionStatus convertFromStorageResponseForRelationshipType(
StorageOperationStatus storageResponse) {
ActionStatus responseEnum;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
index 3d7dd8c622..54c6c9cd59 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
@@ -16,6 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.servlets;
@@ -49,7 +51,7 @@ import org.openecomp.sdc.be.components.impl.ImportUtils;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -649,7 +651,7 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
Either<Map<String, byte[]>, ResponseFormat> csarUIPayloadRes = getCsarFromPayload(resourceInfoObject);
if (csarUIPayloadRes.isRight()) {
- throw new ComponentException(csarUIPayloadRes.right().value());
+ throw new ByResponseFormatComponentException(csarUIPayloadRes.right().value());
}
Map<String, byte[]> csarUIPayload = csarUIPayloadRes.left().value();
@@ -666,7 +668,7 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
}
private Resource throwComponentException(ResponseFormat responseFormat) {
- throw new ComponentException(responseFormat);
+ throw new ByResponseFormatComponentException(responseFormat);
}
private void getAndValidateCsarYaml(Map<String, byte[]> csarUIPayload, Resource resource, User user, String csarUUID) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/exception/ComponentExceptionMapper.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/exception/ComponentExceptionMapper.java
index 4ec1915014..19ef727b57 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/exception/ComponentExceptionMapper.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/exception/ComponentExceptionMapper.java
@@ -1,7 +1,30 @@
+/*-
+ * ============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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
package org.openecomp.sdc.be.servlets.exception;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -29,10 +52,6 @@ public class ComponentExceptionMapper implements ExceptionMapper<ComponentExcept
// TODO log this? BeEcompErrorManager.getInstance().logBeRestApiGeneralError(requestURI);
log.debug("#toResponse - An error occurred: ", exception);
ResponseFormat responseFormat = exception.getResponseFormat();
- if (exception.getResponseFormat()==null) {
- responseFormat = componentsUtils.getResponseFormat(exception.getActionStatus(), exception.getParams());
- }
-
return Response.status(responseFormat.getStatus())
.entity(gson.toJson(responseFormat.getRequestError()))
.build();