Search in sources :

Example 86 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-business-process by wso2.

the class UserSubstitutionUtils method getPaginatedModelFromRequest.

/**
 * Prepare the paginated data model for a substitution query
 * @param propertiesMap
 * @param tenantId
 * @return PaginatedSubstitutesDataModel
 */
private static PaginatedSubstitutesDataModel getPaginatedModelFromRequest(Map<String, String> propertiesMap, int tenantId) {
    PaginatedSubstitutesDataModel model = new PaginatedSubstitutesDataModel();
    if (propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE) != null) {
        model.setSubstitute(propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE));
    }
    if (propertiesMap.get(SubstitutionQueryProperties.USER) != null) {
        model.setUser(propertiesMap.get(SubstitutionQueryProperties.USER));
    }
    String enabled = propertiesMap.get(SubstitutionQueryProperties.ENABLED);
    if (enabled != null) {
        if (enabled.equalsIgnoreCase("true")) {
            model.setEnabled(true);
        } else if (enabled.equalsIgnoreCase("false")) {
            model.setEnabled(false);
        } else {
            throw new ActivitiIllegalArgumentException("Invalid parameter " + enabled + " for enabled property.");
        }
    }
    model.setTenantId(tenantId);
    int start = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.START));
    int size = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.SIZE));
    model.setStart(start);
    model.setSize(size);
    model.setOrder(propertiesMap.get(SubstitutionQueryProperties.ORDER));
    model.setSort(propertiesMap.get(SubstitutionQueryProperties.SORT));
    return model;
}
Also used : PaginatedSubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel)

Example 87 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-business-process by wso2.

the class BPMNDeployer method isWorkerNode.

/**
 * Whether a bps node is worker ( a node that does not participate in archive deployment and only handles
 * input/output . This is determined by looking at the registry read/only property
 * @return
 */
private boolean isWorkerNode() {
    RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
    boolean isWorker = true;
    try {
        isWorker = (registryService.getConfigSystemRegistry().getRegistryContext().isReadOnly());
    } catch (RegistryException e) {
        log.error("Error accessing the configuration registry");
    }
    return isWorker;
}
Also used : RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 88 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-business-process by wso2.

the class ActivitiDAO method querySubstituteInfoWithoutEnabled.

/**
 * Return the list of substitute info based on query parameters except enabled property.
 * @param model data model with only required query parameter values. Leave others as null.
 * @return List<PaginatedSubstitutesDataModel> Result set of substitute info
 */
public List<SubstitutesDataModel> querySubstituteInfoWithoutEnabled(final PaginatedSubstitutesDataModel model) {
    final RowBounds rw = new RowBounds(model.getStart(), model.getSize());
    CustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>>(SubstitutesMapper.class) {

        public List<SubstitutesDataModel> execute(SubstitutesMapper substitutesMapper) {
            return substitutesMapper.querySubstitutesWithoutEnabled(rw, model);
        }
    };
    return managementService.executeCustomSql(customSqlExecution);
}
Also used : PaginatedSubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel) SubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel) AbstractCustomSqlExecution(org.activiti.engine.impl.cmd.AbstractCustomSqlExecution) RowBounds(org.apache.ibatis.session.RowBounds) List(java.util.List) SubstitutesMapper(org.wso2.carbon.bpmn.core.internal.mapper.SubstitutesMapper)

Example 89 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-business-process by wso2.

the class HumanTaskStore method deploy.

/**
 * Handles the deployment steps for the master node and salve node in the cluster
 * @param humanTaskFile
 * @throws Exception
 */
