Search in sources :

Example 11 with Tenant

use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.

the class HTQueryBuildHelperImpl method getAllDeployedTasks.

/**
 * @param ltenantID
 * @return all the deployed tasks for the given tenant
 */
public List<HumanTaskBaseConfiguration> getAllDeployedTasks(long ltenantID) {
    int tenantID = (int) ltenantID;
    HumanTaskStore humanTaskStore = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantID);
    List<HumanTaskBaseConfiguration> humanTaskConfigurations = humanTaskStore.getTaskConfigurations();
    return humanTaskConfigurations;
}
Also used : HumanTaskStore(org.wso2.carbon.humantask.core.store.HumanTaskStore) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration)

Example 12 with Tenant

use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.

the class HumanTaskDeployer method init.

public void init(ConfigurationContext configurationContext) {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    log.info("Initializing HumanTask Deployer for tenant " + tenantId + ".");
    try {
        HumanTaskDeployerServiceComponent.getTenantRegistryLoader().loadTenantRegistry(tenantId);
        createHumanTaskRepository(configurationContext);
        HumanTaskServer humantaskServer = HumanTaskDeployerServiceComponent.getHumanTaskServer();
        humanTaskStore = humantaskServer.getTaskStoreManager().createHumanTaskStoreForTenant(tenantId, configurationContext);
    } catch (DeploymentException e) {
        log.warn(String.format("Human Task Repository creation failed for tenant id [%d]", tenantId), e);
    } catch (RegistryException e) {
        log.warn("Initializing HumanTask Deployer failed for tenant " + tenantId, e);
    }
}
Also used : HumanTaskServer(org.wso2.carbon.humantask.core.HumanTaskServer) DeploymentException(org.apache.axis2.deployment.DeploymentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 13 with Tenant

use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.

the class TaskOperationsImpl method getUserListForRole.

private TUser[] getUserListForRole(String roleName, int tenantId, String actualOwnerUserName) throws RegistryException, UserStoreException {
    TUser[] userList = new TUser[0];
    RegistryService registryService = HumanTaskServiceComponent.getRegistryService();
    if (registryService != null && registryService.getUserRealm(tenantId) != null) {
        UserRealm userRealm = registryService.getUserRealm(tenantId);
        String[] assignableUserNameList = userRealm.getUserStoreManager().getUserListOfRole(roleName);
        if (assignableUserNameList != null) {
            userList = new TUser[assignableUserNameList.length];
            for (int i = 0; i < assignableUserNameList.length; i++) {
                TUser user = new TUser();
                user.setTUser(assignableUserNameList[i]);
                if (StringUtils.isEmpty(actualOwnerUserName)) {
                    userList[i] = user;
                } else if (StringUtils.isNotEmpty(actualOwnerUserName) && !actualOwnerUserName.equals(assignableUserNameList[i])) {
                    userList[i] = user;
                }
            }
        }
    } else {
        log.warn("Cannot load User Realm for Tenant Id: " + tenantId);
    }
    return userList;
}
Also used : UserRealm(org.wso2.carbon.user.core.UserRealm) RegistryService(org.wso2.carbon.registry.core.service.RegistryService)

Example 14 with Tenant

use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.

the class AnalyticsServerProfileBuilder method build.

/**
 * Creates AnalyticsServerProfile for given tenant and Analytic profile.
 *
 * @return AnalyticsServerProfile instance
 */
public AnalyticsServerProfile build() {
    AnalyticsServerProfile analyticsServerProfile = new AnalyticsServerProfile();
    Registry registry;
    String location;
    if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG)) {
        try {
            registry = BPELServiceComponent.getRegistryService().getConfigSystemRegistry(tenantId);
            location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_CONF_REG) + UnifiedEndpointConstants.VIRTUAL_CONF_REG.length());
            loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
        } catch (RegistryException re) {
            String errMsg = "Error while loading Analytic profile from config registry.";
            handleError(errMsg, re);
        }
    } else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG)) {
        try {
            registry = BPELServiceComponent.getRegistryService().getGovernanceSystemRegistry(tenantId);
            location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_GOV_REG) + UnifiedEndpointConstants.VIRTUAL_GOV_REG.length());
            loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
        } catch (RegistryException re) {
            String errMsg = "Error while loading Analytic profile from governance registry.";
            handleError(errMsg, re);
        }
    } else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_REG)) {
        try {
            registry = BPELServiceComponent.getRegistryService().getLocalRepository(tenantId);
            location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_REG) + UnifiedEndpointConstants.VIRTUAL_REG.length());
            loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
        } catch (RegistryException re) {
            String errMsg = "Error while loading Analytic profile from local registry";
            handleError(errMsg, re);
        }
    } else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_FILE)) {
        location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_FILE) + UnifiedEndpointConstants.VIRTUAL_FILE.length());
        loadAnalyticsProfileFromFileSystem(analyticsServerProfile, location);
    } else {
        String errMsg = "Invalid analytics profile location: " + profileLocation;
        handleError(errMsg);
    }
    return analyticsServerProfile;
}
Also used : Registry(org.wso2.carbon.registry.api.Registry) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 15 with Tenant

