diff options
author | Ofir Sonsino <os0695@att.com> | 2017-09-04 14:52:07 +0300 |
---|---|---|
committer | Ofir Sonsino <os0695@att.com> | 2017-09-04 14:52:07 +0300 |
commit | b35670742c728d7d85da2f9c856c51a5889449d6 (patch) | |
tree | 92e544b121b8a47230667f0e0078c188a47dd8eb /vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java | |
parent | 49a483a9b40cb429717ccec69fa99e4908aadbb6 (diff) |
[VID-55] Upgrade Tosca Parser (merge)
Change-Id: I5389f1641ef22df3ed569a154b3c367117c04d04
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java')
-rw-r--r-- | vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java new file mode 100644 index 000000000..9844842f8 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java @@ -0,0 +1,79 @@ +package org.openecomp.vid.services; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; +import org.openecomp.vid.asdc.AsdcCatalogException; +import org.openecomp.vid.asdc.AsdcClient; +import org.openecomp.vid.asdc.beans.Service; +import org.openecomp.vid.asdc.parser.ToscaParser; +import org.openecomp.vid.asdc.parser.ToscaParserImpl; +import org.openecomp.vid.asdc.parser.ToscaParserImpl2; +import org.openecomp.vid.model.ServiceModel; +import org.springframework.beans.factory.annotation.Autowired; + +import java.nio.file.Path; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; + +/** + * The Class VidController. + */ + +public class VidServiceImpl implements VidService { + /** + * The Constant LOG. + */ + private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidServiceImpl.class); + /** + * The Constant dateFormat. + */ + private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + protected final AsdcClient asdcClient; + @Autowired + private ToscaParserImpl2 toscaParser; + + public VidServiceImpl(AsdcClient asdcClient) { + this.asdcClient = asdcClient; + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.vid.controller.VidService#getServices(java.util.Map) + */ + @Override + public Collection<Service> getServices(Map<String, String[]> requestParams) + throws AsdcCatalogException { + return asdcClient.getServices(requestParams); + } + + /* + * (non-Javadoc) + * + * @see org.openecomp.vid.controller.VidService#getService(java.lang.String) + */ + @Override + public ServiceModel getService(String uuid) throws AsdcCatalogException { + final Path serviceCsar = asdcClient.getServiceToscaModel(UUID.fromString(uuid)); + ToscaParser tosca = new ToscaParserImpl(); + serviceCsar.toFile().getAbsolutePath(); + ServiceModel serviceModel = null; + try { + final Service asdcServiceMetadata = asdcClient.getService(UUID.fromString(uuid)); + try { + serviceModel = toscaParser.makeServiceModel(serviceCsar, asdcServiceMetadata); + } + catch (SdcToscaParserException e){ + serviceModel = tosca.makeServiceModel(uuid, serviceCsar, asdcServiceMetadata); + } + } catch (Exception e) { + e.printStackTrace(); + } + return serviceModel; + } + + +}
\ No newline at end of file |