|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bradmcevoy.http.SimpleResource
public class SimpleResource
A very simple resource implementation, which simply takes parameters in the constructor to define the resource, which includes the content Can be useful for resources defined in by code, where the content is a classpath item
| Constructor Summary | |
|---|---|
SimpleResource(java.lang.String name,
java.util.Date modDate,
byte[] content,
java.lang.String contentType,
java.lang.String uniqueId,
Resource secureResource)
|
|
SimpleResource(java.lang.String name,
java.util.Date modDate,
byte[] content,
java.lang.String contentType,
java.lang.String uniqueId,
java.lang.String realm)
|
|
| 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.lang.Long |
getContentLength()
The length of the content in this resource. |
java.lang.String |
getContentType(java.lang.String accepts)
Given a comma separated listed of preferred content types acceptable for a client, return one content type which is the best. |
java.lang.Long |
getMaxAgeSeconds(Auth auth)
How many seconds to allow the content to be cached for, or null if caching is not allowed The provided auth object allows this method to determine an appropriate caching time depending on authenticated context. |
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. |
java.lang.String |
processForm(java.util.Map<java.lang.String,java.lang.String> parameters,
java.util.Map<java.lang.String,FileItem> files)
|
void |
sendContent(java.io.OutputStream out,
Range range,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.String contentType)
Send the resource's content using the given output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleResource(java.lang.String name,
java.util.Date modDate,
byte[] content,
java.lang.String contentType,
java.lang.String uniqueId,
java.lang.String realm)
public SimpleResource(java.lang.String name,
java.util.Date modDate,
byte[] content,
java.lang.String contentType,
java.lang.String uniqueId,
Resource secureResource)
| Method Detail |
|---|
public void sendContent(java.io.OutputStream out,
Range range,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.String contentType)
throws java.io.IOException
GetableResource
sendContent in interface GetableResourceout - - the output stream to send the content torange - - null for normal GET's, not null for partial GET's. May be ignoredparams - - request parameterscontentType - - the contentType selected by negotiation
java.io.IOException - - if there is an exception writing content to the output stream. This
indicates that the client has disconnected (as frequently occurs with http transfers). DO NOT
throw an IOException if there was an internal error generating the response (eg if reading from a database)public java.lang.Long getMaxAgeSeconds(Auth auth)
GetableResource
getMaxAgeSeconds in interface GetableResourcepublic java.lang.String getContentType(java.lang.String accepts)
GetableResourceString mime = ContentTypeUtils.findContentTypes( this.file ); return ContentTypeUtils.findAcceptableContentType( mime, preferredList );
getContentType in interface GetableResourceContentTypeUtilspublic java.lang.Long getContentLength()
GetableResource
getContentLength in interface GetableResourcepublic java.lang.String getUniqueId()
Resource
getUniqueId in interface Resourcepublic java.lang.String getName()
Resource
getName in interface Resource
public java.lang.Object authenticate(java.lang.String user,
java.lang.String password)
Resource
authenticate in interface Resourceuser - - the user name provided by the user's agentpassword - - the password provided by the user's agent
public boolean authorise(Request request,
Request.Method method,
Auth auth)
Resource
authorise in interface Resourcepublic java.lang.String getRealm()
Resource
getRealm in interface Resourcepublic java.util.Date getModifiedDate()
Resource
getModifiedDate in interface Resourcepublic java.lang.String checkRedirect(Request request)
Resource
checkRedirect in interface Resource
public java.lang.String processForm(java.util.Map<java.lang.String,java.lang.String> parameters,
java.util.Map<java.lang.String,FileItem> files)
throws BadRequestException,
NotAuthorizedException,
ConflictException
processForm in interface PostableResourceBadRequestException
NotAuthorizedException
ConflictException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||