Search in sources :

Example 36 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 initProcessStore.

/**
 * Initialize process store/
 *
 * @param eprContext Endpoint reference context
 * @throws Exception if process store initialization failed
 */
private void initProcessStore(EndpointReferenceContext eprContext) throws Exception {
    processStore = new ProcessStoreImpl(eprContext, db.getDataSource(), odeConfigurationProperties);
    processStore.setLocalBPELDeploymentUnitRepo(new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "bpel"));
    processStore.registerListener(new ProcessStoreListenerImpl());
}
Also used : TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) ProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessStoreImpl) File(java.io.File)

Example 37 with Store

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

the class ProcessManagementServiceSkeleton method fillProcessInfo.

/**
 * Fill in the <code>ProcessInfo</code> element of the transfer object.
 *
 * @param info               destination XMLBean
 * @param pconf              process configuration object (from store)
 * @param custom             used to customize the quantity of information produced in the
 *                           info
 * @param tenantProcessStore Tenant's Process store
 * @throws ProcessManagementException If an error occurred while filling process information
 */
private void fillProcessInfo(ProcessInfoType info, ProcessConf pconf, ProcessInfoCustomizer custom, TenantProcessStoreImpl tenantProcessStore) throws ProcessManagementException {
    if (pconf == null) {
        String errMsg = "Process configuration cannot be null.";
        log.error(errMsg);
        throw new ProcessManagementException(errMsg);
    }
    info.setPid(pconf.getProcessId().toString());
    // Active process may be retired at the same time
    if (pconf.getState() == ProcessState.RETIRED) {
        info.setStatus(ProcessStatus.RETIRED);
        info.setOlderVersion(AdminServiceUtils.isOlderVersion(pconf, tenantProcessStore));
    } else if (pconf.getState() == ProcessState.DISABLED) {
        info.setStatus(ProcessStatus.DISABLED);
        info.setOlderVersion(0);
    } else {
        info.setStatus(ProcessStatus.ACTIVE);
        info.setOlderVersion(0);
    }
    info.setVersion(pconf.getVersion());
    DefinitionInfo defInfo = new DefinitionInfo();
    defInfo.setProcessName(pconf.getType());
    BpelDefinition bpelDefinition = new BpelDefinition();
    bpelDefinition.setExtraElement(getProcessDefinition(pconf));
    defInfo.setDefinition(bpelDefinition);
    info.setDefinitionInfo(defInfo);
    DeploymentInfo depInfo = new DeploymentInfo();
    depInfo.setPackageName(pconf.getPackage());
    depInfo.setDocument(pconf.getBpelDocument());
    depInfo.setDeployDate(AdminServiceUtils.toCalendar(pconf.getDeployDate()));
    // TODO: Need to fix this by adding info to process conf.
    depInfo.setDeployer(org.wso2.carbon.bpel.core.BPELConstants.BPEL_DEPLOYER_NAME);
    info.setDeploymentInfo(depInfo);
    if (custom.includeInstanceSummary()) {
        InstanceSummary instanceSummary = new InstanceSummary();
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.ACTIVE);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.COMPLETED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.FAILED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.SUSPENDED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.TERMINATED);
        addFailuresToInstanceSummary(instanceSummary, pconf);
        info.setInstanceSummary(instanceSummary);
    }
    if (custom.includeProcessProperties()) {
        ProcessProperties processProps = new ProcessProperties();
        for (Map.Entry<QName, Node> propEntry : pconf.getProcessProperties().entrySet()) {
            QName key = propEntry.getKey();
            if (key != null) {
                Property_type0 prop = new Property_type0();
                prop.setName(new QName(key.getNamespaceURI(), key.getLocalPart()));
                OMFactory omFac = OMAbstractFactory.getOMFactory();
                OMElement propEle = omFac.createOMElement("PropertyValue", null);
                propEle.setText(propEntry.getValue().getNodeValue());
                prop.addExtraElement(propEle);
                processProps.addProperty(prop);
            }
        }
        info.setProperties(processProps);
    }
    fillPartnerLinks(info, ((ProcessConfigurationImpl) pconf).getProcessDeploymentInfo());
}
Also used : DefinitionInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DefinitionInfo) BpelDefinition(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.BpelDefinition) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) InstanceSummary(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InstanceSummary) Property_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Property_type0) ProcessProperty_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperty_type0) ProcessProperties(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperties) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) OMFactory(org.apache.axiom.om.OMFactory) DeploymentInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeploymentInfo) Map(java.util.Map)

Example 38 with Store

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

