public class FileRepository
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.io.File |
currentFolder |
protected int |
filePerFolder |
protected java.lang.String |
filePrefix |
protected org.apache.commons.logging.Log |
log |
protected java.io.File |
pathToFS |
protected java.lang.String |
repositoryID |
protected org.ow2.weblab.core.extended.jaxb.WebLabMarshaller |
wlm |
| Constructor and Description |
|---|
FileRepository(java.lang.String pathToTheRepository,
int filePerFolder,
java.lang.String repositoryID,
java.lang.String filePrefix) |
| Modifier and Type | Method and Description |
|---|---|
protected org.ow2.weblab.core.model.Resource |
changeUri(org.ow2.weblab.core.model.Resource res)
Check if the resource is already present if not create a unique wlri and change it in the resource
|
protected void |
createNewSubFolder()
Generates a new and unique folder value.
|
org.ow2.weblab.core.model.Resource |
getResource(java.lang.String uri) |
protected org.ow2.weblab.core.model.Resource |
getResourceInside(org.ow2.weblab.core.model.Resource res,
java.lang.String uri)
Recursive route which return resource corresponding to the uri
|
protected org.ow2.weblab.core.model.Resource |
getResourceInside(org.ow2.weblab.core.model.Resource res,
java.lang.String uri,
org.ow2.weblab.core.model.Resource newRes)
recursive route which replace newRes in res
|
protected org.ow2.weblab.core.model.Resource |
getResourceInside(org.ow2.weblab.core.model.Resource res,
java.lang.String uri,
org.ow2.weblab.core.model.Resource newRes,
org.ow2.weblab.core.model.Resource father) |
protected java.lang.String |
getUniqueResource()
Use it to get an unique resource identifier
|
protected java.io.File |
initPathToFS(java.lang.String pathToTheRepository) |
protected org.ow2.weblab.core.model.Resource |
loadFile(java.lang.String fileName)
Load the resource corresponding to the file name
|
protected void |
replaceResource(org.ow2.weblab.core.model.Resource father,
org.ow2.weblab.core.model.Resource oldRes,
org.ow2.weblab.core.model.Resource newRes) |
protected org.ow2.weblab.core.model.Resource |
replaceUri(org.ow2.weblab.core.model.Resource res,
java.lang.String uri)
Replace the old uri with the new one on a resource
|
java.lang.String |
saveResource(org.ow2.weblab.core.model.Resource resource) |
protected void |
setCurrentFolder(java.io.File currentFolder) |
protected void |
writeFile(RepoRI wlRi,
org.ow2.weblab.core.model.Resource res)
Write the resource to the file corresponding to the wlRi
|
protected final java.io.File pathToFS
protected final java.lang.String filePrefix
protected final java.lang.String repositoryID
protected final int filePerFolder
protected final org.apache.commons.logging.Log log
protected java.io.File currentFolder
protected final org.ow2.weblab.core.extended.jaxb.WebLabMarshaller wlm
public FileRepository(java.lang.String pathToTheRepository,
int filePerFolder,
java.lang.String repositoryID,
java.lang.String filePrefix)
throws java.io.IOException
java.io.IOExceptionpublic org.ow2.weblab.core.model.Resource getResource(java.lang.String uri)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException,
java.io.FileNotFoundException
uri - The URI of the resource to retrieveorg.ow2.weblab.core.extended.exception.WebLabCheckedException - If the resource is not foundjava.io.FileNotFoundExceptionpublic java.lang.String saveResource(org.ow2.weblab.core.model.Resource resource)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
resource - The resource to saveorg.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected org.ow2.weblab.core.model.Resource getResourceInside(org.ow2.weblab.core.model.Resource res,
java.lang.String uri)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
res - main resourceuri - uri to findorg.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected org.ow2.weblab.core.model.Resource getResourceInside(org.ow2.weblab.core.model.Resource res,
java.lang.String uri,
org.ow2.weblab.core.model.Resource newRes)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
res - main resourceuri - uri to find (the same as in newRes)newRes - new resource which going to replace the funded oneorg.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected org.ow2.weblab.core.model.Resource getResourceInside(org.ow2.weblab.core.model.Resource res,
java.lang.String uri,
org.ow2.weblab.core.model.Resource newRes,
org.ow2.weblab.core.model.Resource father)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
org.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected void replaceResource(org.ow2.weblab.core.model.Resource father,
org.ow2.weblab.core.model.Resource oldRes,
org.ow2.weblab.core.model.Resource newRes)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
org.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected org.ow2.weblab.core.model.Resource loadFile(java.lang.String fileName)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException,
java.io.FileNotFoundException
fileName - org.ow2.weblab.core.extended.exception.WebLabCheckedExceptionjava.io.FileNotFoundExceptionprotected org.ow2.weblab.core.model.Resource changeUri(org.ow2.weblab.core.model.Resource res)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
res - resourceorg.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected java.lang.String getUniqueResource()
protected org.ow2.weblab.core.model.Resource replaceUri(org.ow2.weblab.core.model.Resource res,
java.lang.String uri)
throws org.ow2.weblab.core.extended.exception.WebLabCheckedException
res - the resource to be changednewUri - the new uriorg.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected void writeFile(RepoRI wlRi, org.ow2.weblab.core.model.Resource res) throws java.io.FileNotFoundException, org.ow2.weblab.core.extended.exception.WebLabCheckedException
wlRi - resource rires - resource to writejava.io.FileNotFoundExceptionorg.ow2.weblab.core.extended.exception.WebLabCheckedExceptionprotected java.io.File initPathToFS(java.lang.String pathToTheRepository)
throws java.io.IOException
pathToTheRepository - The path to the root folder of the repositoryjava.io.IOException - If the folder cannot be createdprotected void createNewSubFolder()
protected void setCurrentFolder(java.io.File currentFolder)
Copyright © 2004-2012. All Rights Reserved.