diff options
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionNotificationSender.java')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionNotificationSender.java | 59 |
1 files changed, 18 insertions, 41 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionNotificationSender.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionNotificationSender.java index 1c6afe5a98..0098eac7d9 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionNotificationSender.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionNotificationSender.java @@ -7,9 +7,9 @@ * 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 - * + * * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.components.distribution.engine; import org.openecomp.sdc.be.config.ConfigurationManager; @@ -34,39 +33,28 @@ import org.springframework.stereotype.Component; public class DistributionNotificationSender { protected static final String DISTRIBUTION_NOTIFICATION_SENDING = "distributionNotificationSending"; - private static final Logger logger = Logger.getLogger(DistributionNotificationSender.class.getName()); - @javax.annotation.Resource protected ComponentsUtils componentUtils; private CambriaHandler cambriaHandler = new CambriaHandler(); - private DistributionEngineConfiguration deConfiguration = - ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration(); + private DistributionEngineConfiguration deConfiguration = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration(); - public ActionStatus sendNotification(String topicName, String distributionId, - EnvironmentMessageBusData messageBusData, INotificationData notificationData, Service service, - User modifier) { + public ActionStatus sendNotification(String topicName, String distributionId, EnvironmentMessageBusData messageBusData, + INotificationData notificationData, Service service, User modifier) { long startTime = System.currentTimeMillis(); - CambriaErrorResponse status = - cambriaHandler.sendNotificationAndClose(topicName, messageBusData.getUebPublicKey(), - messageBusData.getUebPrivateKey(), messageBusData.getDmaaPuebEndpoints(), notificationData, - deConfiguration.getDistributionNotificationTopic().getMaxWaitingAfterSendingSeconds()); - - logger.info("After publishing service {} of version {}. Status is {}", service.getName(), service.getVersion(), - status.getHttpCode()); - - auditDistributionNotification(new AuditDistributionNotificationBuilder().setTopicName(topicName) - .setDistributionId(distributionId).setStatus(status).setService(service) - .setEnvId(messageBusData.getEnvId()).setModifier(modifier) - .setWorkloadContext(notificationData.getWorkloadContext()).setTenant(messageBusData.getTenant())); - + CambriaErrorResponse status = cambriaHandler + .sendNotificationAndClose(topicName, messageBusData.getUebPublicKey(), messageBusData.getUebPrivateKey(), + messageBusData.getDmaaPuebEndpoints(), notificationData, + deConfiguration.getDistributionNotificationTopic().getMaxWaitingAfterSendingSeconds()); + logger.info("After publishing service {} of version {}. Status is {}", service.getName(), service.getVersion(), status.getHttpCode()); + auditDistributionNotification( + new AuditDistributionNotificationBuilder().setTopicName(topicName).setDistributionId(distributionId).setStatus(status).setService(service) + .setEnvId(messageBusData.getEnvId()).setModifier(modifier).setWorkloadContext(notificationData.getWorkloadContext()) + .setTenant(messageBusData.getTenant())); long endTime = System.currentTimeMillis(); - if (logger.isDebugEnabled()) { - logger.debug("After building and publishing artifacts object. Total took {} milliseconds", - endTime - startTime); + logger.debug("After building and publishing artifacts object. Total took {} milliseconds", endTime - startTime); } - return convertCambriaResponse(status); } @@ -74,20 +62,15 @@ public class DistributionNotificationSender { if (this.componentUtils != null) { Integer httpCode = builder.getStatus().getHttpCode(); String httpCodeStr = String.valueOf(httpCode); - String desc = getDescriptionFromErrorResponse(builder.getStatus()); - - this.componentUtils.auditDistributionNotification(builder.getService().getUUID(), - builder.getService().getName(), "Service", builder.getService().getVersion(), builder.getModifier(), - builder.getEnvId(), builder.getService().getLifecycleState().name(), builder.getTopicName(), - builder.getDistributionId(), desc, httpCodeStr, builder.getWorkloadContext(), builder.getTenant()); + this.componentUtils.auditDistributionNotification(builder.getService().getUUID(), builder.getService().getName(), "Service", + builder.getService().getVersion(), builder.getModifier(), builder.getEnvId(), builder.getService().getLifecycleState().name(), + builder.getTopicName(), builder.getDistributionId(), desc, httpCodeStr, builder.getWorkloadContext(), builder.getTenant()); } } private String getDescriptionFromErrorResponse(CambriaErrorResponse status) { - CambriaOperationStatus operationStatus = status.getOperationStatus(); - switch (operationStatus) { case OK: return "OK"; @@ -103,14 +86,11 @@ public class DistributionNotificationSender { return "Error: object not found in U-EB server"; default: return "Error: Internal Cambria server problem"; - } - } private ActionStatus convertCambriaResponse(CambriaErrorResponse status) { CambriaOperationStatus operationStatus = status.getOperationStatus(); - switch (operationStatus) { case OK: return ActionStatus.OK; @@ -126,9 +106,6 @@ public class DistributionNotificationSender { return ActionStatus.OBJECT_NOT_FOUND; default: return ActionStatus.GENERAL_ERROR; - } } - - } |