public List<TaggableItem> getItems(
     TaggableActivity activity,
     TaggingProvider provider,
     boolean getMyItemsOnly,
     String taggedItem) {
   List<TaggableItem> items = new ArrayList<TaggableItem>();
   // Only return items to a specified rating provider
   if (ratingProviderIds.contains(provider.getId())) {
     WizardPageDefinition def = (WizardPageDefinition) activity.getObject();
     for (Iterator<WizardPage> i = def.getPages().iterator(); i.hasNext(); ) {
       // Make sure this page is evaluatable by the current
       // user
       WizardPage page = i.next();
       if (page != null
           && (page.getStatus().equals(MatrixFunctionConstants.PENDING_STATUS)
               || page.getStatus().equals(MatrixFunctionConstants.COMPLETE_STATUS))
           && (!getMyItemsOnly && canEvaluate(page))) {
         items.add(getItem(page));
       }
     }
   } else {
     // Notify other tagging providers that they aren't accepted here yet
     logger.warn(this + ".getItems(): Provider with id " + provider.getId() + " not allowed!");
   }
   return items;
 }
 public List<TaggableItem> getItems(
     TaggableActivity activity,
     String userId,
     TaggingProvider provider,
     boolean getMyItemsOnly,
     String taggedItem) {
   List<TaggableItem> items = new ArrayList<TaggableItem>();
   // Return custom list of items to rating providers. This
   // list should match that seen in the evaluation item list (?)
   if (ratingProviderIds.contains(provider.getId())) {
     WizardPageDefinition def = (WizardPageDefinition) activity.getObject();
     for (Iterator<WizardPage> i = def.getPages().iterator(); i.hasNext(); ) {
       // Make sure this page is evaluatable by the current
       // user
       WizardPage page = i.next();
       if (page != null
           && (page.getStatus().equals(MatrixFunctionConstants.PENDING_STATUS)
               || page.getStatus().equals(MatrixFunctionConstants.COMPLETE_STATUS))
           && (page.getOwner().getId().getValue().equals(userId)
               || (!getMyItemsOnly && canEvaluate(page)))) {
         items.add(getItem(page));
         // There is only one submitted page per definition, so break
         // here
         break;
       }
     }
   } else {
     // Notify other tagging providers that they aren't accepted here yet
     logger.warn(this + ".getItems() 2: Provider with id " + provider.getId() + " not allowed!");
   }
   return items;
 }
 public TaggableItem getItem(
     String itemRef, TaggingProvider provider, boolean getMyItemOnly, String taggedItem) {
   TaggableItem item = null;
   if (checkReference(itemRef)) {
     // Only return item to a specified rating (evalutation) provider
     if (ratingProviderIds.contains(provider.getId())) {
       WizardReference reference = WizardReference.getReference(itemRef);
       if (reference != null) {
         WizardPage page = matrixManager.getWizardPage(idManager.getId(reference.getId()));
         if (page != null
             && (page.getStatus().equals(MatrixFunctionConstants.PENDING_STATUS)
                 || page.getStatus().equals(MatrixFunctionConstants.COMPLETE_STATUS))
             && (page.getOwner()
                     .getId()
                     .getValue()
                     .equals(sessionManager.getCurrentSessionUserId())
                 || (!getMyItemOnly && canEvaluate(page)))) {
           item = getItem(page);
         }
       }
     } else {
       // Notify other tagging providers that they aren't accepted here
       // yet
       logger.warn(this + ".getItem(): Provider with id " + provider.getId() + " not allowed!");
     }
   }
   return item;
 }
 private boolean canEvaluate(WizardPage page) {
   boolean allowed = false;
   CompletedWizard cw = wizardManager.getCompletedWizardByPage(page.getId());
   allowed =
       authzManager.isAuthorized(
           (cw != null)
               ? WizardFunctionConstants.EVALUATE_SPECIFIC_WIZARDPAGE
               : MatrixFunctionConstants.EVALUATE_SPECIFIC_MATRIXCELL,
           page.getId());
   return allowed;
 }
  /* (non-Javadoc)
   * @see org.theospi.utils.mvc.intf.Controller#handleRequest(java.lang.Object, java.util.Map, java.util.Map, java.util.Map, org.springframework.validation.Errors)
   */
  public ModelAndView handleRequest(
      Object requestModel, Map request, Map session, Map application, Errors errors) {
    WizardPage page = (WizardPage) session.get(WizardPageHelper.WIZARD_PAGE);
    Id cellId = idManager.getId((String) request.get("page_id"));
    Id formId = idManager.getId((String) request.get("current_form_id"));
    Cell cell = getMatrixManager().getCellFromPage(cellId);
    boolean sessionPage = true;
    if (page == null) {
      sessionPage = false;
      page = cell.getWizardPage();
    }

    String submitAction = (String) request.get("submit");
    session.remove(WizardPageHelper.WIZARD_PAGE);
    getMatrixManager().removeFromSession(page);
    if (submitAction.equals(DELETE_FORM)) {
      getMatrixManager().detachForm(page.getId(), formId);
    } else // (submitAction.equals(DELETE_FEEDBACK))
    {
      Id reviewId = idManager.getId((String) request.get("review_id"));
      Review review = getReviewManager().getReview(reviewId);
      if (review != null) getReviewManager().deleteReview(review);
      else logger.warn("Null feedback form (perhaps multiple submits):" + reviewId);
    }

    if (sessionPage)
      session.put(WizardPageHelper.WIZARD_PAGE, getMatrixManager().getWizardPage(page.getId()));

    try {
      // unlock and delete content
      String reviewContentId = contentHosting.getUuid(formId.getValue());
      if (getLockManager().isLocked(reviewContentId))
        getLockManager().removeLock(reviewContentId, cellId.getValue());
      getContentHosting().removeResource(formId.getValue());
    } catch (Exception e) {
      logger.warn("Error removing form: " + e.toString());
    }

    // if not submit, then cancel, but both submit and cancel have the some view, so
    return new ModelAndView("continue", "page_id", page.getId().getValue());
  }
