org.apache.axis2.deployment.DeploymentException Java Examples

The following examples show how to use org.apache.axis2.deployment.DeploymentException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataServiceCappDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Un-deploy the data services and remove them from data services.
 *
 * @param carbonApp  find artifacts from this CarbonApplication instance.
 * @param axisConfig AxisConfiguration of the current tenant.
 */
@Override
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig)
        throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Un-Deploying data services of carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> dependencies = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<>();
    for (Artifact.Dependency dependency : dependencies) {
        if (dependency.getArtifact() != null) {
            artifacts.add(dependency.getArtifact());
        }
    }
    undeployDataSources(artifacts, axisConfig);
}
 
Example #2
Source File: CappDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Undeploys the cApp from system when the .car file is deleted from the repository. Find the relevant cApp using
 * the file path and call the undeploy method on applicationManager.
 *
 * @param filePath - deleted .car file path
 * @throws DeploymentException - error while un-deploying cApp
 */
public void undeploy(String filePath) throws DeploymentException {
    CarbonApplication existingApp = null;
    for (CarbonApplication carbonApp : getCarbonApps()) {
        if (filePath.equals(carbonApp.getAppFilePath())) {
            existingApp = carbonApp;
            break;
        }
    }
    if (existingApp != null) {
        undeployCarbonApp(existingApp, axisConfig);
    } else {
        log.info("Undeploying Faulty Carbon Application On : " + filePath);
        removeFaultyCarbonApp(filePath);
    }
    super.undeploy(filePath);
}
 
Example #3
Source File: DeviceTypePluginDeployer.java    From carbon-device-mgt with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
    try {
        DeviceTypeConfiguration deviceTypeConfiguration = getDeviceTypeConfiguration(
                deploymentFileData.getFile().getAbsoluteFile());
        String deviceType = deviceTypeConfiguration.getName();
        String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
        if (deviceType != null && !deviceType.isEmpty() && tenantDomain != null
                && !tenantDomain.isEmpty()) {
            DeviceTypeConfigIdentifier deviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier(deviceType,
                                                                                                   tenantDomain);
            ServiceRegistration serviceRegistration = registerDeviceType(deviceTypeConfigIdentifier,
                                                                         deviceTypeConfiguration);
            this.deviceTypeServiceRegistrations.put(deploymentFileData.getAbsolutePath(), serviceRegistration);
            this.deviceTypeConfigurationDataMap.put(deploymentFileData.getAbsolutePath(),
                                                    deviceTypeConfigIdentifier);
        }
    } catch (Throwable e) {
        log.error("Cannot deploy deviceType : " + deploymentFileData.getName(), e);
        throw new DeploymentException("Device type file " + deploymentFileData.getName() + " is not deployed ", e);
    }

}
 
Example #4
Source File: DataSourceCappDeployer.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Deploy the data source artifacts and add them to datasources.
 *
 * @param carbonApp  - store info in this object after deploying
 * @param axisConfig - AxisConfiguration of the current tenant
 */
@Override
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Deploying carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployUnDeployDataSources(true, artifacts);
}
 
Example #5
Source File: DataSourceCappDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Un-deploy the data sources and remove them from datasources.
 *
 * @param carbonApp  - all information about the existing artifacts are in this instance.
 * @param axisConfig - AxisConfiguration of the current tenant.
 */
@Override
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig)
        throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Un-Deploying carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployUnDeployDataSources(false, artifacts);
}
 
Example #6
Source File: DataSourceCappDeployer.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Un-deploy the data sources and remove them from datasources.
 *
 * @param carbonApp  - all information about the existing artifacts are in this instance.
 * @param axisConfig - AxisConfiguration of the current tenant.
 */
@Override
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig)
        throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Un-Deploying carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployUnDeployDataSources(false, artifacts);
}
 
Example #7
Source File: DataSourceCappDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Deploy the data source artifacts and add them to datasources.
 *
 * @param carbonApp  - store info in this object after deploying
 * @param axisConfig - AxisConfiguration of the current tenant
 */
@Override
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Deploying carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployUnDeployDataSources(true, artifacts);
}
 
Example #8
Source File: DataServiceCappDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Deploy the data service artifacts and add them to data services.
 *
 * @param carbonApp  find artifacts from this CarbonApplication instance.
 * @param axisConfig AxisConfiguration of the current tenant.
 */
