Package org.intalio.tempo.workflow.auth

Examples of org.intalio.tempo.workflow.auth.UserRoles


        Task task = null;
        boolean availableTask = false;
        boolean availableAttachment = false;

        UserRoles credentials = _authProvider.authenticate(participantToken);
        try {
            task = dao.fetchTaskIfExists(taskID);
            availableTask = task instanceof ITaskWithAttachments && task.isAvailableTo(credentials);
            if (availableTask) {
                ITaskWithAttachments taskWithAttachments = (ITaskWithAttachments) task;
                Attachment removedAttachment = taskWithAttachments.removeAttachment(attachmentURL);
                availableAttachment = (removedAttachment != null);
                if (availableAttachment) {
                    dao.updateTask(task);
                    dao.commit();
                    if (_logger.isDebugEnabled())
                        _logger.debug(credentials.getUserID() + " has removed attachment " + attachmentURL
                                + " for Workflow Task " + task);
                }
            }
        } catch (Exception e) {
            _logger.error("Error while delete attachment " + attachmentURL + " for Workflow Task " + taskID, e);
        }
        if (!availableTask || !availableAttachment) {
            throw new UnavailableTaskException(credentials.getUserID() + " cannot remove attachment for Workflow Task "
                    + task + ", is problem with task? - " + availableTask + ", is problem with attachment? - "
                    + availableAttachment);
        }
    }
View Full Code Here


        // DOTO due to all the service from wds is 'x'
        if (participantToken.equalsIgnoreCase("x")) {
            dao.deletePipaTask(formUrl);
            dao.commit();
        } else {
            UserRoles credentials = _authProvider.authenticate(participantToken);
            String userID = credentials.getUserID();
            try {
                Task task = dao.fetchPipa(formUrl);
                if (_permissions.isAuthorized(TaskPermissions.ACTION_DELETE, task, credentials)) {
                    dao.deletePipaTask(formUrl);
                    dao.commit();
View Full Code Here

        map.put(TaskFetcher.FETCH_SUB_QUERY, subQuery);
        return this.getAvailableTasks(dao,participantToken, map);
    }

    public Long countAvailableTasks(ITaskDAOConnection dao,String participantToken, HashMap parameters) throws AuthException {
        UserRoles credentials = _authProvider.authenticate(participantToken);
        try {
            parameters.put(TaskFetcher.FETCH_USER, credentials);
            String klass = (String) parameters.get(TaskFetcher.FETCH_CLASS_NAME);
            if (klass != null)
                parameters.put(TaskFetcher.FETCH_CLASS, TaskTypeMapper.getTaskClassFromStringName(klass));
            return dao.countAvailableTasks(parameters);
        } catch (Exception e) {
            _logger.error("Error while tasks list retrieval for user " + credentials.getUserID(), e);
            throw new RuntimeException(e);
        }
    }
View Full Code Here

            throw new RuntimeException(e);
        }
    }

    public Task[] getAvailableTasks(ITaskDAOConnection dao,String participantToken, HashMap parameters) throws AuthException {
        UserRoles credentials = _authProvider.authenticate(participantToken);
        try {
            parameters.put(TaskFetcher.FETCH_USER, credentials);
            String klass = (String) parameters.get(TaskFetcher.FETCH_CLASS_NAME);
            if (klass != null)
                parameters.put(TaskFetcher.FETCH_CLASS, TaskTypeMapper.getTaskClassFromStringName(klass));
            return dao.fetchAvailableTasks(parameters);
        } catch (Exception e) {
            _logger.error("Error while tasks list retrieval for user " + credentials.getUserID(), e);
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        }
    }

    public void skip(ITaskDAOConnection dao,String taskID, String participantToken) throws AuthException, UnavailableTaskException,
            InvalidTaskStateException, AccessDeniedException {
        UserRoles credentials = _authProvider.authenticate(participantToken);
        Task task = dao.fetchTaskIfExists(taskID);
        checkIsAvailable(taskID, task, credentials);
        if (task instanceof ITaskWithState) {
            ITaskWithState taskWithState = (ITaskWithState) task;
            taskWithState.setState(TaskState.OBSOLETE);
            dao.updateTask(task);
            dao.commit();
            if (_logger.isDebugEnabled())
                _logger.debug(credentials.getUserID() + " has skiped the Workflow Task " + task);
        } else {
            throw new UnavailableTaskException(credentials.getUserID() + " cannot skip Workflow Task " + task);
        }
    }
View Full Code Here

    return (Long) q.getSingleResult();
  }

  private Query buildQuery(Map parameters) {
    // _entityManager.clear();
    UserRoles user = (UserRoles) parameters.get(FETCH_USER);
    Class taskClass = (Class) parameters.get(FETCH_CLASS);
    String subQuery = MapUtils.getString(parameters, FETCH_SUB_QUERY, "");

    ArrayList userIdList = new ArrayList();
    userIdList.add(user.getUserID());
    String baseQuery = parameters.containsKey(FETCH_COUNT) ? QUERY_GENERIC_COUNT
        : QUERY_GENERIC1;
    Query q;
    if (StringUtils.isEmpty(subQuery)) {
      q = _entityManager.createQuery(
          baseQuery + taskClass.getSimpleName() + QUERY_GENERIC2)
          .setParameter(1, userIdList).setParameter(2,
              user.getAssignedRoles());
    } else {
      StringBuffer buffer = new StringBuffer();
      buffer.append(baseQuery).append(taskClass.getSimpleName()).append(
          QUERY_GENERIC2);

      String trim = subQuery.toLowerCase().trim();
      int orderIndex = trim.indexOf("order");
      if (orderIndex == -1) {
        buffer.append(" and ").append(" ( ").append(subQuery).append(
            " ) ");
      } else {
        if (!trim.startsWith("order"))
          buffer.append(" and (").append(
              subQuery.substring(0, orderIndex)).append(") ")
              .append(subQuery.substring(orderIndex));
        else {
          buffer.append(subQuery);
        }
      }
      if (_logger.isDebugEnabled()){
        _logger.debug(buffer.toString());
        _logger.debug("Parameter 1:" + userIdList);
        _logger.debug("Parameter 2:" + user.getAssignedRoles());
      }
      q = _entityManager.createQuery(buffer.toString()).setParameter(1,
          userIdList).setParameter(2, user.getAssignedRoles());
    }
    return q;
  }
View Full Code Here

TOP

Related Classes of org.intalio.tempo.workflow.auth.UserRoles

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.