Search in sources :

Example 91 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.

the class HumanTaskPackageManagementSkeleton method getTenantTaskStore.

// Returns the task store for the tenant.
private HumanTaskStore getTenantTaskStore() {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    HumanTaskServer server = HumanTaskServiceComponent.getHumanTaskServer();
    return server.getTaskStoreManager().getHumanTaskStore(tenantId);
}
Also used : HumanTaskServer(org.wso2.carbon.humantask.core.HumanTaskServer)

Example 92 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store 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 93 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.

the class OperationAuthorizationUtil method authoriseUser.

/**
 * @param task             : The task against which the user being validated.
 * @param validatee        : The OrganizationalEntityDAO being validated.
 * @param allowedRoleTypes : The allowed role types for the validatee object.
 * @param pqe              : PeopleQueryEvaluator for people queries.
 * @return : true if the user is in the specified roles for the given task. false otherwise.
 */
public static boolean authoriseUser(TaskDAO task, OrganizationalEntityDAO validatee, List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoleTypes, PeopleQueryEvaluator pqe) {
    List<GenericHumanRoleDAO> humanRolesInTask = task.getHumanRoles();
    if (isExcludedEntity(task, validatee, pqe)) {
        return false;
    }
    for (GenericHumanRoleDAO role : humanRolesInTask) {
        if (allowedRoleTypes.contains(role.getType())) {
            // check for groups
            for (OrganizationalEntityDAO entityForRole : getGroupOrganizationalEntities(role)) {
                if (OrganizationalEntityDAO.OrganizationalEntityType.GROUP.equals(entityForRole.getOrgEntityType())) {
                    String roleName = entityForRole.getName();
                    List<String> userListForRole = pqe.getUserNameListForRole(roleName);
                    if (userListForRole.contains(validatee.getName())) {
                        return true;
                    }
                }
            }
            // check for users
            // TODO validate user existance in the user store.
            List<OrganizationalEntityDAO> orgEntities = getUserOrganizationalEntities(role);
            Collections.sort(orgEntities, PeopleQueryComparators.peopleNameComparator());
            if (Collections.binarySearch(orgEntities, validatee, PeopleQueryComparators.peopleNameComparator()) >= 0) {
                return true;
            }
        }
    }
    return false;
}
Also used : OrganizationalEntityDAO(org.wso2.carbon.humantask.core.dao.OrganizationalEntityDAO) GenericHumanRoleDAO(org.wso2.carbon.humantask.core.dao.GenericHumanRoleDAO)

Example 94 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.

the class BPELPackageRepository method createBPELPackageParentCollectionWithProperties.

/**
 * Create parent collection to persisting BPEL package information. For example, if you deploy
 * a BPEL archive called 'HelloWorld.zip', we store information of that package in collection
 * named 'HelloWorld'. This will be the root for 'HelloWorld' BPEL package information and
 * there will several versions of this BPEL package in this registry collection which relates
 * to the versions deployed in BPEL engine.
 *
 * @param deploymentContext containing information on current deployment
 * @throws RegistryException        when there is a error accessing registry
 * @throws IOException              if file access error occurred during MD5 checksum generation
 * @throws NoSuchAlgorithmException when there is a error during MD5 generation
 */
private void createBPELPackageParentCollectionWithProperties(BPELDeploymentContext deploymentContext) throws RegistryException, IOException, NoSuchAlgorithmException {
    Collection bpelPackage = configRegistry.newCollection();
    bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_CHECKSUM, Utils.getMD5Checksum(deploymentContext.getBpelArchive()));
    if (log.isDebugEnabled()) {
        log.debug(deploymentContext.getBpelPackageName() + " updating checksum: " + Utils.getMD5Checksum(deploymentContext.getBpelArchive()) + " in registry");
    }
    if (deploymentContext.isFailed()) {
        bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_FAILED);
        bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_ERROR_LOG, deploymentContext.getDeploymentFailureCause());
    // bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_STACK_TRACE,
    // ExceptionUtils.getStackTrace(deploymentContext.getStackTrace()));
    } else {
        bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_DEPLOYED);
    }
    bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentContext.getVersion()));
    configRegistry.put(BPELPackageRepositoryUtils.getResourcePathForBPELPackage(deploymentContext), bpelPackage);
}
Also used : Collection(org.wso2.carbon.registry.core.Collection)

Example 95 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.

the class BPELServerImpl method init.

/**
 * Initialize the ODE BPEL engine.
 *
 * @throws Exception if failed to start the BPEL engine.
 */
public void init() throws Exception {
    bpelServerConfiguration = new BPELServerConfiguration();
    odeConfigurationProperties = new ODEConfigurationProperties(bpelServerConfiguration);
    if (log.isDebugEnabled()) {
        log.debug("Initializing transaction manager");
    }
    initTransactionManager();
    if (log.isDebugEnabled()) {
        log.debug("Creating data source");
    }
    initDataSource();
    if (log.isDebugEnabled()) {
        log.debug("Starting DAO");
    }
    initDAO();
    BPELEndpointReferenceContextImpl eprContext = new BPELEndpointReferenceContextImpl();
    if (log.isDebugEnabled()) {
        log.debug("Initializing BPEL process store");
    }
    initProcessStore(eprContext);
    if (log.isDebugEnabled()) {
        log.debug("Initializing BPEL server");
    }
    initBPELServer(eprContext);
    if (log.isDebugEnabled()) {
        log.debug("Initializing multithreaded connection manager");
    }
    initHttpConnectionManager();
    /* Register event listeners configured in ode-axis2.properties file*/
    registerEventListeners();
    /* Register message exchange interceptors configured in ode-axis.properties file*/
    registerMexInterceptors();
    registerExtensionActivityBundles();
    registerExtensionCorrelationFilters();
    try {
        odeBpelServer.start();
    } catch (Exception e) {
        shutdown();
        String errMsg = "BPEL Server failed to start.";
        log.error(errMsg, e);
        throw new Exception(errMsg, e);
    }
    if (bpelServerConfiguration.getUseDistributedLock() && isAxis2ClusteringEnabled()) {
        BPELServerHolder.getInstance().addObserver(this);
        if (log.isDebugEnabled()) {
            log.debug("Clustering Enabled, Registering Observer for HazelCast service");
        }
    }
    registerMBeans();
}
Also used : BPELServerConfiguration(org.wso2.carbon.bpel.core.ode.integration.config.BPELServerConfiguration) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanRegistrationException(javax.management.MBeanRegistrationException) BpelEngineException(org.apache.ode.bpel.iapi.BpelEngineException)

Aggregations

HashMap (java.util.HashMap)25 Test (org.testng.annotations.Test)21 ArrayList (java.util.ArrayList)18 CharonException (org.wso2.charon3.core.exceptions.CharonException)18 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)18 UserManager (org.wso2.charon3.core.extensions.UserManager)15 Produces (javax.ws.rs.Produces)14 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Path (javax.ws.rs.Path)10 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)10 Map (java.util.Map)9 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)8 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)8 UserStoreException (org.wso2.carbon.user.api.UserStoreException)8 Consumes (javax.ws.rs.Consumes)7 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)7 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)7 Response (feign.Response)6 IOException (java.io.IOException)6