From: remillet Date: Wed, 24 Jan 2018 20:52:04 +0000 (-0800) Subject: DRYD-235: Added showRoles query param to /accounts/${csid} endpoint. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=9e98efc7dd7f989bd4042612eee5bd6c75d56cc1;p=tmp%2Fjakarta-migration.git DRYD-235: Added showRoles query param to /accounts/${csid} endpoint. --- diff --git a/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java b/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java index aa0aa2793..6f9f6d9c0 100644 --- a/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java +++ b/services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java @@ -48,6 +48,7 @@ public class AccountClient extends AbstractServiceClientImpl wrapDoc) - throws Exception { - return wrapDoc.getWrappedObject(); - } + @SuppressWarnings("unchecked") + @Override + public AccountsCommon extractCommonPart(DocumentWrapper wrapDoc) throws Exception { + AccountsCommon account = wrapDoc.getWrappedObject(); + + String includeRolesQueryParamValue = (String) getServiceContext().getQueryParams().getFirst(AccountClient.INCLUDE_ROLES_QP); + boolean includeRoles = Tools.isTrue(includeRolesQueryParamValue); + if (includeRoles) { + AccountRoleSubResource accountRoleResource = new AccountRoleSubResource( + AccountRoleSubResource.ACCOUNT_ACCOUNTROLE_SERVICE); + AccountRole accountRole = accountRoleResource.getAccountRole(getServiceContext(), account.getCsid(), + SubjectType.ROLE); + account.setRole(AccountRoleFactory.convert(accountRole.getRole())); + } + + return wrapDoc.getWrappedObject(); + } @Override public void fillCommonPart(AccountsCommon obj, DocumentWrapper wrapDoc)