Search in sources :

Example 41 with URI

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;
}
Also used : CommentDAO(org.wso2.carbon.humantask.core.dao.CommentDAO) AddComment(org.wso2.carbon.humantask.core.engine.commands.AddComment) URI(org.apache.axis2.databinding.types.URI) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 42 with URI

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;
}
Also used : AttachmentMgtException(org.wso2.carbon.attachment.mgt.skeleton.AttachmentMgtException) Calendar(java.util.Calendar) URI(org.apache.axis2.databinding.types.URI)

Example 43 with URI

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;
}
Also used : Calendar(java.util.Calendar) TaskConfiguration(org.wso2.carbon.humantask.core.store.TaskConfiguration) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) URI(org.apache.axis2.databinding.types.URI)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)16 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)15 OMElement (org.apache.axiom.om.OMElement)13 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)13 Parameter (org.apache.axis2.description.Parameter)11 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)10 URI (java.net.URI)9 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)9 Test (org.junit.Test)9 EndpointReference (org.apache.axis2.addressing.EndpointReference)8 URI (org.apache.axis2.databinding.types.URI)7 IOException (java.io.IOException)5 SynapseException (org.apache.synapse.SynapseException)5 MalformedURLException (java.net.MalformedURLException)4 Calendar (java.util.Calendar)4 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)4 InputStream (java.io.InputStream)3 URISyntaxException (java.net.URISyntaxException)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3