private void preProcessCommunityHome(
     Context context,
     HttpServletRequest request,
     HttpServletResponse response,
     Community community)
     throws ServletException, IOException, SQLException {
   try {
     CommunityHomeProcessor[] chp =
         (CommunityHomeProcessor[]) PluginManager.getPluginSequence(CommunityHomeProcessor.class);
     for (int i = 0; i < chp.length; i++) {
       chp[i].process(context, request, response, community);
     }
   } catch (Exception e) {
     log.error("caught exception: ", e);
     throw new ServletException(e);
   }
 }
  public static void main(String[] argv) throws Exception {
    // set headless for non-gui workstations
    System.setProperty("java.awt.headless", "true");

    // create an options object and populate it
    CommandLineParser parser = new PosixParser();

    Options options = new Options();

    options.addOption(
        "v", "verbose", false, "print all extracted text and other details to STDOUT");
    options.addOption("f", "force", false, "force all bitstreams to be processed");
    options.addOption(
        "n", "noindex", false, "do NOT update the search index after filtering bitstreams");
    options.addOption("i", "identifier", true, "ONLY process bitstreams belonging to identifier");
    options.addOption("m", "maximum", true, "process no more than maximum items");
    options.addOption("h", "help", false, "help");

    CommandLine line = parser.parse(options, argv);

    if (line.hasOption('h')) {
      HelpFormatter myhelp = new HelpFormatter();
      myhelp.printHelp("MediaFilter\n", options);

      System.exit(0);
    }

    if (line.hasOption('v')) {
      isVerbose = true;
    }

    if (line.hasOption('n')) {
      updateIndex = false;
    }

    if (line.hasOption('f')) {
      isForce = true;
    }

    if (line.hasOption('i')) {
      identifier = line.getOptionValue('i');
    }

    if (line.hasOption('m')) {
      max2Process = Integer.parseInt(line.getOptionValue('m'));
      if (max2Process <= 1) {
        System.out.println("Invalid maximum value '" + line.getOptionValue('m') + "' - ignoring");
        max2Process = Integer.MAX_VALUE;
      }
    }

    // set up filters
    filterClasses = (MediaFilter[]) PluginManager.getPluginSequence(MediaFilter.class);
    for (int i = 0; i < filterClasses.length; i++) {
      String filterName = filterClasses[i].getClass().getName();
      String formats = ConfigurationManager.getProperty("filter." + filterName + ".inputFormats");
      if (formats != null) {
        filterFormats.put(filterName, Arrays.asList(formats.split(",[\\s]*")));
      }
    }

    Context c = null;

    try {
      c = new Context();

      // have to be super-user to do the filtering
      c.setIgnoreAuthorization(true);

      // now apply the filters
      if (identifier == null) {
        applyFiltersAllItems(c);
      } else // restrict application scope to identifier
      {
        DSpaceObject dso = HandleManager.resolveToObject(c, identifier);
        if (dso == null) {
          throw new IllegalArgumentException(
              "Cannot resolve " + identifier + " to a DSpace object");
        }

        switch (dso.getType()) {
          case Constants.COMMUNITY:
            applyFiltersCommunity(c, (Community) dso);
            break;
          case Constants.COLLECTION:
            applyFiltersCollection(c, (Collection) dso);
            break;
          case Constants.ITEM:
            applyFiltersItem(c, (Item) dso);
            break;
        }
      }

      // update search index?
      if (updateIndex) {
        System.out.println("Updating search index:");
        DSIndexer.updateIndex(c);
      }

      c.complete();
      c = null;
    } finally {
      if (c != null) {
        c.abort();
      }
    }
  }