Package com.tubeonfire.entity

Examples of com.tubeonfire.entity.Advertising


      } catch (Exception e) {
        position = 0;
      }
      if (place != 0 && position != 0) {
        HttpSession session = req.getSession();
        Advertising obj = new Advertising();
        obj.setPlace(place);
        obj.setPosition(position);
        session.setAttribute("obj", obj);
        req.getRequestDispatcher("/admin/form_advertising.jsp")
            .forward(req, resp);
      } else {
        resp.sendError(4004, "Invalid parameter !");
View Full Code Here


      } catch (Exception e) {
        position = 0;
      }
      if (type == 1 && place != 0 && position != 0) {
        String content = req.getParameter("content");
        Advertising obj = new Advertising();
        obj.setId("advertising_place_" + place + "_position_"
            + position);
        obj.setType(type);
        obj.setPlace(place);
        obj.setPosition(position);
        obj.setContent(content);
        AdvertisingModel.insert(obj);
        session.setAttribute("success", "Action success !");
        resp.sendRedirect("/admin/advertising/manage?place=" + place);
      } else if (type == 2 && place != 0 && position != 0) {
        String title = (String) req.getParameter("title");
        String link = (String) req.getParameter("link");
        String imgKey = BlobKeyProcess.getBlobKey(req, "image");

        Advertising obj = new Advertising();
        obj.setId("advertising_place_" + place + "_position_"
            + position);
        obj.setType(type);
        obj.setPlace(place);
        obj.setPosition(position);
        obj.setTitle(title);
        obj.setLink(link);
        obj.setContent(imgKey);
        AdvertisingModel.insert(obj);
        session.setAttribute("success", "Action success !");
        resp.sendRedirect("/admin/advertising/manage?place=" + place);
      } else {
        resp.sendError(4004, "Invalid parameter !");
View Full Code Here

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
    try {
      HttpSession session = req.getSession();
      String id = req.getParameter("id");
      Advertising obj = AdvertisingModel.byId(id, false);
      if (obj != null) {
        session.setAttribute("action", "edit");
        session.setAttribute("obj", obj);
        req.getRequestDispatcher("/admin/form_advertising.jsp")
            .forward(req, resp);
View Full Code Here

  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    try {
      String id = req.getParameter("id");
      Advertising obj = AdvertisingModel.byId(id, false);
      HttpSession session = req.getSession();
      if (obj != null) {
        int type = 0;
        int place = 0;
        int position = 0;
        String strType = req.getParameter("advertisingType");
        String strPlace = req.getParameter("place");
        String strPosition = req.getParameter("position");
        try {
          type = Integer.parseInt(strType);
        } catch (Exception e) {
          type = 0;
        }
        try {
          place = Integer.parseInt(strPlace);
        } catch (Exception e) {
          place = 0;
        }
        try {
          position = Integer.parseInt(strPosition);
        } catch (Exception e) {
          position = 0;
        }
        if (type == 1 && place != 0 && position != 0) {
          String content = req.getParameter("content");
          obj.setType(type);
          obj.setPlace(place);
          obj.setPosition(position);
          obj.setContent(content);
          AdvertisingModel.insert(obj);
          session.setAttribute("success", "Action success !");
          resp.sendRedirect("/admin/advertising/manage?place="
              + place);
        } else if (type == 2 && place != 0 && position != 0) {
          String title = (String) req.getParameter("title");
          String link = (String) req.getParameter("link");
          String imgKey = BlobKeyProcess.getBlobKey(req, "image");
          obj.setType(type);
          obj.setPlace(place);
          obj.setPosition(position);
          obj.setTitle(title);
          obj.setLink(link);
          obj.setContent(imgKey);
          AdvertisingModel.insert(obj);
          session.setAttribute("success", "Action success !");
          resp.sendRedirect("/admin/advertising/manage?place="
              + place);
        } else {
View Full Code Here

      throws IOException {
    HttpSession session = request.getSession();
    String action = request.getParameter("action");
    if (action != null && action.equals("delete")) {
      String id = request.getParameter("id");
      Advertising obj = AdvertisingModel.byId(id, false);
      if (obj != null) {
        session.setAttribute("success", "Action success !");
        AdvertisingModel.delete(obj);
      }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public static Advertising byId(String id, boolean fromCache) {
    init();
    Advertising obj = new Advertising();
    String prefix = cachePrefix + "id_" + id;
    if (cache != null && cache.containsKey(prefix) && fromCache) {
      obj = (Advertising) cache.get(prefix);
    } else {
      try {
View Full Code Here

  @SuppressWarnings("unchecked")
  public static Advertising getByPlaceAndPosition(int place, int position) {
    try {
      init();
      boolean cached = false;
      Advertising obj = new Advertising();
      String prefix = cachePrefix + "id_" + "advertising_place_" + place
          + "_position_" + position;
      if (cache != null) {
        try {
          obj = (Advertising) cache.get(prefix);
          if (obj != null)
            cached = true;
        } catch (Exception e) {
          cached = false;
        }

      }
      if (!cached) {
        obj = ofy.query(Advertising.class).filter("position", position)
            .filter("place", place).get();
        if (obj != null) {
          cache.put(prefix, obj);
        } else {
          cache.put(prefix, new Advertising());
        }
      }
      return obj;
    } catch (Exception e) {
      log.warning(e.toString());
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public static Advertising byId(String id, boolean fromCache) {
    init();
    Advertising obj = new Advertising();
    String prefix = cachePrefix + "id_" + id;
    if (cache != null && cache.containsKey(prefix) && fromCache) {
      obj = (Advertising) cache.get(prefix);
    } else {
      try {
View Full Code Here

  @SuppressWarnings("unchecked")
  public static Advertising getByPlaceAndPosition(int place, int position) {
    try {
      init();
      Advertising obj = new Advertising();
      String prefix = cachePrefix + "id_" + "advertising_place_" + place
          + "_position_" + position;
      if (cache != null && cache.containsKey(prefix)) {
        obj = (Advertising) cache.get(prefix);
      } else {
View Full Code Here

TOP

Related Classes of com.tubeonfire.entity.Advertising

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.