use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class TaskOperationsImpl method addComment.
/**
* Add a comment to a task.
* @param taskIdURI : task identifier
* @param commentString : comment in plain text
* @return an identifier that can be used to later update or delete the comment.
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public URI addComment(final URI taskIdURI, final String commentString) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
validateTaskId(taskIdURI);
Validate.notEmpty(commentString, "The comment string cannot be empty");
return HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<URI>() {
public URI call() throws Exception {
AddComment addComment = new AddComment(getCaller(), new Long(taskIdURI.toString()), commentString);
addComment.execute();
CommentDAO persisted = addComment.getPersistedComment();
if (persisted != null) {
return ConverterUtil.convertToURI(persisted.getId().toString());
} else {
throw new IllegalStateFault("The persisted comment is null. " + "See error log for more details.");
}
}
});
} catch (Exception ex) {
handleException(ex);
}
return null;
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class TransformerUtils method transformAttachments.
public static TAttachmentInfo[] transformAttachments(List<AttachmentDAO> attachmentList) {
TAttachmentInfo[] array = new TAttachmentInfo[attachmentList.size()];
int counter = 0;
for (AttachmentDAO attachmentDAO : attachmentList) {
TAttachmentInfo attachmentInfo = new TAttachmentInfo();
attachmentInfo.setAccessType(attachmentDAO.getAccessType());
try {
log.debug("TAttachmentInfo(DTO) has the contentCategory, but the AttachmentDAO(DAO) doesn't support " + "that attribute. Assume default attachment category as mime: " + HumanTaskConstants.ATTACHMENT_CONTENT_CATEGORY_MIME);
attachmentInfo.setContentCategory(new URI(HumanTaskConstants.ATTACHMENT_CONTENT_CATEGORY_MIME));
} catch (URI.MalformedURIException e) {
log.error(e.getLocalizedMessage(), e);
}
try {
String attachmentURI = attachmentDAO.getValue();
URI attachmentURL = HumanTaskServerHolder.getInstance().getAttachmentService().getAttachmentService().getAttachmentInfoFromURL(attachmentURI).getUrl();
attachmentInfo.setIdentifier(attachmentURL);
} catch (AttachmentMgtException e) {
log.error(e.getLocalizedMessage(), e);
}
attachmentInfo.setContentType(attachmentDAO.getContentType());
Calendar cal = Calendar.getInstance();
cal.setTime(attachmentDAO.getAttachedAt());
attachmentInfo.setAttachedTime(cal);
TUser user = new TUser();
user.setTUser(attachmentDAO.getAttachedBy().getName());
attachmentInfo.setAttachedBy(user);
attachmentInfo.setName(attachmentDAO.getName());
array[counter] = attachmentInfo;
counter++;
}
return array;
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class TransformerUtils method transformTask.
/**
* Transform a TaskDAO object to a TTaskAbstract object.
*
* @param task : The TaskDAO object to be transformed.
* @param callerUserName : The user name of the caller.
* @return : The transformed TTaskAbstract object.
*/
public static TTaskAbstract transformTask(final TaskDAO task, final String callerUserName) {
TTaskAbstract taskAbstract = new TTaskAbstract();
// Set the task Id
try {
taskAbstract.setId(new URI(task.getId().toString()));
} catch (URI.MalformedURIException e) {
log.warn("Invalid task Id found");
}
taskAbstract.setName(QName.valueOf(task.getDefinitionName()));
taskAbstract.setRenderingMethodExists(true);
// Set the created time
Calendar calCreatedOn = Calendar.getInstance();
calCreatedOn.setTime(task.getCreatedOn());
taskAbstract.setCreatedTime(calCreatedOn);
if (task.getUpdatedOn() != null) {
Calendar updatedTime = Calendar.getInstance();
updatedTime.setTime(task.getUpdatedOn());
taskAbstract.setUpdatedTime(updatedTime);
}
// Set the activation time if exists.
if (task.getActivationTime() != null) {
Calendar calActivationTime = Calendar.getInstance();
calActivationTime.setTime(task.getActivationTime());
taskAbstract.setActivationTime(calActivationTime);
}
// Set the expiration time if exists.
if (task.getExpirationTime() != null) {
Calendar expirationTime = Calendar.getInstance();
expirationTime.setTime(task.getExpirationTime());
taskAbstract.setExpirationTime(expirationTime);
}
if (task.getStartByTime() != null) {
taskAbstract.setStartByTimeExists(true);
} else {
taskAbstract.setStartByTimeExists(false);
}
if (task.getCompleteByTime() != null) {
taskAbstract.setCompleteByTimeExists(true);
} else {
taskAbstract.setCompleteByTimeExists(false);
}
taskAbstract.setTaskType(task.getType().toString());
taskAbstract.setHasSubTasks(CommonTaskUtil.hasSubTasks(task));
taskAbstract.setHasComments(CommonTaskUtil.hasComments(task));
taskAbstract.setHasAttachments(CommonTaskUtil.hasAttachments(task));
taskAbstract.setHasFault(CommonTaskUtil.hasFault(task));
taskAbstract.setHasOutput(CommonTaskUtil.hasOutput(task));
taskAbstract.setEscalated(task.isEscalated());
taskAbstract.setIsSkipable(task.isSkipable());
taskAbstract.setStatus(transformStatus(task.getStatus()));
taskAbstract.setPriority(transformPriority(task.getPriority()));
taskAbstract.setPreviousStatus(transformStatus(task.getStatusBeforeSuspension()));
taskAbstract.setHasPotentialOwners(CommonTaskUtil.hasPotentialOwners(task));
if (CommonTaskUtil.getUserEntityForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER) != null) {
taskAbstract.setActualOwner(createTUser(CommonTaskUtil.getUserEntityForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER)));
}
taskAbstract.setPotentialOwners(transformOrganizationalEntityList(CommonTaskUtil.getOrgEntitiesForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS)));
taskAbstract.setBusinessAdministrators(transformOrganizationalEntityList(CommonTaskUtil.getOrgEntitiesForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS)));
taskAbstract.setNotificationRecipients(transformOrganizationalEntityList(CommonTaskUtil.getOrgEntitiesForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.NOTIFICATION_RECIPIENTS)));
taskAbstract.setTaskStakeholders(transformOrganizationalEntityList(CommonTaskUtil.getOrgEntitiesForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.STAKEHOLDERS)));
taskAbstract.setTaskInitiator(createTUser(CommonTaskUtil.getUserEntityForRole(task, GenericHumanRoleDAO.GenericHumanRoleType.TASK_INITIATOR)));
HumanTaskBaseConfiguration baseConfiguration = CommonTaskUtil.getTaskConfiguration(task);
if (baseConfiguration == null) {
throw new HumanTaskRuntimeException("There's not matching task configuration for " + "task" + task.getName());
}
// Set the versioned package name
taskAbstract.setPackageName(baseConfiguration.getPackageName() + "-" + baseConfiguration.getVersion());
taskAbstract.setTenantId(task.getTenantId());
// If this is a task set the response operation and the port type.
if (TaskType.TASK.equals(task.getType())) {
TaskConfiguration taskConfig = (TaskConfiguration) baseConfiguration;
taskAbstract.setResponseOperationName(taskConfig.getResponseOperation());
taskAbstract.setResponseServiceName(taskConfig.getResponsePortType().toString());
}
taskAbstract.setPresentationName(transformPresentationName(CommonTaskUtil.getDefaultPresentationName(task)));
taskAbstract.setPresentationSubject(transformPresentationSubject(CommonTaskUtil.getDefaultPresentationSubject(task)));
taskAbstract.setPresentationDescription(transformPresentationDescription(CommonTaskUtil.getDefaultPresentationDescription(task)));
// Setting attachment specific information
taskAbstract.setHasAttachments(!task.getAttachments().isEmpty());
taskAbstract.setNumberOfAttachments(task.getAttachments().size());
return taskAbstract;
}
Aggregations