@@ -0,0 +1,2518 @@
+package de.terrestris.shogun2.security.aspect;%0A%0Aimport org.apache.log4j.Logger;%0Aimport org.aspectj.lang.JoinPoint;%0Aimport org.aspectj.lang.ProceedingJoinPoint;%0Aimport org.aspectj.lang.annotation.After;%0Aimport org.aspectj.lang.annotation.Around;%0Aimport org.aspectj.lang.annotation.Aspect;%0A%0Aimport de.terrestris.shogun2.model.PersistentObject;%0A%0A/**%0A * Aspect-class to manage ACL entries when SHOGun2-objects are saved, updated or%0A * deleted by the AbstractCrudService.%0A * %0A * @author Nils B%C3%BChner%0A * %0A */%0A@Aspect%0Apublic class AclManagement %7B%0A%0A%09/**%0A%09 * The Logger%0A%09 */%0A%09private static final Logger LOG = Logger.getLogger(AclManagement.class);%0A%0A%09/**%0A%09 * Creates/updates the ACL data when saveOrUpdate (of the%0A%09 * AbstractCrudService) is called.%0A%09 * %0A%09 * @param joinPoint%0A%09 * @throws Throwable%0A%09 */%0A%09@Around(%22execution(* de.terrestris.shogun2.service.AbstractCrudService.saveOrUpdate(..))%22)%0A%09public void manageAclOnSaveOrUpdate(ProceedingJoinPoint joinPoint)%0A%09%09%09throws Throwable %7B%0A%09%09LOG.debug(%22manageAclWhenSaveOrUpdate is running%22);%0A%0A%09%09// get argument (= object) of saveOrUpdate-call%0A%09%09PersistentObject objectToPersist = (PersistentObject) joinPoint%0A%09%09%09%09.getArgs()%5B0%5D;%0A%0A%09%09// decide whether the object will be created or updated...%0A%09%09boolean objectIsUpdated = objectToPersist.getId() != null;%0A%0A%09%09// actually call the intercepted method%0A%09%09PersistentObject persistedObject = (PersistentObject) joinPoint%0A%09%09%09%09.proceed();%0A%0A%09%09LOG.debug(%22saveOrUpdate returned: %22 + persistedObject);%0A%0A%09%09// handle ACL entries if object has been persisted%0A%09%09if (objectIsUpdated) %7B%0A%09%09%09// TODO delegate the object to some kind of ACL processor that will%0A%09%09%09// update existing ACL entries correctly (according to the type of%0A%09%09%09// the object).%0A%09%09%7D else %7B%0A%09%09%09// TODO delegate the object to some kind of ACL processor that will%0A%09%09%09// create correct ACL entries correctly (according to the type of%0A%09%09%09// the object).%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Removes the ACL data after AbstractCrudService.delete has been called.%0A%09 * %0A%09 * @param joinPoint%0A%09 */%0A%09@After(%22execution(* de.terrestris.shogun2.service.AbstractCrudService.delete(..))%22)%0A%09public void manageAclAfterDelete(JoinPoint joinPoint) %7B%0A%09%09LOG.debug(%22manageAclAfterDelete is running%22);%0A%0A%09%09// get argument (= object) of delete-call%0A%09%09PersistentObject deletedObject = (PersistentObject) joinPoint.getArgs()%5B0%5D;%0A%0A%09%09// TODO delegate the object to some kind of ACL processor that will%0A%09%09// delete existing ACL entries correctly (according to the type of the%0A%09%09// object).%0A%0A%09%09LOG.debug(%22Deleted %22 + deletedObject);%0A%09%7D%0A%0A%7D%0A

Add AclManagement aspect class.