|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object be.re.webdav.Util
public class Util
A collection of utility methods for working with a WebDAV server. Some
methods return localized names or messages. If you want to add translations
for this, you have to add the file
Res_<language_tag>.properties
to the package
be.re.webdav.res
.
Nested Class Summary | |
---|---|
static interface |
Util.DisplayNameHandler
This is for handling DAV:displayname properties in a
multistatus response one by one. |
static interface |
Util.PropertyHandler
This is for handling all properties in a multistatus response one by one. |
static interface |
Util.ReportMultistatus
This is for handling state and error information in a multistatus response per entry. |
static interface |
Util.UrlHandler
This is for handling DAV:href elements in a multistatus
response one by one. |
Method Summary | |
---|---|
static Client.ACE[] |
getAces(URL baseUrl,
Element aclProperty)
Extracts the Access Control Entries from a DAV:acl property
element. |
static String |
getAutoVersion(URL url)
Returns the DAV:auto-version property. |
static String |
getAutoVersion(URL url,
Client client)
Returns the DAV:auto-version property. |
static String |
getAutoVersionValueDisplayName(String value)
Returns the localized display name for the value of the DAV:auto-version property. |
static URL |
getHome(URL user)
Returns the home folder of a user. |
static URL |
getHome(URL user,
Client client)
Returns the home folder of a user. |
static URL |
getHref(URL url,
Element response)
|
static URL |
getOwner(URL url)
Returns the owner of a resource. |
static URL |
getOwner(URL url,
Client client)
Returns the owner of a resource. |
static String |
getPassword(URL user)
Returns the password of a user. |
static String |
getPassword(URL user,
Client client)
Returns the password of a user. |
static String |
getPreconditionMessage(Client.Response response)
Returns the localized message that corresponds to the preconditions in the response. |
static String |
getPreconditionMessage(Node error)
Extracts the localized message that corresponds to the preconditions in the DAV:error element. |
static String |
getPreconditionMessage(String precondition)
Returns the localized message that corresponds to the precondition or the empty string if there is no such message. |
static String |
getPrivilegeDescription(ExpandedName privilege)
Returns the localized description of a privilege. |
static String |
getPrivilegeDescription(Node privilege)
Returns the localized description of a privilege. |
static String |
getPrivilegeDescription(String privilege)
Returns the localized description of a privilege using the local name. |
static ExpandedName[] |
getPrivileges()
Returns all known privileges. |
static String |
getPropertyDisplayName(String property)
Returns the localized display name of a property. |
static int |
getPropertyStatusCode(Node propElement)
Extracts the status code from a property element. |
static long |
getQuotaAvailableBytes(URL user)
Returns the available number of bytes for a user. |
static long |
getQuotaAvailableBytes(URL user,
Client client)
Returns the available number of bytes for a user. |
static long |
getQuotaTotalBytes(URL user)
Returns the total number of bytes a user can use. |
static long |
getQuotaTotalBytes(URL user,
Client client)
Returns the total number of bytes a user can use. |
static long |
getQuotaUsedBytes(URL user)
Returns the number of bytes a user is using. |
static long |
getQuotaUsedBytes(URL user,
Client client)
Returns the number of bytes a user is using. |
static String |
getReasonPhrase(Client.Response response)
Returns the localized reason message that corresponds to the response. |
static String |
getReasonPhrase(String method,
int statusCode)
Returns the localized reason message that corresponds to the method/status code combination. |
static String |
getResource(String key)
A low-level method to retrieve localized strings from the be.re.webdav.res.Res bundle. |
static ExpandedName[] |
getResourceTypes(URL url)
Returns all the resource types a resource has. |
static ExpandedName[] |
getResourceTypes(URL url,
Client client)
Returns all the resource types a resource has. |
static int |
getStatusCode(Element response)
Extracts the status code from a multistatus reponse entry. |
static boolean |
isActivity(URL url)
Tests if the resource is an activity. |
static boolean |
isActivity(URL url,
Client client)
Tests if the resource is an activity. |
static boolean |
isCheckedOut(URL url)
Returns the checked-out state. |
static boolean |
isCheckedOut(URL url,
Client client)
Returns the checked-out state. |
static boolean |
isCollection(URL url)
Tests if the resource is a collection. |
static boolean |
isCollection(URL url,
Client client)
Tests if the resource is a collection. |
static boolean |
isMemberOfOne(URL url,
URL[] collections)
Tests if url is a member of one of the
collections . |
static boolean |
isOwner(URL url,
URL user)
Tests if user owns the resource. |
static boolean |
isOwner(URL url,
URL user,
Client client)
Tests if user owns the resource. |
static boolean |
isPrincipal(URL url)
Tests if the resource is a principal. |
static boolean |
isPrincipal(URL url,
Client client)
Tests if the resource is a principal. |
static boolean |
isVersion(URL url)
Tests if the resource is a version. |
static boolean |
isVersion(URL url,
Client client)
Tests if the resource is a version. |
static boolean |
isView(URL url)
Tests if the resource is a view. |
static boolean |
isView(URL url,
Client client)
Tests if the resource is a view. |
static void |
mkcols(URL url)
Creates the collection resource denoted by url and all of the
parent collection resources if they don't already exist. |
static String[] |
readDisplayNameList(URL collection)
Returns the values of the DAV:displayname properties of the
members of the collection . |
static void |
readDisplayNameList(URL url,
Client.Response response,
Util.DisplayNameHandler handler,
boolean includeCollection)
Processes the values of the DAV:displayname properties in the
entries in a multistatus response. |
static void |
readPropertyList(URL url,
Client.Response response,
Util.PropertyHandler handler,
boolean includeCollection)
Processes all the properties in the entries in a multistatus response. |
static void |
readPropertyList(URL url,
Client.Response response,
Util.PropertyHandler handler,
Util.ReportMultistatus report,
boolean includeCollection)
Processes all the properties in the entries in a multistatus response. |
static void |
readUrlList(URL url,
Client.Response response,
Util.UrlHandler handler)
Processes the DAV:href element in the entries in a multistatus
response. |
static void |
reportMultistatus(Client.Response response,
Util.ReportMultistatus report)
Processes the entries in a multistatus response one by one. |
static void |
setAutoVersion(URL url,
String mode)
Sets the auto-version mode for a resource. |
static void |
setAutoVersion(URL url,
String mode,
Client client)
Sets the auto-version mode for a resource. |
static void |
setHome(URL user,
URL home)
Sets the home folder for a user. |
static void |
setHome(URL user,
URL home,
Client client)
Sets the home folder for a user. |
static void |
setOwner(URL url,
URL owner)
Sets the owner of a resource. |
static void |
setOwner(URL url,
URL owner,
Client client)
Sets the owner of a resource. |
static void |
setPassword(URL user,
String password)
Sets the password for a user. |
static void |
setPassword(URL user,
String password,
Client client)
Sets the password for a user. |
static void |
setQuotaTotalBytes(URL user,
long total)
Sets the total number of bytes a user can use. |
static void |
setQuotaTotalBytes(URL user,
long total,
Client client)
Sets the total number of bytes a user can use. |
static void |
throwException(Client.Response response)
Throw an exception with a localized message that is extracted from the response. |
static void |
throwException(URL url,
String method,
int statusCode)
Throw an exception with a localized message that corresponds to the method/status code combination. |
static void |
throwException(URL url,
String method,
int statusCode,
Node error)
Throw an exception with a localized message that corresponds to the method/status code combination. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Client.ACE[] getAces(URL baseUrl, Element aclProperty)
DAV:acl
property
element.
baseUrl
- the URL to resolve relative URLs in the
aclProperty
against.aclProperty
- a DAV:acl
property element.
public static String getAutoVersion(URL url) throws IOException
DAV:auto-version
property.
url
- the URL of the resource.
DAV:auto-version
property, which may
be null
.
IOException
public static String getAutoVersion(URL url, Client client) throws IOException
DAV:auto-version
property.
url
- the URL of the resource.client
- the Client
object used for the connection.
DAV:auto-version
property, which may
be null
.
IOException
public static String getAutoVersionValueDisplayName(String value)
DAV:auto-version
property.
value
- the value of the DAV:auto-version
property.
public static URL getHome(URL user) throws IOException
user
- the URL for the user.
null
.
IOException
public static URL getHome(URL user, Client client) throws IOException
user
- the URL for the user.client
- the Client
object used for the connection.
null
.
IOException
public static URL getHref(URL url, Element response)
public static URL getOwner(URL url) throws IOException
url
- the URL of the resource.
null
.
IOException
public static URL getOwner(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
null
.
IOException
public static String getPassword(URL user) throws IOException
user
- the URL of the user.
null
.
IOException
public static String getPassword(URL user, Client client) throws IOException
user
- the URL of the user.client
- the Client
object used for the connection.
null
.
IOException
public static int getPropertyStatusCode(Node propElement)
propElement
- the property element.
-1
.public static long getQuotaAvailableBytes(URL user) throws IOException
user
- the URL of the user.
-1
.
IOException
public static long getQuotaAvailableBytes(URL user, Client client) throws IOException
user
- the URL of the user.client
- the Client
object used for the connection.
-1
.
IOException
public static long getQuotaTotalBytes(URL user) throws IOException
user
- the URL of the user.
-1
.
IOException
public static long getQuotaTotalBytes(URL user, Client client) throws IOException
user
- the URL of the user.client
- the Client
object used for the connection.
-1
.
IOException
public static long getQuotaUsedBytes(URL user) throws IOException
user
- the URL of the user.
-1
.
IOException
public static long getQuotaUsedBytes(URL user, Client client) throws IOException
user
- the URL of the user.client
- the Client
object used for the connection.
-1
.
IOException
public static String getPreconditionMessage(String precondition)
precondition
- the local name of the precondition element.
public static String getPreconditionMessage(Client.Response response)
response
- the response from the server.
public static String getPreconditionMessage(Node error)
DAV:error
element.
error
- the error element.
public static String getPrivilegeDescription(Node privilege)
privilege
- the privilege element.
null
.public static String getPrivilegeDescription(ExpandedName privilege)
privilege
- the qualified name of the privilege.
null
.public static String getPrivilegeDescription(String privilege)
privilege
- the local name of the privilege.
null
.public static ExpandedName[] getPrivileges()
public static String getPropertyDisplayName(String property)
property
- the property.
public static String getReasonPhrase(Client.Response response)
response
- the response from the server.
public static String getReasonPhrase(String method, int statusCode)
method
- the method.statusCode
- the status code.
public static String getResource(String key)
be.re.webdav.res.Res
bundle.
key
- the key.
public static ExpandedName[] getResourceTypes(URL url) throws IOException
url
- the URL of the resource.
IOException
public static ExpandedName[] getResourceTypes(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
IOException
public static int getStatusCode(Element response)
response
- the response element.
-1
.public static boolean isActivity(URL url) throws IOException
url
- the URL of the resource.
true
if it is an activity, false
otherwise.
IOException
public static boolean isActivity(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
true
if it is an activity, false
otherwise.
IOException
public static boolean isCheckedOut(URL url) throws IOException
url
- the URL of the resource.
true
if it is checked out, false
otherwise.
IOException
public static boolean isCheckedOut(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
true
if it is checked out, false
otherwise.
IOException
public static boolean isCollection(URL url) throws IOException
url
- the URL of the resource.
true
if it is a collection, false
otherwise.
IOException
public static boolean isCollection(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
true
if it is a collection, false
otherwise.
IOException
public static boolean isMemberOfOne(URL url, URL[] collections) throws IOException
url
is a member of one of the
collections
.
url
- the URL of the resource.collections
- the collections to test against.
true
if it is a member, false
otherwise.
IOException
public static boolean isOwner(URL url, URL user) throws IOException
url
- the URL of the resource.user
- the URL of the user.
true
if the user owns it, false
otherwise.
IOException
public static boolean isOwner(URL url, URL user, Client client) throws IOException
url
- the URL of the resource.user
- the URL of the user.client
- the Client
object used for the connection.
true
if the user owns it, false
otherwise.
IOException
public static boolean isPrincipal(URL url) throws IOException
url
- the URL of the resource.
true
if it is a principal, false
otherwise.
IOException
public static boolean isPrincipal(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
true
if it is a principal, false
otherwise.
IOException
public static boolean isVersion(URL url) throws IOException
url
- the URL of the resource.
true
if it is a version, false
otherwise.
IOException
public static boolean isVersion(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
true
if it is a version, false
otherwise.
IOException
public static boolean isView(URL url) throws IOException
url
- the URL of the resource.
true
if it is a view, false
otherwise.
IOException
public static boolean isView(URL url, Client client) throws IOException
url
- the URL of the resource.client
- the Client
object used for the connection.
true
if it is a view, false
otherwise.
IOException
public static void mkcols(URL url) throws IOException
url
and all of the
parent collection resources if they don't already exist.
url
- the URL of the new collection.
IOException
public static String[] readDisplayNameList(URL collection) throws IOException
DAV:displayname
properties of the
members of the collection
. This is useful to show directory
listings or to extract values from functional collections such as those
that contain activities, principals, etc.
collection
- the URL of the resource.
IOException
public static void readDisplayNameList(URL url, Client.Response response, Util.DisplayNameHandler handler, boolean includeCollection) throws IOException
DAV:displayname
properties in the
entries in a multistatus response.
url
- the request URL.response
- the multistatus response.handler
- the handler that is called for each occurrence of a
DAV:displayname
property.includeCollection
- if set to true
the request URL will
also be considered in case it is a collection.
IOException
public static void readPropertyList(URL url, Client.Response response, Util.PropertyHandler handler, boolean includeCollection) throws IOException
url
- the request URL.response
- the multistatus response.handler
- the handler that is called for each occurrence of the
DAV:propstat
element. The handler will receive the properties
in it. If there are no properties at all for a response entry the handler
is called once with an empty property array.includeCollection
- if set to true
the request URL will
also be considered in case it is a collection.
IOException
public static void readPropertyList(URL url, Client.Response response, Util.PropertyHandler handler, Util.ReportMultistatus report, boolean includeCollection) throws IOException
url
- the request URL.response
- the multistatus response.handler
- the handler that is called for each occurrence of the
DAV:propstat
element. The handler will receive the properties
in it. If there no properties at all for a response entry the handler is
called once with an empty property array.report
- the handler that is called when the status code for an entry
is present but not 200.includeCollection
- if set to true
the request URL will
also be considered in case it is a collection.
IOException
public static void readUrlList(URL url, Client.Response response, Util.UrlHandler handler) throws IOException
DAV:href
element in the entries in a multistatus
response.
url
- the request URL.response
- the multistatus response.handler
- the handler that is called for each entry.
IOException
public static void reportMultistatus(Client.Response response, Util.ReportMultistatus report) throws IOException
response
- the multistatus response.report
- the handler to process one entry.
IOException
public static void setAutoVersion(URL url, String mode) throws IOException
url
- the URL of the resource.mode
- see the WebDAV values for the "auto-version" property.
IOException
public static void setAutoVersion(URL url, String mode, Client client) throws IOException
url
- the URL of the resource.mode
- see the WebDAV values for the "auto-version" property.client
- the Client
object used for the connection.
IOException
public static void setHome(URL user, URL home) throws IOException
user
- the URL of the user.home
- the URL of the home folder.
IOException
public static void setHome(URL user, URL home, Client client) throws IOException
user
- the URL of the user.home
- the URL of the home folder.client
- the Client
object used for the connection.
IOException
public static void setOwner(URL url, URL owner) throws IOException
url
- the URL of the resource.owner
- the URL of owner.
IOException
public static void setOwner(URL url, URL owner, Client client) throws IOException
url
- the URL of the resource.owner
- the URL of owner.client
- the Client
object used for the connection.
IOException
public static void setPassword(URL user, String password) throws IOException
user
- the URL of the user.password
- the password.
IOException
public static void setPassword(URL user, String password, Client client) throws IOException
user
- the URL of the user.password
- the password.client
- the Client
object used for the connection.
IOException
public static void setQuotaTotalBytes(URL user, long total) throws IOException
user
- the URL of the user.total
- the number of logical bytes.
IOException
public static void setQuotaTotalBytes(URL user, long total, Client client) throws IOException
user
- the URL of the user.total
- the number of logical bytes.client
- the Client
object used for the connection.
IOException
public static void throwException(Client.Response response) throws IOException, be.re.net.ProtocolException
response
- the response from the server.
IOException
be.re.net.ProtocolException
public static void throwException(URL url, String method, int statusCode) throws be.re.net.ProtocolException
url
- the URL of the resource.method
- the method.statusCode
- the status code.
be.re.net.ProtocolException
public static void throwException(URL url, String method, int statusCode, Node error) throws be.re.net.ProtocolException
url
- the URL of the resource.method
- the method.statusCode
- the status code.error
- the error element. It may be null
.
be.re.net.ProtocolException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |