|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.globus.mds.MDS
public class MDS
The interface to the Monitoring and Discovery Service.
USING THE MDS CLASS
The intention of the MDS class is to simplify the connection to the Monitoring and Discovery Service (MDS). This includes:The main motivation for this class is to have an intermediate Application Layer which can be easily adapted to different LDAP client libraries (JNDI, Netscape SDK, Microsoft SDK). To adapt to the differnt API's only a limited number of routines have to be ported. The current release is based on JNDI.
- establishing a conection to an MDS Server,
- quering for contents in the MDS,
- printing the result of a query, and
- disconecting from the MDS Server.
Connecting
The first step in using the class is to establish a connection, which is done in the following way:MDS mds = new MDS("www.globus.org", "389", "o=Globus, c=US");The parameters to the mds class are simply the DNS name of the MDS server and the port number for the connection. The default values for the connection to the MDS are set to ldap://mds.globus.org:389, which are used in case no parameters are specified:MDS mds = new MDS();
Searching
Searching the MDS is done with LDAP queries in respect to a base directory specified by a distingished name (DN). The top level of a globus related seraches is:o=Globus, c=USA search is invoked in the following way:NamingEnumeration result;The search result is stored in a NamingEnumeration as provided by JNDI.
result = mds.search("o=Globus, c=US", "(objectclass=*)", MDS.ONELEVEL_SCOPE);
Printing
A result from a search can be modified by the appropiate JNDI functions. A simple print function is provided which is intended to simplify debugging and programming development:mds.print(result, false);
Example
The following example shows a program which connets to the MDS, and prints all ComputeResources located at Argonne National Laboratory:MDS mds = new MDS("mds.globus.org", "389");
try {
mds.connect();
String bindDN =
"o=Argonne National Laboratory, o=Globus,c=US";
Vector result;
result = mds.search(bindDN,
"(objectclass=GlobusComputeResource)", MDS.ONELEVEL_SCOPE);
System.out.println(results);
mds.disconnect();
} catch(MDSException e) {
System.err.println( "Error:"+ e.getLdapMessage() );
}
Field Summary | |
---|---|
protected LdapContext |
ctx
Deprecated. |
protected static String |
DEFAULT_CTX
Deprecated. |
protected Properties |
env
Deprecated. |
protected int |
limit
Deprecated. |
static int |
OBJECT_SCOPE
Deprecated. |
static int |
ONELEVEL_SCOPE
Deprecated. |
static int |
SUBTREE_SCOPE
Deprecated. |
protected int |
timeout
Deprecated. |
protected int |
version
Deprecated. |
Constructor Summary | |
---|---|
MDS()
Deprecated. initilaizes a connetion to the MDS database with its default values |
|
MDS(GlobusURL spec)
Deprecated. initilaizes a connetion to the MDS database using the specified LDAP URL |
|
MDS(String hostname,
String port)
Deprecated. initilaizes a connetion to the MDS database to the speified host and port |
|
MDS(String hostname,
String port,
String baseDN)
Deprecated. initilaizes a connetion to the MDS database to the speified host and port |
Method Summary | |
---|---|
void |
addAttribute(String dn,
MDSResult at)
Deprecated. adds attributes to an entry. |
void |
addEntry(String dn,
MDSResult at)
Deprecated. adds attributes specified in a Attributes to an Object. |
void |
addPropertyChangeListener(PropertyChangeListener l)
Deprecated. |
void |
connect()
Deprecated. connects to the specified server |
void |
connect(String managerDN,
String password)
Deprecated. connects and authenticates to the specified server |
protected SearchControls |
createConstraints(int scope,
String[] attrToReturn)
Deprecated. |
void |
deleteAttribute(String dn,
String attr)
Deprecated. deletes a specific attribute of an entry. |
void |
deleteEntry(String dn)
Deprecated. deletes a specific object specified by the dn. |
void |
deleteTree(String dn,
boolean deleteItSelf)
Deprecated. deletes a subtree starting from dn |
void |
deleteValues(String dn,
MDSResult at)
Deprecated. deletes attributes of an entry. |
void |
disconnect()
Deprecated. disconnects from the MDS server |
MDSResult |
getAttributes(String dn)
Deprecated. This methods returns that attributes of the specified distinguished name. |
MDSResult |
getAttributes(String dn,
String[] attributes)
Deprecated. This methods returns that attributes of the specified distinguished name. |
String |
getBaseDN()
Deprecated. returns the baseDN currently used |
String |
getHostname()
Deprecated. gets the hostname |
int |
getLdapVersion()
Deprecated. gets ldap protocol version |
String |
getPort()
Deprecated. gets the port |
int |
getSearchLimit()
Deprecated. gets search limit |
int |
getSearchTimeout()
Deprecated. returns search timeout |
String |
getURL()
Deprecated. gets the URL |
Hashtable |
list(String baseDN)
Deprecated. Lists the objects bound to the argument. |
void |
reconnect()
Deprecated. reconnects to the server. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Deprecated. |
void |
renameEntry(String oldDN,
String newDN)
Deprecated. renames an object in an LDAP database. |
void |
renameEntry(String oldDN,
String newDN,
boolean deleteOldDN)
Deprecated. renames an object in an LDAP database. |
Hashtable |
search(String filter,
int searchScope)
Deprecated. issues a specified search to the MDS. |
Hashtable |
search(String filter,
String[] attrToReturn,
int searchScope)
Deprecated. issues a specified search to the MDS starting from the base DN. |
Hashtable |
search(String baseDN,
String filter,
int searchScope)
Deprecated. issues a specified search to the MDS starting from the base DN. |
Hashtable |
search(String baseDN,
String filter,
String[] attrToReturn,
int searchScope)
Deprecated. issues a specified search to the MDS starting from the base DN. |
NamingEnumeration |
searchl(String baseDN,
String filter,
String[] attrToReturn,
int searchScope)
Deprecated. Issues a search starting from the basDN. |
void |
setBaseDN(String baseDN)
Deprecated. sets the baseDN to the specified value |
void |
setHostname(String hostname)
Deprecated. sets the hostname to the specified value |
void |
setLdapVersion(int newVersion)
Deprecated. sets ldap protocol version |
void |
setPort(String port)
Deprecated. Sets the port to the specified value |
void |
setSearchLimit(int newLimit)
Deprecated. sets search limit - number of returned entries |
void |
setSearchTimeout(int newTimeout)
Deprecated. sets search timeout |
void |
updateAttribute(String dn,
MDSResult at)
Deprecated. updates attributes of an entry. |
void |
updateEntry(String dn,
MDSResult at)
Deprecated. updates specifed dn with attributes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int limit
protected int timeout
protected int version
public static final int SUBTREE_SCOPE
public static final int ONELEVEL_SCOPE
public static final int OBJECT_SCOPE
protected static final String DEFAULT_CTX
protected LdapContext ctx
protected Properties env
Constructor Detail |
---|
public MDS()
public MDS(String hostname, String port)
hostname
- specifies the hostname to which to connectport
- is the port on which the conection is establishedpublic MDS(String hostname, String port, String baseDN)
hostname
- specifies the hostname to which to connectport
- is the port on which the conection is establishedbaseDN
- is the base DN from which searches are rootedpublic MDS(GlobusURL spec)
spec
- the LDAP URL spec from which connection information is
derivedMethod Detail |
---|
public void addPropertyChangeListener(PropertyChangeListener l)
public void removePropertyChangeListener(PropertyChangeListener l)
public void setBaseDN(String baseDN)
baseDN
- public String getBaseDN()
public void setPort(String port)
port
- public String getPort()
public void setHostname(String hostname)
hostname
- public String getHostname()
public String getURL()
public void setSearchTimeout(int newTimeout)
newTimeout
- public int getSearchTimeout()
public void setSearchLimit(int newLimit)
newLimit
- public int getSearchLimit()
public void setLdapVersion(int newVersion)
newVersion
- public int getLdapVersion()
public void connect() throws MDSException
an
- MDSexception if unable to connect
MDSException
public void connect(String managerDN, String password) throws MDSException
managerDN
- specifies the distingushed name of the directory manager
or userpassword
- specifies the password of the directory manager or user
an
- MDSexception if unable to connect
MDSException
public void disconnect() throws MDSException
an
- MDSexception if failed to disconnect
MDSException
public void reconnect() throws MDSException
an
- MDSexception if unable to reconnect
MDSException
public Hashtable search(String filter, int searchScope) throws MDSException
filter
- a common LDAP filtersearchScope
- sets the scope of the search
an
- MDSexception if something goes bad
MDSException
public Hashtable search(String filter, String[] attrToReturn, int searchScope) throws MDSException
filter
- a common LDAP filterattrToReturn
- searchScope
- sets the scope of the search
an
- MDSexception if something goes bad
MDSException
public Hashtable search(String baseDN, String filter, int searchScope) throws MDSException
baseDN
- filter
- a common LDAP filtersearchScope
- sets the scope of the search
an
- MDSexception if something goes bad
MDSException
public Hashtable search(String baseDN, String filter, String[] attrToReturn, int searchScope) throws MDSException
baseDN
- the base DN from which thefilter
- a common LDAP filterattrToReturn
- an array of attributes to be returnedsearchScope
- sets the scope of the search
an
- MDSexception if something goes bad
MDSException
public NamingEnumeration searchl(String baseDN, String filter, String[] attrToReturn, int searchScope) throws NamingException
baseDN
- the base dn from which the search is startedfilter
- the filter for the searchattrToReturn
- an array of attributes to returnsearchScope
- The search scope
NamingException
- when an LDAP error occurs.public Hashtable list(String baseDN) throws MDSException
baseDN
-
an
- MDSexception if something goes bad
MDSException
public MDSResult getAttributes(String dn) throws MDSException
dn
-
an
- MDSexception if something goes bad
MDSException
public MDSResult getAttributes(String dn, String[] attributes) throws MDSException
dn
- attributes
-
an
- MDSexception if something goes bad
MDSException
protected SearchControls createConstraints(int scope, String[] attrToReturn)
public void deleteEntry(String dn) throws MDSException
dn
- the distinguished name of the object to be deleted.
an
- MDSexception if something goes bad
MDSException
public void renameEntry(String oldDN, String newDN) throws MDSException
oldDN
- newDN
-
an
- MDSexception if something goes bad
MDSException
public void renameEntry(String oldDN, String newDN, boolean deleteOldDN) throws MDSException
oldDN
- newDN
- deleteOldDN
- deletes old dn from the entry
MDSException
public void updateEntry(String dn, MDSResult at) throws MDSException
dn
- the distinguished name of the object.at
-
an
- MDSexception if something goes bad
MDSException
public void addEntry(String dn, MDSResult at) throws MDSException
dn
- the distinguished name of the object.at
-
an
- MDSexception if something goes bad
MDSException
public void deleteAttribute(String dn, String attr) throws MDSException
dn
- the distinguished name of the entryattr
- the attribute name of the attribute to be deleted.
an
- MDSexception if something goes bad
MDSException
public void deleteValues(String dn, MDSResult at) throws MDSException
dn
- the distinguished name of the entry.at
- a set of attributes to delete
an
- MDSexception if something goes bad
MDSException
public void updateAttribute(String dn, MDSResult at) throws MDSException
dn
- the distinguished name of the entry.at
- a set of attributes to replace or add
an
- MDSexception if something goes bad
MDSException
public void addAttribute(String dn, MDSResult at) throws MDSException
dn
- the distinguished name of the object.at
-
an
- MDSexception if something goes bad
MDSException
public void deleteTree(String dn, boolean deleteItSelf) throws MDSException
dn
- the distinguished name of the object.deleteItSelf
- if set to true, it also deletes the dn
an
- MDSexception if something goes bad
MDSException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |