fr.cnes.sitools.resources.order.utils
Class OrderResourceUtils

java.lang.Object
  extended by fr.cnes.sitools.resources.order.utils.OrderResourceUtils

public final class OrderResourceUtils
extends java.lang.Object

Utils methods for OrderResource

Author:
m.gond

Field Summary
static java.lang.String DIRECTORY_PATTERN
          zipFilePattern name
static java.lang.String FILE_LIST_PATTERN
          fileListPattern name
static java.lang.String ZIP_FILE_PATTERN
          zipFilePattern name 0 = orderName, 1 = timestamp
 
Method Summary
static org.restlet.data.Reference addFile(org.restlet.representation.Representation repr, org.restlet.data.Reference refDest, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context)
          Create a file from the following Representation at the given urlDest.
static org.restlet.data.Reference copyFile(org.restlet.data.Reference fileUrl, org.restlet.data.Reference destUrl, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context)
          Copy a file from fileUrl to destUrl destUrl must contain the fileName
static void deleteFile(org.restlet.data.Reference refFile, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context)
          Create a file from the following Representation at the given urlDest.
static SitoolsApplication getApplication(org.restlet.Context context)
          Gets the SitoolsApplication from the context corresponding to the TaskUtils.PARENT_APPLICATION variable
static DataSetApplication getDataSetApplication(org.restlet.Context context)
          Gets the DatasetApplication from the context corresponding to the TaskUtils.PARENT_APPLICATION variable
static java.lang.String getDataStorageUrl(org.restlet.Context context)
          Gets the dataStorageUrl value
static org.restlet.representation.Representation getFile(org.restlet.data.Reference fileUrl, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context)
          Gets the representation of a File
static java.lang.String getFileName(java.lang.String url)
          Get the fileName contained in the given url https://www.google.fr/search?
static AttributeValue getInParam(ResourceParameter param, Record rec)
          Util method to retrieve an AttributeValue from a Record from a given USER_INPUT ResourceParameter
static java.lang.String getResourceOrderStorageUrl(org.restlet.Context context)
          Gets the userStorageUrl value
static java.lang.String getTemporaryStorageUrl(org.restlet.Context context)
          Gets the userStorageUrl value
static org.restlet.data.Reference getUserAvailableFolderPath(org.restlet.security.User user, org.restlet.Context context)
          Get an available folder path for a given User If there is a user , the folder will point into the userstorage of this user If not it will point into the tmp directory Folder hierarchy is SVAClassName/SvaTaskId
static org.restlet.data.Reference getUserAvailableFolderPath(org.restlet.security.User user, java.lang.String folderName, org.restlet.Context context)
          Get an available folder path for a given User and a given folderName If there is a user, the folder will point into the userstorage of this user If not it will point into the tmp directory Folder hierarchy is folderName or SVAClassName/SvaTaskId if folderName is null
static java.lang.String getUserAvailableFolderUrl(org.restlet.security.User user, java.lang.String folderName, org.restlet.Context context)
          getUserAvailableFolderUrl
static java.lang.String getUserStorageUrl(java.lang.String userIdentifier, org.restlet.Context context)
          Gets the userStorageUrl value for a given userIdentifier
static org.restlet.data.Reference riapToExternal(org.restlet.data.Reference reference, SitoolsSettings settings)
          Rewrite the given reference to change the host domain
static void tarFiles(java.util.List<org.restlet.data.Reference> listOfFiles, java.util.Map<org.restlet.data.Reference,java.lang.String> refMap, java.lang.String destFilePath, java.lang.String archiveFileName, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context, boolean gzip)
          Zip the files listed in listOfFiles into the given destFilePath
static void tarFiles(java.util.List<org.restlet.data.Reference> listOfFiles, java.lang.String destFilePath, java.lang.String archiveFileName, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context, boolean gzip)
          Zip the files listed in listOfFiles into the given destFilePath
static void zipFiles(java.util.List<org.restlet.data.Reference> listOfFiles, java.util.Map<org.restlet.data.Reference,java.lang.String> refMap, java.lang.String destFilePath, java.lang.String destFileName, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context)
          Zip the files listed in listOfFiles into the given destFilePath
static void zipFiles(java.util.List<org.restlet.data.Reference> listOfFiles, java.lang.String destFilePath, org.restlet.data.ClientInfo clientInfo, org.restlet.Context context)
          Zip the files listed in listOfFiles into the given destFilePath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZIP_FILE_PATTERN

public static final java.lang.String ZIP_FILE_PATTERN
zipFilePattern name 0 = orderName, 1 = timestamp