@Override
public void deployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) throws DeploymentException {
    if (log.isDebugEnabled()) {
        log.debug("Deploying data services of carbon application - " + carbonApp.getAppName());
    }
    ApplicationConfiguration appConfig = carbonApp.getAppConfig();
    List<Artifact.Dependency> dependencies = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<>();
    for (Artifact.Dependency dependency : dependencies) {
        if (dependency.getArtifact() != null) {
            artifacts.add(dependency.getArtifact());
        }
    }
    deployDataSources(artifacts, axisConfig);
}
 
Example #9
Source File: ArtifactDeploymentManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Function to execute artifact deployment
 */
public void deploy() {

    Set<Map.Entry<String, Deployer>> deploymentEntries = dirToDeployerMap.entrySet();
    for (Map.Entry<String, Deployer> deployerEntry : deploymentEntries) {
        if (log.isDebugEnabled()) {
            log.debug("Deploying artifacts from: " + deployerEntry.getKey());
        }

        File confDirFile = new File(deployerEntry.getKey());
        if (confDirFile.isDirectory() && confDirFile.exists()) {
            File[] configFiles = confDirFile.listFiles();
            if (configFiles == null) {
                if (log.isDebugEnabled()) {
                    log.debug("No configurations found to deploy in: " + deployerEntry.getKey());
                }
                continue;
            }

            // Deploy each config file
            for (File configFile : configFiles) {
                if (configFile.isFile()) {
                    try {
                        deployerEntry.getValue().deploy(new DeploymentFileData(configFile, deployerEntry.getValue()));
                    } catch (DeploymentException e) {
                        log.error("Error occurred while deploying : " + configFile.getName(), e);
                    }
                }
            }
        }
    }
}
 
Example #10
Source File: ArtifactDeploymentManager.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Function to register deployer
 *
 * @param directoryPath
 * @param deployer
 */
public void registerDeployer(String directoryPath, Deployer deployer) throws DeploymentException {
    if (deployer != null) {
        dirToDeployerMap.put(directoryPath, deployer);
    } else {
        throw new DeploymentException("Registering null deployer for target directory: " + directoryPath);
    }
}
 
Example #11
Source File: UserStoreConfigurationDeployer.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger un-deploying of a deployed file. Removes the deleted user store from chain
 *
 * @param fileName: domain name --> file name
 * @throws org.apache.axis2.deployment.DeploymentException for any errors
 */
public void undeploy(String fileName) throws DeploymentException {

    if (fileName != null) {
        String ext = FilenameUtils.getExtension(fileName);
        if (!UserStoreConfigurationConstants.ENC_EXTENSION.equalsIgnoreCase(ext)) {
            UserStoreDeploymentManager userStoreDeploymentManager = new UserStoreDeploymentManager();
            userStoreDeploymentManager.undeploy(fileName);
        }
    }
}
 
Example #12
Source File: DeviceTypeCAppDeployer.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Override
public void deployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfig)
        throws DeploymentException {
    List<Artifact.Dependency> artifacts =
            carbonApplication.getAppConfig().getApplicationArtifact().getDependencies();

    for (Artifact.Dependency dep : artifacts) {
        Artifact artifact = dep.getArtifact();
        if (!validateArtifact(artifact)) {
            continue;
        }
        addArtifact(artifact);
    }

    try {
        deployTypeSpecifiedArtifacts(deviceTypeUIs, axisConfig, null,
                                     DeviceTypePluginConstants.CDMF_UI_TYPE_DIR);
        deployTypeSpecifiedArtifacts(deviceTypePlugins, axisConfig,
                                     DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_EXTENSION,
                                     DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_DIR);

    } catch (Exception e) {
        throw new DeploymentException(e.getMessage(), e);
    } finally {
        deviceTypePlugins.clear();
        deviceTypeUIs.clear();
    }

}
 
Example #13
Source File: DeviceTypeCAppDeployer.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
protected void deployTypeSpecifiedArtifacts(List<Artifact> artifacts, AxisConfiguration axisConfig,
                                          String fileType, String directory) throws DeploymentException {
    for (Artifact artifact : artifacts) {
        Deployer deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, directory, fileType);
        if (deployer != null) {
            deploy(deployer, artifact);
        }
    }
}
 
Example #14
Source File: DeviceTypeCAppDeployer.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Override
public void undeployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfig)
        throws DeploymentException {
    List<Artifact.Dependency> artifacts =
            carbonApplication.getAppConfig().getApplicationArtifact().getDependencies();

    deviceTypePlugins.clear();
    deviceTypeUIs.clear();

    for (Artifact.Dependency dep : artifacts) {
        Artifact artifact = dep.getArtifact();
        if (!validateArtifact(artifact)) {
            continue;
        }
        addArtifact(artifact);
    }

    try {
        undeployTypeSpecifiedArtifacts(deviceTypeUIs, axisConfig, null,
                                       DeviceTypePluginConstants.CDMF_UI_TYPE_DIR);
        undeployTypeSpecifiedArtifacts(deviceTypePlugins, axisConfig,
                                       DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_EXTENSION,
                                       DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_DIR);
    } finally {
        deviceTypePlugins.clear();
        deviceTypeUIs.clear();
    }

}
 
Example #15
Source File: CloudControllerDeployer.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public void undeploy(String file) throws DeploymentException {
    if (file.contains(FILE_NAME)) {
        // grab the entry from Map
        if (fileToIaasProviderListMap.containsKey(file)) {
            // remove 'em
            CloudControllerConfig.getInstance().getIaasProviders().removeAll(fileToIaasProviderListMap.get(file));
            log.info("Successfully un-deployed the cloud-controller XML file specified at " +
                    file);
        }

        CloudControllerConfig.getInstance().setDataPubConfig(null);
        CloudControllerConfig.getInstance().setTopologyConfig(null);
    }
}
 
Example #16
Source File: DeviceTypeCAppDeployer.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
protected void undeployTypeSpecifiedArtifacts(List<Artifact> artifacts, AxisConfiguration axisConfig, String fileType
        , String directory) throws DeploymentException {
    for (Artifact artifact : artifacts) {
            Deployer deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, directory, fileType);
        if (deployer != null &&
                AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) {
            undeploy(deployer, artifact);
        }
    }
}
 
Example #17
Source File: DeviceTypeCAppDeployer.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
void deploy(Deployer deployer, Artifact artifact) throws DeploymentException {
    String fileName = artifact.getFiles().get(0).getName();
    String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
    try {
        deployer.deploy(new DeploymentFileData(new File(artifactPath)));
        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
    } catch (Exception e) {
        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
        log.error("Deployment is failed due to " + e.getMessage(), e);
        throw new DeploymentException(e.getMessage(), e);
    }
}
 
Example #18
Source File: DeviceTypeCAppDeployer.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
private void undeploy(Deployer deployer, Artifact artifact) throws DeploymentException {
    String fileName = artifact.getFiles().get(0).getName();
    String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
    try {
        deployer.undeploy(new DeploymentFileData(new File(artifactPath), deployer).getAbsolutePath());
        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
    } catch (Exception e) {
        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
        log.error("Undeployment is failed due to " + e.getMessage(), e);
        throw new DeploymentException(e.getMessage(), e);
    }
}
 
Example #19
Source File: DeviceTypePluginDeployer.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Override
public void undeploy(String filePath) throws DeploymentException {
    DeviceTypeConfigIdentifier deviceTypeConfigIdentifier = this.deviceTypeConfigurationDataMap.get(filePath);
    unregisterDeviceType(filePath);
    this.deviceTypeConfigurationDataMap.remove(filePath);
    log.info("Device Type undeployed successfully : " + deviceTypeConfigIdentifier.getDeviceType() + " for tenant "
                     + deviceTypeConfigIdentifier.getTenantDomain());
}
 
Example #20
Source File: DeviceTypePluginDeployerTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test(description = "Testing deviceType deploy method by deploying Android device type")
public void deploy() throws DeploymentException, IllegalAccessException {
    deviceTypePluginDeployer.deploy(deploymentFileData);
    Map<String, ServiceRegistration> tempServiceRegistration = (Map<String, ServiceRegistration>)
            deviceTypeServiceRegistrations.get(deviceTypePluginDeployer);
    Assert.assertEquals(tempServiceRegistration.get(deploymentFileData.getAbsolutePath()), serviceRegistration);
    Map<String, DeviceTypeConfigIdentifier> tempDeviceTypeConfig = (Map<String, DeviceTypeConfigIdentifier>)
            deviceTypeConfigurationDataMap.get(deviceTypePluginDeployer);
    DeviceTypeConfigIdentifier deviceTypeConfigIdentifier = tempDeviceTypeConfig.get(deploymentFileData
            .getAbsolutePath());
    Assert.assertEquals(deviceTypeConfigIdentifier.getDeviceType(), "android");
}
 
Example #21
Source File: DeviceTypePluginDeployerTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test(dependsOnMethods = {"deploy"} , description = "Testing deviceType undeploy method by un-deploying Android " +
        "device type")
