use of org.wso2.carbon.registry.core.exceptions.RegistryException 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;
}
use of org.wso2.carbon.registry.core.exceptions.RegistryException in project carbon-business-process by wso2.
the class AnalyticsServerProfileBuilder method loadAnalyticsProfileFromRegistry.
/**
* Load Analytics profile from given registry and registry path.
*
* @param analyticsServerProfile AnalyticsServerProfile instance
* @param registry Registry space where file is located
* @param location Registry path of the profile file
*/
private void loadAnalyticsProfileFromRegistry(AnalyticsServerProfile analyticsServerProfile, Registry registry, String location) {
try {
if (registry.resourceExists(location)) {
Resource resource = registry.get(location);
String resourceContent = new String((byte[]) resource.getContent());
parseAnalyticsProfile(resourceContent, analyticsServerProfile);
} else {
String errMsg = "The resource: " + location + " does not exist.";
handleError(errMsg);
}
} catch (RegistryException e) {
String errMsg = "Error occurred while reading the resource from registry: " + location + " to build the Analytics server profile: " + profileLocation;
handleError(errMsg, e);
}
}
use of org.wso2.carbon.registry.core.exceptions.RegistryException 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;
}
use of org.wso2.carbon.registry.core.exceptions.RegistryException in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method addLatestArchiveToRegistryCollection.
/**
* Add latest human task package zip to the registry
*
* @param humanTaskDeploymentUnit
* @param humanTaskFile
* @throws HumanTaskStoreException
* @throws RegistryException
*/
private void addLatestArchiveToRegistryCollection(HumanTaskDeploymentUnit humanTaskDeploymentUnit, File humanTaskFile) throws HumanTaskStoreException, RegistryException {
FileInputStream fileInputStream = null;
try {
Resource latestHumanTaskArchive = configRegistry.newResource();
fileInputStream = new FileInputStream(humanTaskFile);
latestHumanTaskArchive.setContent(fileInputStream);
configRegistry.put(HumanTaskPackageRepositoryUtils.getHumanTaskPackageArchiveResourcePath(humanTaskDeploymentUnit.getPackageName()), latestHumanTaskArchive);
} catch (FileNotFoundException ex) {
String errMsg = "HumanTask package zip file couldn't found on given location " + humanTaskFile.getAbsolutePath();
throw new HumanTaskStoreException(errMsg, ex);
} catch (RegistryException ex) {
String errMsg = "Exception occurred while adding latest archive to registry collection";
throw new RegistryException(errMsg, ex);
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
log.warn("Cannot close file input stream.", e);
}
}
}
}
use of org.wso2.carbon.registry.core.exceptions.RegistryException in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method createHumanTaskPackageParentCollectionWithProperties.
/**
* Create parent collection for human task package using DeploymentUnitDAO
*
* @param deploymentUnitDAO
* @throws RegistryException
*/
private void createHumanTaskPackageParentCollectionWithProperties(DeploymentUnitDAO deploymentUnitDAO) throws RegistryException {
Collection humanPackage = configRegistry.newCollection();
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, deploymentUnitDAO.getChecksum());
if (log.isDebugEnabled()) {
log.debug(deploymentUnitDAO.getPackageName() + " updating checksum: " + deploymentUnitDAO.getChecksum() + " in registry");
}
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf(deploymentUnitDAO.getStatus()));
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentUnitDAO.getVersion()));
configRegistry.put(HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage(deploymentUnitDAO), humanPackage);
}
Aggregations