use of com.zimbra.soap.admin.message.GetAdminConsoleUICompRequest in project zm-mailbox by Zimbra.
the class GetAdminConsoleUIComp method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
GetAdminConsoleUICompRequest req = zsc.elementToJaxb(request);
AccountSelector accountSel = req.getAccount();
DistributionListSelector dlSel = req.getDl();
Element resp = zsc.createElement(AdminConstants.GET_ADMIN_CONSOLE_UI_COMP_RESPONSE);
if ((null != accountSel) && (null != dlSel)) {
throw ServiceException.INVALID_REQUEST("can only specify eith account or dl", null);
}
Account authedAcct = getAuthenticatedAccount(zsc);
Set<String> added = new HashSet<String>();
GroupMembership aclGroups = null;
if (accountSel != null) {
AccountBy by = accountSel.getBy().toKeyAccountBy();
String key = accountSel.getKey();
Account acct = prov.get(by, key);
AccountHarvestingCheckerUsingCheckRight checker = new AccountHarvestingCheckerUsingCheckRight(zsc, context, Admin.R_viewAccountAdminUI);
if (acct == null) {
defendAgainstAccountHarvestingWhenAbsent(by, key, zsc, checker);
} else {
if (!authedAcct.getId().equals(acct.getId())) {
defendAgainstAccountHarvesting(acct, by, key, zsc, checker);
}
addValues(acct, resp, added, false);
aclGroups = prov.getGroupMembership(acct, true);
}
} else if (dlSel != null) {
Key.DistributionListBy by = dlSel.getBy().toKeyDistributionListBy();
String key = dlSel.getKey();
DistributionList dl = prov.getDLBasic(by, key);
GroupHarvestingCheckerUsingCheckRight checker = new GroupHarvestingCheckerUsingCheckRight(zsc, context, Admin.R_viewDistributionListAdminUI);
if (dl == null) {
defendAgainstGroupHarvestingWhenAbsent(by, key, zsc, checker);
} else {
defendAgainstGroupHarvesting(dl, by, key, zsc, checker);
addValues(dl, resp, added, false);
aclGroups = prov.getGroupMembership(dl, true);
}
} else {
// use the authed account
addValues(authedAcct, resp, added, false);
aclGroups = prov.getGroupMembership(authedAcct, true);
}
if (aclGroups != null) {
for (String groupId : aclGroups.groupIds()) {
DistributionList dl = prov.get(Key.DistributionListBy.id, groupId);
addValues(dl, resp, added, true);
}
}
return resp;
}
Aggregations