Esempio n. 1
0
  /**
   * doImport called when "eventSubmit_doBatch_Archive_PreProcess" is in the request parameters to
   * do the prep work for archiving a bunch of sites that match the criteria
   */
  public void doBatch_Archive_PreProcess(RunData data, Context context) {

    SessionState state =
        ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());

    if (!securityService.isSuperUser()) {
      addAlert(state, rb.getString("archive.batch.auth"));
      return;
    }

    // if we have a selected term then use that as the batch export param
    String selectedTerm = data.getParameters().getString("archive-term");

    log.debug("selectedTerm: " + selectedTerm);

    if (StringUtils.isBlank(selectedTerm)) {
      addAlert(state, rb.getString("archive.batch.term.text.missingterm"));
      state.setAttribute(STATE_MODE, BATCH_MODE);
      return;
    }

    // set the message
    state.setAttribute(
        "confirmString",
        rb.getFormattedMessage("archive.batch.term.text.confirm.1", new Object[] {selectedTerm}));

    // get the sites that match the criteria
    Map<String, String> propertyCriteria = new HashMap<String, String>();
    propertyCriteria.put("term_eid", selectedTerm);
    List<Site> sites =
        siteService.getSites(
            SelectionType.ANY, null, null, propertyCriteria, SortType.TITLE_ASC, null);

    if (sites.isEmpty()) {
      addAlert(
          state,
          rb.getFormattedMessage("archive.batch.term.text.nosites", new Object[] {selectedTerm}));
      state.setAttribute(STATE_MODE, BATCH_MODE);
      return;
    }

    // convert to new list so that we dont load entire sites into context
    List<SparseSite> ssites = new ArrayList<SparseSite>();
    for (Site s : sites) {
      ssites.add(new SparseSite(s.getId(), s.getTitle()));
    }

    state.setAttribute("sites", ssites);

    // put into state for next pass
    state.setAttribute("selectedTerm", selectedTerm);

    // set mode so we go to next template
    state.setAttribute(STATE_MODE, BATCH_ARCHIVE_CONFIRM_MODE);
  }
Esempio n. 2
0
  public static java.util.List getSites(
      org.sakaiproject.site.api.SiteService.SelectionType param0,
      java.lang.Object param1,
      java.lang.String param2,
      java.util.Map param3,
      org.sakaiproject.site.api.SiteService.SortType param4,
      org.sakaiproject.javax.PagingPosition param5) {
    org.sakaiproject.site.api.SiteService service = getInstance();
    if (service == null) return null;

    return service.getSites(param0, param1, param2, param3, param4, param5);
  }
Esempio n. 3
0
 /**
  * Get all the sites a user has access to.
  *
  * @return An array of site IDs.
  */
 protected String[] getAllUsersSites() {
   List<Site> sites =
       siteService.getSites(
           org.sakaiproject.site.api.SiteService.SelectionType.ACCESS,
           null,
           null,
           null,
           null,
           null);
   List<String> siteIds = new ArrayList<String>(sites.size());
   for (Site site : sites) {
     if (site != null && site.getId() != null) {
       siteIds.add(site.getId());
     }
   }
   siteIds.add(siteService.getUserSiteId(currentUser));
   return siteIds.toArray(new String[siteIds.size()]);
 }