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();
}
}
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;
}
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;
}
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;
}
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());
}
Aggregations