📄 dsmlcontext.java
字号:
* <code>cons</code> specifies a search scope of
* <code>SearchControls.OBJECT_SCOPE</code> or
* <code>SearchControls.SUBSTREE_SCOPE</code>), its name is the empty
* string. The <tt>SearchResult</tt> may also contain attributes of the
* matching object if the <tt>cons</tt> argument specified that attributes
* be returned.
* <p/>
* If the object does not have a requested attribute, that
* nonexistent attribute will be ignored. Those requested
* attributes that the object does have will be returned.
* <p/>
* A directory might return more attributes than were requested
* (see <strong>Attribute Type Names</strong> in the class description)
* but is not allowed to return arbitrary, unrelated attributes.
* <p/>
* See also <strong>Operational Attributes</strong> in the class
* description.
* <p/>
* <p>Equivalent to search(name, filter, null, cons).
*
* @param name the name of the context or object to search
* @param filter the filter expression to use for the search; may not be null
* @param cons the search controls that control the search. If null,
* the default search controls are used (equivalent
* to <tt>(new SearchControls())</tt>).
* @return an enumeration of <tt>SearchResult</tt>s of
* the objects that satisfy the filter; never null
* @throws javax.naming.directory.InvalidSearchFilterException if the search filter specified is
* not supported or understood by the underlying directory
* @throws javax.naming.directory.InvalidSearchControlsException if the search controls
* contain invalid settings
* @throws javax.naming.NamingException if a naming exception is encountered
* @see #search(javax.naming.Name, String, Object[], javax.naming.directory.SearchControls)
* @see javax.naming.directory.SearchControls
* @see javax.naming.directory.SearchResult
*/
public NamingEnumeration search(Name name, String filter, SearchControls cons) throws NamingException
{
return search(name, filter, null, cons);
}
/**
* <p>Searches in the named context or object for entries that satisfy the
* given search filter. Performs the search as specified by
* the search controls.
* <p/>
* See {@link #search(javax.naming.Name, String, Object[], javax.naming.directory.SearchControls)} for details.
*
* @param name the name of the context or object to search
* @param filterExpr the filter expression to use for the search.
* The expression may contain variables of the
* form "<code>{i}</code>" where <code>i</code>
* is a nonnegative integer. May not be null.
* @param filterArgs <b>NOT IMPLEMENTED!</b>
* the array of arguments to substitute for the variables
* in <code>filterExpr</code>. The value of
* <code>filterArgs[i]</code> will replace each
* occurrence of "<code>{i}</code>".
* If null, equivalent to an empty array.
* @param cons the search controls that control the search. If null,
* the default search controls are used (equivalent
* to <tt>(new SearchControls())</tt>).
* @return an enumeration of <tt>SearchResult</tt>s of the objects
* that satisfy the filter; never null
* @throws ArrayIndexOutOfBoundsException if <tt>filterExpr</tt> contains
* <code>{i}</code> expressions where <code>i</code> is outside
* the bounds of the array <code>filterArgs</code>
* @throws javax.naming.directory.InvalidSearchControlsException if <tt>cons</tt> contains
* invalid settings
* @throws javax.naming.directory.InvalidSearchFilterException if <tt>filterExpr</tt> with
* <tt>filterArgs</tt> represents an invalid search filter
* @throws javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(String name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException
{
if (filterExpr == null)
throw new NamingException("null ldap filter in DsmlContext search");
if (filterArgs != null && filterArgs.length > 0)
throw new NamingException("filter arguments not implemented in com.ca.jndiproviders.dsml provider");
log.finest("search III (" + name.toString() + ") + filter: " + filterExpr);
if (cons == null)
cons = DEFAULT_SEARCH_CONTROLS;
// translate JNDI search scope into DSML speak
String searchScope;
switch (cons.getSearchScope())
{
case SearchControls.OBJECT_SCOPE:
searchScope = BASEOBJECT;
break;
case SearchControls.ONELEVEL_SCOPE:
searchScope = SINGLELEVEL;
break;
case SearchControls.SUBTREE_SCOPE:
searchScope = WHOLESUBTREE;
break;
default:
throw new NamingException("unexpected error; unknown search scope in SearchControl object: " + cons.getSearchScope()); // really, really, really should be impossible
}
// translate JNDI alias handling into DSML speak
String jndiAliasHandling = (String) environment.get("java.naming.ldap.derefAliases");
if (jndiAliasHandling == null)
jndiAliasHandling = "always";
String aliasHandling = "derefAlways";
if (jndiAliasHandling.equals("always"))
aliasHandling = ALWAYS;
else if (jndiAliasHandling.equals("never"))
aliasHandling = NEVER;
else if (jndiAliasHandling.equals("finding"))
aliasHandling = FINDING;
else if (jndiAliasHandling.equals("searching"))
aliasHandling = SEARCHING;
// doesn't seem to be anything corresponding to the DSML 'types only' flag, unless possibly it is cons.getReturningObjFlag()??
// do the DSML search using the jndiproviders search controls data, environment data, and passed parameters
NamingEnumeration returnEnum = doDsmlSearch(name, searchScope, aliasHandling, cons.getCountLimit(), cons.getTimeLimit(), false, filterExpr, cons.getReturningAttributes());
return returnEnum;
}
/**
* Searches in the named context or object for entries that satisfy the
* given search filter. Performs the search as specified by
* the search controls.
* <p/>
* The interpretation of <code>filterExpr</code> is based on RFC
* 2254. It may additionally contain variables of the form
* <code>{i}</code> -- where <code>i</code> is an integer -- that
* refer to objects in the <code>filterArgs</code> array. The
* interpretation of <code>filterExpr</code> is otherwise
* identical to that of the <code>filter</code> parameter of the
* method <code>search(Name, String, SearchControls)</code>.
* <p/>
* When a variable <code>{i}</code> appears in a search filter, it
* indicates that the filter argument <code>filterArgs[i]</code>
* is to be used in that place. Such variables may be used
* wherever an <em>attr</em>, <em>value</em>, or
* <em>matchingrule</em> production appears in the filter grammar
* of RFC 2254, section 4. When a string-valued filter argument
* is substituted for a variable, the filter is interpreted as if
* the string were given in place of the variable, with any
* characters having special significance within filters (such as
* <code>'*'</code>) having been escaped according to the rules of
* RFC 2254.
* <p/>
* For directories that do not use a string representation for
* some or all of their attributes, the filter argument
* corresponding to an attribute value may be of a type other than
* String. Directories that support unstructured binary-valued
* attributes, for example, should accept byte arrays as filter
* arguments. The interpretation (if any) of filter arguments of
* any other type is determined by the service provider for that
* directory, which maps the filter operations onto operations with
* corresponding semantics in the underlying directory.
* <p/>
* This method returns an enumeration of the results.
* Each element in the enumeration contains the name of the object
* and other information about the object (see <code>SearchResult</code>).
* The name is either relative to the target context of the search
* (which is named by the <code>name</code> parameter), or
* it is a URL string. If the target context is included in
* the enumeration (as is possible when
* <code>cons</code> specifies a search scope of
* <code>SearchControls.OBJECT_SCOPE</code> or
* <code>SearchControls.SUBSTREE_SCOPE</code>),
* its name is the empty string.
* <p/>
* The <tt>SearchResult</tt> may also contain attributes of the matching
* object if the <tt>cons</tt> argument specifies that attributes be
* returned.
* <p/>
* If the object does not have a requested attribute, that
* nonexistent attribute will be ignored. Those requested
* attributes that the object does have will be returned.
* <p/>
* A directory might return more attributes than were requested
* (see <strong>Attribute Type Names</strong> in the class description)
* but is not allowed to return arbitrary, unrelated attributes.
* <p/>
* If a search filter with invalid variable substitutions is provided
* to this method, the result is undefined.
* When changes are made to this DirContext,
* the effect on enumerations returned by prior calls to this method
* is undefined.
* <p/>
* See also <strong>Operational Attributes</strong> in the class
* description.
*
* @param name the name of the context or object to search
* @param filterExpr the filter expression to use for the search.
* The expression may contain variables of the
* form "<code>{i}</code>" where <code>i</code>
* is a nonnegative integer. May not be null.
* @param filterArgs the array of arguments to substitute for the variables
* in <code>filterExpr</code>. The value of
* <code>filterArgs[i]</code> will replace each
* occurrence of "<code>{i}</code>".
* If null, equivalent to an empty array.
* @param cons the search controls that control the search. If null,
* the default search controls are used (equivalent
* to <tt>(new SearchControls())</tt>).
* @return an enumeration of <tt>SearchResult</tt>s of the objects
* that satisfy the filter; never null
* @throws ArrayIndexOutOfBoundsException if <tt>filterExpr</tt> contains
* <code>{i}</code> expressions where <code>i</code> is outside
* the bounds of the array <code>filterArgs</code>
* @throws javax.naming.directory.InvalidSearchControlsException if <tt>cons</tt> contains
* invalid settings
* @throws javax.naming.directory.InvalidSearchFilterException if <tt>filterExpr</tt> with
* <tt>filterArgs</tt> represents an invalid search filter
* @throws javax.naming.NamingException if a naming exception is encountered
* @see #search(javax.naming.Name, javax.naming.directory.Attributes, String[])
* @see java.text.MessageFormat
*/
public NamingEnumeration search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException
{
return search(name.toString(), filterExpr, filterArgs, cons);
}
/**
* Closes this context.
* This method releases this context's resources immediately, instead of
* waiting for them to be released automatically by the garbage collector.
* <p/>
* <p> This method is idempotent: invoking it on a context that has
* already been closed has no effect. Invoking any other method
* on a closed context is not allowed, and results in undefined behaviour.
*
* @throws javax.naming.NamingException if a naming exception is encountered
*/
public void close() throws NamingException
{
log.finest("close()");
// TODO - any cleanup required here?
//To change body of implemented methods use File | Settings | File Templates.
}
/**
* Retrieves the full name of this context within its own namespace.
* <p/>
* <p> Many naming services have a notion of a "full name" for objects
* in their respective namespaces. For example, an LDAP entry has
* a distinguished name, and a DNS record has a fully qualified name.
* This method allows the client application to retrieve this name.
* The string returned by this method is not a JNDI composite name
* and should not be passed directly to context methods.
* In naming systems for which the notion of full name does not
* make sense, <tt>OperationNotSupportedException</tt> is thrown.
*
* @return this context's name in its own namespace; never null
* @throws javax.naming.OperationNotSupportedException if the naming system does
* not have the notion of a full name
* @throws javax.naming.NamingException if a naming exception is encountered
* @since 1.3
*/
public String getNameInNamespace() throws NamingException
{
log.finest("getNameInNamespace()");
return contextName;
}
/**
* Destroys the named context and removes it from the namespace.
* See {@link #destroySubcontext(javax.naming.Name)} for details.
*
* @param name the name of the context to be destroyed; may not be empty
* @throws javax.naming.NameNotFoundException if an intermediate context does not exist
* @throws javax.naming.NotContextException if the name is bound but does not name a
* context, or does not name a context of the appropriate type
* @throws javax.naming.ContextNotEmptyException if the named context is not empty
* @throws javax.naming.NamingException if a naming exception is encountered
*/
public void destroySubcontext(St
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -