KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > policyframework > forms > AbstractFavoriteResourceForm


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.policyframework.forms;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.struts.action.ActionMapping;
27
28 import com.sslexplorer.boot.PropertyList;
29 import com.sslexplorer.input.MultiSelectSelectionModel;
30 import com.sslexplorer.navigation.FavoriteResourceType;
31 import com.sslexplorer.policyframework.Resource;
32 import com.sslexplorer.policyframework.ResourceUtil;
33 import com.sslexplorer.security.SessionInfo;
34 import com.sslexplorer.security.User;
35
36 /**
37  * Abstract extension of {@link com.sslexplorer.policyframework.forms.AbstractResourceForm}
38  * that should be used to edit resources that are capable of supporting favorites
39  * (i.e. their {@link com.sslexplorer.policyframework.ResourceType} is
40  * an instance of {@link com.sslexplorer.navigation.FavoriteResourceType}.
41  *
42  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
43  */

44 public abstract class AbstractFavoriteResourceForm extends AbstractResourceForm {
45     static Log log = LogFactory.getLog(AbstractFavoriteResourceForm.class);
46
47     // Private instance variables
48

49     private boolean favorite;
50
51     /**
52      * Get whether a policy favorite should be created for this resource
53      *
54      * @return policy favorite
55      */

56     public boolean isFavorite() {
57         return favorite;
58     }
59
60     /**
61      * Set wheth a policy favorite should be created for this resource
62      *
63      * @param favorite policy favorite
64      */

65     public void setFavorite(boolean favorite) {
66         this.favorite = favorite;
67     }
68
69     /* (non-Javadoc)
70      * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
71      */

72     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
73         super.reset(mapping, request);
74         this.favorite = false ;
75     }
76
77     /* (non-Javadoc)
78      * @see com.sslexplorer.policyframework.forms.AbstractResourceForm#initialise(com.sslexplorer.security.User, com.sslexplorer.boot.policyframework.Resource, boolean, com.sslexplorer.input.MultiSelectSelectionModel, com.sslexplorer.boot.PropertyList, com.sslexplorer.security.User)
79      */

80     public void initialise(User user, Resource resource, boolean editing, MultiSelectSelectionModel policyModel,
81                     PropertyList selectedPolicies, User owner, boolean assignOnly) throws Exception JavaDoc {
82         super.initialise(user, resource, editing, policyModel, selectedPolicies, owner, assignOnly);
83         this.favorite = ResourceUtil.isResourceGlobalFavorite(resource);
84     }
85
86     /* (non-Javadoc)
87      * @see com.sslexplorer.policyframework.forms.AbstractResourceForm#getResourceByName(java.lang.String, com.sslexplorer.security.SessionInfo)
88      */

89     public Resource getResourceByName(String JavaDoc name, SessionInfo session) throws Exception JavaDoc {
90         return ((FavoriteResourceType)getResource().getResourceType()).getResourceByName(name, session);
91     }
92
93 }
Popular Tags