KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > backoffice > action > content > MovePublicationAction


1 package org.nextime.ion.backoffice.action.content;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.servlet.ServletException JavaDoc;
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7 import javax.servlet.http.HttpServletResponse JavaDoc;
8 import org.apache.struts.action.ActionForm;
9 import org.apache.struts.action.ActionForward;
10 import org.apache.struts.action.ActionMapping;
11 import org.nextime.ion.backoffice.action.BaseAction;
12 import org.nextime.ion.commons.PublicationSorter;
13 import org.nextime.ion.framework.business.Publication;
14 import org.nextime.ion.framework.business.Section;
15 import org.nextime.ion.framework.mapping.Mapping;
16
17 public class MovePublicationAction extends BaseAction {
18
19     public ActionForward perform(
20         ActionMapping mapping,
21         ActionForm form,
22         HttpServletRequest JavaDoc request,
23         HttpServletResponse JavaDoc response)
24         throws IOException JavaDoc, ServletException JavaDoc {
25
26         // check if user is correctly logged
27
checkUser(request);
28
29         // get publication
30
try {
31             Mapping.begin();
32             
33             Publication p = Publication.getInstance(request.getParameter("pId"));
34             Section s = Section.getInstance(request.getParameter("id"));
35             // up or down ?
36
if( request.getParameter("type").equals("up") ) {
37                 PublicationSorter.upPublication(p, s);
38             } else {
39                 PublicationSorter.downPublication(p, s);
40             }
41             
42             Mapping.commit();
43         } catch (Exception JavaDoc e) {
44             Mapping.rollback();
45             throw new ServletException JavaDoc(e);
46         }
47
48         // Forward to the next page
49
return (mapping.findForward("ok"));
50
51     }
52
53 }
54
Popular Tags