@Override public Object renamePrivilege(final String component, final String service, final List<? extends Authorizable> oldAuthorizables, final List<? extends Authorizable> newAuthorizables, final String requestor) throws Exception { Preconditions.checkNotNull(component); Preconditions.checkNotNull(service); Preconditions.checkNotNull(oldAuthorizables); Preconditions.checkNotNull(newAuthorizables); if (oldAuthorizables.size() != newAuthorizables.size()) { throw new SentryAccessDeniedException( "rename privilege denied: the size of oldAuthorizables must equals the newAuthorizables " + "oldAuthorizables:" + Arrays.toString(oldAuthorizables.toArray()) + " " + "newAuthorizables:" + Arrays.toString(newAuthorizables.toArray())); } delegate.getTransactionManager().executeTransactionWithRetry( pm -> { pm.setDetachAllOnCommit(false); // No need to detach objects privilegeOperator.renamePrivilege(toTrimmedLower(component), toTrimmedLower(service), oldAuthorizables, newAuthorizables, requestor, pm); return null; }); return null; }
@Override public CommitContext renamePrivilege(String component, String service, List<? extends Authorizable> oldAuthorizables, List<? extends Authorizable> newAuthorizables, String requestor) throws SentryUserException { Preconditions.checkNotNull(component); Preconditions.checkNotNull(service); Preconditions.checkNotNull(oldAuthorizables); Preconditions.checkNotNull(newAuthorizables); if (oldAuthorizables.size() != newAuthorizables.size()) { throw new SentryAccessDeniedException( "rename privilege denied: the size of oldAuthorizables must equals the newAuthorizables " + "oldAuthorizables:" + Arrays.toString(oldAuthorizables.toArray()) + " " + "newAuthorizables:" + Arrays.toString(newAuthorizables.toArray())); } PersistenceManager pm = null; boolean rollbackTransaction = true; try { pm = openTransaction(); privilegeOperator.renamePrivilege(toTrimmedLower(component), toTrimmedLower(service), oldAuthorizables, newAuthorizables, requestor, pm); CommitContext commitContext = commitUpdateTransaction(pm); rollbackTransaction = false; return commitContext; } finally { if (rollbackTransaction) { rollbackTransaction(pm); } } }