public void unDeploy() throws DeploymentException, IllegalAccessException {
    deviceTypePluginDeployer.undeploy(deploymentFileData.getAbsolutePath());
    Map<String, ServiceRegistration> tempServiceRegistration = (Map<String, ServiceRegistration>)
            deviceTypeServiceRegistrations.get(deviceTypePluginDeployer);
    Assert.assertNull(tempServiceRegistration.get(deploymentFileData.getAbsolutePath()));
    Map<String, DeviceTypeConfigIdentifier> tempDeviceTypeConfig = (Map<String, DeviceTypeConfigIdentifier>)
            deviceTypeConfigurationDataMap.get(deviceTypePluginDeployer);
    Assert.assertNull(tempDeviceTypeConfig.get(deploymentFileData.getAbsolutePath()));
}
 
Example #22
Source File: UserStoreConfigurationDeployer.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger un-deploying of a deployed file. Removes the deleted user store from chain
 *
 * @param fileName: domain name --> file name
 * @throws org.apache.axis2.deployment.DeploymentException for any errors
 */
public void undeploy(String fileName) throws DeploymentException {

    if (fileName != null) {
        String ext = FilenameUtils.getExtension(fileName);
        if (!UserStoreConfigurationConstants.ENC_EXTENSION.equalsIgnoreCase(ext)) {
            UserStoreDeploymentManager userStoreDeploymentManager = new UserStoreDeploymentManager();
            userStoreDeploymentManager.undeploy(fileName);
        }
    }
}
 
Example #23
Source File: DataServiceCappDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Deploy data services.
 * adding the data service to the data services.
 * there can be multiple data sources as separate xml files.
 *
 * @param artifacts  list of artifacts to be deployed.
 * @param axisConfig axis configuration.
 */
private void deployDataSources(List<Artifact> artifacts, AxisConfiguration axisConfig)
        throws DeploymentException {
    for (Artifact artifact : artifacts) {
        if (DS_TYPE.equals(artifact.getType())) {
            List<CappFile> files = artifact.getFiles();
            if (files == null || files.isEmpty()) {
                throw new DeploymentException("DataServiceCappDeployer::deployDataServices --> "
                                                      + "Error No data services found in the artifact to deploy");
            }
            for (CappFile cappFile : files) {
                String fileName = cappFile.getName();
                String dataServiceConfigPath = artifact.getExtractedPath() + File.separator + fileName;

                File file = new File(dataServiceConfigPath);
                if (!file.exists()) {
                    throw new DeploymentException("DataServiceCappDeployer::deployDataServices --> "
                                                          + "Error Data service file cannot be found in artifact, "
                                                          + "file name - " + fileName);
                }
                // access the deployment engine through axis config
                DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
                Deployer deployer = deploymentEngine.getDeployer(DS_DIR, "dbs");

                try {
                    // Call the deploy method of the deployer
                    deployer.deploy(new DeploymentFileData(new File(dataServiceConfigPath), deployer));
                    artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
                } catch (DeploymentException e) {
                    artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                    throw new DeploymentException(
                            "DataServiceCappDeployer::deployDataServices --> "
                                    + "Error in deploying data service: " + e.getMessage(), e);
                }
            }
        }
    }
}
 
Example #24
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Deploy class mediators contains in the CApp
 *
 * @param artifacts List of Artifacts contains in the capp
 * @param axisConfig AxisConfiguration of the current tenant
 * @throws DeploymentException if something goes wrong while deployment
 */
private void deployClassMediators(List<Artifact.Dependency> artifacts,
                                 AxisConfiguration axisConfig) throws DeploymentException {
    for (Artifact.Dependency dependency : artifacts) {

        Artifact artifact = dependency.getArtifact();
        if (!validateArtifact(artifact)) {
            continue;
        }

        if (SynapseAppDeployerConstants.MEDIATOR_TYPE.endsWith(artifact.getType())) {

            Deployer deployer = getClassMediatorDeployer(axisConfig);

            if (deployer != null) {
                artifact.setRuntimeObjectName(artifact.getName());
                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;
                }
            }
        }
    }
}
 
Example #25
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Un-deploys Synapse artifacts found in this application. Just delete the files from the
 * hot folders. Synapse hot deployer will do the rest..
 *
 * @param carbonApplication - CarbonApplication instance
 * @param axisConfig - AxisConfiguration of the current tenant
 */
