Search in sources :

Example 1 with RegistryException

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

the class BPMNDataPublisher method getKPIConfiguration.

/**
 * Get DAS config details of given certain process which are configured for analytics from the config registry
 *
 * @param processDefinitionId Process definition ID
 * @return KPI configuration details in JSON format. Ex:<p>
 * {"processDefinitionId":"myProcess3:1:32518","eventStreamName":"t_666_process_stream","eventStreamVersion":"1.0.0"
 * ,"eventStreamDescription":"This is the event stream generated to configure process analytics with DAS, for the
 * processt_666","eventStreamNickName":"t_666_process_stream","eventStreamId":"t_666_process_stream:1.0.0",
 * "eventReceiverName":"t_666_process_receiver","pcProcessId":"t:666",
 * "processVariables":[{"name":"processInstanceId","type":"string","isAnalyzeData":"false",
 * "isDrillDownData":"false"}
 * ,{"name":"valuesAvailability","type":"string","isAnalyzeData":"false","isDrillDownData":"false"}
 * ,{"name":"custid","type":"string","isAnalyzeData":false,"isDrillDownData":false}
 * ,{"name":"amount","type":"long","isAnalyzeData":false,"isDrillDownData":false}
 * ,{"name":"confirm","type":"bool","isAnalyzeData":false,"isDrillDownData":false}]}
 * @throws RegistryException
 */
public JsonNode getKPIConfiguration(String processDefinitionId) throws RegistryException, IOException {
    String resourcePath = AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/" + AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME;
    try {
        RegistryService registryService = BPMNAnalyticsHolder.getInstance().getRegistryService();
        Registry configRegistry = registryService.getConfigSystemRegistry();
        if (configRegistry.resourceExists(resourcePath)) {
            Resource processRegistryResource = configRegistry.get(resourcePath);
            String dasConfigDetailsJSONStr = new String((byte[]) processRegistryResource.getContent(), StandardCharsets.UTF_8);
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.readTree(dasConfigDetailsJSONStr);
        }
        return null;
    } catch (RegistryException e) {
        String errMsg = "Error in Getting DAS config details of given process definition id :" + processDefinitionId + " from the BPS Config registry-" + resourcePath;
        throw new RegistryException(errMsg, e);
    }
}
Also used : Resource(org.wso2.carbon.registry.api.Resource) Registry(org.wso2.carbon.registry.api.Registry) RegistryService(org.wso2.carbon.registry.core.service.RegistryService) RegistryException(org.wso2.carbon.registry.api.RegistryException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with RegistryException

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

the class BPELPackageRepository method getBPELPackageInfo.

public BPELPackageInfo getBPELPackageInfo(String packageLocationInRegistry) throws RegistryException {
    BPELPackageInfo bpelPackage = new BPELPackageInfo();
    String name = packageLocationInRegistry.substring(packageLocationInRegistry.lastIndexOf('/') + 1);
    bpelPackage.setName(name);
    bpelPackage.setPackageLocationInRegistry(packageLocationInRegistry);
    Resource packageResource = configRegistry.get(packageLocationInRegistry);
    bpelPackage.setLatestVersion(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_VERSION));
    bpelPackage.setChecksum(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_CHECKSUM));
    BPELPackageInfo.Status status = getStatus(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS));
    bpelPackage.setStatus(status);
    if (status.equals(BPELPackageInfo.Status.FAILED)) {
        bpelPackage.setCauseForDeploymentFailure(packageResource.getProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_ERROR_LOG));
    }
    bpelPackage.setAvailableVersions(getVersionsOfPackage(packageLocationInRegistry));
    return bpelPackage;
}
Also used : Resource(org.wso2.carbon.registry.core.Resource)

Example 3 with RegistryException

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

the class BPELPackageRepository method addLatestArchiveToRegistryCollection.

private void addLatestArchiveToRegistryCollection(BPELDeploymentContext bpelDeploymentContext) throws FileNotFoundException, RegistryException {
    Resource latestBPELArchive = configRegistry.newResource();
    FileInputStream stream = new FileInputStream(bpelDeploymentContext.getBpelArchive());
    latestBPELArchive.setContent(stream);
    configRegistry.put(BPELPackageRepositoryUtils.getBPELPackageArchiveResourcePath(bpelDeploymentContext.getBpelPackageName()), latestBPELArchive);
}
Also used : Resource(org.wso2.carbon.registry.core.Resource) FileInputStream(java.io.FileInputStream)

