diff --git a/security/src/main/java/org/genesys/blocks/security/service/CustomAclService.java b/security/src/main/java/org/genesys/blocks/security/service/CustomAclService.java index 276918dab7985d162b92c7c94ebb3d0f77110e09..50ffb7cc2c7d859a7050315c1e9b53cb7a8fb175 100644 --- a/security/src/main/java/org/genesys/blocks/security/service/CustomAclService.java +++ b/security/src/main/java/org/genesys/blocks/security/service/CustomAclService.java @@ -69,6 +69,22 @@ public interface CustomAclService { */ void createOrUpdatePermissions(AclAwareModel entity); + /** + * Updates inheriting status of object identity + * + * @param objectIdIdentity the id of object identity + * @param entriesInheriting the inheriting status + */ + AclObjectIdentity updateInheriting(long objectIdIdentity, boolean entriesInheriting); + + /** + * Updates parent object of object identity + * + * @param objectIdIdentity the id of object identity + * @param parentObjectId the id of parent object identity + */ + AclObjectIdentity updateParentObject(long objectIdIdentity, long parentObjectId); + /** * Removes the permissions on ACL model. * diff --git a/security/src/main/java/org/genesys/blocks/security/service/impl/CustomAclServiceImpl.java b/security/src/main/java/org/genesys/blocks/security/service/impl/CustomAclServiceImpl.java index efcc8839ad5024cd0aedae9554a5ce7fead2ee7e..6768e6fd690ac3074bf77f5a5db332422c93fb98 100644 --- a/security/src/main/java/org/genesys/blocks/security/service/impl/CustomAclServiceImpl.java +++ b/security/src/main/java/org/genesys/blocks/security/service/impl/CustomAclServiceImpl.java @@ -184,6 +184,52 @@ public class CustomAclServiceImpl implements CustomAclService { } } + @Override + @PreAuthorize("hasRole('ADMINISTRATOR')") + public AclObjectIdentity updateInheriting(final long objectIdIdentity, final boolean entriesInheriting) { + final AclObjectIdentity objectIdentity = aclObjectIdentityPersistence.findOne(objectIdIdentity); + if (objectIdentity == null) { + LOG.warn("ACL object identity not found by id={}", objectIdIdentity); + return null; + } + + if (objectIdentity.isEntriesInheriting() == entriesInheriting) { + return objectIdentity; + } else { + try { + LOG.info("Updating inheriting status for OID={} to {}", objectIdentity, entriesInheriting); + objectIdentity.setEntriesInheriting(entriesInheriting); + return aclObjectIdentityPersistence.save(objectIdentity); + } finally { + clearAclCache(); + } + } + } + + @Override + @PreAuthorize("hasRole('ADMINISTRATOR')") + public AclObjectIdentity updateParentObject(final long objectIdIdentity, final long parentObjectId) { + final AclObjectIdentity objectIdentity = aclObjectIdentityPersistence.findOne(objectIdIdentity); + if (objectIdentity == null) { + LOG.warn("ACL object identity not found by id={}", objectIdIdentity); + return null; + } + + final AclObjectIdentity parentObject = aclObjectIdentityPersistence.findOne(parentObjectId); + if (parentObject == null) { + LOG.warn("ACL object identity not found by id={}", objectIdIdentity); + return null; + } + + try { + LOG.trace("Updating ACL parent to {}", parentObject); + objectIdentity.setParentObject(parentObject); + return aclObjectIdentityPersistence.save(objectIdentity); + } finally { + clearAclCache(); + } + } + /** * Remove ACL data for AclAwareModel: deletes {@link AclObjectIdentity} and * associated {@link AclEntry} list. If target happens to be {@link AclSid},