@Override
  public BasicWorkflowItem startWithoutNotify(Context c, WorkspaceItem wsi)
      throws SQLException, AuthorizeException, IOException {
    // make a hash table entry with item ID for no notify
    // notify code checks no notify hash for item id
    noEMail.put(wsi.getItem().getID(), Boolean.TRUE);

    return start(c, wsi);
  }
Ejemplo n.º 2
0
  @Override
  public void alertUsersOnTaskActivation(
      Context c, XmlWorkflowItem wfi, String emailTemplate, List<EPerson> epa, String... arguments)
      throws IOException, SQLException, MessagingException {
    if (noEMail.containsKey(wfi.getItem().getID())) {
      // suppress email, and delete key
      noEMail.remove(wfi.getItem().getID());
    } else {
      Email mail = Email.getEmail(I18nUtil.getEmailFilename(c.getCurrentLocale(), emailTemplate));
      for (String argument : arguments) {
        mail.addArgument(argument);
      }
      for (EPerson anEpa : epa) {
        mail.addRecipient(anEpa.getEmail());
      }

      mail.send();
    }
  }
  protected void notifyGroupOfTask(
      Context c, BasicWorkflowItem wi, Group mygroup, List<EPerson> epa)
      throws SQLException, IOException {
    // check to see if notification is turned off
    // and only do it once - delete key after notification has
    // been suppressed for the first time
    UUID myID = wi.getItem().getID();

    if (noEMail.containsKey(myID)) {
      // suppress email, and delete key
      noEMail.remove(myID);
    } else {
      try {
        // Get the item title
        String title = getItemTitle(wi);

        // Get the submitter's name
        String submitter = getSubmitterName(wi);

        // Get the collection
        Collection coll = wi.getCollection();

        String message = "";

        for (EPerson anEpa : epa) {
          Locale supportedLocale = I18nUtil.getEPersonLocale(anEpa);
          Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "submit_task"));
          email.addArgument(title);
          email.addArgument(coll.getName());
          email.addArgument(submitter);

          ResourceBundle messages = ResourceBundle.getBundle("Messages", supportedLocale);
          switch (wi.getState()) {
            case WFSTATE_STEP1POOL:
              message = messages.getString("org.dspace.workflow.WorkflowManager.step1");

              break;

            case WFSTATE_STEP2POOL:
              message = messages.getString("org.dspace.workflow.WorkflowManager.step2");

              break;

            case WFSTATE_STEP3POOL:
              message = messages.getString("org.dspace.workflow.WorkflowManager.step3");

              break;
          }
          email.addArgument(message);
          email.addArgument(getMyDSpaceLink());
          email.addRecipient(anEpa.getEmail());
          email.send();
        }
      } catch (MessagingException e) {
        String gid = (mygroup != null) ? String.valueOf(mygroup.getID()) : "none";
        log.warn(
            LogManager.getHeader(
                c,
                "notifyGroupofTask",
                "cannot email user group_id="
                    + gid
                    + " workflow_item_id="
                    + wi.getID()
                    + ":  "
                    + e.getMessage()));
      }
    }
  }