use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class ModifyIdentity method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(zsc);
Identity identity = null;
if (!canModifyOptions(zsc, account))
throw ServiceException.PERM_DENIED("can not modify options");
Provisioning prov = Provisioning.getInstance();
Element eIdentity = request.getElement(AccountConstants.E_IDENTITY);
Map<String, Object> attrs = AccountService.getAttrs(eIdentity, AccountConstants.A_NAME);
// remove anything that doesn't start with zimbraPref. ldap will also do additional checks
for (Iterator<String> it = attrs.keySet().iterator(); it.hasNext(); ) if (// if this changes, make sure we don't let them ever change objectclass
!it.next().toLowerCase().startsWith("zimbrapref"))
it.remove();
String key, id = eIdentity.getAttribute(AccountConstants.A_ID, null);
if (id != null) {
identity = prov.get(account, Key.IdentityBy.id, key = id);
} else {
identity = prov.get(account, Key.IdentityBy.name, key = eIdentity.getAttribute(AccountConstants.A_NAME));
}
if (identity == null) {
String[] childIds = account.getChildAccount();
for (String childId : childIds) {
Account childAccount = prov.get(AccountBy.id, childId, zsc.getAuthToken());
if (childAccount != null) {
Identity childIdentity;
if (id != null) {
childIdentity = prov.get(childAccount, Key.IdentityBy.id, key = id);
} else {
childIdentity = prov.get(childAccount, Key.IdentityBy.name, key = eIdentity.getAttribute(AccountConstants.A_NAME));
}
if (childIdentity != null) {
identity = childIdentity;
account = childAccount;
break;
}
}
}
}
if (identity == null)
throw AccountServiceException.NO_SUCH_IDENTITY(key);
prov.modifyIdentity(account, identity.getName(), attrs);
Element response = zsc.createElement(AccountConstants.MODIFY_IDENTITY_RESPONSE);
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAllLocales method handle.
@Override
public Element handle(Element request, Map<String, Object> context) {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Locale[] locales = WebClientL10nUtil.getAllLocalesSorted();
Element response = zsc.createElement(AccountConstants.GET_ALL_LOCALES_RESPONSE);
for (Locale locale : locales) {
ToXML.encodeLocale(response, locale, Locale.US);
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAvailableLocales method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(zsc);
if (!canAccessAccount(zsc, account)) {
throw ServiceException.PERM_DENIED("can not access account");
}
Locale displayLocale = getDisplayLocale(account, context);
// get installed locales, sorted
Locale[] installedLocales = WebClientL10nUtil.getLocales(displayLocale);
// get avail locales for this account/COS
Set<String> allowedLocales = account.getMultiAttrSet(Provisioning.A_zimbraAvailableLocale);
Locale[] availLocales = null;
if (allowedLocales.size() > 0) {
availLocales = computeAvailLocales(installedLocales, allowedLocales);
} else {
availLocales = installedLocales;
}
Element response = zsc.createElement(AccountConstants.GET_AVAILABLE_LOCALES_RESPONSE);
for (Locale locale : availLocales) {
if (locale != null) {
ToXML.encodeLocale(response, locale, displayLocale);
} else {
break;
}
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetAvailableSkins method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(zsc);
if (!canAccessAccount(zsc, account)) {
throw ServiceException.PERM_DENIED("can not access account");
}
String[] availSkins = SkinUtil.getSkins(account);
Element response = zsc.createElement(AccountConstants.GET_AVAILABLE_SKINS_RESPONSE);
for (String skin : availSkins) {
Element skinElem = response.addElement(AccountConstants.E_SKIN);
skinElem.addAttribute(AccountConstants.A_NAME, skin);
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetDistributionList method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Account acct = getAuthenticatedAccount(zsc);
Element response = zsc.createElement(AccountConstants.GET_DISTRIBUTION_LIST_RESPONSE);
Group group = getGroupBasic(request, prov);
GetDistributionListHandler handler = new GetDistributionListHandler(group, request, response, prov, acct);
handler.handle();
return response;
}
Aggregations