public void undeployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfig)
        throws DeploymentException{

    List<Artifact.Dependency> artifacts = carbonApplication.getAppConfig()
            .getApplicationArtifact().getDependencies();
    // Reverse artifacts dependency order should be used for un deployment, EI-1737
    Map<String, List<Artifact.Dependency>> artifactTypeMap = getOrderedArtifactsMap(artifacts);
    List<String> artifactTypesList = new ArrayList<String>(artifactTypeMap.keySet());
    Collections.reverse(artifactTypesList);

    for (String artifactType : artifactTypesList) {
        undeployArtifactType(carbonApplication, axisConfig, artifactTypeMap.get(artifactType));
    }
}
 
Example #26
Source File: SynapseAppDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Deploy the artifacts which can be deployed through this deployer (endpoints, sequences,
 * proxy service etc.).
 *
 * @param carbonApp  - CarbonApplication instance to check for 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();

    deployClassMediators(artifacts, axisConfig);
    deploySynapseLibrary(artifacts, axisConfig);
    Map<String, List<Artifact.Dependency>> artifactTypeMap = getOrderedArtifactsMap(artifacts);

    //deploy artifacts
    for (String artifactType : artifactTypeMap.keySet()) {
        deployArtifactType(artifactTypeMap.get(artifactType), carbonApp, axisConfig);
    }
}
 
Example #27
Source File: FileRegistryResourceDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
public void undeployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfiguration) throws DeploymentException {
    ApplicationConfiguration appConfig = carbonApplication.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    undeployRegistryArtifacts(artifacts, carbonApplication.getAppNameWithVersion());
}
 
Example #28
Source File: FileRegistryResourceDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
public void deployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfiguration)
                                                                                        throws DeploymentException {
    ApplicationConfiguration appConfig = carbonApplication.getAppConfig();
    List<Artifact.Dependency> deps = appConfig.getApplicationArtifact().getDependencies();

    List<Artifact> artifacts = new ArrayList<Artifact>();
    for (Artifact.Dependency dep : deps) {
        if (dep.getArtifact() != null) {
            artifacts.add(dep.getArtifact());
        }
    }
    deployRegistryArtifacts(artifacts, carbonApplication.getAppNameWithVersion());
}
 
Example #29
Source File: CappDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Axis2 deployment engine will call this method when a .car archive is deployed. So we only have to call the
 * cAppDeploymentManager to deploy it using the absolute path of the deployed .car file.
 *
 * @param deploymentFileData - info about the deployed file
 * @throws DeploymentException - error while deploying cApp
 */
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
    String artifactPath = deploymentFileData.getAbsolutePath();
    try {
        deployCarbonApps(artifactPath);
    } catch (Exception e) {
        log.error("Error while deploying carbon application " + artifactPath, e);
    }

    super.deploy(deploymentFileData);
}
 
Example #30
Source File: TransportBuilderUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
* Builds a TransportOutDescription object based on the specified XML configuration.
   * The XML should be as follows.
   *
   * <transportSender name="myTransport" class="my.transport.sender.Class">
   *     <parameter name="param1">value 1</parameter>
   *     <parameter name="param1">value 1</parameter>
   * </transportSender>
*
* @param transport An Iterator of OMElement which contains transport configurations.
   * @param init Whether to initialize the sender or not
* @return an array of transport out descriptions
* @throws DeploymentException on error
*/
  public static TransportOutDescription processTransportSender(
          OMElement transport, boolean init) throws DeploymentException {

      if (!TAG_TRANSPORT_SENDER.equals(transport.getLocalName())) {
          throw new DeploymentException("Invalid top level element in the transport sender " +
                  "configuration");
      }

      String name = transport.getAttributeValue(new QName(ATTRIBUTE_NAME));
      if (name == null || "".equals(name)) {
          throw new DeploymentException("Transport name is not specified in the receiver " +
                  "configuration");
      }

      String className = transport.getAttributeValue(new QName(ATTRIBUTE_CLASS));
      if (className == null || "".equals(className)) {
          throw new DeploymentException("Class name is not specified in the receiver " +
                  "configuration");
      }

      TransportOutDescription transportOut = new TransportOutDescription(name);
      if (init) {
          try {
              Class clazz = TransportBuilderUtils.class.getClassLoader().loadClass(className);
              TransportSender sender = (TransportSender) clazz.newInstance();
              transportOut.setSender(sender);
          } catch (Exception e) {
              throw new DeploymentException("Error while initializing transport sender", e);
          }
      }

      Iterator itr = transport.getChildrenWithName(new QName(TAG_PARAMETER));
      processParameters(itr, transportOut);
      return transportOut;
  }