Package org.nextime.ion.backoffice.action.content

Source Code of org.nextime.ion.backoffice.action.content.ViewSectionAction

package org.nextime.ion.backoffice.action.content;

import java.io.IOException;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.nextime.ion.backoffice.action.BaseAction;
import org.nextime.ion.backoffice.bean.SectionTypes;
import org.nextime.ion.backoffice.bean.TypeBean;

import org.nextime.ion.framework.business.Section;
import org.nextime.ion.framework.mapping.Mapping;

public class ViewSectionAction extends BaseAction {

  public ActionForward perform(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {

    // check if user is correctly logged
    checkUser(request);

    // fill data
    try {
      Mapping.begin();

      Vector sections;
      Vector publications;

      Section section = Section.getInstance(request.getParameter("id"));
      sections = section.listSubSections();
      publications = section.listPublications();
      request.setAttribute("section",section);
      request.setAttribute("sectionName", section.getMetaData("name"));
      try {
        String description = SectionTypes.getSectionBean(servlet,section.getMetaData("template")+"").getDescription();
        request.setAttribute("sectionDescription", description);
      } catch (Exception e) {
        //e.printStackTrace();
      }

      // list subsections
      request.setAttribute("sections", sections);
      request.setAttribute("sectionsSize", new Integer(sections.size()));

      // list publications
      request.setAttribute("publications", publications);
      request.setAttribute(
        "publicationsSize",
        new Integer(publications.size()));

    } catch (Exception e) {
      throw new ServletException(e);
    } finally {
      Mapping.rollback();
    }

    // Forward to the next page
    return (mapping.findForward("view"));

  }

}
TOP

Related Classes of org.nextime.ion.backoffice.action.content.ViewSectionAction

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.