|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.could.util.http.WebDavClient
A class implementing an extremely simple WebDAV Level 1 client based on
the HttpClient
.
Once opened this class will represent a WebDAV collection. Users of this class can then from an instance of this, deal with relative parent and children resources.
Constructor Summary | |
WebDavClient(Location location)
Create a new WebDavClient instance opening the collection
identified by the specified Location . |
Method Summary | |
WebDavClient |
delete(String child)
Delete the child resource (or collection) of the collection represented by this WebDavClient instance. |
InputStream |
get(String child)
Fetch the contents of the specified child resource of the collection represented by this WebDavClient instance. |
long |
getContentLength()
Return the content length (in bytes) of the collection represented by this WebDavClient as passed to us by the WebDAV server. |
long |
getContentLength(String child)
Return the content length (in bytes) associated with the specified child of the collection represented by this WebDavClient . |
String |
getContentType()
Return the content type (mime-type) of the collection represented by this WebDavClient as passed to us by the WebDAV server. |
String |
getContentType(String child)
Return the content type (mime-type) associated with the specified child of the collection represented by this WebDavClient . |
Date |
getCreationDate()
Return the creation Date of the collection represented
by this WebDavClient as passed to us by the WebDAV server. |
Date |
getCreationDate(String child)
Return the creation Date associated with the specified
child of the collection represented by this WebDavClient . |
Date |
getLastModified()
Return the last modified Date of the collection represented
by this WebDavClient as passed to us by the WebDAV server. |
Date |
getLastModified(String child)
Return the last modified Date associated with the specified
child of the collection represented by this WebDavClient . |
Location |
getLocation()
Return the Location associated with the collection
represented by this WebDavClient . |
Location |
getLocation(String child)
Return the Location associated with the specified child of
the collection represented by this WebDavClient . |
boolean |
hasChild(String child)
Checks if the collection represented by this WebDavClient
contains the specified child. |
boolean |
isCollection(String child)
Checks if the specified child of the collection represented by this WebDavClient instance is a collection. |
Iterator |
iterator()
Return an Iterator over String s for all the children
of the collection represented by this WebDavClient instance. |
static void |
main(String[] args)
A command-line interface to a WebDAV repository. |
WebDavClient |
mkcol(String child)
Create a new collection as a child of the collection represented by this WebDavClient instance. |
WebDavClient |
open(String child)
Open the specified child collection of the collection represented by this WebDavClient as a new WebDavClient instance. |
WebDavClient |
parent()
Open the parent collection of the collection represented by this WebDavClient as a new WebDavClient instance. |
OutputStream |
put(String child)
Create a new (or update the contents of a) child of of the collection represented by this WebDavClient instance. |
OutputStream |
put(String child,
long length)
Create a new (or update the contents of a) child of of the collection represented by this WebDavClient instance. |
WebDavClient |
refresh()
Refresh this WebDavClient instance re-connecting to the remote
collection and re-reading its properties. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WebDavClient(Location location) throws NullPointerException, IOException
Create a new WebDavClient
instance opening the collection
identified by the specified Location
.
location
- the Location
of the WebDAV collection to open.
IOException
- if an I/O or network error occurred, or if the
Location
specified does not point to a
WebDAV collection.
NullPointerException
- if the Location
was null.Method Detail |
public WebDavClient refresh() throws IOException
Refresh this WebDavClient
instance re-connecting to the remote
collection and re-reading its properties.
WebDavClient
instance.
IOException
public InputStream get(String child) throws NullPointerException, IOException
Fetch the contents of the specified child resource of the collection
represented by this WebDavClient
instance.
InputStream
.
IOException
- if an I/O or network error occurred, or if the
child specified represents a collection.
NullPointerException
- if the child was null.isCollection(String)
public WebDavClient delete(String child) throws NullPointerException, IOException
Delete the child resource (or collection) of the collection
represented by this WebDavClient
instance.
WebDavClient
instance.
IOException
- if an I/O or network error occurred, or if the
child specified represents a collection.
NullPointerException
- if the child was null.public WebDavClient mkcol(String child) throws NullPointerException, IOException
Create a new collection as a child of the collection represented
by this WebDavClient
instance.
In comparison to put(String)
and put(String, long)
this method will fail if the specified child already exist.
WebDavClient
instance.
IOException
- if an I/O or network error occurred, or if the
child specified already exist.
NullPointerException
- if the child was null.hasChild(String)
public OutputStream put(String child) throws NullPointerException
Create a new (or update the contents of a) child of of the collection
represented by this WebDavClient
instance.
This method will behave exactly like the put(String, long)
method, but the data written to the returned OutputStream
will
be buffered in memory and will be transmitted to the remote
server only when the OutputStream.close()
method is called.
If the returned OutputStream
is garbage collected before the
close()
method is called, the entire
transaction will be aborted and no connection to the remote server will
be established.
Use this method in extreme cases. In normal circumstances always rely
on the put(String, long)
method.
OutputStream
instance.
NullPointerException
- if the child was null.put(String, long)
public OutputStream put(String child, long length) throws NullPointerException, IOException
Create a new (or update the contents of a) child of of the collection
represented by this WebDavClient
instance.
If the specified child already exists
on
the remote server, it will be deleted
before
writing.
OutputStream
instance.
NullPointerException
- if the child was null.
IOException
- if an I/O or network error occurred, or if the
child specified already exist.public WebDavClient open(String child) throws NullPointerException, IOException
Open the specified child collection of the collection represented by
this WebDavClient
as a new WebDavClient
instance.
If the specified child is ".
" this method
will behave exactly like refresh()
and this instance
will be returned.
If the specified child is "..
" this method
will behave exactly like parent()
.
WebDavClient
instance.
NullPointerException
- if the child was null.
IOException
- if an I/O or network error occurred, or if the
child specified did not exist.public WebDavClient parent() throws IOException
Open the parent collection of the collection represented by this
WebDavClient
as a new WebDavClient
instance.
WebDavClient
instance.
IOException
- if an I/O or network error occurred, or if the
child specified did not exist.public Iterator iterator()
Return an Iterator
over String
s for all the children
of the collection represented by this WebDavClient
instance.
public boolean hasChild(String child)
Checks if the collection represented by this WebDavClient
contains the specified child.
public Location getLocation()
Return the Location
associated with the collection
represented by this WebDavClient
.
The returned Location
can be different from the one specified
at construction, in case the server redirected us upon connection.
public long getContentLength()
Return the content length (in bytes) of the collection represented
by this WebDavClient
as passed to us by the WebDAV server.
public String getContentType()
Return the content type (mime-type) of the collection represented
by this WebDavClient
as passed to us by the WebDAV server.
public Date getLastModified()
Return the last modified Date
of the collection represented
by this WebDavClient
as passed to us by the WebDAV server.
public Date getCreationDate()
Return the creation Date
of the collection represented
by this WebDavClient
as passed to us by the WebDAV server.
public Location getLocation(String child) throws IOException
Return the Location
associated with the specified child of
the collection represented by this WebDavClient
.
IOException
- if the specified child does not exist.
NullPointerException
- if the specified child was null.public boolean isCollection(String child) throws IOException
Checks if the specified child of the collection represented by this
WebDavClient
instance is a collection.
IOException
public long getContentLength(String child) throws IOException
Return the content length (in bytes) associated with the specified
child of the collection represented by this WebDavClient
.
IOException
- if the specified child does not exist.
NullPointerException
- if the specified child was null.public String getContentType(String child) throws IOException
Return the content type (mime-type) associated with the specified
child of the collection represented by this WebDavClient
.
IOException
- if the specified child does not exist.
NullPointerException
- if the specified child was null.public Date getLastModified(String child) throws IOException
Return the last modified Date
associated with the specified
child of the collection represented by this WebDavClient
.
IOException
- if the specified child does not exist.
NullPointerException
- if the specified child was null.public Date getCreationDate(String child) throws IOException
Return the creation Date
associated with the specified
child of the collection represented by this WebDavClient
.
IOException
- if the specified child does not exist.
NullPointerException
- if the specified child was null.public static void main(String[] args) throws IOException
A command-line interface to a WebDAV repository.
When invoked from the command line, this class requires one only argument, the URL location of the WebDAV repository to connect to.
After connection this method will interact with the user using an extremely simple console-based interface.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |