com.bradmcevoy.http
Interface Resource

All Known Subinterfaces:
CollectionResource, CopyableResource, CustomPropertyResource, DeletableCollectionResource, DeletableResource, DigestResource, FileResource, FolderResource, GetableResource, LockableResource, LockingCollectionResource, LockNullResource, MakeCollectionableResource, MoveableResource, PartialllyUpdateableResource, PostableResource, PropFindableResource, PropPatchableResource, PutableResource, QuotaResource, ReplaceableResource, ReportableResource
All Known Implementing Classes:
ClassPathResourceFactory.ClassPathResource, FckCommon, FckFileManagerResource, FckQuickUploaderResource, SimpleDigestResource, SimpleResource

public interface Resource

Implementations should implement compareTo as an alphabetic comparison on the name property

Author:
Alienware1

Method Summary
 java.lang.Object authenticate(java.lang.String user, java.lang.String password)
          Check the given credentials, and return a relevant object if accepted.
 boolean authorise(Request request, Request.Method method, Auth auth)
          Return true if the current user is permitted to access this resource using the specified method.
 java.lang.String checkRedirect(Request request)
          Determine if a redirect is required for this request, and if so return the URL to redirect to.
 java.util.Date getModifiedDate()
          The date and time that this resource, or any part of this resource, was last modified.
 java.lang.String getName()
          Note that this name MUST be consistent with URL resolution in your ResourceFactory

If they aren't consistent Milton will generate a different href in PropFind responses then what clients have request and this will cause either an error or no resources to be displayed

 java.lang.String getRealm()
          Return the security realm for this resource.
 java.lang.String getUniqueId()
          Returning a null value is allowed, and disables the ETag field.
 

Method Detail

getUniqueId

java.lang.String getUniqueId()
Returning a null value is allowed, and disables the ETag field.

If a unique id is returned it will be combined with the modified date (if available) to produce an ETag which identifies this version of this resource.

Returns:
- a string which uniquely identifies this resource. This will be used in the ETag header field, and affects caching of resources.

getName

java.lang.String getName()
Note that this name MUST be consistent with URL resolution in your ResourceFactory

If they aren't consistent Milton will generate a different href in PropFind responses then what clients have request and this will cause either an error or no resources to be displayed

Returns:
- the name of this resource. Ie just the local name, within its folder

authenticate

java.lang.Object authenticate(java.lang.String user,
                              java.lang.String password)
Check the given credentials, and return a relevant object if accepted.

Returning null indicates credentials were not accepted

Parameters:
user - - the user name provided by the user's agent
password - - the password provided by the user's agent
Returns:
- if credentials are accepted, some object to attach to the Auth object. otherwise null

authorise

boolean authorise(Request request,
                  Request.Method method,
                  Auth auth)
Return true if the current user is permitted to access this resource using the specified method.

Note that the current user may be determined by the Auth associated with the request, or by a separate, application specific, login mechanism such as a session variable or cookie based system. This method should correctly interpret all such mechanisms

The auth given as a parameter will be null if authentication failed. The auth associated with the request will still exist


getRealm

java.lang.String getRealm()
Return the security realm for this resource. Just any string identifier.

This will be used to construct authorization challenges and will be used on Digest authentication to construct the expected response.


getModifiedDate

java.util.Date getModifiedDate()
The date and time that this resource, or any part of this resource, was last modified. For dynamic rendered resources this should consider everything which will influence its output.

Resources for which no such date can be calculated should return null.

This field, if not null, is used to reply to conditional GETs (ie GET with if-modified-since). If the modified-since argument is later then the modified date then we return a 304 - Not Modified.

Although nulls are explicitly allowed by milton, certain client applications might require modified dates for file browsing. For example, the command line client on Vista doesn't work properly if this is null.


checkRedirect

java.lang.String checkRedirect(Request request)
Determine if a redirect is required for this request, and if so return the URL to redirect to. May be absolute or relative.

Called after authorization check but before any method specific processing

Return null for no redirect



Copyright © 2011. All Rights Reserved.