1 104 package com.ivata.groupware.business.library.struts; 105 106 import java.lang.reflect.InvocationTargetException ; 107 108 import javax.servlet.http.HttpServletRequest ; 109 import javax.servlet.http.HttpServletResponse ; 110 import javax.servlet.http.HttpSession ; 111 112 import org.apache.commons.beanutils.PropertyUtils; 113 import org.apache.struts.action.ActionErrors; 114 import org.apache.struts.action.ActionForm; 115 import org.apache.struts.action.ActionMapping; 116 117 import com.ivata.groupware.admin.security.server.SecuritySession; 118 import com.ivata.groupware.business.addressbook.person.group.right.RightConstants; 119 import com.ivata.groupware.business.library.Library; 120 import com.ivata.groupware.business.library.right.LibraryRights; 121 import com.ivata.groupware.business.library.topic.TopicDO; 122 import com.ivata.mask.MaskFactory; 123 import com.ivata.mask.util.StringHandling; 124 import com.ivata.mask.util.SystemException; 125 import com.ivata.mask.web.struts.MaskAction; 126 import com.ivata.mask.web.struts.MaskAuthenticator; 127 128 129 138 public class FindTopicAction extends MaskAction { 139 Library library; 140 LibraryRights libraryRights; 141 142 151 public FindTopicAction(Library library, LibraryRights libraryRights, 152 MaskFactory maskFactory, MaskAuthenticator authenticator) { 153 super(maskFactory, authenticator); 154 this.library = library; 155 this.libraryRights = libraryRights; 156 } 157 158 181 public String execute(final ActionMapping mapping, 182 final ActionErrors errors, 183 final ActionForm form, 184 final HttpServletRequest request, 185 final HttpServletResponse response, 186 final HttpSession session) throws SystemException { 187 SecuritySession securitySession = (SecuritySession) session.getAttribute("securitySession"); 188 try { 189 TopicForm libraryTopicForm = new TopicForm(library); 190 191 String requestId = request.getParameter( 193 "id"); 194 Integer id; 195 if (requestId != null) { 196 id = StringHandling.integerValue(requestId); 197 } else { 198 id = (Integer ) PropertyUtils.getSimpleProperty(form, "id"); 199 } 200 201 TopicDO topic = library.findTopicByPrimaryKey(securitySession, id); 202 203 libraryTopicForm.setTopic(topic); 204 205 java.util.Collection rights = libraryRights.findRightsForItemsInTopic( 207 securitySession, 208 id, 209 RightConstants.ACCESS_VIEW); 210 Integer [] tmp = new Integer [rights.size()]; 211 int a = 0; 212 213 for (java.util.Iterator i = rights.iterator(); i.hasNext();) { 214 tmp[a] = (Integer ) i.next(); 215 a++; 216 } 217 218 libraryTopicForm.setRightsViewItem(tmp); 219 220 rights = libraryRights.findRightsForItemsInTopic(securitySession, 222 id, 223 RightConstants.ACCESS_ADD); 224 tmp = new Integer [rights.size()]; 225 a = 0; 226 227 for (java.util.Iterator i = rights.iterator(); i.hasNext();) { 228 tmp[a] = (Integer ) i.next(); 229 a++; 230 } 231 232 libraryTopicForm.setRightsAddItem(tmp); 233 234 rights = libraryRights.findRightsForItemsInTopic(securitySession, 236 id, 237 RightConstants.ACCESS_AMEND); 238 tmp = new Integer [rights.size()]; 239 a = 0; 240 241 for (java.util.Iterator i = rights.iterator(); i.hasNext();) { 242 tmp[a] = (Integer ) i.next(); 243 a++; 244 } 245 246 libraryTopicForm.setRightsAmendItem(tmp); 247 248 rights = libraryRights.findRightsForItemsInTopic(securitySession, 250 id, 251 RightConstants.ACCESS_REMOVE); 252 tmp = new Integer [rights.size()]; 253 a = 0; 254 255 for (java.util.Iterator i = rights.iterator(); i.hasNext();) { 256 tmp[a] = (Integer ) i.next(); 257 a++; 258 } 259 260 libraryTopicForm.setRightsRemoveItem(tmp); 261 262 rights = libraryRights.findRightsForTopic(securitySession, 264 id, 265 RightConstants.ACCESS_VIEW); 266 tmp = new Integer [rights.size()]; 267 a = 0; 268 269 for (java.util.Iterator i = rights.iterator(); i.hasNext();) { 270 tmp[a] = (Integer ) i.next(); 271 a++; 272 } 273 274 libraryTopicForm.setRightsView(tmp); 275 276 rights = libraryRights.findRightsForTopic(securitySession, 278 id, 279 RightConstants.ACCESS_AMEND); 280 tmp = new Integer [rights.size()]; 281 a = 0; 282 283 for (java.util.Iterator i = rights.iterator(); i.hasNext();) { 284 tmp[a] = (Integer ) i.next(); 285 a++; 286 } 287 288 libraryTopicForm.setRightsAmend(tmp); 289 290 rights = libraryRights.findRightsForTopic(securitySession, 292 id, 293 RightConstants.ACCESS_REMOVE); 294 tmp = new Integer [rights.size()]; 295 a = 0; 296 297 for (java.util.Iterator i = rights.iterator(); i.hasNext();) { 298 tmp[a] = (Integer ) i.next(); 299 a++; 300 } 301 302 libraryTopicForm.setRightsRemove(tmp); 303 libraryTopicForm.setTopicTab_activeTab(new Integer (0)); 304 session.setAttribute("libraryTopicForm", libraryTopicForm); 305 session.removeAttribute("topicTab_activeTab"); 306 307 return "libraryTopic"; 309 } catch (NoSuchMethodException e) { 310 throw new SystemException(e); 311 } catch (InvocationTargetException e) { 312 throw new SystemException(e); 313 } catch (IllegalAccessException e) { 314 throw new SystemException(e); 315 } 316 } 317 } 318 | Popular Tags |