diff options
Diffstat (limited to 'vid-app-common/src/main/java/org/openecomp/vid/services')
-rw-r--r-- | vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java | 17 | ||||
-rw-r--r-- | vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java | 79 |
2 files changed, 96 insertions, 0 deletions
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java b/vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java new file mode 100644 index 000000000..4fb0ff160 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java @@ -0,0 +1,17 @@ +package org.openecomp.vid.services; + +import org.openecomp.vid.asdc.AsdcCatalogException; +import org.openecomp.vid.asdc.beans.Service; +import org.openecomp.vid.model.ServiceModel; + +import java.util.Collection; +import java.util.Map; + +public interface VidService { + + Collection<Service> getServices(Map<String, String[]> requestParams) + throws AsdcCatalogException; + + ServiceModel getService(String uuid) throws AsdcCatalogException; + +}
\ No newline at end of file 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 |