com.sas.hls.resource.workspace
Interface WorkspaceResourceService


public interface WorkspaceResourceService

Service for manipulating files and folders in a user's workspace.


Method Summary
 WorkspaceResource copy(String sourcePath, String destinationPath)
          Copy the file or folder from the source path to the destination path.
 WorkspaceFile createFile(String path, String localFilePath, boolean createParentFolders)
          Create a new file in the workspace.
 WorkspaceFolder createFolder(String path, boolean createParentFolders)
          Create a folder at the given location.
 void delete(String path)
          Delete the specified resource in the workspace.
 void downloadFile(String path, String outputFilePath)
          Download the contents of a specified workspace file to the specified local file.
 boolean exists(String path)
          Indicates if the specified resource exists in the workspace.
 List<WorkspaceResource> getChildren(String path)
          Return the children of the specified workspace folder.
 WorkspaceResource getResource(String path)
          Get a client representation of the specified resource in the workspace.
 WorkspaceResource move(String sourcePath, String destinationFolderPath)
          Move the file or folder from one location to another.
 WorkspaceResource rename(String path, String name)
          Rename the workspace resource.
 WorkspaceFile updateFileContents(String path, String localFilePath)
          Replace the current content of the workspace file with the content of the specified local file.
 

Method Detail

createFolder

WorkspaceFolder createFolder(String path,
                             boolean createParentFolders)
                             throws WorkspaceResourceNotFoundException,
                                    WorkspaceResourceExistsException
Create a folder at the given location.

Parameters:
path - The folder to create.
createParentFolders - Flag indicating if missing parent containers should be automatically created during this operation.
Returns:
The newly created folder.
Throws:
WorkspaceResourceNotFoundException - Thrown if createParentFolders is set to false and an expected folder container does NOT exist.
WorkspaceResourceExistsException - Thrown when the requested folder already exists.

createFile

WorkspaceFile createFile(String path,
                         String localFilePath,
                         boolean createParentFolders)
                         throws WorkspaceResourceNotFoundException,
                                WorkspaceResourceExistsException,
                                IOException
Create a new file in the workspace. Use updateFileContents(String, String) if you wish to replace the content of an existing workspace file.

Parameters:
path - The full path of the workspace file to be created.
localFilePath - The local file with the contents for the new WorkspaceFile.
createParentFolders - Flag indicating if missing parent containers should be automatically created during this operation.
Returns:
WorkspaceFile The newly created workspace file.
Throws:
WorkspaceResourceNotFoundException - Thrown if you did not specify createParentFolders=true, and one of the parent containers specified for this new resource does not already exist.
WorkspaceResourceExistsException - Throw if a file already exists at the specified path.
IOException - see the exception text for more details.

copy

WorkspaceResource copy(String sourcePath,
                       String destinationPath)
                       throws WorkspaceResourceNotFoundException,
                              WorkspaceResourceCopyException,
                              WorkspaceResourceExistsException
Copy the file or folder from the source path to the destination path. The destination path is the full path of the newly created copy, so this includes the name of the new object.

Parameters:
sourcePath - The path of the file or folder to copy.
destinationPath - The path of the destination file or folder to create, this includes the name of the newly created copy.
Returns:
The newly created workspace resource.
Throws:
WorkspaceResourceNotFoundException - The specified source resource was not found.
WorkspaceResourceCopyException - The copy request is not possible; typically the destination path was a child of the source path.
WorkspaceResourceExistsException - A resource already exists at the destination path.

delete

void delete(String path)
            throws WorkspaceResourceNotFoundException,
                   WorkspaceResourceDeleteException
Delete the specified resource in the workspace.

Parameters:
path - The full path of the resource to be deleted.
Throws:
WorkspaceResourceNotFoundException - The specified resource was not found in your workspace.
WorkspaceResourceDeleteException - The specified resource could not be deleted.

downloadFile

void downloadFile(String path,
                  String outputFilePath)
                  throws WorkspaceResourceNotFoundException,
                         IOException
Download the contents of a specified workspace file to the specified local file.

Parameters:
path - The workspace file you wish to download.
outputFilePath - The file location you would like the workspaceFile contents to be placed.
Throws:
WorkspaceResourceNotFoundException - The specified resource was not found in your workspace.
IOException - see the exception text for more details.

exists

boolean exists(String path)
Indicates if the specified resource exists in the workspace.

Parameters:
path - The path of the workspace resource.
Returns:
boolean value indicating if the named resource exists in the workspace.

getChildren

List<WorkspaceResource> getChildren(String path)
                                    throws WorkspaceResourceNotFoundException
Return the children of the specified workspace folder.

Parameters:
path - The parent folder.
Returns:
List of the children of the parent folder.
Throws:
WorkspaceResourceNotFoundException - The parent folder specified can not be found in the workspace.

getResource

WorkspaceResource getResource(String path)
                              throws WorkspaceResourceNotFoundException
Get a client representation of the specified resource in the workspace.

Parameters:
path - The path of the resource.
Returns:
the workspace resource located at the given path.
Throws:
WorkspaceResourceNotFoundException - Thrown if a resource is not found at that location.

updateFileContents

WorkspaceFile updateFileContents(String path,
                                 String localFilePath)
                                 throws WorkspaceResourceNotFoundException,
                                        IOException
Replace the current content of the workspace file with the content of the specified local file. Use createFile to add new files to the workspace. Use createFile(String, String, boolean) if you wish to put content into a file that doesn't already exist in your workspace.

Parameters:
path - The full path of the existing workspace file to be updated
localFilePath - The name of the local file with the new contents to be put in the workspace file.
Returns:
the updated workspace file
Throws:
WorkspaceResourceNotFoundException - A resource was not found at the specified location.
IOException - see the exception text for more details.

rename

WorkspaceResource rename(String path,
                         String name)
                         throws WorkspaceResourceNotFoundException,
                                WorkspaceResourceExistsException
Rename the workspace resource.

Parameters:
path - The path of the workspace resource to rename.
name - The new name
Returns:
WorkspaceResource Resource with the new name.
Throws:
WorkspaceResourceNotFoundException - A resource was not found at the specified location.
WorkspaceResourceExistsException - A resource already exists in the targetFolder with the name newName.

move

WorkspaceResource move(String sourcePath,
                       String destinationFolderPath)
                       throws WorkspaceResourceNotFoundException,
                              WorkspaceResourceExistsException,
                              WorkspaceResourceMoveException
Move the file or folder from one location to another.

Parameters:
sourcePath - The path of the file or folder to move.
destinationFolderPath - The folder to move the resource to.
Returns:
The newly moved workspace resource.
Throws:
WorkspaceResourceNotFoundException - The specified source resource was not found.
WorkspaceResourceExistsException - A resource already exists at the destination path.
WorkspaceResourceMoveException - The move request was not possible.


Copyright (c) 2014, SAS Institute Inc., Cary, NC, USA