Search in sources :

Example 1 with CommentDAO

use of org.wso2.carbon.humantask.core.dao.CommentDAO 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)

Aggregations

URI (org.apache.axis2.databinding.types.URI)1 CommentDAO (org.wso2.carbon.humantask.core.dao.CommentDAO)1 HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)1 AddComment (org.wso2.carbon.humantask.core.engine.commands.AddComment)1 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)1 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)1 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)1 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)1 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1 UserStoreException (org.wso2.carbon.user.core.UserStoreException)1