Package com.tubeonfire.entity

Examples of com.tubeonfire.entity.SiteConfig


public class ReportErrorServlet extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    try {
      SiteConfig siteConfig = SiteConfigModel.get();
      String id = req.getParameter("id");
      StringBuilder mailContent = new StringBuilder();
      mailContent.append("User has reported video error <br/>");
      mailContent.append("Please visit <a href=\"http://"
          + req.getServerName() + "/video/" + id
          + "/error_page.html\">this link</a> to check again !");
      Properties props = new Properties();
      Session sessions = Session.getDefaultInstance(props, null);

      String msgBody = mailContent.toString();
      try {
        Message msg = new MimeMessage(sessions);
        msg.setSubject("Tubeonfire - Video Error Report");
        msg.setFrom(new InternetAddress(siteConfig.getAdminEmail(),
            "Tubeonfire Assistant"));
        msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
            siteConfig.getAdminEmail(), siteConfig.getAdminEmail()));
        msg.setContent(msgBody, "text/html");
        Transport.send(msg);

      } catch (AddressException e) {
        e.printStackTrace();
View Full Code Here


  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
    try {
      String obj = req.getParameter("obj");
      SiteConfig siteConfig = SiteConfigModel.get();
      if (siteConfig == null) {
        siteConfig = new SiteConfig();
        siteConfig.setId(IdUniqueHelper.getId());
        SiteConfigModel.insert(siteConfig);
      }
      req.setAttribute("siteConfig", siteConfig);
      if (obj != null && obj.equals("seo")) {
        req.getRequestDispatcher("/admin/form_seo.jsp").forward(req,
View Full Code Here

  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    try {
      HttpSession session = req.getSession();
      String obj = req.getParameter("obj");
      SiteConfig siteConfig = SiteConfigModel.get();
      if (obj != null && obj.equals("seo")) {
        String siteName = req.getParameter("siteName");
        String siteTitle = req.getParameter("siteTitle");
        String siteDescription = req.getParameter("siteDescription");
        String siteKeyword = req.getParameter("siteKeyword");
        String analyticCode = req.getParameter("analyticCode");
        if (siteName != null && !siteName.isEmpty()) {
          siteConfig.setSiteName(siteName);
        }
        if (siteTitle != null && !siteTitle.isEmpty()) {
          siteConfig.setSiteTitle(siteTitle);
        }
        if (siteKeyword != null && !siteKeyword.isEmpty()) {
          siteConfig.setSiteKeyword(siteKeyword);
        }
        if (siteDescription != null && !siteDescription.isEmpty()) {
          siteConfig.setSiteDescription(siteDescription);
        }
        if (analyticCode != null && !analyticCode.isEmpty()) {
          siteConfig.setAnalyticCode(analyticCode);
        }
        SiteConfigModel.insert(siteConfig);
        session.setAttribute("success", "Action success !");
        req.setAttribute("siteConfig", siteConfig);
        req.getRequestDispatcher("/admin/form_seo.jsp").forward(req,
            resp);
      } else if (obj != null && obj.equals("logo")) {
        String slogan = (String) req.getParameter("slogan");
        String imgKey = BlobKeyProcess.getBlobKey(req, "image");
        if (slogan != null && !slogan.isEmpty()) {
          siteConfig.setLogoSlogan(slogan);
        }
        if (imgKey == null || imgKey.isEmpty()) {
          siteConfig.setLogoKey("/images/logo.png");
        } else {
          siteConfig.setLogoKey(imgKey);
        }
        SiteConfigModel.insert(siteConfig);
        session.setAttribute("success", "Action success !");
        resp.sendRedirect("/admin/config?obj=logo");
      } else if (obj != null && obj.equals("social")) {
        String twiterLink = (String) req.getParameter("twiterLink");
        String twiterName = (String) req.getParameter("twiterName");
        String facebookLink = (String) req.getParameter("facebookLink");
        String facebookAdminId = (String) req
            .getParameter("facebookAdminId");
        if (twiterLink != null && !twiterLink.isEmpty()) {
          siteConfig.setTwiterLink(twiterLink);
        }
        if (twiterName != null && !twiterName.isEmpty()) {
          siteConfig.setTwiterName(twiterName);
        }
        if (facebookLink != null && !facebookLink.isEmpty()) {
          siteConfig.setFacebookLink(facebookLink);
        }
        if (facebookAdminId != null && !facebookAdminId.isEmpty()) {
          siteConfig.setFacebookAdminId(facebookAdminId);
        }
        SiteConfigModel.insert(siteConfig);
        session.setAttribute("success", "Action success !");
        req.setAttribute("siteConfig", siteConfig);
        req.getRequestDispatcher("/admin/form_social.jsp").forward(req,
            resp);
      } else if (obj != null && obj.equals("slideshow")) {
        String slideOption = (String) req.getParameter("slideOption");
        if (slideOption != null && !slideOption.isEmpty()) {
          siteConfig.setSlideStyle(slideOption);
        }
        SiteConfigModel.insert(siteConfig);
        session.setAttribute("success", "Action success !");
        req.setAttribute("siteConfig", siteConfig);
        req.getRequestDispatcher("/admin/form_slideshow.jsp").forward(
            req, resp);
      } else if (obj != null && obj.equals("system")) {
        String strAdminEmail = (String) req.getParameter("adminEmail");
        String strDisplayObject = (String) req
            .getParameter("displayObject");
        String strPlaylistQuantity = (String) req
            .getParameter("homePagePlaylistQuantity");
        String strChannelQuantity = (String) req
            .getParameter("homePageChannelQuantity");
        String strTubeQuantity = (String) req
            .getParameter("homePageTubeQuantity");
        if (strAdminEmail != null && strAdminEmail.length() > 0) {
          siteConfig.setAdminEmail(strAdminEmail);
        }
        try {
          siteConfig.setHomePageDisplayObject(Integer
              .parseInt(strDisplayObject));
        } catch (Exception e) {
          siteConfig.setHomePageBlockQuantity(2);
        }
        try {
          siteConfig
              .setHomePageBlockQuantity(Integer.parseInt(siteConfig
                  .getHomePageDisplayObject() == 1 ? strPlaylistQuantity
                  : strChannelQuantity));
        } catch (Exception e) {
          siteConfig.setHomePageBlockQuantity(4);
        }
        try {
          siteConfig.setHomePageTubePerBlockQuantity(Integer
              .parseInt(strTubeQuantity));
        } catch (Exception e) {
          siteConfig.setHomePageTubePerBlockQuantity(6);
        }
        SiteConfigModel.insert(siteConfig);
        session.setAttribute("success", "Action success !");
        req.setAttribute("siteConfig", siteConfig);
        req.getRequestDispatcher("/admin/form_system.jsp").forward(req,
View Full Code Here

  @SuppressWarnings("unchecked")
  public static SiteConfig get() {
    init();
    try {
      boolean cached = false;
      SiteConfig obj = new SiteConfig();
      if (cache != null) {
        try {
          obj = (SiteConfig) cache.get(cachePrefix);
          if (obj != null)
            cached = true;
        } catch (Exception e) {
          cached = false;
        }
      }
      if (!cached) {
        try {
          obj = (SiteConfig) ofy.query(SiteConfig.class).get();
          if (obj == null) {
            obj = new SiteConfig();
            obj.setId(IdUniqueHelper.getId());
            insert(obj);
          }
          cache.put(cachePrefix, obj);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      return obj;
    } catch (Exception e) {
      e.printStackTrace();
      return new SiteConfig();
    }
  }
View Full Code Here

TOP

Related Classes of com.tubeonfire.entity.SiteConfig

Copyright © 2018 www.massapicom. 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.