Search in sources :

Example 26 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project core-util by WSO2Telco.

the class UserRoleProsser method getRolesByUserName.

public List<String> getRolesByUserName(String userName) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class, null);
    List<String> currentUserRoleList = null;
    try {
        RealmConfiguration realmConfiguration = new RealmConfiguration();
        String[] currentUserRoles = realmService.getUserRealm(realmConfiguration).getUserStoreManager().getRoleListOfUser(userName);
        currentUserRoleList = Arrays.asList(currentUserRoles);
    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        log.error("unable to retrieve user roles for user " + userName + " : ", e);
    }
    if (currentUserRoleList != null && !currentUserRoleList.isEmpty()) {
        return currentUserRoleList;
    } else {
        return Collections.emptyList();
    }
}
Also used : RealmConfiguration(org.wso2.carbon.user.api.RealmConfiguration) RealmService(org.wso2.carbon.user.core.service.RealmService) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext)

Example 27 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project core-util by WSO2Telco.

the class ClaimUtil method convertToClaims.

public org.wso2.carbon.user.core.claim.Claim[] convertToClaims(ClaimDTO[] claims) {
    if (claims == null) {
        return new org.wso2.carbon.user.core.claim.Claim[0];
    }
    org.wso2.carbon.user.core.claim.Claim[] claimz = new org.wso2.carbon.user.core.claim.Claim[claims.length];
    int i = 0;
    for (ClaimDTO claim : claims) {
        claimz[i] = convertToClaim(claim);
        i++;
    }
    return claimz;
}
Also used : ClaimDTO(org.wso2.carbon.um.ws.api.stub.ClaimDTO)

Example 28 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project ballerina by ballerina-lang.

the class ParserUtils method prepareCompilerContext.

/**
 * Returns a CompilerContext for the provided fileName and Ballerina source content.
 *
 * @param fileName - File name. This can be any arbitrary name as as we haven't save the file yet.
 * @param source   - Ballerina source content that needs to be parsed.
 * @return CompilerContext
 */
private static CompilerContext prepareCompilerContext(String fileName, String source) {
    CompilerContext context = new CompilerContext();
    List<Name> names = new ArrayList<>();
    names.add(new org.wso2.ballerinalang.compiler.util.Name("."));
    // Registering custom PackageRepository to provide ballerina content without a file in file-system
    context.put(PackageRepository.class, new InMemoryPackageRepository(PackageID.DEFAULT, "", fileName, source.getBytes(StandardCharsets.UTF_8)));
    return context;
}
Also used : CompilerContext(org.wso2.ballerinalang.compiler.util.CompilerContext) ArrayList(java.util.ArrayList) Name(org.wso2.ballerinalang.compiler.util.Name) Name(org.wso2.ballerinalang.compiler.util.Name)

Example 29 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types in project carbon-business-process by wso2.

the class EndpointConfiguration method loadUEPOMFromRegistry.

private OMElement loadUEPOMFromRegistry(Registry registry, String location) throws AxisFault {
    OMElement uepOMElement = null;
    try {
        if (registry.resourceExists(location)) {
            Resource resource = registry.get(location);
            String resourceContent = new String((byte[]) resource.getContent());
            uepOMElement = new StAXOMBuilder(new ByteArrayInputStream(resourceContent.getBytes())).getDocumentElement();
        } else {
            String errMsg = "The resource: " + location + " does not exist.";
            handleError(errMsg);
        }
    } catch (org.wso2.carbon.registry.api.RegistryException e) {
        String errMsg = "Error occurred while reading the resource from registry: " + location + " to build the Unified End Point: " + location;
        handleError(errMsg, e);
    } catch (XMLStreamException e) {
        String errMsg = "Error occurred while creating the OMElement out of Unified End Point " + "profile: " + location;
        handleError(errMsg, e);
    }
    return uepOMElement;
}
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)

Example 30 with org.wso2.carbon.humantask.client.api.types

use of org.wso2.carbon.humantask.client.api.types 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)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)18 APIMgtAdminService (org.wso2.carbon.apimgt.core.api.APIMgtAdminService)13 HashMap (java.util.HashMap)12 Query (javax.persistence.Query)9 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)9 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)5 TAttachment (org.wso2.carbon.attachment.mgt.skeleton.types.TAttachment)5 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)4 AttachmentDAO (org.wso2.carbon.attachment.mgt.core.dao.AttachmentDAO)4 AttachmentMgtException (org.wso2.carbon.attachment.mgt.core.exceptions.AttachmentMgtException)4 AttachmentMgtException (org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException)4 Test (org.testng.annotations.Test)3 ConfigurationException (org.wso2.carbon.config.ConfigurationException)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2 Connection (java.sql.Connection)2 List (java.util.List)2