use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.

the class HumanTaskStore method createAxisService.

// Creates the AxisService object from the provided ServiceBuilder object.
private AxisService createAxisService(WSDL11ToAxisServiceBuilder serviceBuilder, HumanTaskBaseConfiguration config) throws AxisFault {
    AxisService axisService;
    axisService = serviceBuilder.populateService();
    axisService.setParent(getTenantAxisConfig());
    axisService.setWsdlFound(true);
    axisService.setCustomWsdl(true);
    // axisService.setFileName(new URL(taskConfig.getWsdlDefLocation()));
    axisService.setClassLoader(getTenantAxisConfig().getServiceClassLoader());
    Utils.setEndpointsToAllUsedBindings(axisService);
    axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
    /* Setting service type to use in service management*/
    axisService.addParameter(ServerConstants.SERVICE_TYPE, "humantask");
    /* Fix for losing of security configuration  when updating human-task package*/
    axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
    Iterator operations = axisService.getOperations();
    AxisHumanTaskMessageReceiver msgReceiver = new AxisHumanTaskMessageReceiver();
    msgReceiver.setHumanTaskEngine(HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine());
    // Setting the task configuration to the message receiver. Hence no need to search for task configuration, when
    // the actual task invocation happens, we will already have the task configuration attached to the message receiver
    // itself
    msgReceiver.setTaskBaseConfiguration(config);
    while (operations.hasNext()) {
        AxisOperation operation = (AxisOperation) operations.next();
        // Setting Message Receiver even if operation has a message receiver specified.
        // This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
        // is set to operations).
        operation.setMessageReceiver(msgReceiver);
        getTenantAxisConfig().getPhasesInfo().setOperationPhases(operation);
    }
    Set<String> exposedTransports = getTenantAxisConfig().getTransportsIn().keySet();
    // Add the transports to axis2 service by reading from the tenant transport config
    for (String transport : exposedTransports) {
        axisService.addExposedTransport(transport);
    }
    if (HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isHtCoordinationEnabled() && HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isTaskRegistrationEnabled() && config.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
        // Only Engage coordination module in-case of Tasks. Coordination module is not required for notifications
        axisService.engageModule(getConfigContext().getAxisConfiguration().getModule("htcoordination"));
    }
    return axisService;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) Iterator(java.util.Iterator) Parameter(org.apache.axis2.description.Parameter) AxisHumanTaskMessageReceiver(org.wso2.carbon.humantask.core.integration.AxisHumanTaskMessageReceiver)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)180 UserStoreException (org.wso2.carbon.user.api.UserStoreException)88 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)83 ArrayList (java.util.ArrayList)79 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)70 PreparedStatement (java.sql.PreparedStatement)51 SQLException (java.sql.SQLException)50 IOException (java.io.IOException)49 Connection (java.sql.Connection)49 HashMap (java.util.HashMap)44 ResultSet (java.sql.ResultSet)43 JSONObject (org.json.simple.JSONObject)41 Resource (org.wso2.carbon.registry.core.Resource)40 Registry (org.wso2.carbon.registry.core.Registry)38 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)34 API (org.wso2.carbon.apimgt.api.model.API)34 Test (org.junit.Test)33 File (java.io.File)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)32 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.api.APIMgtResourceNotFoundException)30