diff options
author | talig <talig@amdocs.com> | 2017-12-20 14:30:43 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2017-12-21 11:12:33 +0000 |
commit | 8e9c0653dd6c6862123c9609ae34e1206d86456e (patch) | |
tree | 5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core | |
parent | 785ebcc95de3e064e843bec04ba7a209d854fc7c (diff) |
Add collaboration feature
Issue-ID: SDC-767
Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795
Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core')
6 files changed, 66 insertions, 18 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java index e7ff3aa8ee..39a53b499d 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java @@ -12,7 +12,17 @@ import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import org.openecomp.sdc.tosca.datatypes.model.*; +import org.openecomp.sdc.tosca.datatypes.model.ArtifactDefinition; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityAssignment; +import org.openecomp.sdc.tosca.datatypes.model.Import; +import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition; +import org.openecomp.sdc.tosca.datatypes.model.NodeFilter; +import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition; +import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping; import org.openecomp.sdc.tosca.services.DataModelUtil; import org.openecomp.sdc.tosca.services.ToscaUtil; import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator; @@ -21,11 +31,28 @@ import org.yaml.snakeyaml.error.YAMLException; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.jar.Manifest; import java.util.regex.Pattern; -import static org.openecomp.core.converter.datatypes.Constants.*; +import static org.openecomp.core.converter.datatypes.Constants.capabilities; +import static org.openecomp.core.converter.datatypes.Constants.definitionsDir; +import static org.openecomp.core.converter.datatypes.Constants.globalStName; +import static org.openecomp.core.converter.datatypes.Constants.globalSubstitution; +import static org.openecomp.core.converter.datatypes.Constants.inputs; +import static org.openecomp.core.converter.datatypes.Constants.mainStName; +import static org.openecomp.core.converter.datatypes.Constants.manifestFileName; +import static org.openecomp.core.converter.datatypes.Constants.metadataFile; +import static org.openecomp.core.converter.datatypes.Constants.nodeType; +import static org.openecomp.core.converter.datatypes.Constants.openecompHeatIndex; +import static org.openecomp.core.converter.datatypes.Constants.outputs; +import static org.openecomp.core.converter.datatypes.Constants.requirements; import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME; public class ToscaConverterImpl implements ToscaConverter { @@ -89,9 +116,8 @@ public class ToscaConverterImpl implements ToscaConverter { } } catch (YAMLException ye) { throw new CoreException(new ErrorCode.ErrorCodeBuilder() - .withMessage("Invalid YAML content in file " + key + ". reason - " - + ye.getMessage()) - .withCategory(ErrorCategory.APPLICATION).build()); + .withMessage("Invalid YAML content in file " + key) + .withCategory(ErrorCategory.APPLICATION).build(), ye); } } @@ -181,9 +207,8 @@ public class ToscaConverterImpl implements ToscaConverter { } catch (YAMLException ye) { throw new CoreException(new ErrorCode.ErrorCodeBuilder() - .withMessage("Invalid YAML content in file" + serviceTemplateName + ". reason - " - + ye.getMessage()) - .withCategory(ErrorCategory.APPLICATION).build()); + .withMessage("Invalid YAML content in file" + serviceTemplateName) + .withCategory(ErrorCategory.APPLICATION).build(), ye); } diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java index 520e41817e..4917533dd8 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java @@ -5,6 +5,8 @@ import org.openecomp.core.converter.api.ToscaConverterManager; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import java.lang.reflect.Constructor; @@ -14,8 +16,10 @@ import java.util.Map; public class ToscaConverterManagerImpl implements ToscaConverterManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ToscaConverterManagerImpl.class.getName()); private static List<ToscaConverter> toscaConverters; private static final String toscaConverterFileName = "ToscaConverters.json"; + private static final String TOSCA_CONVERTER_IMPL_FORMAT_ERROR = "Failed to construct TOSCA converter for '%s' implementation."; static { toscaConverters = getConvertersList(); @@ -40,7 +44,8 @@ public class ToscaConverterManagerImpl implements ToscaConverterManager { Class<?> clazz = Class.forName(implClassName); Constructor<?> constructor = clazz.getConstructor(); toscaConvertersList.add((ToscaConverter) constructor.newInstance()); - }catch (Exception e){ + }catch (Exception ex){ + LOGGER.debug(String.format(TOSCA_CONVERTER_IMPL_FORMAT_ERROR, implClassName), ex); continue; } } diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java index 20ac6413e7..d34d46796d 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java @@ -4,6 +4,8 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.openecomp.core.converter.errors.CreateToscaObjectErrorBuilder; import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import java.lang.reflect.Field; import java.util.HashSet; @@ -20,6 +22,8 @@ public class ToscaConverterUtil { private static final String DEFAULT_CAPITAL = "Default"; private static Set<String> defaultValueKeys; + private static Logger LOGGER = LoggerFactory.getLogger(ToscaConverterUtil.class.getName()); + static { defaultValueKeys = Stream.of(DEFAULT, DEFAULT_CAPITAL).collect(Collectors.toSet()); @@ -30,10 +34,10 @@ public class ToscaConverterUtil { Class<T> classToCreate) { try { return createObjectUsingSetters(objectCandidate, classToCreate); - } catch (Exception e) { + } catch (Exception ex) { throw new CoreException( - new CreateToscaObjectErrorBuilder(classToCreate.getSimpleName(), objectId, e.getMessage()) - .build()); + new CreateToscaObjectErrorBuilder(classToCreate.getSimpleName(), objectId) + .build(), ex); } } @@ -68,6 +72,8 @@ public class ToscaConverterUtil { return Objects.nonNull(fieldValueToAssign) && Objects.nonNull(classToCreate.getMethod(methodName, field.getType())); } catch (NoSuchMethodException e) { + LOGGER.debug(String.format("Could not extract method '%s' from class '%s'. returning false " + + "with filedType '%s'.", methodName, classToCreate, field.getType()), e); return false; } } diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java index 22780af343..ee39af98c9 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java @@ -7,7 +7,14 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import static org.openecomp.core.converter.datatypes.Constants.*; +import static org.openecomp.core.converter.datatypes.Constants.definitionVersion; +import static org.openecomp.core.converter.datatypes.Constants.inputs; +import static org.openecomp.core.converter.datatypes.Constants.metadata; +import static org.openecomp.core.converter.datatypes.Constants.nodeTemplates; +import static org.openecomp.core.converter.datatypes.Constants.nodeTypes; +import static org.openecomp.core.converter.datatypes.Constants.outputs; +import static org.openecomp.core.converter.datatypes.Constants.substitutionMappings; +import static org.openecomp.core.converter.datatypes.Constants.topologyTemplate; public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderService { diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java index 5ee96aba07..df34b89cbb 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java @@ -2,7 +2,6 @@ package org.openecomp.core.converter.impl; import org.apache.commons.collections.CollectionUtils; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.openecomp.core.converter.ToscaConverter; import org.openecomp.core.impl.ToscaConverterImpl; diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java index 1ee8f6c05f..82a36950f3 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java @@ -13,9 +13,15 @@ import java.net.URL; import java.util.Map; import java.util.Set; -import static org.openecomp.sdc.common.utils.CommonUtil.*; -import static org.junit.Assert.*; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.DEFININTION_VERSION; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.TEMPLATE_NAME_PROPERTY; +import static org.openecomp.sdc.common.utils.CommonUtil.validateAndUploadFileContent; public class ToscaConvertorDefinitionsTest { |