下面列出了javax.naming.directory.SearchControls#OBJECT_SCOPE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected ContextEnumerator(Context context, int scope, String contextName,
boolean returnSelf)
throws NamingException {
if(context == null) {
throw new IllegalArgumentException("null context passed");
}
root = context;
// No need to list children if we're only searching object
if (scope != SearchControls.OBJECT_SCOPE) {
children = getImmediateChildren(context);
}
this.scope = scope;
this.contextName = contextName;
// pretend root is processed, if we're not supposed to return ourself
rootProcessed = !returnSelf;
prepNextChild();
}
protected ContextEnumerator(Context context, int scope, String contextName,
boolean returnSelf)
throws NamingException {
if(context == null) {
throw new IllegalArgumentException("null context passed");
}
root = context;
// No need to list children if we're only searching object
if (scope != SearchControls.OBJECT_SCOPE) {
children = getImmediateChildren(context);
}
this.scope = scope;
this.contextName = contextName;
// pretend root is processed, if we're not supposed to return ourself
rootProcessed = !returnSelf;
prepNextChild();
}
protected ContextEnumerator(Context context, int scope, String contextName,
boolean returnSelf)
throws NamingException {
if(context == null) {
throw new IllegalArgumentException("null context passed");
}
root = context;
// No need to list children if we're only searching object
if (scope != SearchControls.OBJECT_SCOPE) {
children = getImmediateChildren(context);
}
this.scope = scope;
this.contextName = contextName;
// pretend root is processed, if we're not supposed to return ourself
rootProcessed = !returnSelf;
prepNextChild();
}
protected ContextEnumerator(Context context, int scope, String contextName,
boolean returnSelf)
throws NamingException {
if(context == null) {
throw new IllegalArgumentException("null context passed");
}
root = context;
// No need to list children if we're only searching object
if (scope != SearchControls.OBJECT_SCOPE) {
children = getImmediateChildren(context);
}
this.scope = scope;
this.contextName = contextName;
// pretend root is processed, if we're not supposed to return ourself
rootProcessed = !returnSelf;
prepNextChild();
}
protected ContextEnumerator(Context context, int scope, String contextName,
boolean returnSelf)
throws NamingException {
if(context == null) {
throw new IllegalArgumentException("null context passed");
}
root = context;
// No need to list children if we're only searching object
if (scope != SearchControls.OBJECT_SCOPE) {
children = getImmediateChildren(context);
}
this.scope = scope;
this.contextName = contextName;
// pretend root is processed, if we're not supposed to return ourself
rootProcessed = !returnSelf;
prepNextChild();
}
public Binding next() throws NamingException {
if (!rootProcessed) {
rootProcessed = true;
return new Binding("", root.getClass().getName(),
root, true);
}
if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
return getNextDescendant();
}
throw new NoSuchElementException();
}
public Binding next() throws NamingException {
if (!rootProcessed) {
rootProcessed = true;
return new Binding("", root.getClass().getName(),
root, true);
}
if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
return getNextDescendant();
}
throw new NoSuchElementException();
}
public Binding next() throws NamingException {
if (!rootProcessed) {
rootProcessed = true;
return new Binding("", root.getClass().getName(),
root, true);
}
if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
return getNextDescendant();
}
throw new NoSuchElementException();
}
public Binding next() throws NamingException {
if (!rootProcessed) {
rootProcessed = true;
return new Binding("", root.getClass().getName(),
root, true);
}
if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
return getNextDescendant();
}
throw new NoSuchElementException();
}
public Binding next() throws NamingException {
if (!rootProcessed) {
rootProcessed = true;
return new Binding("", root.getClass().getName(),
root, true);
}
if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
return getNextDescendant();
}
throw new NoSuchElementException();
}
public Binding next() throws NamingException {
if (!rootProcessed) {
rootProcessed = true;
return new Binding("", root.getClass().getName(),
root, true);
}
if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
return getNextDescendant();
}
throw new NoSuchElementException();
}
public boolean hasMore() throws NamingException {
return !rootProcessed ||
(scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
@Test
public void testSearchScopeObjectScopeSetInConstructorIsUsed() throws Exception {
DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.OBJECT_SCOPE);
assertThat(tested.getSearchControls().getSearchScope()).as("OBJECT_SCOPE, ").isEqualTo(SearchControls.OBJECT_SCOPE);
}
public boolean hasMore() throws NamingException {
return !rootProcessed ||
(scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
public boolean hasMore() throws NamingException {
return !rootProcessed ||
(scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
public static Node fromXML(TransformationGraph graph, Element nodeXML) throws XMLConfigurationException, AttributeNotFoundException {
ComponentXMLAttributes xattribs = new ComponentXMLAttributes(nodeXML, graph);
LdapReader aLdapReader = null;
int i_scope = SearchControls.OBJECT_SCOPE;
String scope = xattribs.getString(XML_SCOPE_ATTRIBUTE, null);
String sMsg = null;
if (scope == null) {
sMsg = "Missing scope specification";
} else if(scope.equalsIgnoreCase("OBJECT")) {
// i_scope = SearchControls.OBJECT_SCOPE; // default value
} else if(scope.equalsIgnoreCase("ONELEVEL")) {
i_scope = SearchControls.ONELEVEL_SCOPE;
} else if(scope.equalsIgnoreCase("SUBTREE")) {
i_scope = SearchControls.SUBTREE_SCOPE;
} else {
sMsg = "Invalid scope specification \"" + scope + "\"";
}
if (sMsg != null) {
StringBuffer msg = new StringBuffer();
msg.append(sMsg);
msg.append(" in component ").append(xattribs.getString(Node.XML_ID_ATTRIBUTE, "unknown ID"));
msg.append("; defaulting to scope \"OBJECT\"");
logger.warn(msg.toString());
}
if(xattribs.exists(XML_USER_ATTRIBUTE) && xattribs.exists(XML_PASSWORD_ATTRIBUTE) ) {
aLdapReader = new LdapReader(
xattribs.getString(Node.XML_ID_ATTRIBUTE),
xattribs.getStringEx(XML_LDAPURL_ATTRIBUTE, null, RefResFlag.URL),
xattribs.getString(XML_BASE_ATTRIBUTE, null),
xattribs.getString(XML_FILTER_ATTRIBUTE, null),
i_scope,
xattribs.getString(XML_USER_ATTRIBUTE),
xattribs.getStringEx(XML_PASSWORD_ATTRIBUTE, RefResFlag.PASSWORD));
} else {
aLdapReader = new LdapReader(
xattribs.getString(Node.XML_ID_ATTRIBUTE),
xattribs.getStringEx(XML_LDAPURL_ATTRIBUTE, null, RefResFlag.URL),
xattribs.getString(XML_BASE_ATTRIBUTE, null),
xattribs.getString(XML_FILTER_ATTRIBUTE, null),
i_scope);
}
if (xattribs.exists(XML_MULTI_VALUE_SEPARATOR_ATTRIBUTE)) {
aLdapReader.setMultiValueSeparator(xattribs.getString(XML_MULTI_VALUE_SEPARATOR_ATTRIBUTE));
}
if (xattribs.exists(XML_ALIAS_HANDLING_ATTRIBUTE)) {
aLdapReader.setAliasHandling(Enum.valueOf(AliasHandling.class, xattribs.getString(XML_ALIAS_HANDLING_ATTRIBUTE)));
}
if (xattribs.exists(XML_REFERRAL_HANDLING_ATTRIBUTE)) {
aLdapReader.setReferralHandling(Enum.valueOf(ReferralHandling.class, xattribs.getString(XML_REFERRAL_HANDLING_ATTRIBUTE)));
}
if (xattribs.exists(XML_DEFAULT_MAPPING_FIELD)){
aLdapReader.setDefaultMappingField(xattribs.getString(XML_DEFAULT_MAPPING_FIELD));
}
if (xattribs.exists(XML_PAGE_SIZE)){
aLdapReader.setPageSize(xattribs.getInteger(XML_PAGE_SIZE));
}
if (xattribs.exists(XML_ALL_LDAP_ATTRIBUTES)){
aLdapReader.setAllAttributes(xattribs.getBoolean(XML_ALL_LDAP_ATTRIBUTES));
}
if (xattribs.exists(XML_ADDITIONAL_BINARY_ATTRIBUTES)){
aLdapReader.setAdditionalBinaryAttributes(xattribs.getString(XML_ADDITIONAL_BINARY_ATTRIBUTES));
}
if (xattribs.exists(XML_ADDITIONAL_LDAP_ENV)){
aLdapReader.setLdapExtraPropertiesDef(xattribs.getString(XML_ADDITIONAL_LDAP_ENV));
}
return aLdapReader;
}
public boolean hasMore() throws NamingException {
return !rootProcessed ||
(scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
public boolean hasMore() throws NamingException {
return !rootProcessed ||
(scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
public boolean hasMore() throws NamingException {
return !rootProcessed ||
(scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
/**
* Create the default validator, creates {@link SearchControls} with search scope <code>OBJECT_SCOPE</code>,
* a countLimit of 1, returningAttributes of objectclass and timeLimit of 500.
* The default base is an empty string and the default filter is objectclass=*
*/
public DefaultDirContextValidator() {
this(SearchControls.OBJECT_SCOPE);
}