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; }