1 23 24 package org.infoglue.cms.controllers.kernel.impl.simple; 25 26 import java.util.ArrayList ; 27 import java.util.HashMap ; 28 import java.util.List ; 29 import java.util.Map ; 30 31 import org.apache.log4j.Logger; 32 import org.exolab.castor.jdo.Database; 33 import org.infoglue.cms.entities.structure.SiteNode; 34 import org.infoglue.cms.entities.structure.SiteNodeVO; 35 import org.infoglue.cms.entities.structure.SiteNodeVersion; 36 import org.infoglue.cms.entities.structure.SiteNodeVersionVO; 37 import org.infoglue.cms.exception.Bug; 38 import org.infoglue.cms.exception.ConstraintException; 39 import org.infoglue.cms.exception.SystemException; 40 import org.infoglue.cms.security.InfoGluePrincipal; 41 42 43 46 47 public class SiteNodeVersionControllerProxy extends SiteNodeVersionController 48 { 49 private final static Logger logger = Logger.getLogger(SiteNodeVersionControllerProxy.class.getName()); 50 51 protected static final Integer NO = new Integer (0); 52 protected static final Integer YES = new Integer (1); 53 protected static final Integer INHERITED = new Integer (2); 54 55 private static List interceptors = new ArrayList (); 56 57 public static SiteNodeVersionControllerProxy getSiteNodeVersionControllerProxy() 58 { 59 return new SiteNodeVersionControllerProxy(); 60 } 61 62 63 private List getInterceptors(Integer interceptorPointId) throws SystemException, Bug 64 { 65 interceptors = InterceptionPointController.getController().getInterceptorsVOList(interceptorPointId); 67 68 return interceptors; 69 } 70 71 97 123 124 127 128 public SiteNodeVersionVO getACLatestActiveSiteNodeVersionVO(InfoGluePrincipal infogluePrincipal, Integer siteNodeId, Database db) throws ConstraintException, SystemException, Bug, Exception 129 { 130 SiteNodeVersionVO siteNodeVersionVO = getLatestActiveSiteNodeVersionVO(db, siteNodeId); 131 132 if(siteNodeVersionVO != null) 133 { 134 Map hashMap = new HashMap (); 135 hashMap.put("siteNodeVersionId", siteNodeVersionVO.getId()); 136 137 intercept(hashMap, "SiteNodeVersion.Read", infogluePrincipal, db); 138 } 139 140 return getLatestActiveSiteNodeVersionVO(db, siteNodeId); 141 } 142 143 144 147 148 public SiteNodeVersionVO getACLatestActiveSiteNodeVersionVO(InfoGluePrincipal infogluePrincipal, Integer siteNodeId) throws ConstraintException, SystemException, Bug, Exception 149 { 150 SiteNodeVersionVO siteNodeVersionVO = getLatestActiveSiteNodeVersionVO(siteNodeId); 151 152 Map hashMap = new HashMap (); 153 hashMap.put("siteNodeVersionId", siteNodeVersionVO.getId()); 154 155 intercept(hashMap, "SiteNodeVersion.Read", infogluePrincipal); 156 157 return getLatestActiveSiteNodeVersionVO(siteNodeId); 158 } 159 160 161 164 175 176 179 180 public SiteNodeVersionVO acUpdate(InfoGluePrincipal infogluePrincipal, SiteNodeVersionVO siteNodeVersionVO) throws ConstraintException, SystemException, Bug, Exception 181 { 182 Map hashMap = new HashMap (); 183 hashMap.put("siteNodeVersionId", siteNodeVersionVO.getId()); 184 185 intercept(hashMap, "SiteNodeVersion.Write", infogluePrincipal); 186 187 return update(siteNodeVersionVO); 188 } 189 190 193 194 public SiteNodeVersionVO acUpdate(InfoGluePrincipal infogluePrincipal, SiteNodeVersionVO siteNodeVersionVO, Database db) throws ConstraintException, SystemException, Bug, Exception 195 { 196 Map hashMap = new HashMap (); 197 hashMap.put("siteNodeVersionId", siteNodeVersionVO.getId()); 198 199 intercept(hashMap, "SiteNodeVersion.Write", infogluePrincipal, db); 200 201 return update(siteNodeVersionVO, db); 202 } 203 204 207 218 219 222 238 239 242 243 public Integer getProtectedSiteNodeVersionId(Integer siteNodeVersionId) 244 { 245 logger.info("siteNodeVersionId:" + siteNodeVersionId); 246 Integer protectedSiteNodeVersionId = null; 247 248 try 249 { 250 SiteNodeVersionVO siteNodeVersionVO = getSiteNodeVersionVOWithId(siteNodeVersionId); 251 logger.info("Is Protected: " + siteNodeVersionVO.getIsProtected()); 252 if(siteNodeVersionVO != null) 253 { 254 if(siteNodeVersionVO.getIsProtected() != null) 255 { 256 if(siteNodeVersionVO.getIsProtected().intValue() == NO.intValue()) 257 protectedSiteNodeVersionId = null; 258 else if(siteNodeVersionVO.getIsProtected().intValue() == YES.intValue()) 259 protectedSiteNodeVersionId = siteNodeVersionVO.getId(); 260 else if(siteNodeVersionVO.getIsProtected().intValue() == INHERITED.intValue()) 261 { 262 SiteNodeVO parentSiteNodeVO = SiteNodeController.getParentSiteNode(siteNodeVersionVO.getSiteNodeId()); 263 if(parentSiteNodeVO != null) 264 { 265 siteNodeVersionVO = getLatestSiteNodeVersionVO(parentSiteNodeVO.getSiteNodeId()); 266 protectedSiteNodeVersionId = getProtectedSiteNodeVersionId(siteNodeVersionVO.getSiteNodeVersionId()); 267 } 268 } 269 } 270 } 271 } 272 catch(Exception e) 273 { 274 logger.warn("An error occurred trying to get if the siteNodeVersion is protected:" + e.getMessage(), e); 275 } 276 277 return protectedSiteNodeVersionId; 278 } 279 280 283 284 public Integer getProtectedSiteNodeVersionId(Integer siteNodeVersionId, Database db) 285 { 286 logger.info("siteNodeVersionId:" + siteNodeVersionId); 287 Integer protectedSiteNodeVersionId = null; 288 289 try 290 { 291 SiteNodeVersion siteNodeVersion = getSiteNodeVersionWithId(siteNodeVersionId, db); 292 logger.info("Is Protected: " + siteNodeVersion.getIsProtected()); 293 if(siteNodeVersion != null) 294 { 295 if(siteNodeVersion.getIsProtected() != null) 296 { 297 if(siteNodeVersion.getIsProtected().intValue() == NO.intValue()) 298 protectedSiteNodeVersionId = null; 299 else if(siteNodeVersion.getIsProtected().intValue() == YES.intValue()) 300 protectedSiteNodeVersionId = siteNodeVersion.getId(); 301 else if(siteNodeVersion.getIsProtected().intValue() == INHERITED.intValue()) 302 { 303 SiteNode parentSiteNode = siteNodeVersion.getOwningSiteNode().getParentSiteNode(); 304 if(parentSiteNode != null) 305 { 306 siteNodeVersion = getLatestSiteNodeVersion(db, parentSiteNode.getSiteNodeId(), false); 307 protectedSiteNodeVersionId = getProtectedSiteNodeVersionId(siteNodeVersion.getSiteNodeVersionId(), db); 308 } 309 } 310 } 311 } 312 } 313 catch(Exception e) 314 { 315 logger.warn("An error occurred trying to get if the siteNodeVersion is protected:" + e.getMessage(), e); 316 } 317 318 return protectedSiteNodeVersionId; 319 } 320 321 324 325 public boolean getIsSiteNodeVersionProtected(Integer siteNodeVersionId) 326 { 327 logger.info("siteNodeVersionId:" + siteNodeVersionId); 328 boolean isSiteNodeVersionProtected = false; 329 330 try 331 { 332 SiteNodeVersionVO siteNodeVersionVO = getSiteNodeVersionVOWithId(siteNodeVersionId); 333 logger.info("Is Protected: " + siteNodeVersionVO.getIsProtected()); 334 if(siteNodeVersionVO != null) 335 { 336 if(siteNodeVersionVO.getIsProtected() != null) 337 { 338 if(siteNodeVersionVO.getIsProtected().intValue() == NO.intValue()) 339 isSiteNodeVersionProtected = false; 340 else if(siteNodeVersionVO.getIsProtected().intValue() == YES.intValue()) 341 isSiteNodeVersionProtected = true; 342 else if(siteNodeVersionVO.getIsProtected().intValue() == INHERITED.intValue()) 343 { 344 SiteNodeVO parentSiteNodeVO = SiteNodeController.getParentSiteNode(siteNodeVersionVO.getSiteNodeId()); 345 if(parentSiteNodeVO != null) 346 { 347 siteNodeVersionVO = getLatestSiteNodeVersionVO(parentSiteNodeVO.getSiteNodeId()); 348 isSiteNodeVersionProtected = getIsSiteNodeVersionProtected(siteNodeVersionVO.getSiteNodeVersionId()); 349 } 350 } 351 } 352 } 353 } 354 catch(Exception e) 355 { 356 logger.warn("An error occurred trying to get if the siteNodeVersion is protected:" + e.getMessage(), e); 357 } 358 359 return isSiteNodeVersionProtected; 360 } 361 362 365 366 public boolean getIsSiteNodeVersionProtected(Integer siteNodeVersionId, Database db) 367 { 368 logger.info("siteNodeVersionId:" + siteNodeVersionId); 369 boolean isSiteNodeVersionProtected = false; 370 371 try 372 { 373 SiteNodeVersion siteNodeVersion = getSiteNodeVersionWithId(siteNodeVersionId, db); 374 logger.info("Is Protected: " + siteNodeVersion.getIsProtected()); 375 if(siteNodeVersion != null) 376 { 377 if(siteNodeVersion.getIsProtected() != null) 378 { 379 if(siteNodeVersion.getIsProtected().intValue() == NO.intValue()) 380 isSiteNodeVersionProtected = false; 381 else if(siteNodeVersion.getIsProtected().intValue() == YES.intValue()) 382 isSiteNodeVersionProtected = true; 383 else if(siteNodeVersion.getIsProtected().intValue() == INHERITED.intValue()) 384 { 385 SiteNode parentSiteNode = SiteNodeController.getParentSiteNode(siteNodeVersion.getValueObject().getSiteNodeId(), db); 386 if(parentSiteNode != null) 387 { 388 siteNodeVersion = getLatestSiteNodeVersion(db, parentSiteNode.getSiteNodeId(), false); 389 isSiteNodeVersionProtected = getIsSiteNodeVersionProtected(siteNodeVersion.getSiteNodeVersionId(), db); 390 } 391 } 392 } 393 } 394 } 395 catch(Exception e) 396 { 397 logger.warn("An error occurred trying to get if the siteNodeVersion is protected:" + e.getMessage(), e); 398 } 399 400 return isSiteNodeVersionProtected; 401 } 402 403 } 404 | Popular Tags |