KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > managementtool > actions > ViewRolePropertiesAction


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.applications.managementtool.actions;
25
26 import java.net.URLEncoder JavaDoc;
27 import java.util.Collections JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.apache.log4j.Logger;
31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController;
32 import org.infoglue.cms.controllers.kernel.impl.simple.RoleControllerProxy;
33 import org.infoglue.cms.controllers.kernel.impl.simple.RolePropertiesController;
34 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO;
35 import org.infoglue.cms.entities.management.RoleProperties;
36 import org.infoglue.cms.entities.management.RolePropertiesVO;
37 import org.infoglue.cms.security.InfoGlueRole;
38 import org.infoglue.cms.util.CmsPropertyHandler;
39
40 public class ViewRolePropertiesAction extends ViewEntityPropertiesAction
41 {
42     private final static Logger logger = Logger.getLogger(ViewRolePropertiesAction.class.getName());
43
44     private static final long serialVersionUID = 1L;
45
46     private String JavaDoc roleName;
47     private RolePropertiesVO rolePropertiesVO;
48     private List JavaDoc rolePropertiesVOList;
49     
50     
51     public ViewRolePropertiesAction()
52     {
53         this.setCurrentAction("ViewRoleProperties.action");
54         this.setUpdateAction("UpdateRoleProperties");
55         this.setCancelAction("ViewRole.action");
56         this.setToolbarKey("tool.managementtool.viewRoleProperties.header");
57         this.setTitleKey("tool.managementtool.viewRoleProperties.header");
58         this.setArguments("");
59         this.setEntityName(RoleProperties.class.getName());
60     }
61         
62     /**
63      * Initializes all properties needed for the usecase.
64      * @param extranetRoleId
65      * @throws Exception
66      */

67
68     protected void initialize(String JavaDoc roleName) throws Exception JavaDoc
69     {
70         super.initialize();
71                 
72         logger.info("roleName:" + roleName);
73         
74         List JavaDoc contentTypeDefinitionVOList = RolePropertiesController.getController().getContentTypeDefinitionVOList(roleName);
75         if(contentTypeDefinitionVOList != null && contentTypeDefinitionVOList.size() > 0)
76             this.setContentTypeDefinitionVO((ContentTypeDefinitionVO)contentTypeDefinitionVOList.get(0));
77         
78         InfoGlueRole infoGlueRole = RoleControllerProxy.getController().getRole(roleName);
79         rolePropertiesVOList = RolePropertiesController.getController().getRolePropertiesVOList(roleName, this.getLanguageId());
80         if(rolePropertiesVOList != null && rolePropertiesVOList.size() > 0)
81         {
82             this.rolePropertiesVO = (RolePropertiesVO)rolePropertiesVOList.get(0);
83             this.setContentTypeDefinitionId(this.rolePropertiesVO.getContentTypeDefinitionId());
84         }
85         else
86         {
87             this.setContentTypeDefinitionId(this.getContentTypeDefinitionVO().getContentTypeDefinitionId());
88         }
89         
90         logger.info("this.rolePropertiesVO:" + this.rolePropertiesVO);
91         
92         this.setAttributes(ContentTypeDefinitionController.getController().getContentTypeAttributes(this.getContentTypeDefinitionVO().getSchemaValue()));
93     
94         logger.info("attributes:" + this.getContentTypeAttributes().size());
95         logger.info("availableLanguages:" + this.getAvailableLanguages().size());
96         
97     }
98
99     public String JavaDoc doExecute() throws Exception JavaDoc
100     {
101         this.initialize(getRoleName());
102         
103         return "success";
104     }
105
106
107     /**
108      * Returns a list of digital assets available for this content version.
109      */

110     
111     public List JavaDoc getDigitalAssets()
112     {
113         List JavaDoc digitalAssets = null;
114         
115         try
116         {
117             if(this.rolePropertiesVO != null && this.rolePropertiesVO.getId() != null)
118             {
119                 digitalAssets = RolePropertiesController.getController().getDigitalAssetVOList(this.rolePropertiesVO.getId());
120             }
121         }
122         catch(Exception JavaDoc e)
123         {
124             logger.warn("We could not fetch the list of digitalAssets: " + e.getMessage(), e);
125         }
126         
127         return digitalAssets;
128     }
129
130     
131     
132     
133
134     /**
135      * Returns all current Category relationships for th specified attrbiute name
136      * @param attribute
137      * @return
138      */

139     public List JavaDoc getRelatedCategories(String JavaDoc attribute)
140     {
141         try
142         {
143             if(this.rolePropertiesVO != null && this.rolePropertiesVO.getId() != null)
144                 return getPropertiesCategoryController().findByPropertiesAttribute(attribute, RoleProperties.class.getName(), this.rolePropertiesVO.getId());
145         }
146         catch(Exception JavaDoc e)
147         {
148             logger.warn("We could not fetch the list of defined category keys: " + e.getMessage(), e);
149         }
150
151         return Collections.EMPTY_LIST;
152     }
153
154     
155     public String JavaDoc getXML()
156     {
157         return (this.rolePropertiesVO == null) ? null : this.rolePropertiesVO.getValue();
158     }
159
160     
161     public String JavaDoc getRoleName()
162     {
163         return roleName;
164     }
165
166     public RolePropertiesVO getRolePropertiesVO()
167     {
168         return rolePropertiesVO;
169     }
170
171     public List JavaDoc getRolePropertiesVOList()
172     {
173         return rolePropertiesVOList;
174     }
175
176     public void setRoleName(String JavaDoc roleName)
177     {
178         this.roleName = roleName;
179         this.setOwnerEntityId(roleName);
180     }
181     
182     public Integer JavaDoc getEntityId()
183     {
184         return this.rolePropertiesVO.getId();
185     }
186     
187     public void setOwnerEntityId(String JavaDoc ownerEntityId)
188     {
189         super.setOwnerEntityId(ownerEntityId);
190         this.roleName = ownerEntityId;
191     }
192      
193     public String JavaDoc getReturnAddress() throws Exception JavaDoc
194     {
195         String JavaDoc URIEncoding = CmsPropertyHandler.getURIEncoding();
196         return this.getCurrentAction() + "?roleName=" + URLEncoder.encode(this.roleName, URIEncoding) + "&languageId=" + this.getLanguageId();
197     }
198
199     public String JavaDoc getCancelAddress() throws Exception JavaDoc
200     {
201         String JavaDoc URIEncoding = CmsPropertyHandler.getURIEncoding();
202         return this.getCancelAction() + "?roleName=" + URLEncoder.encode(this.roleName, URIEncoding);
203     }
204 }
205
Popular Tags