Search in sources :

Example 1 with ZipParser

use of org.onap.so.asdc.util.ZipParser in project so by onap.

the class ASDCController method processNsstNotification.

private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
    Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
    try {
        String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
        boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement")) && iNotif.getResources().isEmpty();
        if (isNeedInital) {
            String artifactContent = null;
            List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
            Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream().filter(e -> e.getArtifactType().equalsIgnoreCase("WORKFLOW")).findFirst();
            if (artifactOpt.isPresent()) {
                IArtifactInfo artifactInfo = artifactOpt.get();
                logger.debug("Ready to parse this serviceArtifactUUID:  " + artifactInfo.getArtifactUUID());
                String filePath = Paths.get(getMsoConfigPath(), "ASDC", artifactInfo.getArtifactVersion(), artifactInfo.getArtifactName()).normalize().toString();
                ZipParser zipParserInstance = ZipParser.getInstance();
                artifactContent = zipParserInstance.parseJsonForZip(filePath);
                logger.debug("serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
                ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
                resourceStructure.setResourceType(ResourceType.OTHER);
                toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure, artifactContent);
            } else {
                logger.debug("serviceArtifact is null");
                toscaInstaller.installNsstService(toscaResourceStructure, null, null);
            }
        }
    } catch (IOException e) {
        logger.error("serviceArtifact parse failure for service uuid:  " + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
    } catch (Exception e) {
        logger.error("error NSST process resource failure ", e);
    }
}
Also used : ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) ONAPLogConstants(org.onap.logging.ref.slf4j.ONAPLogConstants) IFinalDistrStatusMessage(org.onap.sdc.api.consumer.IFinalDistrStatusMessage) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) INotificationData(org.onap.sdc.api.notification.INotificationData) ASDCDownloadException(org.onap.so.asdc.client.exceptions.ASDCDownloadException) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) WatchdogComponentDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ResourceType(org.onap.so.asdc.installer.ResourceType) ASDCNotificationLogging(org.onap.so.asdc.util.ASDCNotificationLogging) MessageEnum(org.onap.so.logger.MessageEnum) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) WatchdogDistribution(org.onap.so.asdc.tenantIsolation.WatchdogDistribution) IDistributionClientDownloadResult(org.onap.sdc.api.results.IDistributionClientDownloadResult) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) ASDCParametersException(org.onap.so.asdc.client.exceptions.ASDCParametersException) DistributionStatus(org.onap.so.asdc.tenantIsolation.DistributionStatus) StandardCharsets(java.nio.charset.StandardCharsets) IDistributionClient(org.onap.sdc.api.IDistributionClient) List(java.util.List) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) DistributionActionResultEnum(org.onap.sdc.utils.DistributionActionResultEnum) Optional(java.util.Optional) LoggingAnchor(org.onap.so.logger.LoggingAnchor) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WatchdogDistributionStatusRepository(org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository) ZipParser(org.onap.so.asdc.util.ZipParser) MapperFeature(com.fasterxml.jackson.databind.MapperFeature) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance) ErrorCode(org.onap.logging.filter.base.ErrorCode) IDistributionStatusMessage(org.onap.sdc.api.consumer.IDistributionStatusMessage) IDistributionClientResult(org.onap.sdc.api.results.IDistributionClientResult) DistributionStatusEnum(org.onap.sdc.utils.DistributionStatusEnum) WatchdogComponentDistributionStatus(org.onap.so.db.request.beans.WatchdogComponentDistributionStatus) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileOutputStream(java.io.FileOutputStream) IVfResourceInstaller(org.onap.so.asdc.installer.IVfResourceInstaller) Include(com.fasterxml.jackson.annotation.JsonInclude.Include) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) File(java.io.File) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) ToscaResourceInstaller(org.onap.so.asdc.installer.heat.ToscaResourceInstaller) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) Component(org.springframework.stereotype.Component) Paths(java.nio.file.Paths) MDC(org.slf4j.MDC) SdcPropertyNames(org.onap.sdc.tosca.parser.impl.SdcPropertyNames) DeployActivitySpecs(org.onap.so.asdc.activity.DeployActivitySpecs) DistributionClientFactory(org.onap.sdc.impl.DistributionClientFactory) Metadata(org.onap.sdc.toscaparser.api.elements.Metadata) IOException(java.io.IOException) PnfResourceStructure(org.onap.so.asdc.installer.PnfResourceStructure) ResourceStructure(org.onap.so.asdc.installer.ResourceStructure) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) ToscaResourceStructure(org.onap.so.asdc.installer.ToscaResourceStructure) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException) ASDCDownloadException(org.onap.so.asdc.client.exceptions.ASDCDownloadException) ASDCParametersException(org.onap.so.asdc.client.exceptions.ASDCParametersException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) VfResourceStructure(org.onap.so.asdc.installer.VfResourceStructure) ZipParser(org.onap.so.asdc.util.ZipParser) IArtifactInfo(org.onap.sdc.api.notification.IArtifactInfo) IResourceInstance(org.onap.sdc.api.notification.IResourceInstance)

Aggregations

Include (com.fasterxml.jackson.annotation.JsonInclude.Include)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 MapperFeature (com.fasterxml.jackson.databind.MapperFeature)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Paths (java.nio.file.Paths)1 List (java.util.List)1 Optional (java.util.Optional)1 ErrorCode (org.onap.logging.filter.base.ErrorCode)1 ONAPLogConstants (org.onap.logging.ref.slf4j.ONAPLogConstants)1 IDistributionClient (org.onap.sdc.api.IDistributionClient)1 IDistributionStatusMessage (org.onap.sdc.api.consumer.IDistributionStatusMessage)1 IFinalDistrStatusMessage (org.onap.sdc.api.consumer.IFinalDistrStatusMessage)1 IArtifactInfo (org.onap.sdc.api.notification.IArtifactInfo)1 INotificationData (org.onap.sdc.api.notification.INotificationData)1