Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZCS-4586 update AccountInfo Model and the AccountRepository with Lice… #32

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 LicenseInfo
*/
public LicenseInfo getLicense() {
return License;
}

/**
* @param LicenseInfo the LicenseInfo 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 GetAccountInfo document handler.
*/
protected final GetAccountInfo accountInfoHandler;

/**
* The GetInfo 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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for now.

We may consider determining if the communityUrl is requested before doing the entire getAccountInfo request just for that. Or, perhaps adding it to getInfo and deprecating the other since it is seemingly the only thing missing?

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