constraints.setDerefLinkFlag(deref_link);
constraints.setCountLimit(count_limit);
if (attrList.length > 0) {
constraints.setReturningAttributes(attrList);
}
NamingEnumeration ldapresults = ctx.search(searchbase, filter, constraints);
if (!doc_element.equals("")) {
transformer.start(doc_element, attr);
}
while (ldapresults != null && ldapresults.hasMore()) {
if (!row_element.equals("")) {
transformer.start(row_element, attr);
}
SearchResult si = (SearchResult)ldapresults.next();
javax.naming.directory.Attributes attrs = si.getAttributes();
if (attrs != null) {
NamingEnumeration ae = attrs.getAll();
while (ae.hasMoreElements()) {
Attribute at = (Attribute)ae.next();
Enumeration vals = at.getAll();
String attrID = at.getID();
if (showAttribute) {
transformer.start(attrID, attr);
}
String attrVal = (String)vals.nextElement();
if (query_index > 0) {
switch (transformer.getQuery(query_index-1).current_state) {
case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT:
if (!transformer.getQuery(query_index-1).filter.equals("")) {
transformer.getQuery(query_index-1).filter.concat(", ");
}
transformer.getQuery(query_index-1).filter.concat(attrID).concat("=").concat(attrVal);
break;
default:
transformer.start(attrID, attr);
}
} else {
transformer.data(String.valueOf(attrVal));
}
if (showAttribute) {
transformer.end(attrID);
}
}
}
if (!row_element.equals("")) {
transformer.end(row_element);
}
}
if (!doc_element.equals("")) {
transformer.end(doc_element);
}
} catch(Exception e) {
if (sax_error) {
throw new Exception ("[LDAPTransformer] Error in LDAP-Query: " + e.toString());
} else {
transformer.start(error_element, attr);
transformer.data("[LDAPTransformer] Error in LDAP-Query: " + e);
transformer.end(error_element);
transformer.getTheLogger().error("[LDAPTransformer] Exception: " + e.toString());
}
}
break;
case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT:
try {
if (scope.equals("OBJECT_SCOPE")) {
constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
} else if (scope.equals("SUBTREE_SCOPE")) {
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
} else {
constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
}
constraints.setTimeLimit(time_limit);
constraints.setDerefLinkFlag(deref_link);
constraints.setCountLimit(count_limit);
if (attrList.length != 1) {
transformer.start(error_element, attr);
transformer.data("Increment must reference exactly 1 attribute.");
transformer.end(error_element);
} else {
constraints.setReturningAttributes(attrList);
NamingEnumeration ldapresults = ctx.search(searchbase, filter, constraints);
int attrVal = 0;
String attrID = "";
SearchResult si = null;
while (ldapresults != null && ldapresults.hasMore()) {
si = (SearchResult)ldapresults.next();
javax.naming.directory.Attributes attrs = si.getAttributes();
if (attrs != null) {
NamingEnumeration ae = attrs.getAll();
while (ae.hasMoreElements()) {
Attribute at = (Attribute)ae.next();
Enumeration vals = at.getAll();
attrID = at.getID();
attrVal = Integer.parseInt((String)vals.nextElement());
}
}