use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException in project carbon-business-process by wso2.
the class HumanTaskPackageManagementSkeleton method fillTaskDefinitionInfo.
private TaskDefinitionInfo fillTaskDefinitionInfo(HumanTaskBaseConfiguration taskConf) throws PackageManagementException {
TaskDefinitionInfo taskDefInfo = new TaskDefinitionInfo();
taskDefInfo.setTaskName(taskConf.getName());
HumanTaskDefinition taskDefinition = new HumanTaskDefinition();
taskDefinition.setExtraElement(createTaskDefOMElement(taskConf.getHumanTaskDefinitionFile()));
taskDefInfo.setDefinition(taskDefinition);
return taskDefInfo;
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException in project carbon-business-process by wso2.
the class HumanTaskPackageManagementSkeleton method getTaskConfigInfo.
/**
* + * Check the configuration type and return the configuration information for a given task ID
* + * @param taskId
* + * @return TaskConfigInfoResponse response
* + * @throws PackageManagementException
* +
*/
public TaskConfigInfoResponse getTaskConfigInfo(QName taskId) throws PackageManagementException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
TaskConfigInfoResponse response = null;
HumanTaskBaseConfiguration taskConf = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantId).getTaskConfiguration(taskId);
if (taskConf != null) {
response = new TaskConfigInfoResponse();
if (taskConf.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
response.setTaskName(taskConf.getName());
response.setServiceName(taskConf.getServiceName());
response.setPortName(taskConf.getPortName());
response.setCallbackServiceName(((TaskConfiguration) taskConf).getCallbackServiceName());
response.setCallbackPortName(((TaskConfiguration) taskConf).getCallbackPortName());
} else if (taskConf.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.NOTIFICATION) {
response.setTaskName(((NotificationConfiguration) taskConf).getName());
response.setServiceName(taskConf.getServiceName());
response.setPortName(taskConf.getPortName());
}
}
return response;
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException in project carbon-business-process by wso2.
the class HumanTaskPackageManagementSkeleton method createTaskDefOMElement.
private OMElement createTaskDefOMElement(File humanTaskDefFile) throws PackageManagementException {
XMLStreamReader reader;
FileInputStream fis = null;
OMElement humanTaskDefinition;
try {
fis = new FileInputStream(humanTaskDefFile);
XMLInputFactory xif = XMLInputFactory.newInstance();
reader = xif.createXMLStreamReader(fis);
StAXOMBuilder builder = new StAXOMBuilder(reader);
humanTaskDefinition = builder.getDocumentElement();
humanTaskDefinition.build();
} catch (XMLStreamException e) {
String errMsg = "XML stream reader exception: " + humanTaskDefFile.getAbsolutePath();
log.error(errMsg, e);
throw new PackageManagementException(errMsg, e);
} catch (FileNotFoundException e) {
String errMsg = "HT File reading exception: " + humanTaskDefFile.getAbsolutePath();
log.error(errMsg, e);
throw new PackageManagementException(errMsg, e);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
log.warn("Cannot close file input stream.", e);
}
}
}
return humanTaskDefinition;
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException in project carbon-business-process by wso2.
the class HumanTaskPackageManagementSkeleton method listTasksInPackage.
/**
* Lists the tasks in the given package name.
*
* @param packageName : The name of the package to list task definitions.
* @return : The Task_type0 array containing the task definition information.
*/
public Task_type0[] listTasksInPackage(String packageName) throws PackageManagementException {
if (StringUtils.isEmpty(packageName)) {
throw new IllegalArgumentException("The provided package name is empty!");
}
try {
List<SimpleTaskDefinitionInfo> taskDefsInPackage = getTenantTaskStore().getTaskConfigurationInfoListForPackage(packageName);
Task_type0[] taskDefArray = new Task_type0[taskDefsInPackage.size()];
int i = 0;
for (SimpleTaskDefinitionInfo taskDefinitionInfo : taskDefsInPackage) {
taskDefArray[i] = createTaskTypeObject(taskDefinitionInfo);
i++;
}
return taskDefArray;
} catch (Exception ex) {
String errMsg = "listTasksInPackage operation failed";
log.error(errMsg, ex);
throw new PackageManagementException(errMsg, ex);
}
}
use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException in project carbon-business-process by wso2.
the class BPELPackageManagementServiceSkeleton method listDeployedPackagesPaginated.
public DeployedPackagesPaginated listDeployedPackagesPaginated(int page, String packageSearchString) throws PackageManagementException {
int tPage = page;
List<BPELPackageInfo> packages;
DeployedPackagesPaginated paginatedPackages = new DeployedPackagesPaginated();
TenantProcessStoreImpl tenantProcessStore = getTenantProcessStore();
BPELPackageRepository packageRepo = tenantProcessStore.getBPELPackageRepository();
try {
// Can return null and we should handle that
packages = packageRepo.getBPELPackages();
} catch (Exception e) {
String errorMessage = "Cannot get the BPEL Package list from repository.";
log.error(errorMessage, e);
throw new PackageManagementException(errorMessage, e);
}
if (packages != null) {
// Calculating pagination information
if (tPage < 0 || tPage == Integer.MAX_VALUE) {
tPage = 0;
}
int startIndex = tPage * BPELConstants.ITEMS_PER_PAGE;
int endIndex = (tPage + 1) * BPELConstants.ITEMS_PER_PAGE;
int numberOfPackages = packages.size();
int totalPackages = 0;
BPELPackageInfo[] packagesArray = packages.toArray(new BPELPackageInfo[numberOfPackages]);
for (int i = 0; i < numberOfPackages; i++) {
if (!packagesArray[i].getName().toLowerCase().contains(packageSearchString.toLowerCase())) {
continue;
}
int count = getPackageVersionCount(packagesArray[i]);
if (totalPackages + count > startIndex && totalPackages < endIndex) {
// In-order to get the total number of packages count
// if (totalPackages >= endIndex) {
// break;
// }
int maxRemainingPackages = totalPackages < startIndex && (totalPackages + count) > startIndex ? startIndex - (totalPackages + count) : endIndex - totalPackages;
PackageType packageType = getPackageInfo(packagesArray[i], maxRemainingPackages);
paginatedPackages.add_package(packageType);
}
totalPackages += count;
}
int pages = (int) Math.ceil((double) totalPackages / BPELConstants.ITEMS_PER_PAGE);
paginatedPackages.setPages(pages);
} else {
// Returning empty result set with pages equal to zero for cases where null is returned from
// BPEL repo.
paginatedPackages.setPages(0);
}
return paginatedPackages;
}
Aggregations