use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class GalSearchControl method generateLocalResourceSearchQuery.
private boolean generateLocalResourceSearchQuery(Account galAcct) throws ServiceException {
String query = mParams.getQuery();
StringBuilder searchQuery = new StringBuilder();
if (!Strings.isNullOrEmpty(query)) {
searchQuery.append("contact:\"");
// escape quotes
searchQuery.append(query.replace("\"", "\\\""));
searchQuery.append("\" AND");
}
searchQuery.append(" #zimbraAccountCalendarUserType:RESOURCE");
for (DataSource ds : galAcct.getAllDataSources()) {
if (ds.getType() != DataSourceType.gal)
continue;
String galType = ds.getAttr(Provisioning.A_zimbraGalType);
if (galType.compareTo("ldap") == 0)
continue;
searchQuery.append(" AND (");
searchQuery.append(" inid:").append(ds.getFolderId());
searchQuery.append(")");
ZimbraLog.gal.debug("query: " + searchQuery.toString());
mParams.parseSearchParams(mParams.getRequest(), searchQuery.toString());
return true;
}
return false;
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class GalSearchControl method generateSearchQuery.
private void generateSearchQuery(Account galAcct) throws ServiceException {
String query = mParams.getQuery();
String searchByDn = mParams.getSearchEntryByDn();
GalSearchType type = mParams.getType();
StringBuilder searchQuery = new StringBuilder();
if (searchByDn != null) {
searchQuery.append("#dn:(" + searchByDn + ")");
} else if (!Strings.isNullOrEmpty(query)) {
searchQuery.append("contact:\"");
// escape quotes
searchQuery.append(query.replace("\"", "\\\""));
searchQuery.append("\" AND");
}
GalSearchQueryCallback queryCallback = mParams.getExtraQueryCallback();
if (queryCallback != null) {
String extraQuery = queryCallback.getMailboxSearchQuery();
if (extraQuery != null) {
ZimbraLog.gal.debug("extra search query: " + extraQuery);
searchQuery.append(" (").append(extraQuery).append(") AND");
}
}
GalMode galMode = mParams.getDomain().getGalMode();
boolean first = true;
for (DataSource ds : galAcct.getAllDataSources()) {
if (ds.getType() != DataSourceType.gal)
continue;
String galType = ds.getAttr(Provisioning.A_zimbraGalType);
if (galMode == GalMode.ldap && galType.compareTo("zimbra") == 0)
continue;
if (galMode == GalMode.zimbra && galType.compareTo("ldap") == 0)
continue;
if (first)
searchQuery.append("(");
else
searchQuery.append(" OR");
first = false;
searchQuery.append(" inid:").append(ds.getFolderId());
}
if (!first)
searchQuery.append(")");
switch(type) {
case resource:
searchQuery.append(" AND #zimbraAccountCalendarUserType:RESOURCE");
break;
case group:
searchQuery.append(" AND #type:group");
break;
case account:
searchQuery.append(" AND !(#zimbraAccountCalendarUserType:RESOURCE)");
break;
case all:
break;
}
ZimbraLog.gal.debug("query: %s", searchQuery);
mParams.parseSearchParams(mParams.getRequest(), searchQuery.toString());
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class GalImport method searchGal.
private void searchGal(String syncToken, SearchGalResult result, boolean fetchGroupMembers) throws ServiceException {
ZimbraLog.gal.debug("searchGal: " + syncToken);
DataSource ds = getDataSource();
GalSearchParams params = new GalSearchParams(ds);
params.setGalResult(result);
params.setToken(syncToken);
params.setQuery("*");
for (String attr : ZIMBRA_ATTRS) params.getConfig().getRules().add(attr + "=" + attr);
params.getConfig().getRules().setFetchGroupMembers(fetchGroupMembers);
params.getConfig().getRules().setNeedSMIMECerts(true);
Provisioning.getInstance().searchGal(params);
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class DataSourceCallback method scheduleAccount.
private void scheduleAccount(Account account) throws ServiceException {
ZimbraLog.datasource.info("Updating schedule for all DataSources for account %s.", account.getName());
List<DataSource> dataSources = Provisioning.getInstance().getAllDataSources(account);
for (DataSource ds : dataSources) {
DataSourceManager.updateSchedule(account, ds);
}
}
use of com.zimbra.cs.account.DataSource in project zm-mailbox by Zimbra.
the class CreateDataSource method handle.
public Element handle(Element request, Map<String, Object> context) throws ServiceException, SoapFaultException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
String id = request.getAttribute(AdminConstants.E_ID);
Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
if (account == null)
throw AccountServiceException.NO_SUCH_ACCOUNT(id);
checkAdminLoginAsRight(zsc, prov, account);
Element dsEl = request.getElement(AccountConstants.E_DATA_SOURCE);
Map<String, Object> attrs = AdminService.getAttrs(dsEl);
DataSourceType type = DataSourceType.fromString(dsEl.getAttribute(AccountConstants.A_TYPE));
// Note: isDomainAdminOnly *always* returns false for pure ACL based AccessManager
if (isDomainAdminOnly(zsc)) {
// yuck, can't really integrate into AdminDocumentHandler methods cleanly
// have to check separately here
AttributeClass klass = ModifyDataSource.getAttributeClassFromType(type);
checkModifyAttrs(zsc, klass, attrs);
}
String name = dsEl.getAttribute(AccountConstants.A_NAME);
DataSource ds = Provisioning.getInstance().createDataSource(account, type, name, attrs);
Element response = zsc.createElement(AdminConstants.CREATE_DATA_SOURCE_RESPONSE);
com.zimbra.cs.service.account.ToXML.encodeDataSource(response, ds);
return response;
}
Aggregations