the class HumanTaskPackageRepository method createHumanTaskPackageParentCollectionWithProperties.

/**
 * Create parent collection to persisting human task package information. For example, if you deploy
 * a human task archive called 'ClaimsApprovalTask.zip', we store information of that package in collection
 * named 'ClaimsApprovalTask'. This will be the root for 'ClaimsApprovalTask' human task package information and
 * there will several versions of this human task package in this registry collection which relates
 * to the versions deployed in human task engine.
 *
 * @param humanTaskDeploymentUnit containing information on current deployment
 * @throws RegistryException when there is a error accessing registry
 */
private void createHumanTaskPackageParentCollectionWithProperties(HumanTaskDeploymentUnit humanTaskDeploymentUnit) throws RegistryException {
    Collection humanPackage = configRegistry.newCollection();
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, humanTaskDeploymentUnit.getMd5sum());
    if (log.isDebugEnabled()) {
        log.debug(humanTaskDeploymentUnit.getPackageName() + " updating checksum: " + humanTaskDeploymentUnit.getMd5sum() + " in registry");
    }
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf(humanTaskDeploymentUnit.getTaskPackageStatus()));
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION, Long.toString(humanTaskDeploymentUnit.getVersion()));
    configRegistry.put(HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage(humanTaskDeploymentUnit), humanPackage);
}
Also used : Collection(org.wso2.carbon.registry.core.Collection)

Example 39 with Store

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

the class BPELDeployer method init.

public void init(ConfigurationContext configurationContext) {
    Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    log.info("Initializing BPEL Deployer for tenant " + tenantId + ".");
    File bpelRepo = null;
    try {
        BPELDeployerServiceComponent.getTenantRegistryLoader().loadTenantRegistry(tenantId);
        bpelRepo = createBPELRepository(configurationContext);
    } catch (DeploymentException e) {
        log.warn("BPEL repository creation failed.", e);
    } catch (RegistryException e) {
        log.warn("Initialization of tenant process store failed for tenant: " + tenantId + " This can cause issues in deployment of BPEL packages.", e);
    }
    BPELServer bpsServer = BPELDeployerServiceComponent.getBPELServer();
    tenantProcessStore = bpsServer.getMultiTenantProcessStore().createProcessStoreForTenant(configurationContext);
    tenantProcessStore.setBpelArchiveRepo(bpelRepo);
    configurationContext.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, bpsServer.getHttpConnectionManager());
    try {
        tenantProcessStore.init();
    } catch (Exception re) {
        log.warn("Initialization of tenant process store failed for tenant: " + tenantId + " This can cause issues in deployment of BPEL packages.", re);
    }
}
Also used : DeploymentException(org.apache.axis2.deployment.DeploymentException) BPELServer(org.wso2.carbon.bpel.core.ode.integration.BPELServer) File(java.io.File) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) DeploymentException(org.apache.axis2.deployment.DeploymentException)

Example 40 with Store

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

the class UserSubstitutionService method updateSubstituteInfo.

/**
 * Update the substitute info of the given user in the request path. Use the same format used in POST method.
 * @param user - user that need to update his substitute info
 * @param request - substitute info that need to be updated
 * @return
 * @throws URISyntaxException
 */
@PUT
@Path("/{user}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateSubstituteInfo(@PathParam("user") String user, SubstitutionRequest request) throws URISyntaxException {
    try {
        if (!subsFeatureEnabled) {
            return Response.status(405).build();
        }
        request.setAssignee(user);
        String assignee = getRequestedAssignee(user);
        String substitute = validateAndGetSubstitute(request.getSubstitute(), assignee);
        Date endTime = null;
        Date startTime = new Date();
        DateTime requestStartTime = null;
        if (request.getStartTime() != null) {
            requestStartTime = new DateTime(request.getStartTime());
            startTime = new Date(requestStartTime.getMillis());
        }
        if (request.getEndTime() != null) {
            endTime = validateEndTime(request.getEndTime(), requestStartTime);
        }
        if (!UserSubstitutionUtils.validateTasksList(request.getTaskList(), assignee)) {
            throw new ActivitiIllegalArgumentException("Invalid task list provided, for substitution.");
        }
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        UserSubstitutionUtils.handleUpdateSubstitute(assignee, substitute, startTime, endTime, true, request.getTaskList(), tenantId);
        return Response.ok().build();
    } catch (UserStoreException e) {
        throw new ActivitiException("Error accessing User Store", e);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) UserStoreException(org.wso2.carbon.user.api.UserStoreException) DateTime(org.joda.time.DateTime)

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