use of org.craftercms.studio.api.v2.deployment.Deployer in project carbon-mediation by wso2.
the class SynapseAppDeployer method undeployArtifactType.
/**
* Un deploy a given artifact type
* @param carbonApplication
* @param axisConfig
* @param artifacts
*/
private void undeployArtifactType(CarbonApplication carbonApplication, AxisConfiguration axisConfig, List<Artifact.Dependency> artifacts) {
for (Artifact.Dependency dep : artifacts) {
Artifact artifact = dep.getArtifact();
if (!validateArtifact(artifact)) {
continue;
}
Deployer deployer;
String artifactDir = null;
if (SynapseAppDeployerConstants.MEDIATOR_TYPE.endsWith(artifact.getType())) {
deployer = getClassMediatorDeployer(axisConfig);
} else if (SynapseAppDeployerConstants.SYNAPSE_LIBRARY_TYPE.equals(artifact.getType())) {
deployer = getSynapseLibraryDeployer(axisConfig);
} else {
String artifactDirName = getArtifactDirName(artifact);
if (artifactDirName == null) {
continue;
}
deployer = getDeployer(axisConfig, artifactDirName);
artifactDir = getArtifactDirPath(axisConfig, artifactDirName);
}
if (deployer != null && AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) {
String fileName = artifact.getFiles().get(0).getName();
String artifactName = artifact.getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
File artifactInRepo = new File(artifactDir + File.separator + fileName);
try {
// version in its name in the synapse config (ex: MyAPI:v1 instead of MyAPI)
if (SynapseAppDeployerConstants.API_TYPE.equals(artifact.getType())) {
Properties properties = new Properties();
SynapseArtifactDeploymentStore deploymentStore = getSynapseConfiguration(axisConfig).getArtifactDeploymentStore();
if (deploymentStore != null) {
properties.put(SynapseConstants.CLASS_MEDIATOR_LOADERS, deploymentStore.getClassMediatorClassLoaders());
}
artifactName = extractApiNameFromArtifact(artifact, fileName, properties);
}
if (SynapseAppDeployerConstants.MEDIATOR_TYPE.endsWith(artifact.getType())) {
if (deployer instanceof AbstractSynapseArtifactDeployer) {
((AbstractSynapseArtifactDeployer) deployer).setCustomLog(carbonApplication.getAppName(), AppDeployerUtils.getTenantIdLogString(AppDeployerUtils.getTenantId()));
}
deployer.undeploy(artifactPath);
} else if (SynapseAppDeployerConstants.SYNAPSE_LIBRARY_TYPE.equals(artifact.getType())) {
String libQName = getArtifactName(artifactPath, axisConfig);
deleteImport(libQName, axisConfig);
deployer.undeploy(artifactPath);
} else if (SynapseAppDeployerConstants.SEQUENCE_TYPE.equals(artifact.getType()) && handleMainFaultSeqUndeployment(artifact, axisConfig)) {
} else if (artifactInRepo.exists()) {
log.info("Deleting artifact at " + artifactInRepo.getAbsolutePath());
if (!artifactInRepo.delete()) {
log.error("Unable to delete " + artifactInRepo.getAbsolutePath());
}
} else {
// use reflection to avoid having synapse as a dependency
Class[] paramString = new Class[1];
paramString[0] = String.class;
Method method = deployer.getClass().getDeclaredMethod("undeploySynapseArtifact", paramString);
method.invoke(deployer, artifactName);
}
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
File artifactFile = new File(artifactPath);
if (artifactFile.exists() && !artifactFile.delete()) {
log.warn("Couldn't delete App artifact file : " + artifactPath);
}
} catch (Exception e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
log.error("Error occured while trying to un deploy : " + artifactName);
}
}
}
}
use of org.craftercms.studio.api.v2.deployment.Deployer in project wso2-synapse by wso2.
the class ConnectorDeployer method deployConnectorResources.
/**
* Extract and load connector resources.
*
* @param connectorList list which has connector resources
*/
static void deployConnectorResources(List<String> connectorList) {
for (int x = 0; x < connectorList.size(); x++) {
String javaTempTestDir = System.getProperty(Constants.PRAM_TEMP_DIR) + File.separator + Constants.CONNECTOR_TEST_FOLDER;
createDir(javaTempTestDir);
BufferedOutputStream out = null;
try {
byte[] decodedConnector = Base64.decode(connectorList.get(x));
String connectorZip = javaTempTestDir + File.separator + "connector-" + x + ".zip";
out = new BufferedOutputStream(new FileOutputStream(connectorZip), 4096);
out.write(decodedConnector);
// deploy connector zip
LibDeployerUtils.createSynapseLibrary(connectorZip);
SynapseConfiguration configuration = UnitTestingExecutor.getExecuteInstance().getSynapseConfiguration();
AxisConfiguration axisConfiguration = configuration.getAxisConfiguration();
Deployer deployer = getSynapseLibraryDeployer(axisConfiguration);
deployer.deploy(new DeploymentFileData(new File(connectorZip), deployer));
try {
String artifactName = getArtifactName(connectorZip, axisConfiguration);
if (artifactName != null) {
if (configuration.getSynapseImports().get(artifactName) == null) {
String libName = artifactName.substring(artifactName.lastIndexOf("}") + 1);
String libraryPackage = artifactName.substring(1, artifactName.lastIndexOf("}"));
updateStatus(artifactName, libName, libraryPackage, "enabled", axisConfiguration);
}
}
} catch (AxisFault axisFault) {
log.error("Unable to update status for the synapse library : ", axisFault);
}
} catch (DeploymentException e) {
log.error("Error while deploying the synapse library : ", e);
} catch (IOException e) {
log.error("Error while writing the output stream of connector zip file", e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
log.error("Error while closing the output stream of connector zip file", e);
}
}
}
}
}
use of org.craftercms.studio.api.v2.deployment.Deployer 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());
}
}
}
}
use of org.craftercms.studio.api.v2.deployment.Deployer in project carbon-business-process by wso2.
the class BPELAppDeployer method deployArtifacts.
/**
* Check the artifact type and if it is a BPEL, copy it to the BPEL deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for BPEL artifacts
* @param axisConfig - AxisConfiguration of the current tenant
*/
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
// loop through all artifacts
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (!isAccepted(artifact.getType())) {
log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " + artifact.getType() + ". Required features are not installed in the system");
continue;
}
if (BPEL_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPEL_DIR, "zip");
} else {
continue;
}
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("BPEL workflows must have a single file to " + "be deployed. But " + files.size() + " files found.");
continue;
}
if (deployer != null) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
throw e;
}
}
}
}
use of org.craftercms.studio.api.v2.deployment.Deployer in project carbon-business-process by wso2.
the class BPMNAppDeployer method deployArtifacts.
/**
* Check the artifact type and if it is a BPMN artifact, copy it to the BPMN deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for BPMN artifacts
* @param axisConfig - AxisConfiguration of the current tenant
*/
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
// loop through all dependencies
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (!isAccepted(artifact.getType())) {
log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " + artifact.getType() + ". Required features are not installed in the system");
continue;
}
if (BPMN_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, BPMN_DIR, "bar");
} else {
continue;
}
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("BPMN artifacts must have a single file to " + "be deployed. But " + files.size() + " files found.");
continue;
}
if (deployer != null) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
File artifactFile = new File(artifactPath);
if (artifactFile.exists() && !artifactFile.delete()) {
log.warn("Couldn't delete App artifact file : " + artifactPath);
}
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
throw e;
}
}
}
}
Aggregations