X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fmodelloader%2Fnotification%2FEventCallback.java;h=059964e1314ba30b923412c94864676eeaf23e47;hb=fe17f093d5c61207949eebef95b83baf5139be50;hp=3b32315478aa6c17c2be3e7f35b058ab8caec415;hpb=ef768a7c864f0d807d8696449f5eed7a4552316f;p=aai%2Fmodel-loader.git diff --git a/src/main/java/org/openecomp/modelloader/notification/EventCallback.java b/src/main/java/org/openecomp/modelloader/notification/EventCallback.java index 3b32315..059964e 100644 --- a/src/main/java/org/openecomp/modelloader/notification/EventCallback.java +++ b/src/main/java/org/openecomp/modelloader/notification/EventCallback.java @@ -1,23 +1,25 @@ -/*- +/** * ============LICENSE_START======================================================= - * MODEL LOADER SERVICE + * Model Loader * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017 AT&T Intellectual Property. + * Copyright © 2017 Amdocs + * All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. */ - package org.openecomp.modelloader.notification; import org.openecomp.sdc.api.IDistributionClient; @@ -40,8 +42,9 @@ import org.openecomp.modelloader.config.ModelLoaderConfig; import org.openecomp.modelloader.entity.Artifact; import org.openecomp.modelloader.entity.catalog.VnfCatalogArtifact; import org.openecomp.modelloader.entity.catalog.VnfCatalogArtifactHandler; +import org.openecomp.modelloader.entity.model.IModelParser; import org.openecomp.modelloader.entity.model.ModelArtifactHandler; -import org.openecomp.modelloader.entity.model.ModelArtifactParser; +import org.openecomp.modelloader.entity.model.ModelParserFactory; import org.openecomp.modelloader.service.ModelLoaderMsgs; import org.slf4j.MDC; @@ -80,7 +83,6 @@ public class EventCallback implements INotificationCallback { List artifacts = getArtifacts(data); List modelArtifacts = new ArrayList(); List catalogArtifacts = new ArrayList(); - ModelArtifactParser modelArtParser = new ModelArtifactParser(); for (IArtifactInfo artifact : artifacts) { // Grab the current time so we can measure the download time for the @@ -102,16 +104,22 @@ public class EventCallback implements INotificationCallback { break; } - logger.debug("Artifact: " + artifact.getArtifactName() + " Payload:\n" + new String(downloadResult.getArtifactPayload())); + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, + "Downloaded artifact: " + artifact.getArtifactName() + " Payload:\n" + new String(downloadResult.getArtifactPayload())); publishDownloadSuccess(data, artifact, downloadResult); - if ((artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()) == 0) - || (artifact.getArtifactType() - .compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()) == 0)) { - modelArtifacts.addAll(modelArtParser.parse(downloadResult.getArtifactPayload(), - downloadResult.getArtifactName())); + if ((artifact.getArtifactType().compareToIgnoreCase(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE.toString()) == 0) + || (artifact.getArtifactType().compareToIgnoreCase(ArtifactTypeEnum.MODEL_QUERY_SPEC.toString()) == 0)) { + IModelParser parser = ModelParserFactory.createModelParser(downloadResult.getArtifactPayload(), downloadResult.getArtifactName()); + List parsedArtifacts = parser.parse(downloadResult.getArtifactPayload(), downloadResult.getArtifactName()); + if (parsedArtifacts != null && !parsedArtifacts.isEmpty()) { + modelArtifacts.addAll(parsedArtifacts); + } else { + success = false; + publishDeployFailure(data, artifact); + break; + } } else if (artifact.getArtifactType() .compareToIgnoreCase(ArtifactTypeEnum.VNF_CATALOG.toString()) == 0) { catalogArtifacts @@ -150,6 +158,8 @@ public class EventCallback implements INotificationCallback { } } } + } else { + statusString = "FAILURE"; } auditLogger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, @@ -212,9 +222,6 @@ public class EventCallback implements INotificationCallback { metricsLogger.info(ModelLoaderMsgs.EVENT_PUBLISHED, null, override, "download success", artifact.getArtifactName(), sendDownloadStatus.getDistributionActionResult().toString()); - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Downloaded artifact: " + artifact.getArtifactName()); - if (sendDownloadStatus.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, "Failed to publish download success status: "