See Also:
Constant Field Values

DIRECTORY_PATTERN

public static final java.lang.String DIRECTORY_PATTERN
zipFilePattern name

See Also:
Constant Field Values

FILE_LIST_PATTERN

public static final java.lang.String FILE_LIST_PATTERN
fileListPattern name

See Also:
Constant Field Values
Method Detail

addFile

public static org.restlet.data.Reference addFile(org.restlet.representation.Representation repr,
                                                 org.restlet.data.Reference refDest,
                                                 org.restlet.data.ClientInfo clientInfo,
                                                 org.restlet.Context context)
                                          throws SitoolsException
Create a file from the following Representation at the given urlDest. urlDest must be relative url using RIAP. It must contains the file name as well

Parameters:
repr - the representation
refDest - the destination reference. Must be complete with file name in it
clientInfo - the ClientInfo to check if the user has the rights to add the file
context - The context
Returns:
The location of the new File
Throws:
SitoolsException - if there is an error while creating the file

copyFile

public static org.restlet.data.Reference copyFile(org.restlet.data.Reference fileUrl,
                                                  org.restlet.data.Reference destUrl,
                                                  org.restlet.data.ClientInfo clientInfo,
                                                  org.restlet.Context context)
                                           throws SitoolsException
Copy a file from fileUrl to destUrl destUrl must contain the fileName

Parameters:
fileUrl - the file to copy
destUrl - the destination folder url
clientInfo - the ClientInfo to check if the user has the rights to copy the file
context - The context
Returns:
the url of the created file
Throws:
SitoolsException - if the copy is unsuccessful

deleteFile

public static void deleteFile(org.restlet.data.Reference refFile,
                              org.restlet.data.ClientInfo clientInfo,
                              org.restlet.Context context)
                       throws SitoolsException
Create a file from the following Representation at the given urlDest. urlDest must be relative url using RIAP. It must contains the file name as well

Parameters:
refFile - the file reference
clientInfo - the ClientInfo to check if the user has the rights to delete the file
context - The context
Throws:
SitoolsException - if there is an error while deleting the file

getUserAvailableFolderPath

public static org.restlet.data.Reference getUserAvailableFolderPath(org.restlet.security.User user,
                                                                    org.restlet.Context context)
Get an available folder path for a given User If there is a user , the folder will point into the userstorage of this user If not it will point into the tmp directory Folder hierarchy is SVAClassName/SvaTaskId

Parameters:
user - the User
context - The context
Returns:
the url of the folder

getUserAvailableFolderPath

public static org.restlet.data.Reference getUserAvailableFolderPath(org.restlet.security.User user,
                                                                    java.lang.String folderName,
                                                                    org.restlet.Context context)
Get an available folder path for a given User and a given folderName If there is a user, the folder will point into the userstorage of this user If not it will point into the tmp directory Folder hierarchy is folderName or SVAClassName/SvaTaskId if folderName is null

Parameters:
user - the User
folderName - the name of the folder
context - The context
Returns:
the url of the folder

getUserAvailableFolderUrl

public static java.lang.String getUserAvailableFolderUrl(org.restlet.security.User user,
                                                         java.lang.String folderName,
                                                         org.restlet.Context context)
getUserAvailableFolderUrl

Parameters:
user -
folderName -
context -
Returns:

getFile

public static org.restlet.representation.Representation getFile(org.restlet.data.Reference fileUrl,
                                                                org.restlet.data.ClientInfo clientInfo,
                                                                org.restlet.Context context)
                                                         throws SitoolsException
Gets the representation of a File

Parameters:
fileUrl - the url of the file
clientInfo - the ClientInfo to check if the user has the rights to get the file
context - The context
Returns:
the Representation of a File
Throws:
SitoolsException - if there is an error while getting the file

zipFiles

public static void zipFiles(java.util.List<org.restlet.data.Reference> listOfFiles,
                            java.lang.String destFilePath,
                            org.restlet.data.ClientInfo clientInfo,
                            org.restlet.Context context)
                     throws SitoolsException
Zip the files listed in listOfFiles into the given destFilePath

Parameters:
listOfFiles - list of files to zip, must be RIAP or HTTP file url
destFilePath - the complete file path of the destination zip file, it must contains the zip file names and must be a local path
clientInfo - the ClientInfo to check if the user has the rights to zip the file
context - The context
Throws:
SitoolsException - If something is wrong

zipFiles

