KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > transfer > SiteContextForm


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

20
21 package com.methodhead.transfer;
22
23 import java.io.Serializable JavaDoc;
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.action.ActionErrors;
28 import org.apache.struts.action.ActionError;
29 import org.apache.struts.validator.DynaValidatorForm;
30 import com.methodhead.aikp.IntKey;
31 import com.methodhead.sitecontext.SiteContext;
32 import org.apache.log4j.Logger;
33 import java.util.List JavaDoc;
34
35 /**
36  * Extends base class to set <code>installedExtensions</code> and
37  * <code>extensions</code> in <code>reset()</code>.
38  */

39 public class SiteContextForm
40 extends
41   com.methodhead.sitecontext.SiteContextForm
42 implements
43   Serializable JavaDoc {
44
45   public void reset(
46     ActionMapping mapping,
47     HttpServletRequest JavaDoc request ) {
48
49     super.reset( mapping, request );
50
51     SiteExtension siteExtension = new SiteExtension();
52
53     //
54
// set installedExtensions, the list of all extensions available
55
//
56
set( "installedExtensions", siteExtension.getInstalledExtensions() );
57
58     if ( logger_.isDebugEnabled() ) {
59       Extension[] extensions = ( Extension[] )get( "installedExtensions" );
60       logger_.debug( "Found " + extensions.length + " installed extension(s)" );
61     }
62
63     if ( !"new".equals( get( "action" ) ) ) {
64       //
65
// set extensions, the list of all extensions enabled for the selected
66
// site context
67
//
68
SiteContext siteContext = new SiteContext();
69       siteContext.load( new IntKey( request.getParameter( "id" ) ) );
70
71       set( "extensions", siteExtension.loadAllForSiteContext( siteContext ) );
72
73       if ( logger_.isDebugEnabled() ) {
74         List JavaDoc list = ( List JavaDoc )get( "extensions" );
75         logger_.debug( "Found " + list.size() + " enabled extension(s) for " + siteContext );
76       }
77     }
78   }
79
80   private static Logger logger_ = Logger.getLogger( SiteContextForm.class );
81 }
82
Popular Tags