Search in sources :

Example 21 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project wso2-synapse by wso2.

the class LibraryArtifactDeployer method undeploySynapseArtifact.

public void undeploySynapseArtifact(String artifactName) {
    // get Old Lib config
    Library existingLib = null;
    try {
        existingLib = getSynapseConfiguration().getSynapseLibraries().get(artifactName);
        existingLib.unLoadLibrary();
        getSynapseConfiguration().removeSynapseImport(artifactName);
        getSynapseConfiguration().removeSynapseLibrary(artifactName);
    } catch (DeploymentException e) {
        handleDeploymentError(e.getMessage(), e);
    }
}
Also used : DeploymentException(org.apache.axis2.deployment.DeploymentException) Library(org.apache.synapse.libraries.model.Library)

Example 22 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project wso2-synapse by wso2.

the class LocalEntryDeployer method updateSynapseArtifact.

@Override
public String updateSynapseArtifact(OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) {
    if (log.isDebugEnabled()) {
        log.debug("LocalEntry update from file : " + fileName + " has started");
    }
    try {
        Entry e = EntryFactory.createEntry(artifactConfig, properties);
        if (e == null) {
            handleSynapseArtifactDeploymentError("Local entry update failed. The artifact " + "defined in the file: " + fileName + " is not a valid local entry.");
            return null;
        }
        e.setFileName(new File(fileName).getName());
        if (log.isDebugEnabled()) {
            log.debug("Local entry: " + e.getKey() + " has been built from the file: " + fileName);
        }
        if (existingArtifactName.equals(e.getKey())) {
            getSynapseConfiguration().updateEntry(existingArtifactName, e);
        } else {
            // The user has changed the name of the entry
            // We should add the updated entry as a new entry and remove the old one
            getSynapseConfiguration().addEntry(e.getKey(), e);
            getSynapseConfiguration().removeEntry(existingArtifactName);
            log.info("Local entry: " + existingArtifactName + " has been undeployed");
        }
        log.info("Endpoint: " + e.getKey() + " has been updated from the file: " + fileName);
        return e.getKey();
    } catch (DeploymentException e) {
        handleSynapseArtifactDeploymentError("Error while updating the local entry from the " + "file: " + fileName);
    }
    return null;
}
Also used : Entry(org.apache.synapse.config.Entry) DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File)

Example 23 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project wso2-synapse by wso2.

the class TaskDeployer method updateSynapseArtifact.

@Override
public String updateSynapseArtifact(OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) {
    if (log.isDebugEnabled()) {
        log.debug("StartupTask update from file : " + fileName + " has started");
    }
    try {
        Startup st = StartupFinder.getInstance().getStartup(artifactConfig, properties);
        st.setFileName((new File(fileName)).getName());
        if (log.isDebugEnabled()) {
            log.debug("StartupTask: " + st.getName() + " has been built from the file: " + fileName);
        }
        Startup existingSt = getSynapseConfiguration().getStartup(existingArtifactName);
        existingSt.destroy();
        st.init(getSynapseEnvironment());
        if (existingArtifactName.equals(st.getName())) {
            getSynapseConfiguration().updateStartup(st);
        } else {
            getSynapseConfiguration().addStartup(st);
            getSynapseConfiguration().removeStartup(existingArtifactName);
            log.info("StartupTask: " + existingArtifactName + " has been undeployed");
        }
        log.info("StartupTask: " + st.getName() + " has been updated from the file: " + fileName);
        return st.getName();
    } catch (DeploymentException e) {
        handleSynapseArtifactDeploymentError("Error while updating the startup task from the " + "file: " + fileName);
    }
    return null;
}
Also used : DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File) Startup(org.apache.synapse.Startup)

Example 24 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project wso2-synapse by wso2.

the class LibDeployerUtils method createSynapseLibrary.