public static void zipFiles(java.util.List<org.restlet.data.Reference> listOfFiles,
                            java.util.Map<org.restlet.data.Reference,java.lang.String> refMap,
                            java.lang.String destFilePath,
                            java.lang.String destFileName,
                            org.restlet.data.ClientInfo clientInfo,
                            org.restlet.Context context)
                     throws SitoolsException
Zip the files listed in listOfFiles into the given destFilePath

Parameters:
listOfFiles - list of files to zip, must be RIAP or HTTP file url
destFilePath - the complete file path of the destination zip file, it must contains the zip file names and must be a local path
clientInfo - the ClientInfo to check if the user has the rights to zip the file
context - The context
Throws:
SitoolsException - If something is wrong

tarFiles

public static void tarFiles(java.util.List<org.restlet.data.Reference> listOfFiles,
                            java.lang.String destFilePath,
                            java.lang.String archiveFileName,
                            org.restlet.data.ClientInfo clientInfo,
                            org.restlet.Context context,
                            boolean gzip)
                     throws SitoolsException
Zip the files listed in listOfFiles into the given destFilePath

Parameters:
listOfFiles - list of files to zip, must be RIAP or HTTP file url
destFilePath - the complete file path of the destination zip file, it must contains the zip file names and must be a local path
clientInfo - the ClientInfo to check if the user has the rights to zip the file
context - The context
Throws:
SitoolsException - If something is wrong

tarFiles

public static void tarFiles(java.util.List<org.restlet.data.Reference> listOfFiles,
                            java.util.Map<org.restlet.data.Reference,java.lang.String> refMap,
                            java.lang.String destFilePath,
                            java.lang.String archiveFileName,
                            org.restlet.data.ClientInfo clientInfo,
                            org.restlet.Context context,
                            boolean gzip)
                     throws SitoolsException
Zip the files listed in listOfFiles into the given destFilePath

Parameters:
listOfFiles - list of files to zip, must be RIAP or HTTP file url
destFilePath - the complete file path of the destination zip file, it must contains the zip file names and must be a local path
clientInfo - the ClientInfo to check if the user has the rights to zip the file
context - The context
Throws:
SitoolsException - If something is wrong

getFileName

public static java.lang.String getFileName(java.lang.String url)
Get the fileName contained in the given url https://www.google.fr/search?safe =off&q=ReadableByteChannel+fileoutputStream &spell=1&sa=X&ei=6XM4UtFZrPLsBr7kgegK&ved=0CC8QBSgA

Parameters:
url - the url of a file
Returns:
the file name if it exists, null if not

getDataSetApplication

public static DataSetApplication getDataSetApplication(org.restlet.Context context)
Gets the DatasetApplication from the context corresponding to the TaskUtils.PARENT_APPLICATION variable

Parameters:
context - The context
Returns:
the DatasetApplication or null if the application is not a DatasetApplication

getApplication

public static SitoolsApplication getApplication(org.restlet.Context context)
Gets the SitoolsApplication from the context corresponding to the TaskUtils.PARENT_APPLICATION variable

Parameters:
context - The context
Returns:
the SitoolsApplication

getUserStorageUrl

public static java.lang.String getUserStorageUrl(java.lang.String userIdentifier,
                                                 org.restlet.Context context)
Gets the userStorageUrl value for a given userIdentifier

Parameters:
userIdentifier - the userIdentifier
context - The context
Returns:
the userStorageUrl

getDataStorageUrl

public static java.lang.String getDataStorageUrl(org.restlet.Context context)
Gets the dataStorageUrl value

Parameters:
context - The context
Returns:
the dataStorageUrl

getTemporaryStorageUrl

public static java.lang.String getTemporaryStorageUrl(org.restlet.Context context)
Gets the userStorageUrl value

Parameters:
context - The context
Returns:
the userStorageUrl

getResourceOrderStorageUrl

public static java.lang.String getResourceOrderStorageUrl(org.restlet.Context context)
Gets the userStorageUrl value

Parameters:
context - The context
Returns:
the userStorageUrl

getInParam

public static AttributeValue getInParam(ResourceParameter param,
                                        Record rec)
Util method to retrieve an AttributeValue from a Record from a given USER_INPUT ResourceParameter

Parameters:
param - the ResourceParameter
rec - the Record
Returns:
the AttributeValue

riapToExternal

public static org.restlet.data.Reference riapToExternal(org.restlet.data.Reference reference,
                                                        SitoolsSettings settings)
Rewrite the given reference to change the host domain

Parameters:
reference - the Reference
settings - TODO
Returns:
the rewriten reference


Copyright © 2010-2013 CNES. All Rights Reserved.