|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.webdav.client.EboDAVSwitch
Class for constructing and issuing WebDAV requests, and fetching WebDAV responses.
EboDAVSwitch provides the following capabilities:
EboDAVSwitch provides helper and utility methods to simplify access to low-level WebDAV functions, which are implemented via the Jakarta Slide content management framework. Helper methods expose less of the Slide API than utility methods. The advantage of helper methods is that you can send a complete WebDAV request in a single line of code. The advantage of utility methods is that you gain access to additional functionality provided by the Slide API.
Here is an example of how you might use utility methods to issue a WebDAV request to add a category to a document:
try { EboDAVSwitch dav = new EboDAVSwitch(); dav.startSession("myhost.server.com",80); Credentials credentials = dav.createCredentials("username","password"); dav.setCredentials(credentials); State state = dav.getState(); state.setAuthenticateToken("Basic realm = \"AUTHENTICATION_REALM\""); dav.setState(state); PropPatchMethod ppm = (PropPatchMethod)dav.createWebdavMethod(dav.PROPPATCH_METHOD,document); String uuid = "12345678901234567890123456789012"; // Some category UUID String document = "/Director/WebDAVService/main/MyFolder/MyDocument.htm"; // Document's full path ppm.addPropertyToSet(uuid, null, "AC", EboWebdavConstants.PROPPATCH_ADDCATEGORY); dav.executeCommand(ppm); Document res = ppm.getResponseDocument(); // End the session dav.endSession(); } catch (Exception e) { System.out.println(e.getMessage()); }Here is an example of how to issue the same WebDAV request using the helper method addCategoryToDocument():
EboDAVSwitch dav = new EboDAVSwitch(); // Start the session dav.startSession("jango.novell.com",80); int status = 0; String uuid = "12345678901234567890123456789012"; // Some category UUID String document = "/Director/WebDAVService/main/MyFolder/MyDocument.htm"; // Document's full path status = dav.addCategoryToDocument("username","password","Basic realm = \"AUTHENTICATION_REALM\"",document,uuid); // End the session dav.endSession();
Constructor Summary | |
EboDAVSwitch()
EboDAVSwitch constructor. |
Method Summary | |
int |
addCategoryToDocument(String username,
String password,
String realm,
String document,
String category_uuid)
Assigns a category reference to a document. |
String |
checkLockToken(String element)
Checks who has an object locked. |
int |
copyElement(String username,
String password,
String realm,
String element,
String destination,
boolean overwrite,
boolean autoGenerate)
Copies a resource or collection. |
org.apache.webdav.lib.Credentials |
createCredentials(String username,
String password)
Creates a new Slide Credentials object for authenticating users. |
int |
createNewDocument(String username,
String password,
String realm,
String folder,
String document,
String document_type,
byte[] content)
Creates a new document. |
org.apache.webdav.lib.methods.WebdavMethod |
createWebdavMethod(int method,
String path)
Creates the Slide WebDAV method you want to execute as part of your WebDAV request. |
int |
deleteDocument(String username,
String password,
String realm,
String document)
Deletes a document. |
void |
endSession()
Ends a WebDAV client session and cleans up any EboDAVSwitch objects. |
void |
executeCommand(org.apache.webdav.lib.methods.WebdavMethod method)
Executes a WebDAV Command. |
Hashtable |
getCategories(String username,
String password,
String realm,
String element)
Gets category UUIDs and names. |
org.apache.webdav.lib.WebdavClient |
getClient()
Gets the Slide WebDAV client. |
org.apache.webdav.lib.Credentials |
getCredentials()
Gets credentials from the EboDAVSwitch client. |
boolean |
getDebug(boolean debug)
This method returns the state of debug messages. |
Hashtable |
getFieldValues(String username,
String password,
String realm,
String element)
Returns a hashtable of custom fields and their values. |
String |
getPropValue(Document propsXML,
String key)
Gets the values of a particular node in an XML document object. |
String |
getRoot()
Gets the root path for the WebDAV servlet. |
org.apache.webdav.lib.State |
getState()
Gets state. |
boolean |
isDirectory(String element)
Checks to see if an element is a directory (collection). |
int |
lockDocument(String username,
String password,
String realm,
String document)
Locks a document. |
int |
makeCollection(String username,
String password,
String realm,
String parent_folder,
String folder,
boolean autoGenerate)
Creates a folder (collection). |
int |
moveElement(String username,
String password,
String realm,
String element,
String destination,
boolean autoGenerate)
Moves or renames a resource or collection. |
void |
printXMLToConsole(Document doc)
Prints the XML passed in to the console. |
int |
putDocument(String username,
String password,
String realm,
String document,
byte[] data)
Updates a document. |
int |
removeAllCategoriesFromDocument(String username,
String password,
String realm,
String document)
Removes all category references from a document. |
int |
removeCategoryFromDocument(String username,
String password,
String realm,
String document,
String category_uuid)
Removes a category reference from a document. |
String |
returnXMLAsString(Document doc)
Gets the XML that was passed in and converts it to a string. |
void |
setCredentials(org.apache.webdav.lib.Credentials cred)
Sets credentials on the EboDAVSwitch client. |
void |
setDebug(boolean flag)
This method allows the user to turn console debug messages on and off. |
void |
setDebug(int level)
Sets the debug level on the slide code. |
int |
setFieldValueForDocument(String username,
String password,
String realm,
String document,
String field_name,
String field_value)
Sets the value of a custom field in a document. |
void |
setRoot(String root)
Sets the root path for the WebDAV servlet. |
void |
setState(org.apache.webdav.lib.State state)
Sets state with your authentication token. |
void |
startSession(String url)
Starts a WebDAV client session on the default port 80. |
void |
startSession(String url,
int port)
Starts a WebDAV client session. |
int |
unlockDocument(String username,
String password,
String realm,
String document)
Unlocks a document. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public EboDAVSwitch()
Method Detail |
public org.apache.webdav.lib.WebdavClient getClient()
public org.apache.webdav.lib.methods.WebdavMethod createWebdavMethod(int method, String path)
method
- Method to create.path
- URL path that the method should be set to.public void startSession(String url, int port)
url
- URL of the server where WebDAV is implemented.port
- Port number for that server.public void setDebug(int level)
level
- Level of debug to set into the WebDAV client.public void setDebug(boolean flag)
flag
- True turns debug messages on while false turns debug off.public boolean getDebug(boolean debug)
public void startSession(String url)
url
- URL of the server where WebDAV is implemented.public void endSession()
public void setState(org.apache.webdav.lib.State state)
state
- State object used to maintain cookies, authentication, etc.public org.apache.webdav.lib.State getState()
public void setRoot(String root)
root
- Path to the WebDAV servlet.public String getRoot()
public org.apache.webdav.lib.Credentials createCredentials(String username, String password)
username
- User name for the Credentials object.password
- Password for the Credentials object. This is a utility method.public void setCredentials(org.apache.webdav.lib.Credentials cred)
cred
- Credentials object to set.EboDAVSwitch.getCredentials()
public org.apache.webdav.lib.Credentials getCredentials()
EboDAVSwitch.setCredentials(Credentials cred)
public void executeCommand(org.apache.webdav.lib.methods.WebdavMethod method) throws com.sssw.webdav.client.EboDAVException, MalformedURLException, IOException
method
- WebDAV method to execute.public void printXMLToConsole(Document doc)
Primarily for debugging.
doc
- XML to print.public String returnXMLAsString(Document doc)
Primarily for debugging.
doc
- XML to return as a string.public String getPropValue(Document propsXML, String key) throws com.sssw.webdav.client.EboDAVException
propsXML
- XML Document object that contains the value.key
- Name of the target node.public String checkLockToken(String element) throws com.sssw.webdav.client.EboDAVException
element
- Full path of the element to check the lock on.public Hashtable getFieldValues(String username, String password, String realm, String element) throws com.sssw.webdav.client.EboDAVException
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.element
- Full path of the element to get the field values for.public Hashtable getCategories(String username, String password, String realm, String element) throws com.sssw.webdav.client.EboDAVException
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.element
- Full path of the element whose categories will be checked.public boolean isDirectory(String element) throws com.sssw.webdav.client.EboDAVException
xml
- Full path of the element to be checked.public int addCategoryToDocument(String username, String password, String realm, String document, String category_uuid) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- Full path of the target document.category_uuid
- UUID of the category to add.public int removeCategoryFromDocument(String username, String password, String realm, String document, String category_uuid) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- The full path of the target document.category_uuid
- UUID of the category to remove.public int removeAllCategoriesFromDocument(String username, String password, String realm, String document) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- The full path of the target document.public int setFieldValueForDocument(String username, String password, String realm, String document, String field_name, String field_value) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- Full path of the target document.field_name
- Name of the field to update.field_value
- Value for the field.public int createNewDocument(String username, String password, String realm, String folder, String document, String document_type, byte[] content) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.folder
- Full path of the folder for the new document.document
- Name of the target document.document_type
- Name of the document type.content
- Content for the new document.public int lockDocument(String username, String password, String realm, String document) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- Full path of the document to lock.public int unlockDocument(String username, String password, String realm, String document) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- Full path of the document to unlock.public int deleteDocument(String username, String password, String realm, String document) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- Full path of the document to delete.public int putDocument(String username, String password, String realm, String document, byte[] data) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.document
- Full path of the document to update.data
- Data for updating the document.public int makeCollection(String username, String password, String realm, String parent_folder, String folder, boolean autoGenerate) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.parent_folder
- Name of parent folder relative to host.folder
- Name of folder to create under parent_folder.autoGenerate
- Flag indicating whether to generate all folders in the path if they don't already exist. True = generate the folders.public int moveElement(String username, String password, String realm, String element, String destination, boolean autoGenerate) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.element
- The full path of the object to move or rename.destination
- The full path of the desired new location, or the same path as element but with a new name.autoGenerate
- Flag indicating whether to generate folders that don't exist. True = generate the folders.public int copyElement(String username, String password, String realm, String element, String destination, boolean overwrite, boolean autoGenerate) throws com.sssw.webdav.client.EboDAVException
** Note: If you need to exercise more control over credentials and state, it is recommended that you not use this method.
username
- User name for credentials.password
- Password for credentials.realm
- Realm in which to authenticate credentials.element
- The full path of the object to copydestination
- The full path of the desired new locationoverwrite
- Flag indicating whether or not to overwrite an existing element of the same name. True = overwrite the element.autoGenerate
- Flag indicating whether to generate folders that don't exist. True = generate the folders.
|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |