@Override public AccountListResult findChildsRecursively(KapuaId scopeId) throws KapuaException { // // Argument validation ArgumentValidator.notNull(scopeId, "scopeId"); // // Make sure account exists Account account = findById(scopeId); if (account == null) { throw new KapuaEntityNotFoundException(Account.TYPE, scopeId); } // // Check Access authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.read, account.getId())); return entityManagerSession.onResult(em -> { AccountListResult result = null; TypedQuery<Account> q; q = em.createNamedQuery("Account.findChildAccountsRecursive", Account.class); q.setParameter("parentAccountPath", "\\" + account.getParentAccountPath() + "/%"); result = new AccountListResultImpl(); result.addItems(q.getResultList()); return result; }); }
@Override public AccountListResult findChildsRecursively(KapuaId scopeId) throws KapuaException { // // Argument validation ArgumentValidator.notNull(scopeId, "scopeId"); // // Make sure account exists Account account = findById(scopeId); if (account == null) { throw new KapuaEntityNotFoundException(Account.TYPE, scopeId); } // // Check Access authorizationService.checkPermission(permissionFactory.newPermission(AccountDomains.ACCOUNT_DOMAIN, Actions.read, account.getId())); return entityManagerSession.onResult(em -> { AccountListResult result = null; TypedQuery<Account> q; q = em.createNamedQuery("Account.findChildAccountsRecursive", Account.class); q.setParameter("parentAccountPath", "\\" + account.getParentAccountPath() + "/%"); result = new AccountListResultImpl(); result.addItems(q.getResultList()); return result; }); }
String parentAccountPath = account.getParentAccountPath();
String parentAccountPath = account.getParentAccountPath();
throw new KapuaAccountException(KapuaAccountErrorCodes.ILLEGAL_ARGUMENT, null, "account.scopeId"); if (!oldAccount.getParentAccountPath().equals(account.getParentAccountPath())) { throw new KapuaAccountException(KapuaAccountErrorCodes.ILLEGAL_ARGUMENT, null, "account.parentAccountPath");
throw new KapuaAccountException(KapuaAccountErrorCodes.ILLEGAL_ARGUMENT, null, "account.scopeId"); if (!oldAccount.getParentAccountPath().equals(account.getParentAccountPath())) { throw new KapuaAccountException(KapuaAccountErrorCodes.ILLEGAL_ARGUMENT, null, "account.parentAccountPath");
String parentAccountPath = AccountDAO.find(em, null, accountCreator.getScopeId()).getParentAccountPath() + "/" + account.getId(); account.setParentAccountPath(parentAccountPath); return AccountDAO.update(em, account);
String parentAccountPath = AccountDAO.find(em, null, accountCreator.getScopeId()).getParentAccountPath() + "/" + account.getId(); account.setParentAccountPath(parentAccountPath); return AccountDAO.update(em, account);