KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > module > admin > AdminBlocks


1
2  /*
3  -- GeiNuke --
4 Copyright (c) 2005 by Roberto Sidoti [geinuke@users.sourceforge.net]
5  http://www.hostingjava.it/-geinuke/
6
7 This file is part of GeiNuke.
8
9     GeiNuke is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     GeiNuke is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with GeiNuke; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */

23 package com.geinuke.module.admin;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.HashMap JavaDoc;
27
28 import javax.servlet.http.HttpServletRequest JavaDoc;
29 import javax.servlet.http.HttpServletResponse JavaDoc;
30
31 import org.apache.velocity.context.Context;
32
33 import com.geinuke.common.GlobalConfigurationI;
34 import com.geinuke.common.ModuleWidgetI;
35 import com.geinuke.common.NukeModuleI;
36 import com.geinuke.common.UserI;
37 import com.geinuke.middle.IBlockBL;
38 import com.geinuke.middle.IUserBL;
39 import com.geinuke.module.ModuleWriter;
40 import com.geinuke.servlet.GeiServlet;
41 import com.geinuke.util.Paginator;
42 import com.geinuke.vo.ModuleDBVO;
43 import com.geinuke.vo.RoleVO;
44
45
46
47 public class AdminBlocks implements ModuleWidgetI{
48
49     public NukeModuleI handleAction(ModuleDBVO module, Context ctx,HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res, UserI user, GlobalConfigurationI gConf) throws Exception JavaDoc {
50         NukeModuleI mod=null;
51         String JavaDoc moduleTempName=null;
52         HashMap JavaDoc rolesX=null;
53         ArrayList JavaDoc blocks=null,roles=null;
54         RoleVO r=null;
55         
56         IBlockBL bbl=(IBlockBL)GeiServlet.getBL("IBlockBL");
57         IUserBL ubl=(IUserBL)GeiServlet.getBL("IUserBL");
58         String JavaDoc upd=req.getParameter("upd");
59         if(upd!=null){
60             int id= Integer.parseInt( req.getParameter("id") );
61             bbl.updateSingleBlock(id,upd);
62             
63         }
64         rolesX=new HashMap JavaDoc();
65         roles=ubl.getAllRoles();
66         for(int i=0;i<roles.size();i++){
67             r=(RoleVO)roles.get(i);
68             rolesX.put(""+r.getLevela(),r);
69         }
70         ctx.put("roles",rolesX);
71         moduleTempName=gConf.getModulePage(module.getName(),req);
72         blocks=bbl.getAllBlocks();
73         
74         String JavaDoc pag=req.getParameter("wp");
75         Paginator pager=new Paginator(blocks,5,"Admin.jhtm?op=adminblocks");
76         if(pag!=null){
77             blocks=pager.getPage(Integer.parseInt(pag));
78         }else{
79             blocks=pager.getPage(1);
80         }
81         
82         ctx.put("pag",pager);
83         ctx.put("blocksDB",blocks);
84         mod=ModuleWriter.fill(ctx,module,moduleTempName);
85         return mod;
86     }
87
88 }
Popular Tags