Example usage for org.springframework.security.acls.model AlreadyExistsException AlreadyExistsException

List of usage examples for org.springframework.security.acls.model AlreadyExistsException AlreadyExistsException

Introduction

In this page you can find the example usage for org.springframework.security.acls.model AlreadyExistsException AlreadyExistsException.

Prototype

public AlreadyExistsException(String msg, Throwable t) 

Source Link

Document

Constructs an AlreadyExistsException with the specified message and root cause.

Usage

From source file:eu.europeana.aas.acl.CassandraMutableAclService.java

@Override
public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException {
    Assert.notNull(objectIdentity, "Object Identity required");

    if (LOG.isDebugEnabled()) {
        LOG.debug("BEGIN createAcl: objectIdentity: " + objectIdentity);
    }// www. j  a  va  2 s  . co m

    // Need to retrieve the current principal, in order to know who "owns"
    // this ACL (can be changed later on)
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    PrincipalSid sid = new PrincipalSid(auth);

    AclObjectIdentity newAoi = new AclObjectIdentity(objectIdentity);
    newAoi.setOwnerId(sid.getPrincipal());
    newAoi.setOwnerPrincipal(true);
    newAoi.setEntriesInheriting(false);

    try {
        aclRepository.saveAcl(newAoi);
    } catch (AclAlreadyExistsException e) {
        throw new AlreadyExistsException(e.getMessage(), e);
    }

    // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
    Acl acl = readAclById(objectIdentity);
    Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned");

    if (LOG.isDebugEnabled()) {
        LOG.debug("END createAcl: acl: " + acl);
    }
    return (MutableAcl) acl;
}

From source file:org.springframework.security.acls.cassandra.CassandraMutableAclService.java

public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException {
    Assert.notNull(objectIdentity, "Object Identity required");

    if (LOG.isDebugEnabled()) {
        LOG.debug("BEGIN createAcl: objectIdentity: " + objectIdentity);
    }/*from ww w . ja  va2 s.c  o m*/

    // Need to retrieve the current principal, in order to know who "owns"
    // this ACL (can be changed later on)
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    PrincipalSid sid = new PrincipalSid(auth);

    AclObjectIdentity newAoi = new AclObjectIdentity(objectIdentity);
    newAoi.setOwnerId(sid.getPrincipal());
    newAoi.setOwnerPrincipal(true);
    newAoi.setEntriesInheriting(false);

    try {
        aclRepository.saveAcl(newAoi);
    } catch (AclAlreadyExistsException e) {
        throw new AlreadyExistsException(e.getMessage(), e);
    }

    // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
    Acl acl = readAclById(objectIdentity);
    Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned");

    if (LOG.isDebugEnabled()) {
        LOG.debug("END createAcl: acl: " + acl);
    }
    return (MutableAcl) acl;
}