All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aeontronix.enhancedmule.tools.runtime.ApplicationDeploymentFailedException Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha4
Show newest version
/*
 * Copyright (c) Aeontronix 2019
 */

package com.aeontronix.enhancedmule.tools.runtime;

import com.aeontronix.enhancedmule.tools.anypoint.application.DeploymentException;

import java.util.ArrayList;
import java.util.List;

public class ApplicationDeploymentFailedException extends DeploymentException {
    private int failed;
    private int successful;
    private int other;
    private List messages;

    public ApplicationDeploymentFailedException() {
        super("Failed to deploy application");
    }

    public ApplicationDeploymentFailedException(Throwable cause) {
        super(cause);
    }

    public ApplicationDeploymentFailedException(int failed, int successful, int other, List messages) {
        super("Failed to deploy application (failed: " + failed + ", successful: " + successful + ", other: " + other + ") : " + messages);
        this.failed = failed;
        this.successful = successful;
        this.other = other;
        this.messages = messages;
    }

    public int getFailed() {
        return failed;
    }

    public void setFailed(int failed) {
        this.failed = failed;
    }

    public int getSuccessful() {
        return successful;
    }

    public void setSuccessful(int successful) {
        this.successful = successful;
    }

    public int getOther() {
        return other;
    }

    public void setOther(int other) {
        this.other = other;
    }

    public List getMessages() {
        return messages;
    }

    public void setMessages(List messages) {
        this.messages = messages;
    }

    public static ApplicationDeploymentFailedException create(HApplication application) {
        if (application.getApplicationDeployments() != null) {
            int successful = 0;
            int failed = 0;
            int other = 0;
            ArrayList messages = new ArrayList<>();
            for (ApplicationDeployment deployment : application.getApplicationDeployments()) {
                if (HDeploymentResult.DEPLOYMENT_FAILED.equals(deployment.getLastReportedStatus())) {
                    failed++;
                } else if (HDeploymentResult.STARTED.equals(deployment.getLastReportedStatus())) {
                    successful++;
                } else {
                    other++;
                }
                if (deployment.getMessage() != null) {
                    messages.add(deployment.getMessage());
                }
            }
            return new ApplicationDeploymentFailedException(failed, successful, other, messages);
        } else {
            return new ApplicationDeploymentFailedException();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy