Search in sources :

Example 6 with SubscriptionStatusWithData

use of org.ligoj.app.api.SubscriptionStatusWithData in project ligoj-api by ligoj.

the class NodeResource method checkSubscriptionStatus.

/**
 * Check status for a subscription.
 *
 * @param subscription
 *            Subscription entity.
 * @param parameters
 *            Parameters of a subscription.
 * @return status of given subscription.
 */
public SubscriptionStatusWithData checkSubscriptionStatus(final Subscription subscription, final Map<String, String> parameters) {
    final String node = subscription.getNode().getId();
    try {
        log.info("Check status of a subscription attached to {}...", node);
        // Find the plug-in associated to the requested node
        final ToolPlugin toolPlugin = locator.getResourceExpected(node, ToolPlugin.class);
        // Call service which check status
        final SubscriptionStatusWithData status = toolPlugin.checkSubscriptionStatus(subscription.getId(), node, parameters);
        status.setNode(node);
        log.info("Check status of a subscription attached to {} succeed", node);
        return status;
    } catch (final Exception e) {
        // NOSONAR
        // Do not pollute logs with this failures
        // Service is down when an exception is thrown, log the error
        // without trace
        log.warn("Check status of a subscription attached to {} failed : {}", node, e.getMessage());
    }
    return new SubscriptionStatusWithData(false);
}
Also used : SubscriptionStatusWithData(org.ligoj.app.api.SubscriptionStatusWithData) ToolPlugin(org.ligoj.app.api.ToolPlugin) ValidationJsonException(org.ligoj.bootstrap.core.validation.ValidationJsonException) BusinessException(org.ligoj.bootstrap.core.resource.BusinessException)

Example 7 with SubscriptionStatusWithData

use of org.ligoj.app.api.SubscriptionStatusWithData in project plugin-prov by ligoj.

the class AbstractProvResource method checkSubscriptionStatus.

@Override
public SubscriptionStatusWithData checkSubscriptionStatus(final int subscription, final String node, final Map<String, String> parameters) {
    final SubscriptionStatusWithData status = new SubscriptionStatusWithData();
    // Complete the tool status with the generic quote data
    status.put("quote", provResource.getSusbcriptionStatus(subscription));
    return status;
}
Also used : SubscriptionStatusWithData(org.ligoj.app.api.SubscriptionStatusWithData)

Aggregations

SubscriptionStatusWithData (org.ligoj.app.api.SubscriptionStatusWithData)7 Test (org.junit.jupiter.api.Test)2 ToolPlugin (org.ligoj.app.api.ToolPlugin)2 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)2 JiraPluginResource (org.ligoj.app.resource.node.sample.JiraPluginResource)2 ServicePluginLocator (org.ligoj.app.resource.ServicePluginLocator)1 EventVo (org.ligoj.app.resource.node.EventVo)1 JenkinsPluginResource (org.ligoj.app.resource.node.sample.JenkinsPluginResource)1 SonarPluginResource (org.ligoj.app.resource.node.sample.SonarPluginResource)1 BusinessException (org.ligoj.bootstrap.core.resource.BusinessException)1 TechnicalException (org.ligoj.bootstrap.core.resource.TechnicalException)1 ValidationJsonException (org.ligoj.bootstrap.core.validation.ValidationJsonException)1