public void deploy(File humanTaskFile) throws Exception {
    // Currently using the registry read/write mount property to determine whether this node is a master node
    // or a salve node.
    // Handle this properly with hazelcast leader for cluster scenario TODO
    boolean isMasterServer = !isServerReadOnly();
    // Versions of this ht package is already deployed
    boolean isExistingPackage = false;
    // Exactly matching ht package already exists
    boolean isPackageReload = false;
    DeploymentUnitDAO currentlyActiveTaskPackage = null;
    String md5sum = HumanTaskStoreUtils.getMD5Checksum(humanTaskFile);
    String packageName = FilenameUtils.removeExtension(humanTaskFile.getName());
    List<DeploymentUnitDAO> existingDeploymentUnitsForPackage = getExistingDeploymentUnitsForPackage(packageName.trim());
    if (existingDeploymentUnitsForPackage != null && existingDeploymentUnitsForPackage.size() > 0) {
        isExistingPackage = true;
        for (DeploymentUnitDAO dao : existingDeploymentUnitsForPackage) {
            if ((dao.getStatus() == (TaskPackageStatus.ACTIVE))) {
                // extract the currently active task package
                currentlyActiveTaskPackage = dao;
                if (dao.getChecksum().equals(md5sum)) {
                    // Check whether the md5sum matches the active task package.
                    isPackageReload = true;
                }
            }
        }
    }
    // We will only allow writes to db only for the master node to avoid duplicate version creation
    if (isExistingPackage && isPackageReload) {
        // Reload the existing versions of the human task package . No need of creating a new version of the package
        // This could be due to server restart, deployment of the same package or master node has already deployed the
        // new version of the package
        // First check if the currently active task package is already loaded
        String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
        if (activePackageName != null && activePackageName.equals(currentlyActiveTaskPackage.getName())) {
            if (log.isDebugEnabled()) {
                log.debug("This task package and its previous versions are already loaded " + activePackageName);
            }
            // This task package and its previous versions are already loaded , hence return
            return;
        }
        // Load the existing versions of the package
        reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
        return;
    }
    // New version of the package is being deployed on top of the existing version
    if (isExistingPackage && !isPackageReload) {
        if (isMasterServer) {
            // Retire the existing version of the package and deploy the new version
            // This could be two scenarios. Server restart with new version and deploying on existing version.
            String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
            if (activePackageName == null) {
                // This is a server restart, we need to load existing versions
                reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
            }
            long newVersion = getNextVersion();
            HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
            validateTaskConfig(newDeploymentUnit);
            retireTaskPackageConfigurations(currentlyActiveTaskPackage.getName());
            currentlyActiveTaskPackage.setStatus(TaskPackageStatus.RETIRED);
            updateDeploymentUnitDao(currentlyActiveTaskPackage);
            // Retiring of currently active package is complete.
            // Create and deploy new version
            deployNewTaskVersion(newDeploymentUnit, newVersion);
            // Add new version of human task package to registry
            // Update the zip and package properties in the registry
            repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
            // Successfully deployed the packages.
            return;
        } else {
            // Cannot allow creation of a new version from slave nodes, deploy the new version on the master node
            // first to avoid duplicate version creation
            // Write log, issue warning and return
            log.warn("Cannot deploy new version of the task in slave node. Hence deploy the task archive in master" + "node fist");
            return;
        }
    }
    if (!isMasterServer) {
        // Issue warning, write warn message and return as we cannot allow deployment of new versions on slave nodes
        // before deployment of the ht package in the master node
        log.warn("Cannot deploy a new version on the package on the salve node first, " + "Deploy the package on the master node first");
        return;
    }
    // Create new version of deployment unit
    // Process the human task configurations
    // Store deployment unit information to the db
    // Deploy axis2 services
    // Adding HumanTask package the registry.
    long newVersion = getNextVersion();
    HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
    validateTaskConfig(newDeploymentUnit);
    deployNewTaskVersion(newDeploymentUnit, newVersion);
    repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
    return;
}
Also used : DeploymentUnitDAO(org.wso2.carbon.humantask.core.dao.DeploymentUnitDAO) HumanTaskDeploymentUnit(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit)

Example 90 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-business-process by wso2.

the class ProcessConfigurationImpl method getEndpointProperties.

public Map<String, String> getEndpointProperties(EndpointReference endpointReference) {
    /**
     * This method is only there to use by ODEProcess#getTimeout method. Because we can't change
     * internals of ODE we have to make our configuration mechanism transparent to ODE.
     * Therefore I only added mex.timeout property to map and returned it here. If there are
     * more properties like this which use by BPEL engine we have to make our configuration
     * mechanism transparent and add that property to this map.
     */
    EndpointConfiguration epConf = null;
    final Map map = eprContext.getConfigLookup(endpointReference);
    final QName service = (QName) map.get("service");
    final String port = (String) map.get("port");
    if (log.isDebugEnabled()) {
        log.debug("Looking Endpoint configuration properties for service: " + service + " and port: " + port);
    }
    if (bpelPackageConfiguration != null) {
        epConf = (EndpointConfiguration) bpelPackageConfiguration.getEndpoints().get(service.getLocalPart(), service.getNamespaceURI(), port);
    }
    HashMap<String, String> props = new HashMap<String, String>();
    if (epConf != null) {
        props.put(BPELConstants.ODE_MEX_TIMEOUT, epConf.getMexTimeout());
    }
    return props;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) EndpointConfiguration(org.wso2.carbon.bpel.common.config.EndpointConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) MultiKeyMap(org.apache.commons.collections.map.MultiKeyMap)

Aggregations

HashMap (java.util.HashMap)42 ArrayList (java.util.ArrayList)32 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)32 Resource (org.wso2.carbon.registry.core.Resource)23 Map (java.util.Map)21 Test (org.junit.Test)21 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)21 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)17 API (org.wso2.carbon.apimgt.api.model.API)16 UserStoreException (org.wso2.carbon.user.api.UserStoreException)16 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 JSONObject (org.json.simple.JSONObject)14 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)14 List (java.util.List)13 IOException (java.io.IOException)11 QName (javax.xml.namespace.QName)11 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)11 Properties (java.util.Properties)10 GovernanceException (org.wso2.carbon.governance.api.exception.GovernanceException)10