1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 import java.util.List ; 29 30 import org.apache.log4j.Logger; 31 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 32 import org.infoglue.cms.controllers.kernel.impl.simple.AccessRightController; 33 import org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy; 34 import org.infoglue.cms.controllers.kernel.impl.simple.GroupControllerProxy; 35 import org.infoglue.cms.controllers.kernel.impl.simple.InterceptionPointController; 36 import org.infoglue.cms.controllers.kernel.impl.simple.RoleControllerProxy; 37 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeVersionController; 38 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeVersionControllerProxy; 39 import org.infoglue.cms.entities.content.ContentVO; 40 import org.infoglue.cms.entities.management.AccessRightVO; 41 import org.infoglue.cms.entities.structure.SiteNodeVersionVO; 42 import org.infoglue.cms.exception.AccessConstraintException; 43 import org.infoglue.cms.exception.Bug; 44 import org.infoglue.cms.exception.SystemException; 45 import org.infoglue.cms.util.AccessConstraintExceptionBuffer; 46 47 48 51 52 public class ViewAccessRightsAction extends InfoGlueAbstractAction 53 { 54 private final static Logger logger = Logger.getLogger(ViewAccessRightsAction.class.getName()); 55 56 private static final long serialVersionUID = 1L; 57 58 private Integer interceptionPointId = null; 59 private String interceptionPointName = null; 60 private String interceptionPointCategory = null; 61 private String extraParameters = ""; 62 private String returnAddress; 63 private String colorScheme; 64 65 private List interceptionPointVOList = new ArrayList (); 66 private List roleList = null; 67 private List groupList = null; 68 private Collection accessRightsUserRows = null; 69 70 public String doExecute() throws Exception 71 { 72 AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); 73 74 if(interceptionPointCategory.equalsIgnoreCase("Content")) 75 { 76 if(extraParameters == null || extraParameters.equals("")) 77 throw new SystemException("The content category must have a content id sent in so don't set 'Use extra data for access control' to no for those interception points."); 78 79 Integer contentId = new Integer (extraParameters); 80 ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId); 81 if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 82 { 83 Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId); 84 if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", contentId.toString())) 85 ceb.add(new AccessConstraintException("Content.contentId", "1006")); 86 } 87 } 88 else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion")) 89 { 90 if(extraParameters == null || extraParameters.equals("")) 91 throw new SystemException("The sitenode category must have a sitenode id sent in so don't set 'Use extra data for access control' to no for those interception points."); 92 93 Integer siteNodeVersionId = new Integer (extraParameters); 94 SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId); 95 if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) 96 { 97 Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId); 98 if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString())) 99 ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006")); 100 } 101 } 102 103 ceb.throwIfNotEmpty(); 104 105 this.interceptionPointVOList = InterceptionPointController.getController().getInterceptionPointVOList(interceptionPointCategory); 106 this.roleList = RoleControllerProxy.getController().getAllRoles(); 108 this.groupList = GroupControllerProxy.getController().getAllGroups(); 109 111 this.accessRightsUserRows = AccessRightController.getController().getAccessRightsUserRows(interceptionPointCategory, extraParameters); 114 115 return "success"; 116 } 117 118 public boolean getHasAccessRight(Integer interceptionPointId, String extraParameters, String roleName) throws SystemException, Bug 119 { 120 try 121 { 122 List accessRights = AccessRightController.getController().getAccessRightVOList(interceptionPointId, extraParameters, roleName); 123 boolean hasAccessRight = (accessRights.size() > 0) ? true : false; 124 return hasAccessRight; 125 } 126 catch(Exception e) 127 { 128 logger.warn(e); 129 throw new SystemException(e); 130 } 131 } 132 133 public Integer getAccessRightId(Integer interceptionPointId, String extraParameters) throws SystemException, Bug 134 { 135 List accessRights = AccessRightController.getController().getAccessRightVOListOnly(interceptionPointId, extraParameters); 136 return accessRights.size() > 0 ? ((AccessRightVO)accessRights.get(0)).getAccessRightId() : null; 137 } 138 139 public Collection getAccessRightGroups(Integer accessRightId) throws SystemException, Bug 140 { 141 Collection accessRightGroups = AccessRightController.getController().getAccessRightGroupVOList(accessRightId); 142 return accessRightGroups; 143 } 144 145 public List getRoleList() 146 { 147 return this.roleList; 148 } 149 150 public List getGroupList() 151 { 152 return this.groupList; 153 } 154 155 public String getReturnAddress() 156 { 157 return returnAddress; 158 } 159 160 public void setReturnAddress(String returnAddress) 161 { 162 this.returnAddress = returnAddress; 163 } 164 165 public String getColorScheme() 166 { 167 return this.colorScheme; 168 } 169 170 public void setColorScheme(String colorScheme) 171 { 172 this.colorScheme = colorScheme; 173 } 174 175 public Integer getInterceptionPointId() 176 { 177 return this.interceptionPointId; 178 } 179 180 public void setInterceptionPointId(Integer interceptionPointId) 181 { 182 this.interceptionPointId = interceptionPointId; 183 } 184 185 public String getExtraParameters() 186 { 187 return this.extraParameters; 188 } 189 190 public String getInterceptionPointName() 191 { 192 return this.interceptionPointName; 193 } 194 195 public void setExtraParameters(String extraParameters) 196 { 197 this.extraParameters = extraParameters; 198 } 199 200 public void setInterceptionPointName(String interceptionPointName) 201 { 202 this.interceptionPointName = interceptionPointName; 203 } 204 205 public String getInterceptionPointCategory() 206 { 207 return this.interceptionPointCategory; 208 } 209 210 public void setInterceptionPointCategory(String interceptionPointCategory) 211 { 212 this.interceptionPointCategory = interceptionPointCategory; 213 } 214 215 public List getInterceptionPointVOList() 216 { 217 return this.interceptionPointVOList; 218 } 219 220 public Collection getAccessRightsUserRows() 221 { 222 return accessRightsUserRows; 223 } 224 } | Popular Tags |