예제 #6
0
  /* (non-Javadoc)
   * @see org.theospi.portfolio.security.app.ApplicationAuthorizer#isAuthorized(org.theospi.portfolio.security.AuthorizationFacade, org.theospi.portfolio.shared.model.Agent, java.lang.String, org.theospi.portfolio.shared.model.Id)
   */
  public Boolean isAuthorized(AuthorizationFacade facade, Agent agent, String function, Id id) {
    logger.debug("isAuthorized?(...) invoked in MatrixAuthorizer");

    if (MatrixFunctionConstants.EVALUATE_MATRIX.equals(function)
        || MatrixFunctionConstants.REVIEW_MATRIX.equals(function)
        || MatrixFunctionConstants.USE_SCAFFOLDING.equals(function)) {
      return new Boolean(facade.isAuthorized(function, id));
    } else if (MatrixFunctionConstants.DELETE_SCAFFOLDING.equals(function)) {
      Scaffolding scaffolding = getMatrixManager().getScaffolding(id);
      if (scaffolding == null) return new Boolean(facade.isAuthorized(agent, function, id));

      if (!scaffolding.isPublished() && (scaffolding.getOwner().equals(agent))
          || facade.isAuthorized(agent, function, scaffolding.getWorksiteId()))
        return new Boolean(true);
    } else if (ContentHostingService.EVENT_RESOURCE_READ.equals(function)) {
      return isFileAuth(facade, agent, id);
    } else if (function.equals(MatrixFunctionConstants.CREATE_SCAFFOLDING)) {
      return new Boolean(facade.isAuthorized(agent, function, id));
    } else if (function.equals(MatrixFunctionConstants.EDIT_SCAFFOLDING)) {
      return new Boolean(facade.isAuthorized(agent, function, id));
    } else if (function.equals(MatrixFunctionConstants.EXPORT_SCAFFOLDING)) {
      return new Boolean(facade.isAuthorized(agent, function, id));
    } else if (function.equals(MatrixFunctionConstants.VIEW_SCAFFOLDING_GUIDANCE)) {
      // If I can eval, review, or own it
      ScaffoldingCell sCell = getMatrixManager().getScaffoldingCellByWizardPageDef(id);
      // sCell.getWizardPageDefinition().get

      if (sCell == null)
        throw new NullPointerException(
            "The cell was not found.  Wizard Page Def for cell: " + id.getValue());

      Boolean returned = null;

      Id worksiteId = sCell.getScaffolding().getWorksiteId();

      // first check global perms for the site
      if (checkPerms(
          facade,
          new String[] {
            MatrixFunctionConstants.USE_SCAFFOLDING,
            MatrixFunctionConstants.EVALUATE_MATRIX,
            MatrixFunctionConstants.REVIEW_MATRIX
          },
          worksiteId)) {
        return Boolean.valueOf(true);
      }

      for (Iterator iter = sCell.getCells().iterator(); iter.hasNext(); ) {
        Cell cell = (Cell) iter.next();
        if (checkPerms(
            facade,
            new String[] {
              MatrixFunctionConstants.EVALUATE_MATRIX, MatrixFunctionConstants.REVIEW_MATRIX
            },
            cell.getId())) {
          return Boolean.valueOf(true);
        }
      }
      returned = Boolean.valueOf(sCell.getScaffolding().getOwner().equals(agent));
      if (returned.booleanValue()) return returned;
    } else if (function.equals(MatrixFunctionConstants.EDIT_SCAFFOLDING_GUIDANCE)) {
      ScaffoldingCell sCell = getMatrixManager().getScaffoldingCellByWizardPageDef(id);
      Agent owner = null;
      if (sCell != null) {
        owner = sCell.getScaffolding().getOwner();
      }
      return new Boolean(agent.equals(owner));
    } else if (function.equals(MatrixFunctionConstants.EVALUATE_SPECIFIC_MATRIXCELL)) {
      WizardPage page = getMatrixManager().getWizardPage(id);
      Id siteId = idManager.getId(page.getPageDefinition().getSiteId());
      //       make sure that the target site gets tested

      facade.pushAuthzGroups(siteId.getValue());
      return new Boolean(
          facade.isAuthorized(agent, MatrixFunctionConstants.EVALUATE_MATRIX, siteId));
    }

    return null; // don't care
  }
