Search in sources :

Example 1 with DataSourceInfo

use of com.zimbra.soap.admin.type.DataSourceInfo in project zm-mailbox by Zimbra.

the class ModifyDataSource method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException, SoapFaultException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    ModifyDataSourceRequest req = zsc.elementToJaxb(request);
    String id = req.getId();
    if (null == id) {
        throw ServiceException.INVALID_REQUEST("missing required attribute: " + AdminConstants.E_ID, null);
    }
    Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
    defendAgainstAccountOrCalendarResourceHarvesting(account, AccountBy.id, id, zsc, Admin.R_adminLoginAs, Admin.R_adminLoginCalendarResourceAs);
    DataSourceInfo dataSource = req.getDataSource();
    Map<String, Object> attrs = dataSource.getAttrsAsOldMultimap();
    String dsId = dataSource.getId();
    DataSource ds = prov.get(account, Key.DataSourceBy.id, dsId);
    if (ds == null) {
        throw ServiceException.INVALID_REQUEST("Cannot find data source with id=" + dsId, null);
    }
    DataSourceType type = ds.getType();
    // Note: isDomainAdminOnly *always* returns false for pure ACL based AccessManager
    if (isDomainAdminOnly(zsc)) {
        // yuck, can't really integrate into AdminDocumentHandler methods
        // have to check separately here
        AttributeClass klass = ModifyDataSource.getAttributeClassFromType(type);
        checkModifyAttrs(zsc, klass, attrs);
    }
    ZimbraLog.addDataSourceNameToContext(ds.getName());
    prov.modifyDataSource(account, dsId, attrs);
    Element response = zsc.createElement(AdminConstants.MODIFY_DATA_SOURCE_RESPONSE);
    return response;
}
Also used : DataSourceInfo(com.zimbra.soap.admin.type.DataSourceInfo) Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) DataSourceType(com.zimbra.soap.admin.type.DataSourceType) Element(com.zimbra.common.soap.Element) ModifyDataSourceRequest(com.zimbra.soap.admin.message.ModifyDataSourceRequest) AttributeClass(com.zimbra.cs.account.AttributeClass) Provisioning(com.zimbra.cs.account.Provisioning) DataSource(com.zimbra.cs.account.DataSource)

Aggregations

Element (com.zimbra.common.soap.Element)1 Account (com.zimbra.cs.account.Account)1 AttributeClass (com.zimbra.cs.account.AttributeClass)1 DataSource (com.zimbra.cs.account.DataSource)1 Provisioning (com.zimbra.cs.account.Provisioning)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 ModifyDataSourceRequest (com.zimbra.soap.admin.message.ModifyDataSourceRequest)1 DataSourceInfo (com.zimbra.soap.admin.type.DataSourceInfo)1 DataSourceType (com.zimbra.soap.admin.type.DataSourceType)1