Search in sources :

Example 1 with WatchdogServiceModVerIdLookup

use of org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup in project so by onap.

the class WatchdogDistribution method executePatchAAI.

public void executePatchAAI(String distributionId, String serviceModelInvariantUUID, String distributionStatus) throws Exception {
    logger.debug("Entered executePatchAAI method with distrubutionId: {} and distributionStatus: ", distributionId, distributionStatus);
    try {
        WatchdogServiceModVerIdLookup lookup = watchdogModVerIdLookupRepository.findOneByDistributionId(distributionId);
        String serviceModelVersionId = "";
        if (lookup != null) {
            serviceModelVersionId = lookup.getServiceModelVersionId();
        }
        logger.debug("Executed RequestDB getWatchdogServiceModVerIdLookup with distributionId: {} " + "and serviceModelVersionId: {}", distributionId, serviceModelVersionId);
        logger.debug("ASDC Notification ServiceModelInvariantUUID : {}", serviceModelInvariantUUID);
        if (serviceModelInvariantUUID == null || "".equals(serviceModelVersionId)) {
            String error = "No Service found with serviceModelInvariantUUID: " + serviceModelInvariantUUID;
            logger.debug(error);
            throw new Exception(error);
        }
        AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(serviceModelInvariantUUID).modelVer(serviceModelVersionId));
        // Do not return relationships if any
        aaiUri.depth(Depth.ZERO);
        logger.debug("Target A&AI Resource URI: {}", aaiUri.build().toString());
        Map<String, String> payload = new HashMap<>();
        payload.put("distribution-status", distributionStatus);
        getAaiClient().update(aaiUri, payload);
        logger.debug("A&AI UPDATE MODEL Version is success!");
    } catch (Exception e) {
        logger.debug("Exception occurred on executePatchAAI : {}", e.getMessage());
        logger.error("Exception occurred", e);
        throw new Exception(e);
    }
}
Also used : HashMap(java.util.HashMap) WatchdogServiceModVerIdLookup(org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)

Example 2 with WatchdogServiceModVerIdLookup

use of org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup in project so by onap.

the class ToscaResourceInstaller method processWatchdog.

public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification, String consumerId) {
    WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID, distributionNotification, consumerId);
    watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
    try {
        WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
        watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
    } catch (ObjectOptimisticLockingFailureException e) {
        logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : {} ", e);
        throw e;
    }
}
Also used : WatchdogDistributionStatus(org.onap.so.db.request.beans.WatchdogDistributionStatus) WatchdogServiceModVerIdLookup(org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup) ObjectOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException)

Aggregations

WatchdogServiceModVerIdLookup (org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup)2 HashMap (java.util.HashMap)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 WatchdogDistributionStatus (org.onap.so.db.request.beans.WatchdogDistributionStatus)1 ObjectOptimisticLockingFailureException (org.springframework.orm.ObjectOptimisticLockingFailureException)1