use of com.zimbra.soap.admin.message.ModifyDataSourceRequest 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 = JaxbUtil.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;
}
Aggregations