Example 4 with RegistryException

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

the class BPELPackageRepository method createPropertiesForUpdatedDeploymentInfo.

/**
 * Creates new properties for the details of updated deployment descriptor information
 * for a process  in the package location of the registry
 *
 * @param processConfiguration - Process's configuration details after updated
 * @throws RegistryException          on registry rollback error case, we'll init the cause to the
 *                                    original exception we got when accessing registry
 * @throws IOException                if file access error occurred during MD5 checksum generation
 * @throws NoSuchAlgorithmException   when there is a error during MD5 generation
 * @throws ProcessManagementException
 */
public void createPropertiesForUpdatedDeploymentInfo(ProcessConfigurationImpl processConfiguration) throws RegistryException, IOException, NoSuchAlgorithmException, ProcessManagementException {
    String versionlessPackageName = BPELPackageRepositoryUtils.getVersionlessPackageName(processConfiguration.getPackage());
    String packageLocation = BPELPackageRepositoryUtils.getResourcePathForDeployInfoUpdatedBPELPackage(processConfiguration.getPackage(), versionlessPackageName);
    Resource bpelPackage = configRegistry.get(packageLocation);
    bpelPackage.setProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_FAILURE + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageFailureCleanUpsAsString(processConfiguration.getCleanupCategories(false)));
    bpelPackage.setProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_SUCCESS + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageSuccessCleanUpsInList(processConfiguration.getCleanupCategories(true)));
    bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_EVENT_GENERATE + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageProcessGenerateType(processConfiguration.getGenerateType()));
    bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_EVENTS + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageProcessEventsInList(processConfiguration.getEvents()));
    bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_INMEMORY + processConfiguration.getProcessId(), String.valueOf(processConfiguration.isTransient()));
    bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_STATE + processConfiguration.getProcessId(), processConfiguration.getState().name());
    // ScopeLevelEnabledEvents list of a process in a bpel package
    List<String> scopeEvents;
    scopeEvents = BPELPackageRepositoryUtils.getBPELPackageScopeEventsInList(processConfiguration.getEvents());
    if (!scopeEvents.isEmpty()) {
        for (int k = 0; k < scopeEvents.size(); k++) {
            bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_SCOPE_EVENT + (k + 1) + processConfiguration.getProcessId(), scopeEvents.get(k));
        }
    }
    configRegistry.put(packageLocation, bpelPackage);
}
Also used : Resource(org.wso2.carbon.registry.core.Resource)

Example 5 with RegistryException

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

the class BPELPackageRepository method handleExceptionWithRollback.

/**
 * Handles exception and rollbacks an already started transaction. Don't use this method if
 * you haven't already started a registry transaction
 *
 * @param msg - Message to log
 * @param e   - original exception
 * @throws RegistryException on registry rollback error case, we'll init the cause to the
 *                           original exception we got when accessing registry
 */
protected void handleExceptionWithRollback(String msg, Exception e) throws Exception {
    Exception cachedException = null;
    log.error(msg, e);
    try {
        configRegistry.rollbackTransaction();
    } catch (RegistryException re) {
        cachedException = re;
        log.error("Transaction rollback failed", re);
    }
    if (cachedException != null) {
        cachedException.initCause(e);
        throw cachedException;
    } else {
        throw e;
    }
}
Also used : RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)235 Resource (org.wso2.carbon.registry.core.Resource)196 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)167 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)145 GenericArtifact (org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact)104 Registry (org.wso2.carbon.registry.core.Registry)95 Test (org.junit.Test)81 GenericArtifactManager (org.wso2.carbon.governance.api.generic.GenericArtifactManager)81 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)75 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)70 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)67 APIPersistenceException (org.wso2.carbon.apimgt.persistence.exceptions.APIPersistenceException)61 UserStoreException (org.wso2.carbon.user.api.UserStoreException)60 API (org.wso2.carbon.apimgt.api.model.API)58 IOException (java.io.IOException)57 ArrayList (java.util.ArrayList)55 QName (javax.xml.namespace.QName)42 APIResource (org.wso2.carbon.apimgt.api.doc.model.APIResource)40 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)40 GovernanceException (org.wso2.carbon.governance.api.exception.GovernanceException)40