예제 #7
0
  public Map referenceData(Map request, Object command, Errors errors) {

    Map model = new HashMap();
    model.put("feedbackSent", false);
    ToolSession session = getSessionManager().getCurrentToolSession();

    CellFormBean cell = (CellFormBean) command;
    if (cell == null || cell.getCell() == null) {
      logger.error("Cell backing bean or cell.getCell() is null");
      clearSession(session);
      model.put("nullCellError", true);
      return model;
    }

    if (request.get("feedbackReturn") != null) {
      // feedbackReturn is returned from FeedbackHelperController and is the Id of the wizardPage of
      // the cell.
      cell.setCell(
          matrixManager.getCellFromPage(idManager.getId(request.get("feedbackReturn").toString())));
      if (request.get("feedbackAction") != null
          && request.get("feedbackAction").toString().equals("save")) {
        model.put("feedbackSent", true);
      }
    }

    model.put("matrixCanViewCell", false);
    if (request.get("comingFromWizard") == null) {
      // depending on isDefaultFeedbackEval, either send the scaffolding id or the scaffolding
      // cell's id
      boolean matrixCanEvaluate =
          getMatrixManager()
              .hasPermission(
                  cell.getCell().getScaffoldingCell().isDefaultEvaluators()
                      ? cell.getCell().getScaffoldingCell().getScaffolding().getId()
                      : cell.getCell().getScaffoldingCell().getWizardPageDefinition().getId(),
                  cell.getCell().getScaffoldingCell().getScaffolding().getWorksiteId(),
                  MatrixFunctionConstants.EVALUATE_MATRIX);
      model.put("matrixCanEvaluate", matrixCanEvaluate);
      // depending on isDefaultFeedbackEval, either send the scaffolding id or the scaffolding
      // cell's id
      // also, compare first result with the user's cell review list by sending the user's cell id
      boolean allowParticipantFeedback =
          cell.getCell().getScaffoldingCell().isDefaultReviewers()
              ? cell.getCell().getScaffoldingCell().getScaffolding().isAllowRequestFeedback()
              : cell.getCell()
                  .getScaffoldingCell()
                  .getWizardPageDefinition()
                  .isAllowRequestFeedback();
      boolean matrixCanReview =
          getMatrixManager()
                  .hasPermission(
                      cell.getCell().getScaffoldingCell().isDefaultReviewers()
                          ? cell.getCell().getScaffoldingCell().getScaffolding().getId()
                          : cell.getCell().getScaffoldingCell().getWizardPageDefinition().getId(),
                      cell.getCell().getScaffoldingCell().getScaffolding().getWorksiteId(),
                      MatrixFunctionConstants.REVIEW_MATRIX)
              || (allowParticipantFeedback
                  && getMatrixManager()
                      .hasPermission(
                          cell.getCell().getWizardPage().getId(),
                          cell.getCell().getScaffoldingCell().getScaffolding().getWorksiteId(),
                          MatrixFunctionConstants.FEEDBACK_MATRIX));
      model.put("matrixCanReview", matrixCanReview);

      boolean hasAnyReviewers =
          cell.getCell().getScaffoldingCell().isDefaultReviewers()
              ? !getMatrixManager()
                  .getSelectedUsers(
                      cell.getCell().getScaffoldingCell().getScaffolding(),
                      MatrixFunctionConstants.REVIEW_MATRIX)
                  .isEmpty()
              : !getMatrixManager()
                  .getSelectedUsers(
                      cell.getCell().getScaffoldingCell().getWizardPageDefinition(),
                      MatrixFunctionConstants.REVIEW_MATRIX)
                  .isEmpty();
      model.put("hasAnyReviewers", hasAnyReviewers);

      // NOTE: matrixCanEval or Review both return true if the user is a
      // super user:
      if (getMatrixManager().canAccessMatrixCell(cell.getCell())) {
        model.put("matrixCanViewCell", true);
      }
    } else {
      WizardPage currentWizPage =
          getMatrixManager().getWizardPage(cell.getCell().getWizardPage().getId());
      Id wizPageDefId = currentWizPage.getPageDefinition().getId();
      String wizardId =
          getWizardManager()
              .getWizardPageSeqByDef(wizPageDefId)
              .getCategory()
              .getWizard()
              .getId()
              .getValue();
      model.put("wizardId", wizardId);
      model.put(
          "isWizardOwner",
          getSessionManager()
              .getCurrentSessionUserId()
              .equals(currentWizPage.getOwner().getId().getValue()));
    }

    if (request.get("decPageId") != null
        && request.get("decWrapperTag") != null
        && request.get("decSiteId") != null) {
      // make sure that we are not coming from another wizard page which should grant you access to
      // this page
      String pageId = (String) request.get("decPageId");
      String siteId = (String) request.get("decSiteId");

      if (getMatrixManager()
          .canUserAccessWizardPageAndLinkedArtifcact(
              siteId,
              pageId,
              "/wizard/page/" + cell.getCell().getWizardPage().getId().getValue())) {
        model.put("matrixCanViewCell", true);
      }
    }

    model.put("isMatrix", "true");
    model.put("isWizard", "false");
    model.put("enableReviewEdit", getEnableReviewEdit());
    model.put("currentUser", getSessionManager().getCurrentSessionUserId());
    model.put("CURRENT_GUIDANCE_ID_KEY", "session." + GuidanceManager.CURRENT_GUIDANCE_ID);

    model.put("isEvaluation", "false");

    // This is the tool session so evaluation tool gets "is_eval_page_id"
    // and the matrix/wizard does not
    if (session.getAttribute("is_eval_page_id") != null) {
      String eval_page_id = (String) session.getAttribute("is_eval_page_id");
      model.put("isEvaluation", "true");
    }

    model.put("pageTitleKey", "view_cell");

    // Check for cell being deleted while user was attempting to view
    if (cell.getCell() == null) {
      clearSession(session);
      return model;
    }

    String pageId = cell.getCell().getWizardPage().getId().getValue();
    String siteId = cell.getCell().getWizardPage().getPageDefinition().getSiteId();
    model.put("siteId", idManager.getId(siteId));
    List reviews =
        getReviewManager()
            .getReviewsByParentAndType(pageId, Review.FEEDBACK_TYPE, siteId, getEntityProducer());
    ArrayList<Node> cellForms =
        new ArrayList<Node>(getMatrixManager().getPageForms(cell.getCell().getWizardPage()));
    Collections.sort(cellForms, new NodeNameComparator());

    if (cell.getCell().getScaffoldingCell().getWizardPageDefinition().isDefaultCustomForm()
        && request.get("comingFromWizard") == null) {
      model.put(
          "cellFormDefs",
          processAdditionalForms(
              cell.getCell().getScaffoldingCell().getScaffolding().getAdditionalForms()));
    } else {
      model.put(
          "cellFormDefs",
          processAdditionalForms(cell.getCell().getScaffoldingCell().getAdditionalForms()));
    }

    model.put("assignments", getUserAssignments(cell));
    model.put("reviews", reviews); // feedback
    model.put(
        "evaluations",
        getReviewManager()
            .getReviewsByParentAndType(
                pageId, Review.EVALUATION_TYPE, siteId, getEntityProducer()));
    model.put(
        "reflections",
        getReviewManager()
            .getReviewsByParentAndType(
                pageId, Review.REFLECTION_TYPE, siteId, getEntityProducer()));
    model.put("cellForms", cellForms);
    model.put("numCellForms", cellForms.size());

    Boolean readOnly = Boolean.valueOf(false);

    // Matrix-only initializations
    if (cell.getCell().getMatrix() != null) {
      model.put(
          "allowItemFeedback",
          getAllowItemFeedback(
              cell.getCell().getScaffoldingCell().getScaffolding().getItemFeedbackOption(),
              reviews,
              cellForms,
              cell.getNodes()));
      model.put(
          "allowGeneralFeedback",
          getAllowGeneralFeedback(
              cell.getCell().getScaffoldingCell().getScaffolding().getGeneralFeedbackOption(),
              reviews));
      model.put(
          "generalFeedbackNone",
          cell.getCell().getScaffoldingCell().getScaffolding().isGeneralFeedbackNone());

      Agent owner = cell.getCell().getMatrix().getOwner();
      readOnly =
          isReadOnly(
              owner,
              getIdManager().getId(cell.getCell().getMatrix().getScaffolding().getReference()));

      Cell pageCell = getMatrixManager().getCellFromPage(getIdManager().getId(pageId));
      Scaffolding scaffolding = pageCell.getMatrix().getScaffolding();

      model.put("objectId", scaffolding.getId().getValue());
      model.put("objectTitle", scaffolding.getTitle());
      model.put("objectDesc", scaffolding.getDescription());
      model.put(
          "wizardOwner",
          rb.getFormattedMessage("matrix_of", new Object[] {owner.getDisplayName()}));
    }

    model.put("readOnlyMatrix", readOnly);

    model.put(
        "styles",
        getStyleManager()
            .createStyleUrlList(getStyleManager().getStyles(getIdManager().getId(pageId))));

    if (getTaggingManager().isTaggable()) {
      TaggableItem item = wizardActivityProducer.getItem(cell.getCell().getWizardPage());
      model.put("taggable", "true");

      // getMatrixManager().getTaggableItems will put the providers into the session
      Set<DecoratedTaggableItem> decoTaggableItems =
          getMatrixManager()
              .getDecoratedTaggableItems(
                  item,
                  cell.getCell().getWizardPage().getPageDefinition().getReference(),
                  cell.getCell().getWizardPage().getOwner().getId().getValue());
      List<DecoratedTaggableItem> decoTaggableItemList =
          new ArrayList<DecoratedTaggableItem>(decoTaggableItems);

      Collections.sort(decoTaggableItemList, decoTaggableItemComparator);
      model.put("taggableItems", decoTaggableItemList);

      ToolSession toolSession = getSessionManager().getCurrentToolSession();
      List<DecoratedTaggingProvider> providers =
          (List) toolSession.getAttribute(HibernateMatrixManagerImpl.PROVIDERS_PARAM);
      // but just double check to make sure that providers doesn't exist
      if (providers == null) {
        providers = getMatrixManager().getDecoratedProviders(item.getActivity());
        toolSession.setAttribute(HibernateMatrixManagerImpl.PROVIDERS_PARAM, providers);
      }
      model.put("helperInfoList", getHelperInfo(item));
      model.put("providers", providers);
      model.put("criteriaRef", cell.getCell().getWizardPage().getPageDefinition().getReference());

      model.put("decoWrapper", "ospMatrix_" + siteId + "_" + pageId);
    }

    clearSession(session);
    return model;
  }
 public TaggableItem getItem(WizardPage wizardPage) {
   return new WizardItemImpl(wizardPage, getActivity(wizardPage.getPageDefinition()));
 }