org.ow2.weblab.content
Class FolderContentManager

java.lang.Object
  extended by org.ow2.weblab.content.FolderContentManager
Direct Known Subclasses:
BinaryFolderContentManager, TextFolderContentManager

public abstract class FolderContentManager
extends java.lang.Object


Field Summary
protected  int bufferSize
           
protected  java.io.File folder
           
protected  java.lang.String propertyFileName
           
protected  java.lang.String propertyKey
           
static java.lang.String SIMPLE_RESOURCE_RDF_HELPER
          The implementation of ResourceHelper to be used.
 
Constructor Summary
protected FolderContentManager(java.lang.String folderPath)
          Constructor
 
Method Summary
protected static boolean checkFolder(java.io.File folder)
          Checks if a folder is right configured.
abstract  org.weblab_project.core.model.content.Content getContent(java.lang.String contentUri, int offset, int limit)
          Return a Content using the contentUri, an offset and a limit.
 java.io.File getFileFromResourceAndPredicate(org.weblab_project.core.model.Resource res, java.lang.String pred)
          Extract the pred object of res to get the file in the FolderContentManager.
protected  java.io.File getFileFromURI(org.weblab_project.core.uri.WebLabRI uri)
          Uses to get a file from a WebLabRI from a content manager.
 java.io.File getFileFromWLRi(java.lang.String uri)
          Returns the native file corresponding to the WLRI.
 java.io.File getFolder()
           
protected static java.lang.String getFolderValue(java.lang.String propertyPath, java.lang.String propertyValue, java.lang.String defaultValue)
          Uses this to automatically get a folder path.
 java.io.File getNativeFileFromResource(org.weblab_project.core.model.Resource res)
          Extract the WebLab.HAS_NATIVE_CONTENT object of res to get the file in the FolderContentManager.
 java.io.File getNormalisedFileFromResource(org.weblab_project.core.model.Resource res)
          Extract the WebLab.HAS_NORMALISED_CONTENT object of res to get the file in the FolderContentManager .
abstract  void saveContent(org.weblab_project.core.model.content.Content content)
          Save the content.
 void setFolder(java.io.File folder)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyKey

protected java.lang.String propertyKey

propertyFileName

protected java.lang.String propertyFileName

bufferSize

protected int bufferSize

folder

protected java.io.File folder

SIMPLE_RESOURCE_RDF_HELPER

public static final java.lang.String SIMPLE_RESOURCE_RDF_HELPER
The implementation of ResourceHelper to be used.

See Also:
Constant Field Values
Constructor Detail

FolderContentManager

protected FolderContentManager(java.lang.String folderPath)
                        throws org.weblab_project.core.exception.WebLabUncheckedException
Constructor

Parameters:
folderPath - The path to the content folder.
Throws:
org.weblab_project.core.exception.WebLabUncheckedException
Method Detail

checkFolder

protected static boolean checkFolder(java.io.File folder)
Checks if a folder is right configured.

Parameters:
folder - The file to check existence.
Returns:
false if folder is not configured.

getFileFromURI

protected java.io.File getFileFromURI(org.weblab_project.core.uri.WebLabRI uri)
Uses to get a file from a WebLabRI from a content manager. Manage weblab and file schemes.

Parameters:
uri - a valid WLRI.
Returns:
the file corresponding to the WLRI.

getFileFromWLRi

public java.io.File getFileFromWLRi(java.lang.String uri)
Returns the native file corresponding to the WLRI.

Parameters:
uri - WLRI which identify the native file.
Returns:
a native file.

getNativeFileFromResource

public java.io.File getNativeFileFromResource(org.weblab_project.core.model.Resource res)
                                       throws org.weblab_project.core.exception.WebLabCheckedException
Extract the WebLab.HAS_NATIVE_CONTENT object of res to get the file in the FolderContentManager.

Parameters:
res - The resource to extract native content.
Returns:
The file representing the native content of the resource.
Throws:
org.weblab_project.core.exception.WebLabCheckedException

getNormalisedFileFromResource

public java.io.File getNormalisedFileFromResource(org.weblab_project.core.model.Resource res)
                                           throws org.weblab_project.core.exception.WebLabCheckedException
Extract the WebLab.HAS_NORMALISED_CONTENT object of res to get the file in the FolderContentManager .

Parameters:
res - The resource to extract normalised content.
Returns:
The file representing the normalised content of the resource.
Throws:
org.weblab_project.core.exception.WebLabCheckedException

getFileFromResourceAndPredicate

public java.io.File getFileFromResourceAndPredicate(org.weblab_project.core.model.Resource res,
                                                    java.lang.String pred)
                                             throws org.weblab_project.core.exception.WebLabCheckedException
Extract the pred object of res to get the file in the FolderContentManager.

Parameters:
res - The resource to extract content.
pred - The predicate used to find content URI in res annotations.
Returns:
The file representing the content of the resource.
Throws:
org.weblab_project.core.exception.WebLabCheckedException

getFolderValue

protected static java.lang.String getFolderValue(java.lang.String propertyPath,
                                                 java.lang.String propertyValue,
                                                 java.lang.String defaultValue)
Uses this to automatically get a folder path. Load it from a property file.

Parameters:
propertyPath - path to the property file.
propertyValue - name of the key in the property file.
defaultValue - value returned if unable to get one.
Returns:
the path to the file repository folder.

getContent

public abstract org.weblab_project.core.model.content.Content getContent(java.lang.String contentUri,
                                                                         int offset,
                                                                         int limit)
                                                                  throws org.weblab_project.core.exception.WebLabCheckedException
Return a Content using the contentUri, an offset and a limit.

Parameters:
contentUri - a valid WLRI which identify a Content in this "repository".
offset - beginning part of the data.
limit - maximum size of the data.
Returns:
a Content object containing data from offset to limit.
Throws:
org.weblab_project.core.exception.WebLabCheckedException - most of time an access problem.

saveContent

public abstract void saveContent(org.weblab_project.core.model.content.Content content)
                          throws org.weblab_project.core.exception.WebLabCheckedException
Save the content.

Parameters:
content - The content to be saved.
Throws:
org.weblab_project.core.exception.WebLabCheckedException - most of time an access problem.

getFolder

public java.io.File getFolder()
Returns:
The folder.

setFolder

public void setFolder(java.io.File folder)
Parameters:
folder - The folder to set.


Copyright © 2004-2011. All Rights Reserved.