From 9e98efc7dd7f989bd4042612eee5bd6c75d56cc1 Mon Sep 17 00:00:00 2001 From: remillet Date: Wed, 24 Jan 2018 12:52:04 -0800 Subject: [PATCH] DRYD-235: Added showRoles query param to /accounts/${csid} endpoint. --- .../services/client/AccountClient.java | 1 + .../storage/AccountDocumentHandler.java | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) 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) -- 2.47.3