Purpose

This exit allows modification or replacement of the Mailing List that is created by ExtraView.

Applies To

Add Issue screen

Signature

public java.util.ArrayList ucMailListUpdate(
      java.sql.Connection dbcon, 
      java.lang.String problemId, 
      Problem prob, 
      SesameSession session, 
      java.util.ArrayList mailList, 
      ProblemFormParam pfp)

Notes

It should return an ArrayList of MailList Objects. If null is returned then the normal Notification Mailing List will be generated.

Example

public ArrayList ucMailListUpdate (Connection con,
                                       String itemId,
                                       Problem item,
                                       SesameSession session,
                                       ArrayList mailList,
                                       ProblemFormParam values)  {
        // NOTE: THE VALUES PARAMETER SEEMS TO BE EMPTY OR CONTAIN JUST ccMail
        String requestReview = values.getString("REQUEST_REVIEW");
        String addendumAlert = values.getString("ADDENDUM_ALERT");
        String areaId = values.getString("AREA");
        String projectId = getProjectId(values);

        // THEREFORE, GET FIELDS FROM RECORD SAVED IN DATABASE
        ArrayList udfs = Problem_UDF.getReference(con, itemId);

        for (int i = 0; i < udfs.size(); i++) {
            Problem_UDF pudf = (Problem_UDF) udfs.get(i);
            String name = pudf.getName();

            if ("REQUEST_REVIEW".equals(name) )
                requestReview = pudf.getUdfListId();
            if ("ADDENDUM_ALERT".equals(name) )
                addendumAlert = pudf.getUdfListId();
        }

        if (item != null) {
            areaId = item.getAreaId();
            projectId = item.getProjctId();
        }
        
        // if Request Review or Addendum Alert is On, then add project Coordinators
        // and backup Coordinators to mailing list
        if (REQUEST_REVIEW__ON.equals(requestReview) 
         || ADDENDUM_ALERT__ON.equals(addendumAlert) ) {
            String projectTitle = getProjectTitle(con, areaId, projectId);
            String projectAdminId = getProjectAdminId(con, projectTitle);
            ArrayList coordinators = getProjectUsers(con, 
                          projectAdminId, 
                          "COORDINATORS");
            String usersList = "";

            for (int i = 0; i < coordinators.size(); i++) {
                String user = (String) coordinators.get(i);
                usersList += user + ";";
            }

            Z.log.writeToLog(Z.log.INFO, 
             " Request Review/Addendum Alert is On, so send email to coordinators: " 
              + coordinators;

            ArrayList backupCoordinators = getProjectUsers(con, 
                      projectAdminId, 
                      "BACKUP_COORDINATORS");

            for (int i = 0; i < backupCoordinators.size(); i++) {
                String user = (String) backupCoordinators.get(i);
                usersList += user + ";";
            }

            Z.log.writeToLog(Z.log.INFO, 
            "Request Review/Addendum Alert is On, so send email-backup coordinators: " 
             + backupCoordinators);

            // also, add project Translators to mailing list when Request Review is On
            if (REQUEST_REVIEW__ON.equals(requestReview) ) {
                ArrayList translators = getProjectUsers(con, 
                         projectAdminId, 
                         "TRANSLATORS");

                for (int i = 0; i < translators.size(); i++) {
                    String user = (String) translators.get(i);
                    usersList += user + ";";
                }

                Z.log.writeToLog(Z.log.INFO, 
                    "Request Review is On, so send email to translators: " 
                     + translators);
            }

            Pr_Notify prNotify = new Pr_Notify(con, session);
            ArrayList newMailList = prNotify.getCCMailList(usersList);

            for (int i = 0; i < newMailList.size(); i++) {
                mailList.add(newMailList.get(i) );
            }
        }
        return mailList;
    }
    /**
     * NOTE: This method is called by base code (instead of ucMailListUpdate), so
     * re-directing to new method name implemented above.
     */
    public ArrayList replaceMailList (Connection dbcon,
                                      String problemId,
                                      Problem prob,
                                      SesameSession session,
                                      ArrayList mailList,
                                      ProblemFormParam pfp) {
        return ucMailListUpdate(dbcon, problemId, prob, session, mailList, pfp);
    }