Skip to content

Commit

Permalink
ZCS-4856 update AccountInfo Model and the AccountRepository with Lice…
Browse files Browse the repository at this point in the history
…nseInfo details
  • Loading branch information
naijenn committed Sep 28, 2018
1 parent 29edec2 commit 8815304
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 17 deletions.
17 changes: 17 additions & 0 deletions src/java/com/zimbra/graphql/models/outputs/AccountInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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.
*/
Expand All @@ -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());
}

Expand All @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 8815304

Please sign in to comment.