use of com.iplanet.ums.SearchTemplate in project OpenAM by OpenRock.
the class SearchFilterManager method getSearchFilterFromTemplate.
static String getSearchFilterFromTemplate(int objectType, String orgDN, String searchTemplateName) {
SearchTemplate searchTemp = null;
String filter;
try {
String searchTempName = ((searchTemplateName == null) ? getSearchTemplateName(objectType) : searchTemplateName);
if (searchTempName == null) {
debug.warning("SearchFilterManager." + "getSearchFilterFromTemplate(): Search template name" + " is null. Unable to retrieve search filter. " + "Returning <empty> value.");
return "";
}
TemplateManager mgr = TemplateManager.getTemplateManager();
Guid orgGuid = ((orgDN == null) ? null : new Guid(orgDN));
searchTemp = mgr.getSearchTemplate(searchTempName, orgGuid, TemplateManager.SCOPE_TOP);
// Get the Original search filter
// Check to see if the filter starts with "(" and ends with ")"
// In which case there is no need to add opening and closing braces.
// otherwise add the opening and closing braces.
} catch (UMSException ue) {
if (debug.messageEnabled()) {
debug.message("SearchFilterManager." + "getSearchFilterFrom" + "Template() Got Exception", ue);
}
}
if (searchTemp != null) {
filter = searchTemp.getSearchFilter();
} else {
// FIXME: Why do we need to make it objectclass=*, can't we send the
// default filter here?
filter = "(objectclass=*)";
}
if (!filter.startsWith("(") || !filter.endsWith(")")) {
filter = "(" + filter + ")";
}
if (debug.messageEnabled()) {
if (searchTemp != null) {
debug.message("SearchFilterManager." + "getSearchFilterFrom" + "Template() SearchTemplate Name = " + searchTemp.getName() + ", objectType = " + objectType + ", orgDN = " + orgDN + ", Obtained Filter = " + searchTemp.getSearchFilter() + ", Modified Filter = " + filter);
} else {
debug.message("SearchFilterManager." + "getSearchFilterFrom" + "Template() Filter = " + filter);
}
}
return filter;
}
Aggregations