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);
}
}
Aggregations