Package com.multysite.controller

Source Code of com.multysite.controller.SitemapServlet

package com.multysite.controller;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.NamespaceManager;
import com.multysite.entity.admin.ApplicationConfig;
import com.multysite.entity.admin.ApplicationTemplate;
import com.multysite.model.NewsModel;
import com.multysite.util.Setting;

@SuppressWarnings("serial")
public class SitemapServlet extends HttpServlet {

  private static final Logger log = Logger.getLogger(SitemapServlet.class
      .getName());

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    try {
      req.setCharacterEncoding("utf-8");
      ApplicationTemplate template = (ApplicationTemplate) req
          .getAttribute("template");
      ApplicationConfig config = (ApplicationConfig) req
          .getAttribute("config");
      if (template != null && config != null) {
        NewsModel model = new NewsModel();
        model.setLimit(500);
        model.prepareList();       
        req.setAttribute("model", model);
        req.setAttribute("url", req.getRequestURL().toString());
        req.getRequestDispatcher("/site-map.jsp").forward(req, resp);
      } else {
        NamespaceManager.set(Setting.getGeneralNamespace());
        resp.sendRedirect("http://" + Setting.getDomain());
      }
    } catch (Exception e) {
      log.warning(e.toString());
      e.printStackTrace();
      resp.sendError(4000,
          "Website is down for maintenance. We are sorry for the inconvenience !");
    }
  }
}
TOP

Related Classes of com.multysite.controller.SitemapServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.