Exemplo n.º 1
0
 private void validatePersist(final Authorization authorization) throws RequiredException {
   this.serviceValidator.validateRequired("authorization", authorization);
   this.serviceValidator.validateRequired(
       "authorization.permission", authorization.getPermission());
   this.serviceValidator.validateRequired("authorization.role", authorization.getRole());
   this.serviceValidator.validateRequired(
       "authorization.permission.operation", authorization.getPermission().getOperation());
   this.serviceValidator.validateRequired(
       "authorization.permission.resource", authorization.getPermission().getResource());
   this.serviceValidator.validateRequired(
       "authorization.role.id", authorization.getRole().getId());
   this.serviceValidator.validateRequired(
       "authorization.permission.operation.id",
       authorization.getPermission().getOperation().getId());
   this.serviceValidator.validateRequired(
       "authorization.permission.resource.id",
       authorization.getPermission().getResource().getId());
 }
Exemplo n.º 2
0
  @Transactional(TransactionPropagationType.REQUIRED)
  public void delete(final Authorization authorization) throws RequiredException {
    this.validateDelete(authorization);

    final Authorization authz = this.load(authorization.getPermission(), authorization.getRole());

    if (authz != null) {
      this.authorizationManager.delete(authorization);
    }
  }
Exemplo n.º 3
0
  @Transactional(TransactionPropagationType.REQUIRED)
  public void insert(final Authorization authorization) throws RequiredException {
    this.validatePersist(authorization);

    final Authorization authz = this.load(authorization.getPermission(), authorization.getRole());

    if (authz == null) {
      this.authorizationManager.insert(authorization);

    } else if (authz.isAllowed() != authorization.isAllowed()) {
      this.authorizationManager.update(authorization);
    }
  }