Search in sources :

Example 36 with Registry

use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method listProcessesInPackage.

public PackageType listProcessesInPackage(String packageName) throws PackageManagementException {
    TenantProcessStoreImpl tenantProcessStore = getTenantProcessStore();
    BPELPackageRepository packageRepo = tenantProcessStore.getBPELPackageRepository();
    try {
        return getPackageInfo(packageRepo.getBPELPackageInfoForPackage(packageName.substring(0, packageName.lastIndexOf("-"))));
    } catch (Exception e) {
        String errMsg = "BPEL package: " + packageName + " failed to load from registry.";
        log.error(errMsg, e);
        throw new PackageManagementException(errMsg, e);
    }
}
Also used : BPELPackageRepository(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) BPELUIException(org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException)

Example 37 with Registry

use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.

the class PublishProcessVariablesService method saveDASconfigInfo.

/**
 * Save DAS configuration details (received from PC), in config registry
 *
 * @param dasConfigDetailsJSONString Details of analytics configuration with WSO2 DAS as a JSON string
 * @throws RegistryException Throws RegistryException if error occurred in accessing registry
 * @throws IOException       Throws IOException if an error occurred in hadling json content
 */
private void saveDASconfigInfo(String dasConfigDetailsJSONString) throws RegistryException, IOException {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    Registry configRegistry = carbonContext.getRegistry(RegistryType.SYSTEM_CONFIGURATION);
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode dasConfigDetailsJOb = objectMapper.readTree(dasConfigDetailsJSONString);
    String processDefinitionId = dasConfigDetailsJOb.get(AnalyticsPublisherConstants.PROCESS_DEFINITION_ID).textValue();
    // create a new resource (text file) to keep process variables
    Resource procVariableJsonResource = configRegistry.newResource();
    procVariableJsonResource.setContent(dasConfigDetailsJSONString);
    procVariableJsonResource.setMediaType(MediaType.APPLICATION_JSON);
    configRegistry.put(AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/" + AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME, procVariableJsonResource);
}
Also used : Resource(org.wso2.carbon.registry.api.Resource) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) Registry(org.wso2.carbon.registry.api.Registry) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 38 with Registry

use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.

the class PublishProcessVariablesService method deleteDASConfigInfo.

/**
 * Delete DAS configuration details (received from PC), from config registry
 *
 * @param processDefinitionIdJSONString JSON string contains process definition id
 * @throws RegistryException Throws RegistryException if error occurred in accessing registry
 * @throws IOException       Throws IOException if an error occurred in hadling json content
 */
private void deleteDASConfigInfo(String processDefinitionIdJSONString) throws RegistryException, IOException {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    Registry configRegistry = carbonContext.getRegistry(RegistryType.SYSTEM_CONFIGURATION);
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode dasConfigDetailsJOb = objectMapper.readTree(processDefinitionIdJSONString);
    String processDefinitionId = dasConfigDetailsJOb.get(AnalyticsPublisherConstants.PROCESS_DEFINITION_ID).textValue();
    configRegistry.delete(AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/" + AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME);
}
Also used : PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) JsonNode(com.fasterxml.jackson.databind.JsonNode) Registry(org.wso2.carbon.registry.api.Registry) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 39 with Registry

use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.

the class ServiceConfigurationUtil method loadOMElement.

private static OMElement loadOMElement(Registry registry, String location) {
    OMElement serviceElement = null;
    ByteArrayInputStream bis = null;
    try {
        if (registry.resourceExists(location)) {
            Resource resource = registry.get(location);
            String resourceContent = new String((byte[]) resource.getContent());
            bis = new ByteArrayInputStream(resourceContent.getBytes());
            serviceElement = new StAXOMBuilder(bis).getDocumentElement();
            serviceElement.build();
        } else {
            String errMsg = "The resource: " + location + " does not exist.";
            log.warn(errMsg);
        }
    } catch (RegistryException | XMLStreamException e) {
        String errMsg = "Error occurred while creating the OMElement out of service.xml " + location;
        log.warn(errMsg, e);
    }
    // }
    return serviceElement;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ByteArrayInputStream(java.io.ByteArrayInputStream) Resource(org.wso2.carbon.registry.api.Resource) OMElement(org.apache.axiom.om.OMElement) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 40 with Registry

use of org.wso2.carbon.registry.core.Registry 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)

Aggregations

RegistryException (org.wso2.carbon.registry.api.RegistryException)18 Registry (org.wso2.carbon.registry.api.Registry)12 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)12 Resource (org.wso2.carbon.registry.api.Resource)10 File (java.io.File)8 IOException (java.io.IOException)8 Resource (org.wso2.carbon.registry.core.Resource)8 OMElement (org.apache.axiom.om.OMElement)7 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)7 Collection (org.wso2.carbon.registry.core.Collection)7 ArrayList (java.util.ArrayList)5 FileNotFoundException (java.io.FileNotFoundException)4 QName (javax.xml.namespace.QName)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 RegistryService (org.wso2.carbon.registry.api.RegistryService)4 ResourceData (org.wso2.carbon.registry.common.ResourceData)4 RegistryService (org.wso2.carbon.registry.core.service.RegistryService)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 FileInputStream (java.io.FileInputStream)3 ProcessEngine (org.activiti.engine.ProcessEngine)3