summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-07-20 01:29:49 +0300
committerMichael Lando <ml636r@att.com>2017-07-20 01:30:06 +0300
commit3c3c833897dbfc0e85feaf36086a505f990ecb76 (patch)
tree8c308fbe7298aa65066ba0fc8a71e51d20d8e0de /catalog-be/src/main/java
parent30db4407bab8cfea48e278d29e55b11c6c0a528c (diff)
[SDC] 1710 rebase + pom modifications
Change-Id: I1f9c0a5201576c7a6b124f6a786db12c1a8cd7c0 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java17
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java48
2 files changed, 58 insertions, 7 deletions
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 77900efd82..e4c75eab05 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
@@ -111,9 +111,7 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
+import org.xml.sax.*;
import org.yaml.snakeyaml.Yaml;
import com.google.gson.Gson;
@@ -2038,6 +2036,17 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
@SuppressWarnings("restriction")
public boolean isValidXml(byte[] xmlToParse) {
XMLReader parser = new SAXParser();
+ try {
+ parser.setFeature("http://apache.org/xml/features/validation/schema", false);
+ } catch (SAXNotRecognizedException e) {
+ e.printStackTrace();
+ log.debug("Xml parser couldn't set feature: \"http://apache.org/xml/features/validation/schema\", false", e.getMessage(), e);
+
+ } catch (SAXNotSupportedException e) {
+ e.printStackTrace();
+ log.debug("Xml parser couldn't set feature: \"http://apache.org/xml/features/validation/schema\", false", e.getMessage(), e);
+
+ }
boolean isXmlValid = true;
try {
parser.parse(new InputSource(new ByteArrayInputStream(xmlToParse)));
@@ -4007,7 +4016,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
private Either<Either<ArtifactDefinition,Operation>,ResponseFormat> getResponseAndAuditInvalidEmptyHeatEnvFile(AuditingActionEnum auditingAction, Component parent, String uniqueId, User user, ArtifactDefinition currHeatArtifact, String artifactId, ComponentTypeEnum componentType) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML, currHeatArtifact.getArtifactName());
handleAuditing(auditingAction, parent, parent.getUniqueId(), user, currHeatArtifact, null, artifactId, responseFormat, componentType, "");
return Either.right(responseFormat);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 56cd91d754..5b6488d788 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -42,12 +42,15 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.info.CreateAndAssotiateInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
@@ -65,11 +68,13 @@ import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
+import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
@@ -487,7 +492,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
Component origComponent = eitherResourceName.left().value();
- resultOp = updateComponentInstanceMetadata(containerComponent, containerComponentType, origComponent, componentInstanceId, componentInstance, inTransaction);
+ resultOp = updateComponentInstanceMetadata(containerComponent, containerComponentType, origComponent, componentInstanceId, componentInstance);
return resultOp;
} finally {
@@ -562,7 +567,8 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
Optional<ComponentInstance> op = componentInstanceList.stream().filter(ci -> ci.getUniqueId().equals(origInst.getUniqueId())).findAny();
if(op.isPresent()){
ComponentInstance updatedCi = op.get();
- updatedCi.setCustomizationUUID(origInst.getCustomizationUUID());
+ updatedCi = buildComponentInstance(updatedCi, origInst);
+
Boolean isUniqueName = validateInstanceNameUniquenessUponUpdate(containerComponent, origInst, updatedCi.getName());
if(!isUniqueName){
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update the name of the component instance {} to {}. A component instance with the same name already exists. ",
@@ -617,7 +623,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private Either<ComponentInstance, ResponseFormat> updateComponentInstanceMetadata(Component containerComponent, ComponentTypeEnum containerComponentType, org.openecomp.sdc.be.model.Component origComponent, String componentInstanceId,
- ComponentInstance componentInstance, boolean inTransaction) {
+ ComponentInstance componentInstance) {
Either<ComponentInstance, ResponseFormat> resultOp = null;
Optional<ComponentInstance> componentInstanceOptional = null;
@@ -1872,4 +1878,40 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
return result;
}
+
+ private ComponentInstance buildComponentInstance(ComponentInstance resourceInstanceForUpdate, ComponentInstance origInstanceForUpdate) {
+
+ Long creationDate = origInstanceForUpdate.getCreationTime();
+
+ Long modificationTime = System.currentTimeMillis();
+ resourceInstanceForUpdate.setCreationTime(creationDate);
+ resourceInstanceForUpdate.setModificationTime(modificationTime);
+
+ resourceInstanceForUpdate.setCustomizationUUID(origInstanceForUpdate.getCustomizationUUID());
+
+ if (StringUtils.isEmpty(resourceInstanceForUpdate.getName())) {
+ resourceInstanceForUpdate.setName(origInstanceForUpdate.getName());
+
+ }
+ if (StringUtils.isEmpty(resourceInstanceForUpdate.getNormalizedName()))
+ resourceInstanceForUpdate.setNormalizedName(origInstanceForUpdate.getNormalizedName());
+
+ if (StringUtils.isEmpty(resourceInstanceForUpdate.getIcon()))
+ resourceInstanceForUpdate.setIcon(origInstanceForUpdate.getIcon());
+
+
+ if (StringUtils.isEmpty(resourceInstanceForUpdate.getComponentVersion()))
+ resourceInstanceForUpdate.setComponentVersion(origInstanceForUpdate.getComponentVersion());
+
+ if (StringUtils.isEmpty(resourceInstanceForUpdate.getComponentName()))
+ resourceInstanceForUpdate.setComponentName(origInstanceForUpdate.getComponentName());
+
+ if (StringUtils.isEmpty(resourceInstanceForUpdate.getToscaComponentName()))
+ resourceInstanceForUpdate.setToscaComponentName(origInstanceForUpdate.getToscaComponentName());
+
+ if (resourceInstanceForUpdate.getOriginType() == null) {
+ resourceInstanceForUpdate.setOriginType(origInstanceForUpdate.getOriginType());
+ }
+ return resourceInstanceForUpdate;
+ }
}