Search in sources :

Example 1 with ZimletUserProperties

use of com.zimbra.cs.zimlet.ZimletUserProperties in project zm-mailbox by Zimbra.

the class GetInfo method doProperties.

private static void doProperties(Element response, Account acct) {
    ZimletUserProperties zp = ZimletUserProperties.getProperties(acct);
    Set<? extends Prop> props = zp.getAllProperties();
    for (Prop prop : props) {
        Element elem = response.addElement(AccountConstants.E_PROPERTY);
        elem.addAttribute(AccountConstants.A_ZIMLET, prop.getZimlet());
        elem.addAttribute(AccountConstants.A_NAME, prop.getName());
        elem.setText(prop.getValue());
    }
}
Also used : Prop(com.zimbra.soap.account.type.Prop) Element(com.zimbra.common.soap.Element) ZimletUserProperties(com.zimbra.cs.zimlet.ZimletUserProperties)

Example 2 with ZimletUserProperties

use of com.zimbra.cs.zimlet.ZimletUserProperties in project zm-mailbox by Zimbra.

the class ModifyProperties method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    if (!canModifyOptions(zsc, account)) {
        throw ServiceException.PERM_DENIED("can not modify options");
    }
    ZimletUserProperties props = ZimletUserProperties.getProperties(account);
    int numUserproperties = request.listElements(AccountConstants.E_PROPERTY).size();
    if (numUserproperties > account.getLongAttr(Provisioning.A_zimbraZimletUserPropertiesMaxNumEntries, 150)) {
        throw AccountServiceException.TOO_MANY_ZIMLETUSERPROPERTIES();
    }
    for (Element e : request.listElements(AccountConstants.E_PROPERTY)) {
        props.setProperty(e.getAttribute(AccountConstants.A_ZIMLET), e.getAttribute(AccountConstants.A_NAME), e.getText());
    }
    props.saveProperties(account);
    Element response = zsc.createElement(AccountConstants.MODIFY_PROPERTIES_RESPONSE);
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) ZimletUserProperties(com.zimbra.cs.zimlet.ZimletUserProperties)

Aggregations

Element (com.zimbra.common.soap.Element)2 ZimletUserProperties (com.zimbra.cs.zimlet.ZimletUserProperties)2 Account (com.zimbra.cs.account.Account)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 Prop (com.zimbra.soap.account.type.Prop)1