From 15b06f7aaffe803dbe13fb77bcca900b4f4997aa Mon Sep 17 00:00:00 2001 From: Christofer MacDonald Date: Thu, 27 Sep 2018 21:31:05 -0400 Subject: [PATCH 1/2] ZCS-4856 update AccountInfo Model and the AccountRepository with LicenseInfo details --- .../graphql/models/outputs/AccountInfo.java | 17 ++++++ .../impl/ZXMLAccountRepository.java | 52 +++++++++++++------ 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java b/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java index 25e500a..bc47d38 100644 --- a/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java +++ b/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java @@ -22,6 +22,7 @@ import com.google.common.collect.Lists; import com.zimbra.common.gql.GqlConstants; import com.zimbra.soap.type.NamedValue; +import com.zimbra.soap.account.type.LicenseInfo; import io.leangen.graphql.annotations.GraphQLNonNull; import io.leangen.graphql.annotations.GraphQLQuery; @@ -47,6 +48,8 @@ public class AccountInfo { private String adminURL; @GraphQLQuery(name=GqlConstants.BOSH_URL, description="bosh url") private String boshURL; + @GraphQLQuery(name=GqlConstants.LICENSE, description="License details") + private LicenseInfo License; /* * default constructor @@ -176,5 +179,19 @@ public String getBoshURL() { public void setBoshURL(String boshURL) { this.boshURL = boshURL; } + + /** + * @return the boshURL + */ + public LicenseInfo getLicense() { + return License; + } + + /** + * @param boshURL the boshURL to set + */ + public void setLicense(LicenseInfo License) { + this.License = License; + } } diff --git a/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java b/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java index 5dcbf2b..81a28e0 100644 --- a/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java +++ b/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java @@ -23,6 +23,7 @@ import com.zimbra.common.soap.Element; import com.zimbra.cs.service.account.EndSession; import com.zimbra.cs.service.account.GetAccountInfo; +import com.zimbra.cs.service.account.GetInfo; import com.zimbra.cs.service.account.GetPrefs; import com.zimbra.cs.service.account.ModifyPrefs; import com.zimbra.graphql.models.RequestContext; @@ -35,6 +36,8 @@ import com.zimbra.soap.account.message.EndSessionRequest; import com.zimbra.soap.account.message.GetAccountInfoRequest; import com.zimbra.soap.account.message.GetAccountInfoResponse; +import com.zimbra.soap.account.message.GetInfoRequest; +import com.zimbra.soap.account.message.GetInfoResponse; import com.zimbra.soap.account.message.GetPrefsRequest; import com.zimbra.soap.account.message.GetPrefsResponse; import com.zimbra.soap.account.message.ModifyPrefsRequest; @@ -53,10 +56,15 @@ public class ZXMLAccountRepository extends ZXMLRepository implements IRepository { /** - * The getAccountInfo document handler. + * The getInfo document handler. */ protected final GetAccountInfo accountInfoHandler; + /** + * The getAccountInfo document handler. + */ + protected final GetInfo detailInfoHandler; + /** * The endSession document handler. */ @@ -76,7 +84,7 @@ public class ZXMLAccountRepository extends ZXMLRepository implements IRepository * Creates an instance with default document handlers. */ public ZXMLAccountRepository() { - this(new GetAccountInfo(), new EndSession(), + this(new GetInfo(), new GetAccountInfo(), new EndSession(), new GetPrefs(), new ModifyPrefs()); } @@ -88,9 +96,10 @@ public ZXMLAccountRepository() { * @param prefsHandler The prefs handler * @param modifyPrefsHandler The pref mutation handler */ - public ZXMLAccountRepository(GetAccountInfo accountInfoHandler, EndSession endSessionHandler, + public ZXMLAccountRepository(GetInfo detailInfoHandler, GetAccountInfo accountInfoHandler, EndSession endSessionHandler, GetPrefs prefsHandler, ModifyPrefs modifyPrefsHandler) { super(); + this.detailInfoHandler = detailInfoHandler; this.accountInfoHandler = accountInfoHandler; this.endSessionHandler = endSessionHandler; this.prefsHandler = prefsHandler; @@ -107,24 +116,33 @@ public ZXMLAccountRepository(GetAccountInfo accountInfoHandler, EndSession endSe public AccountInfo accountInfoGet(RequestContext rctxt) throws ServiceException{ final ZimbraSoapContext zsc = GQLAuthUtilities.getZimbraSoapContext(rctxt); final AccountInfo info = new AccountInfo(); - final AccountSelector selector = new AccountSelector(AccountBy.id, - zsc.getAuthToken().getAccountId()); - final GetAccountInfoRequest request = new GetAccountInfoRequest(selector); + final AccountSelector selector = new AccountSelector(AccountBy.id, zsc.getAuthToken().getAccountId()); + final GetAccountInfoRequest accountInfoRequest = new GetAccountInfoRequest(selector); + final GetInfoRequest request = new GetInfoRequest(); + final Element accountResponse = XMLDocumentUtilities.executeDocument( + accountInfoHandler, + zsc, + XMLDocumentUtilities.toElement(accountInfoRequest)); final Element response = XMLDocumentUtilities.executeDocument( - accountInfoHandler, + detailInfoHandler, zsc, XMLDocumentUtilities.toElement(request)); - if (response != null) { - final GetAccountInfoResponse resp = XMLDocumentUtilities.fromElement(response, + if (accountResponse != null) { + final GetAccountInfoResponse acctResp = XMLDocumentUtilities.fromElement(accountResponse, GetAccountInfoResponse.class); - info.setName(resp.getName()); - info.setAttrs(resp.getAttrs()); - info.setSoapURL(resp.getSoapURL()); - info.setPublicURL(resp.getPublicURL()); - info.setCommunityURL(resp.getCommunityURL()); - info.setChangePasswordURL(resp.getChangePasswordURL()); - info.setAdminURL(resp.getAdminURL()); - info.setBoshURL(resp.getBoshURL()); + info.setName(acctResp.getName()); + info.setAttrs(acctResp.getAttrs()); + info.setSoapURL(acctResp.getSoapURL()); + info.setPublicURL(acctResp.getPublicURL()); + info.setCommunityURL(acctResp.getCommunityURL()); + info.setChangePasswordURL(acctResp.getChangePasswordURL()); + info.setAdminURL(acctResp.getAdminURL()); + info.setBoshURL(acctResp.getBoshURL()); + } + if (response != null) { + final GetInfoResponse resp = XMLDocumentUtilities.fromElement(response, + GetInfoResponse.class); + info.setLicense(resp.getLicense()); } return info; } From 6d892d5b8666d855160a04d3f4cd712c5a845c00 Mon Sep 17 00:00:00 2001 From: Christofer MacDonald Date: Wed, 3 Oct 2018 13:16:39 -0400 Subject: [PATCH 2/2] ZCS-4856 changed details in docblocks to match variable names --- src/java/com/zimbra/graphql/models/outputs/AccountInfo.java | 4 ++-- .../graphql/repositories/impl/ZXMLAccountRepository.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java b/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java index bc47d38..549992a 100644 --- a/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java +++ b/src/java/com/zimbra/graphql/models/outputs/AccountInfo.java @@ -181,14 +181,14 @@ public void setBoshURL(String boshURL) { } /** - * @return the boshURL + * @return the LicenseInfo */ public LicenseInfo getLicense() { return License; } /** - * @param boshURL the boshURL to set + * @param LicenseInfo the LicenseInfo to set */ public void setLicense(LicenseInfo License) { this.License = License; diff --git a/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java b/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java index 81a28e0..bf88d4b 100644 --- a/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java +++ b/src/java/com/zimbra/graphql/repositories/impl/ZXMLAccountRepository.java @@ -56,12 +56,12 @@ public class ZXMLAccountRepository extends ZXMLRepository implements IRepository { /** - * The getInfo document handler. + * The GetAccountInfo document handler. */ protected final GetAccountInfo accountInfoHandler; /** - * The getAccountInfo document handler. + * The GetInfo document handler. */ protected final GetInfo detailInfoHandler;