com.noelios.restlet.local
Class FileClientHelper

java.lang.Object
  extended by org.restlet.util.Helper<T>
      extended by com.noelios.restlet.ConnectorHelper<Client>
          extended by com.noelios.restlet.ClientHelper
              extended by com.noelios.restlet.local.LocalClientHelper
                  extended by com.noelios.restlet.local.EntityClientHelper
                      extended by com.noelios.restlet.local.FileClientHelper

public class FileClientHelper
extends EntityClientHelper

Connector to the file resources accessible. Here is the list of parameters that are supported:

Parameter name Value type Default value Description
temporaryExtension String tmp The name of the extension to use to store the temporary content while uploading content via the PUT method.
resumeUpload boolean false Indicates if a failed upload can be resumed. This will prevent the deletion of the temporary file created.

Author:
Jerome Louvel, Thierry Boileau

Constructor Summary
FileClientHelper(Client client)
          Constructor.
 
Method Summary
protected  boolean checkExtensionsConsistency(java.io.File file, MetadataService metadataService)
          Check that all extensions of the file correspond to a known metadata.
 Entity getEntity(java.lang.String decodedPath)
          Returns a local entity for the given path.
 java.lang.String getTemporaryExtension()
          Returns the name of the extension to use to store the temporary content while uploading content via the PUT method.
 void handle(Request request, Response response)
          Handles a call.
protected  void handleEntity(Request request, Response response, java.lang.String path, java.lang.String decodedPath, MetadataService metadataService)
          Handles a call for a local entity.
protected  void handleFileDelete(Response response, java.io.File file)
          Handles a DELETE call for the FILE protocol.
protected  void handleFilePut(Request request, Response response, java.lang.String path, java.io.File file, MetadataService metadataService)
          Handles a PUT call for the FILE protocol.
 boolean isResumeUpload()
          Indicates if a failed upload can be resumed.
 
Methods inherited from class com.noelios.restlet.local.EntityClientHelper
createReference, getReencodedVariantEntityName, handleEntityGet
 
Methods inherited from class com.noelios.restlet.local.LocalClientHelper
getDefaultLanguage, getMetadataService, getTimeToLive, updateMetadata
 
Methods inherited from class com.noelios.restlet.ClientHelper
getConnectTimeout
 
Methods inherited from class com.noelios.restlet.ConnectorHelper
getProtocols, start, stop, update
 
Methods inherited from class org.restlet.util.Helper
getAttributes, getContext, getHelped, getHelpedParameters, getLogger, setHelped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileClientHelper

public FileClientHelper(Client client)
Constructor.

Parameters:
client - The client to help.
Method Detail

checkExtensionsConsistency

protected boolean checkExtensionsConsistency(java.io.File file,
                                             MetadataService metadataService)
Check that all extensions of the file correspond to a known metadata.

Parameters:
file - The file whose extensions are checked.
metadataService - The metadata service.
Returns:
True if all extensions of the file are known by the metadata service.

getEntity

public Entity getEntity(java.lang.String decodedPath)
Description copied from class: EntityClientHelper
Returns a local entity for the given path.

Specified by:
getEntity in class EntityClientHelper
Parameters:
decodedPath - The path of the entity.
Returns:
A local entity for the given path.

getTemporaryExtension

public java.lang.String getTemporaryExtension()
Returns the name of the extension to use to store the temporary content while uploading content via the PUT method. Defaults to "tmp".

Returns:
The name of the extension to use to store the temporary content.

handle

public void handle(Request request,
                   Response response)
Handles a call.

Overrides:
handle in class EntityClientHelper
Parameters:
request - The request to handle.
response - The response to update.

handleEntity

protected void handleEntity(Request request,
                            Response response,
                            java.lang.String path,
                            java.lang.String decodedPath,
                            MetadataService metadataService)
Description copied from class: EntityClientHelper
Handles a call for a local entity. By default, only GET and HEAD methods are implemented.

Overrides:
handleEntity in class EntityClientHelper
Parameters:
request - The request to handle.
response - The response to update.
path - The entity path.
decodedPath - The URL decoded entity path.
metadataService - The metadataService.

handleFileDelete

protected void handleFileDelete(Response response,
                                java.io.File file)
Handles a DELETE call for the FILE protocol.

Parameters:
response - The response to update.
file - The file or directory to delete.

handleFilePut

protected void handleFilePut(Request request,
                             Response response,
                             java.lang.String path,
                             java.io.File file,
                             MetadataService metadataService)
Handles a PUT call for the FILE protocol.

Parameters:
request - The request to update.
response - The response to update.
path - The encoded path of the requested file or directory.
file - The requested file or directory.
metadataService - The metadata service.

isResumeUpload

public boolean isResumeUpload()
Indicates if a failed upload can be resumed. This will prevent the deletion of the temporary file created. Defaults to "false".

Returns:
True if a failed upload can be resumed, false otherwise.


Copyright © 2005-2008 Noelios Technologies.