public static Library createSynapseLibrary(String libPath) {
    String libFilePath = LibDeployerUtils.formatPath(libPath);
    // extract
    String extractPath = LibDeployerUtils.extractSynapseLib(libFilePath);
    // create synapse lib metadata
    SynapseLibrary synapseLib = LibDeployerUtils.populateDependencies(extractPath + LibDeployerConstants.ARTIFACTS_XML);
    // create a ClassLoader for loading this synapse lib classes/resources
    try {
        ClassLoader libLoader = Utils.getClassLoader(LibDeployerUtils.class.getClassLoader(), extractPath, false);
        synapseLib.setLibClassLoader(libLoader);
    } catch (DeploymentException e) {
        throw new SynapseArtifactDeploymentException("Error setting up lib classpath for Synapse" + " Library  : " + libFilePath, e);
    }
    // resolve synapse lib artifacts
    LibDeployerUtils.searchAndResolveDependencies(extractPath, synapseLib);
    // TODO:reslove local-entry references
    LibDeployerUtils.populateLocalEnties(synapseLib, extractPath + LibDeployerConstants.LOCAL_ENTRIES);
    synapseLib.setFileName(libFilePath);
    return synapseLib;
}
Also used : SynapseArtifactDeploymentException(org.apache.synapse.deployers.SynapseArtifactDeploymentException) SynapseLibrary(org.apache.synapse.libraries.model.SynapseLibrary) SynapseArtifactDeploymentException(org.apache.synapse.deployers.SynapseArtifactDeploymentException) DeploymentException(org.apache.axis2.deployment.DeploymentException)

Example 25 with DeploymentException

use of org.apache.axis2.deployment.DeploymentException in project carbon-business-process by wso2.

the class BPELAppDeployer method undeployArtifacts.

/**
 * Check the artifact type and if it is a BPEL, delete the file from the BPEL
 * deployment hot folder
 *
 * @param carbonApp  - CarbonApplication instance to check for BPEL artifacts
 * @param axisConfig - - axisConfig of the current tenant
 */
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) {
    List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
    for (Artifact.Dependency dep : artifacts) {
        Deployer deployer;
        Artifact artifact = dep.getArtifact();
        if (artifact == null) {
            continue;
        }
        if (BPEL_TYPE.equals(artifact.getType())) {
            deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPEL_DIR, "zip");
        } else {
            continue;
        }
        // loop through all dependencies
        List<CappFile> files = artifact.getFiles();
        if (files.size() != 1) {
            log.error("A BPEL workflow must have a single file. But " + files.size() + " files found.");
            continue;
        }
        if (deployer != null && AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) {
            String fileName = artifact.getFiles().get(0).getName();
            String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            try {
                File artifactFile = new File(artifactPath);
                if (artifactFile.exists() && !artifactFile.delete()) {
                    log.warn("Couldn't delete App artifact file : " + artifactPath);
                }
                deployer.undeploy(artifactPath);
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
            } catch (DeploymentException e) {
                artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                log.error("Error occured while trying to un deploy : " + artifact.getName());
            }
        }
    }
}
Also used : DeploymentException(org.apache.axis2.deployment.DeploymentException) File(java.io.File) CappFile(org.wso2.carbon.application.deployer.config.CappFile) Artifact(org.wso2.carbon.application.deployer.config.Artifact) Deployer(org.apache.axis2.deployment.Deployer) CappFile(org.wso2.carbon.application.deployer.config.CappFile)

Aggregations

DeploymentException (org.apache.axis2.deployment.DeploymentException)32 File (java.io.File)23 Deployer (org.apache.axis2.deployment.Deployer)6 Artifact (org.wso2.carbon.application.deployer.config.Artifact)6 CappFile (org.wso2.carbon.application.deployer.config.CappFile)6 IOException (java.io.IOException)4 AxisFault (org.apache.axis2.AxisFault)3 DeploymentFileData (org.apache.axis2.deployment.repository.util.DeploymentFileData)3 Library (org.apache.synapse.libraries.model.Library)3 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)3 QName (javax.xml.namespace.QName)2 OMElement (org.apache.axiom.om.OMElement)2 Mediator (org.apache.synapse.Mediator)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ZipInputStream (java.util.zip.ZipInputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1