1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 27 import org.infoglue.cms.controllers.kernel.impl.simple.AccessRightController; 28 import org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy; 29 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeVersionController; 30 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeVersionControllerProxy; 31 import org.infoglue.cms.entities.content.ContentVO; 32 import org.infoglue.cms.entities.structure.SiteNodeVersionVO; 33 import org.infoglue.cms.exception.AccessConstraintException; 34 import org.infoglue.cms.util.AccessConstraintExceptionBuffer; 35 import org.infoglue.cms.util.ConstraintExceptionBuffer; 36 37 import webwork.action.Action; 38 39 40 45 46 public class UpdateAccessRightsAction extends InfoGlueAbstractAction 47 { 48 private static final long serialVersionUID = 1L; 49 50 private Integer interceptionPointId; 51 private Integer accessRightId; 52 private String parameters = ""; 53 private String roleName; 54 private String returnAddress; 55 private String url; 56 57 private String interceptionPointCategory; 58 59 private ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); 60 61 public String doExecute() throws Exception 62 { 63 AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); 64 65 if(interceptionPointCategory.equalsIgnoreCase("Content")) 66 { 67 Integer contentId = new Integer (parameters); 68 ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId); 69 if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 70 { 71 Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId); 72 if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString())) 73 ceb.add(new AccessConstraintException("Content.contentId", "1006")); 74 } 75 } 76 else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion")) 77 { 78 Integer siteNodeVersionId = new Integer (parameters); 79 SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId); 80 if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 81 { 82 Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId); 83 if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString())) 84 ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006")); 85 } 86 } 87 88 ceb.throwIfNotEmpty(); 89 90 AccessRightController.getController().update(this.parameters, this.getRequest()); 91 92 this.url = getResponse().encodeRedirectURL(this.returnAddress); 93 94 if(this.returnAddress.indexOf("http") == 0) 96 { 97 getResponse().sendRedirect(url); 98 return Action.NONE; 99 } 100 else 101 return "success"; 102 } 103 104 public String doAddGroups() throws Exception 105 { 106 AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); 107 108 if(interceptionPointCategory.equalsIgnoreCase("Content")) 109 { 110 Integer contentId = new Integer (parameters); 111 ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId); 112 if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 113 { 114 Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId); 115 if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString())) 116 ceb.add(new AccessConstraintException("Content.contentId", "1006")); 117 } 118 } 119 else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion")) 120 { 121 Integer siteNodeVersionId = new Integer (parameters); 122 SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId); 123 if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 124 { 125 Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId); 126 if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString())) 127 ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006")); 128 } 129 } 130 131 ceb.throwIfNotEmpty(); 132 133 String [] groupNames = this.getRequest().getParameterValues("groupName"); 134 AccessRightController.getController().updateGroups(this.accessRightId, this.parameters, groupNames); 135 136 this.url = getResponse().encodeRedirectURL(this.returnAddress); 137 139 return "success"; 140 } 141 142 public String doAddUser() throws Exception 143 { 144 AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); 145 146 if(interceptionPointCategory.equalsIgnoreCase("Content")) 147 { 148 Integer contentId = new Integer (parameters); 149 ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId); 150 if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 151 { 152 Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId); 153 if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString())) 154 ceb.add(new AccessConstraintException("Content.contentId", "1006")); 155 } 156 } 157 else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion")) 158 { 159 Integer siteNodeVersionId = new Integer (parameters); 160 SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId); 161 if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 162 { 163 Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId); 164 if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString())) 165 ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006")); 166 } 167 } 168 169 ceb.throwIfNotEmpty(); 170 171 String userName = this.getRequest().getParameter("userName"); 172 AccessRightController.getController().addUser(interceptionPointCategory, this.parameters, userName, this.getRequest()); 173 174 this.url = getResponse().encodeRedirectURL(this.returnAddress); 175 177 return "success"; 178 } 179 180 public String doDeleteUser() throws Exception 181 { 182 AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); 183 184 if(interceptionPointCategory.equalsIgnoreCase("Content")) 185 { 186 Integer contentId = new Integer (parameters); 187 ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId); 188 if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 189 { 190 Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId); 191 if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString())) 192 ceb.add(new AccessConstraintException("Content.contentId", "1006")); 193 } 194 } 195 else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion")) 196 { 197 Integer siteNodeVersionId = new Integer (parameters); 198 SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId); 199 if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 200 { 201 Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId); 202 if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString())) 203 ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006")); 204 } 205 } 206 207 ceb.throwIfNotEmpty(); 208 209 String userName = this.getRequest().getParameter("userName"); 210 AccessRightController.getController().deleteUser(interceptionPointCategory, this.parameters, userName, this.getRequest()); 211 212 this.url = getResponse().encodeRedirectURL(this.returnAddress); 213 215 return "success"; 216 } 217 218 public String doSaveAndExit() throws Exception 219 { 220 doExecute(); 221 222 return "saveAndExit"; 223 } 224 225 226 public String getReturnAddress() 227 { 228 return returnAddress; 229 } 230 231 public void setReturnAddress(String returnAddress) 232 { 233 this.returnAddress = returnAddress; 234 } 235 236 public Integer getInterceptionPointId() 237 { 238 return this.interceptionPointId; 239 } 240 241 public void setInterceptionPointId(Integer interceptionPointId) 242 { 243 this.interceptionPointId = interceptionPointId; 244 } 245 246 public Integer getAccessRightId() 247 { 248 return accessRightId; 249 } 250 251 public void setAccessRightId(Integer accessRightId) 252 { 253 this.accessRightId = accessRightId; 254 } 255 256 public String getParameters() 257 { 258 return this.parameters; 259 } 260 261 public void setParameters(String parameters) 262 { 263 this.parameters = parameters; 264 } 265 266 public String getInterceptionPointCategory() 267 { 268 return interceptionPointCategory; 269 } 270 271 public void setInterceptionPointCategory(String interceptionPointCategory) 272 { 273 this.interceptionPointCategory = interceptionPointCategory; 274 } 275 276 public String getUrl() 277 { 278 return url; 279 } 280 281 } 282 | Popular Tags |