use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class SoapProvisioning method getAllDataSources.
@Override
public List<DataSource> getAllDataSources(Account account) throws ServiceException {
List<DataSource> result = new ArrayList<DataSource>();
XMLElement req = new XMLElement(AdminConstants.GET_DATA_SOURCES_REQUEST);
req.addElement(AdminConstants.E_ID).setText(account.getId());
Element resp = invoke(req);
for (Element dataSource : resp.listElements(AccountConstants.E_DATA_SOURCE)) {
result.add(new SoapDataSource(account, dataSource, this));
}
return result;
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class SoapProvisioning method deleteDataSource.
@Override
public void deleteDataSource(Account account, String dataSourceId) throws ServiceException {
XMLElement req = new XMLElement(AdminConstants.DELETE_DATA_SOURCE_REQUEST);
req.addElement(AdminConstants.E_ID).setText(account.getId());
Element ds = req.addElement(AccountConstants.E_DATA_SOURCE);
ds.addAttribute(AccountConstants.A_ID, dataSourceId);
invoke(req);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class SoapProvisioning method addAttrElements.
public static void addAttrElements(Element req, Map<String, ? extends Object> attrs) throws ServiceException {
if (attrs == null)
return;
for (Entry<String, ? extends Object> entry : attrs.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof String) {
Element a = req.addElement(AdminConstants.E_A);
a.addAttribute(AdminConstants.A_N, key);
a.setText((String) value);
} else if (value instanceof String[]) {
String[] values = (String[]) value;
if (values.length == 0) {
// an empty array == removing the attr
Element a = req.addElement(AdminConstants.E_A);
a.addAttribute(AdminConstants.A_N, key);
} else {
for (String v : values) {
Element a = req.addElement(AdminConstants.E_A);
a.addAttribute(AdminConstants.A_N, key);
a.setText(v);
}
}
} else if (value == null) {
Element a = req.addElement(AdminConstants.E_A);
a.addAttribute(AdminConstants.A_N, key);
} else {
throw ZClientException.CLIENT_ERROR("invalid attr type: " + key + " " + value.getClass().getName(), null);
}
}
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class SoapServer method reload.
public void reload(SoapProvisioning prov) throws ServiceException {
XMLElement req = new XMLElement(AdminConstants.GET_SERVER_REQUEST);
Element a = req.addElement(AdminConstants.E_SERVER);
a.setText(getId());
a.addAttribute(AdminConstants.A_BY, Key.ServerBy.id.name());
setAttrs(SoapProvisioning.getAttrs(prov.invoke(req).getElement(AdminConstants.E_SERVER)));
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class SoapProvisioning method autoCompleteGal.
@Override
public SearchGalResult autoCompleteGal(Domain d, String query, GalSearchType type, int limit, GalContact.Visitor visitor) throws ServiceException {
String typeStr = type == null ? GalSearchType.all.name() : type.name();
XMLElement req = new XMLElement(AdminConstants.AUTO_COMPLETE_GAL_REQUEST);
req.addElement(AdminConstants.E_NAME).setText(query);
req.addAttribute(AdminConstants.A_DOMAIN, d.getName());
req.addAttribute(AdminConstants.A_TYPE, typeStr);
req.addAttribute(AdminConstants.A_LIMIT, limit);
Element resp = invoke(req);
SearchGalResult result = SearchGalResult.newSearchGalResult(visitor);
result.setHadMore(resp.getAttributeBool(AdminConstants.A_MORE, false));
result.setTokenizeKey(resp.getAttribute(AccountConstants.A_TOKENIZE_KEY, null));
for (Element e : resp.listElements(AdminConstants.E_CN)) {
result.addMatch(new GalContact(e.getAttribute(AdminConstants.A_ID), getAttrs(e)));
}
return result;
}
Aggregations