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);
}
}
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;
}
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;
}
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;
}
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());
}
}
}
}
Aggregations