aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api
diff options
context:
space:
mode:
authoravigaffa <avi.gaffa@amdocs.com>2017-12-31 15:07:39 +0200
committervempo <vitaliy.emporopulo@amdocs.com>2018-01-02 09:41:41 +0200
commitda5dfcd1a354807d13849c7f4ead535ccfa722fa (patch)
treeb4ef0b97d4c25a38bf4a7a8aa5d3626d6b820a17 /openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api
parent25ca73d85757869a6d9cc33861070778503ff153 (diff)
Fixing sonar Exception Handling
Change-Id: I04eb047973a3f5c07dd9dc410cb13af974e8ded1 Issue-ID: SDC-810 Signed-off-by: avigaffa <avi.gaffa@amdocs.com> Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api')
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java219
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java247
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java219
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java248
4 files changed, 458 insertions, 475 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java
index 379b110ff2..c3ee44c3bb 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java
@@ -22,6 +22,7 @@ import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -35,117 +36,113 @@ import java.nio.ByteBuffer;
@Table(keyspace = "dox", name = "vsp_enriched_service_artifact")
public class EnrichedServiceArtifactEntity implements ServiceElementEntity {
- private static final String ENTITY_TYPE;
-
- static {
- ENTITY_TYPE = "Vendor Software Product Service artifact";
- }
-
- @PartitionKey
- @Column(name = "vsp_id")
- public String id;
-
- @PartitionKey(value = 1)
- @Frozen
- public Version version;
-
- @ClusteringColumn
- @Column(name = "name")
- public String name;
-
- @Column(name = "content_data")
- public ByteBuffer contentData;
-
- /**
- * Every entity class must have a default constructor according to
- * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
- * Definition of mapped classes</a>.
- */
- public EnrichedServiceArtifactEntity() {
- // Don't delete! Default constructor is required by DataStax driver
- }
-
- /**
- * Instantiates a new Enriched service artifact entity.
- *
- * @param entity the entity
- */
- public EnrichedServiceArtifactEntity(ServiceArtifact entity) {
- this.id = entity.getVspId();
- this.version = entity.getVersion();
- this.name = entity.getName();
-
- try {
- this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
- } catch (IOException ioException) { //todo fix typo in Traget
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_SERVICE_ENRICH_ARTIFACT, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- LoggerErrorDescription.CREATE_ENRICH_SERVICE_ARTIFACT);
- throw new RuntimeException(ioException);
+
+ private static final String ENTITY_TYPE;
+
+ static {
+ ENTITY_TYPE = "Vendor Software Product Service artifact";
+ }
+
+ @PartitionKey
+ @Column(name = "vsp_id")
+ public String id;
+
+ @PartitionKey(value = 1)
+ @Frozen
+ public Version version;
+
+ @ClusteringColumn
+ @Column(name = "name")
+ public String name;
+
+ @Column(name = "content_data")
+ public ByteBuffer contentData;
+
+ /**
+ * Every entity class must have a default constructor according to
+ * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
+ * Definition of mapped classes</a>.
+ */
+ public EnrichedServiceArtifactEntity() {
+ // Don't delete! Default constructor is required by DataStax driver
+ }
+
+ /**
+ * Instantiates a new Enriched service artifact entity.
+ *
+ * @param entity the entity
+ */
+ public EnrichedServiceArtifactEntity(ServiceArtifact entity) {
+ this.id = entity.getVspId();
+ this.version = entity.getVersion();
+ this.name = entity.getName();
+
+ try {
+ this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
+ } catch (IOException ioException) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_SERVICE_ENRICH_ARTIFACT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ LoggerErrorDescription.CREATE_ENRICH_SERVICE_ARTIFACT);
+ throw new SdcRuntimeException(ioException);
+ }
+
+ }
+
+ @Override
+ public String getEntityType() {
+ return ENTITY_TYPE;
+ }
+
+ @Override
+ public String getFirstClassCitizenId() {
+ return getId();
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Version getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public ByteBuffer getContentData() {
+ return contentData;
+ }
+
+ public void setContentData(ByteBuffer contentData) {
+ this.contentData = contentData;
}
- }
-
- @Override
- public String getEntityType() {
- return ENTITY_TYPE;
- }
-
- @Override
- public String getFirstClassCitizenId() {
- return getId();
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Version getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(Version version) {
- this.version = version;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public ByteBuffer getContentData() {
- return contentData;
- }
-
- public void setContentData(ByteBuffer contentData) {
- this.contentData = contentData;
- }
-
- /**
- * Gets service artifact.
- *
- * @return the service artifact
- */
- public ServiceArtifact getServiceArtifact() {
- ServiceArtifact serviceArtifact = new ServiceArtifact();
- serviceArtifact.setName(this.getName());
- serviceArtifact.setVersion(this.getVersion());
- serviceArtifact.setContentData(this.getContentData().array());
- serviceArtifact.setVspId(this.getId());
- return serviceArtifact;
- }
+ public ServiceArtifact getServiceArtifact() {
+ ServiceArtifact serviceArtifact = new ServiceArtifact();
+ serviceArtifact.setName(this.getName());
+ serviceArtifact.setVersion(this.getVersion());
+ serviceArtifact.setContentData(this.getContentData().array());
+ serviceArtifact.setVspId(this.getId());
+ return serviceArtifact;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java
index b6b627872b..65c3d94687 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java
@@ -22,6 +22,7 @@ import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -36,130 +37,124 @@ import java.nio.ByteBuffer;
@Table(keyspace = "dox", name = "vsp_enriched_service_template")
public class EnrichedServiceTemplateEntity implements ServiceElementEntity {
- private static final String ENTITY_TYPE;
-
- static {
- ENTITY_TYPE = "Vendor Software Product Service model";
- }
-
- @PartitionKey
- @Column(name = "vsp_id")
- public String id;
-
- @PartitionKey(value = 1)
- @Frozen
- public Version version;
-
- @ClusteringColumn
- @Column(name = "name")
- public String name;
-
- @Column(name = "content_data")
- public ByteBuffer contentData;
-
- @Column(name = "base_name")
- private String baseName;
-
- /**
- * Every entity class must have a default constructor according to
- * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
- * Definition of mapped classes</a>.
- */
- public EnrichedServiceTemplateEntity() {
- // Don't delete! Default constructor is required by DataStax driver
- }
-
- /**
- * Instantiates a new Enriched service template entity.
- *
- * @param entity the entity
- */
- public EnrichedServiceTemplateEntity(ServiceTemplate entity) {
- this.id = entity.getVspId();
- this.version = entity.getVersion();
- this.name = entity.getName();
- this.setBaseName(entity.getBaseName());
- try {
- this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
- } catch (IOException ioException) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_ENRICH_SERVICE_TEMPLATE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- LoggerErrorDescription.CREATE_ENRICH_SERVICE_TEMPLATE);
- throw new RuntimeException(ioException);
- }
-
- }
-
- public String getBaseName() {
- return baseName;
- }
-
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
- @Override
- public String getEntityType() {
- return ENTITY_TYPE;
- }
-
- @Override
- public String getFirstClassCitizenId() {
- return getId();
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Version getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(Version version) {
- this.version = version;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public ByteBuffer getContentData() {
- return contentData;
- }
-
- public void setContentData(ByteBuffer contentData) {
- this.contentData = contentData;
- }
-
- /**
- * Gets service template.
- *
- * @return the service template
- */
- public ServiceTemplate getServiceTemplate() {
- ServiceTemplate serviceTemplate = new ServiceTemplate();
- serviceTemplate.setName(this.getName());
- serviceTemplate.setVersion(this.getVersion());
- serviceTemplate.setContentData(this.getContentData().array());
- serviceTemplate.setVspId(this.getId());
- serviceTemplate.setBaseName(this.getBaseName());
- return serviceTemplate;
-
- }
+ private static final String ENTITY_TYPE;
+
+ static {
+ ENTITY_TYPE = "Vendor Software Product Service model";
+ }
+
+ @PartitionKey
+ @Column(name = "vsp_id")
+ public String id;
+
+ @PartitionKey(value = 1)
+ @Frozen
+ public Version version;
+
+ @ClusteringColumn
+ @Column(name = "name")
+ public String name;
+
+ @Column(name = "content_data")
+ public ByteBuffer contentData;
+
+ @Column(name = "base_name")
+ private String baseName;
+
+ /**
+ * Every entity class must have a default constructor according to
+ * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
+ * Definition of mapped classes</a>.
+ */
+ public EnrichedServiceTemplateEntity() {
+ // Don't delete! Default constructor is required by DataStax driver
+ }
+
+ /**
+ * Instantiates a new Enriched service template entity.
+ *
+ * @param entity the entity
+ */
+ public EnrichedServiceTemplateEntity(ServiceTemplate entity) {
+ this.id = entity.getVspId();
+ this.version = entity.getVersion();
+ this.name = entity.getName();
+ this.setBaseName(entity.getBaseName());
+ try {
+ this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
+ } catch (IOException ioException) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_ENRICH_SERVICE_TEMPLATE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ LoggerErrorDescription.CREATE_ENRICH_SERVICE_TEMPLATE);
+ throw new SdcRuntimeException(ioException);
+ }
+
+ }
+
+ public String getBaseName() {
+ return baseName;
+ }
+
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ @Override
+ public String getEntityType() {
+ return ENTITY_TYPE;
+ }
+
+ @Override
+ public String getFirstClassCitizenId() {
+ return getId();
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Version getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public ByteBuffer getContentData() {
+ return contentData;
+ }
+
+ public void setContentData(ByteBuffer contentData) {
+ this.contentData = contentData;
+ }
+
+ public ServiceTemplate getServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setName(getName());
+ serviceTemplate.setVersion(getVersion());
+ serviceTemplate.setContentData(getContentData().array());
+ serviceTemplate.setVspId(getId());
+ serviceTemplate.setBaseName(getBaseName());
+ return serviceTemplate;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java
index 579bdf29e0..802cf1767f 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java
@@ -22,6 +22,7 @@ import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -35,117 +36,113 @@ import java.nio.ByteBuffer;
@Table(keyspace = "dox", name = "vsp_service_artifact")
public class ServiceArtifactEntity implements ServiceElementEntity {
- private static final String ENTITY_TYPE;
-
- static {
- ENTITY_TYPE = "Vendor Software Product Service artifact";
- }
-
- @PartitionKey
- @Column(name = "vsp_id")
- public String id;
-
- @PartitionKey(value = 1)
- @Frozen
- public Version version;
-
- @ClusteringColumn
- @Column(name = "name")
- public String name;
-
- @Column(name = "content_data")
- public ByteBuffer contentData;
-
- /**
- * Every entity class must have a default constructor according to
- * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
- * Definition of mapped classes</a>.
- */
- public ServiceArtifactEntity() {
- // Don't delete! Default constructor is required by DataStax driver
- }
-
- /**
- * Instantiates a new Service artifact entity.
- *
- * @param entity the entity
- */
- public ServiceArtifactEntity(ServiceArtifact entity) {
- this.id = entity.getVspId();
- this.version = entity.getVersion();
- this.name = entity.getName();
-
- try {
- this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
- } catch (IOException ioException) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_SERVICE_ARTIFACT, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- LoggerErrorDescription.CREATE_SERVICE_ARTIFACT);
- throw new RuntimeException(ioException);
+ private static final String ENTITY_TYPE;
+
+ static {
+ ENTITY_TYPE = "Vendor Software Product Service artifact";
+ }
+
+ @PartitionKey
+ @Column(name = "vsp_id")
+ public String id;
+
+ @PartitionKey(value = 1)
+ @Frozen
+ public Version version;
+
+ @ClusteringColumn
+ @Column(name = "name")
+ public String name;
+
+ @Column(name = "content_data")
+ public ByteBuffer contentData;
+
+ /**
+ * Every entity class must have a default constructor according to
+ * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
+ * Definition of mapped classes</a>.
+ */
+ public ServiceArtifactEntity() {
+ // Don't delete! Default constructor is required by DataStax driver
+ }
+
+ /**
+ * Instantiates a new Service artifact entity.
+ *
+ * @param entity the entity
+ */
+ public ServiceArtifactEntity(ServiceArtifact entity) {
+ this.id = entity.getVspId();
+ this.version = entity.getVersion();
+ this.name = entity.getName();
+
+ try {
+ this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
+ } catch (IOException ioException) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_SERVICE_ARTIFACT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ LoggerErrorDescription.CREATE_SERVICE_ARTIFACT);
+ throw new SdcRuntimeException(ioException);
+ }
+
+ }
+
+ @Override
+ public String getEntityType() {
+ return ENTITY_TYPE;
+ }
+
+ @Override
+ public String getFirstClassCitizenId() {
+ return getId();
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Version getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public ByteBuffer getContentData() {
+ return contentData;
+ }
+
+ public void setContentData(ByteBuffer contentData) {
+ this.contentData = contentData;
+ }
+
+ public ServiceArtifact getServiceArtifact() {
+ ServiceArtifact serviceArtifact = new ServiceArtifact();
+ serviceArtifact.setName(this.getName());
+ serviceArtifact.setVersion(this.getVersion());
+ serviceArtifact.setContentData(this.getContentData().array());
+ serviceArtifact.setVspId(this.getId());
+ return serviceArtifact;
}
- }
-
- @Override
- public String getEntityType() {
- return ENTITY_TYPE;
- }
-
- @Override
- public String getFirstClassCitizenId() {
- return getId();
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Version getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(Version version) {
- this.version = version;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public ByteBuffer getContentData() {
- return contentData;
- }
-
- public void setContentData(ByteBuffer contentData) {
- this.contentData = contentData;
- }
-
- /**
- * Gets service artifact.
- *
- * @return the service artifact
- */
- public ServiceArtifact getServiceArtifact() {
- ServiceArtifact serviceArtifact = new ServiceArtifact();
- serviceArtifact.setName(this.getName());
- serviceArtifact.setVersion(this.getVersion());
- serviceArtifact.setContentData(this.getContentData().array());
- serviceArtifact.setVspId(this.getId());
- return serviceArtifact;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java
index 17f17dc83f..71b3e49a20 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java
@@ -22,6 +22,7 @@ import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -36,131 +37,124 @@ import java.nio.ByteBuffer;
@Table(keyspace = "dox", name = "vsp_service_template")
public class ServiceTemplateEntity implements ServiceElementEntity {
- private static final String ENTITY_TYPE;
-
- static {
- ENTITY_TYPE = "Vendor Software Product Service model";
- }
-
- @PartitionKey
- @Column(name = "vsp_id")
- public String id;
-
- @PartitionKey(value = 1)
- @Frozen
- public Version version;
-
- @ClusteringColumn
- @Column(name = "name")
- public String name;
-
- @Column(name = "content_data")
- public ByteBuffer contentData;
-
- @Column(name = "base_name")
- private String baseName;
-
- /**
- * Every entity class must have a default constructor according to
- * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
- * Definition of mapped classes</a>.
- */
- public ServiceTemplateEntity() {
- // Don't delete! Default constructor is required by DataStax driver
- }
-
- /**
- * Instantiates a new Service template entity.
- *
- * @param entity the entity
- */
- public ServiceTemplateEntity(ServiceTemplate entity) {
- this.id = entity.getVspId();
- this.version = entity.getVersion();
- this.name = entity.getName();
- this.setBaseName(entity.getBaseName());
- try {
- this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
- } catch (IOException ioException) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_SERVICE_TEMPLATE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- LoggerErrorDescription.CREATE_SERVICE_TEMPLATE);
- throw new RuntimeException(ioException);
- }
-
- }
-
- public String getBaseName() {
- return baseName;
- }
-
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
- @Override
- public String getEntityType() {
- return ENTITY_TYPE;
- }
-
- @Override
- public String getFirstClassCitizenId() {
- return getId();
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Version getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(Version version) {
- this.version = version;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public ByteBuffer getContentData() {
- return contentData;
- }
-
- public void setContentData(ByteBuffer contentData) {
- this.contentData = contentData;
- }
-
-
- /**
- * Gets service template.
- *
- * @return the service template
- */
- public ServiceTemplate getServiceTemplate() {
- ServiceTemplate serviceTemplate = new ServiceTemplate();
- serviceTemplate.setName(this.getName());
- serviceTemplate.setVersion(this.getVersion());
- serviceTemplate.setContentData(this.getContentData().array());
- serviceTemplate.setVspId(this.getId());
- serviceTemplate.setBaseName(this.getBaseName());
- return serviceTemplate;
-
- }
+ private static final String ENTITY_TYPE;
+
+ static {
+ ENTITY_TYPE = "Vendor Software Product Service model";
+ }
+
+ @PartitionKey
+ @Column(name = "vsp_id")
+ public String id;
+
+ @PartitionKey(value = 1)
+ @Frozen
+ public Version version;
+
+ @ClusteringColumn
+ @Column(name = "name")
+ public String name;
+
+ @Column(name = "content_data")
+ public ByteBuffer contentData;
+
+ @Column(name = "base_name")
+ private String baseName;
+
+ /**
+ * Every entity class must have a default constructor according to
+ * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
+ * Definition of mapped classes</a>.
+ */
+ public ServiceTemplateEntity() {
+ // Don't delete! Default constructor is required by DataStax driver
+ }
+
+ /**
+ * Instantiates a new Service template entity.
+ *
+ * @param entity the entity
+ */
+ public ServiceTemplateEntity(ServiceTemplate entity) {
+ this.id = entity.getVspId();
+ this.version = entity.getVersion();
+ this.name = entity.getName();
+ this.setBaseName(entity.getBaseName());
+ try {
+ this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
+ } catch (IOException ioException) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_SERVICE_TEMPLATE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ LoggerErrorDescription.CREATE_SERVICE_TEMPLATE);
+ throw new SdcRuntimeException(ioException);
+ }
+
+ }
+
+ public String getBaseName() {
+ return baseName;
+ }
+
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ @Override
+ public String getEntityType() {
+ return ENTITY_TYPE;
+ }
+
+ @Override
+ public String getFirstClassCitizenId() {
+ return getId();
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Version getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public ByteBuffer getContentData() {
+ return contentData;
+ }
+
+ public void setContentData(ByteBuffer contentData) {
+ this.contentData = contentData;
+ }
+
+ public ServiceTemplate getServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setName(getName());
+ serviceTemplate.setVersion(getVersion());
+ serviceTemplate.setContentData(getContentData().array());
+ serviceTemplate.setVspId(getId());
+ serviceTemplate.setBaseName(getBaseName());
+ return serviceTemplate;
+ }
}