Class orion.fileClient.FileClient
				
				
			
				The file client provides a convenience API for interacting with file services
provided by plugins. This class handles authorization, and authentication-related
error handling.
				
				
					
Defined in:  </jobs/genie.orion/orion-client-stable/workspace/bundles/org.eclipse.orion.client.core/web/orion/fileClient.js>.
				
			
| Constructor Attributes | Constructor Name and Description | 
|---|---|
| Creates a new file client. | 
| Method Attributes | Method Name and Description | 
|---|---|
| changeWorkspace(workspaceLocation)
								 | |
| copyFile(sourceLocation, targetLocation, targetName)
								 Copies a file or directory. | |
| createFile(parentLocation, fileName, eventData)
								 Create a new file in a specified location. | |
| createFolder(parentLocation, folderName, eventData)
								 Creates a folder. | |
| createProject(url, projectName, serverPath, create)
								 Adds a project to a workspace. | |
| createWorkspace(workspaceName)
								 Creates a new workspace with the given name. | |
| deleteFile(deleteLocation, eventData)
								 Deletes a file, directory, project or workspace. | |
| fetchChildren(parentLocation)
								 Obtains the children of a remote resource | |
| fileServiceName(itemLocation)
								 Returns the name of the file service managing this location | |
| fileServiceRootURL(itemLocation)
								 Returns the root url of the file service managing this location | |
| find(sourceLocation, findStr, option)
								 Find a string inside a file | |
| getProject(context)
								 Computes the project context from the given location | |
| getService(itemLocation)
								 Returns the file service managing this location | |
| getWorkspace(resourceLocation)
								 Gets the workspace of the specified resource location. | |
| loadWorkspace(workspaceLocation, onLoad)
								 Loads the workspace with the given id and sets it to be the current
workspace for the IDE. | |
| loadWorkspaces(systemLocation)
								 Loads all the user's workspaces for the specified file system. | |
| moveFile(sourceLocation, targetLocation, targetName)
								 Moves a file or directory. | |
| read(readLocation, isMetadata)
								 Returns the contents or metadata of the file at the given location. | |
| readBlob(readLocation)
								 Returns the blob contents of the file at the given location. | |
| remoteExport(sourceLocation, options)
								 Exports file and directory contents to another server | |
| remoteImport(targetLocation, options, parentLocation)
								 Imports file and directory contents from another server | |
| search(searchParams)
								 Performs a search with the given search parameters. | |
| write(writeLocation, contents, args)
								 Writes the contents or metadata of the file at the given location. | 
					Method Detail
				
				
					 
					
					
					
					changeWorkspace(workspaceLocation)
					
					
					- Parameters:
- workspaceLocation
					
					{Deferred}
					copyFile(sourceLocation, targetLocation, targetName)
					
					
					
						Copies a file or directory.
						
						
					
					
					
					
						
							- Parameters:
- {String} sourceLocation
- The location of the file or directory to copy.
- {String} targetLocation
- The location of the target folder.
- {String} targetName
- The name of the destination file or directory in the case of a rename
- Returns:
- {Deferred} A deferred that will copy the given file to its new location
					
					{Deferred}
					createFile(parentLocation, fileName, eventData)
					
					
					
						Create a new file in a specified location. Returns a deferred that will provide
The new file object when ready.
						
						
					
					
					
					
						
							- Parameters:
- {String} parentLocation
- The location of the parent folder
- {String} fileName
- The name of the file to create
- {Object} eventData
- The event data that will be sent back.
- Returns:
- {Deferred} A deferred that will provide the new file object
					
					{Object, Deferred}
					createFolder(parentLocation, folderName, eventData)
					
					
					
						Creates a folder.
						
						
					
					
					
					
						
							- Parameters:
- {String} parentLocation
- The location of the parent folder
- {String} folderName
- The name of the folder to create
- {Object} eventData
- The event data that will be sent back.
- Returns:
- {Object} JSON representation of the created folder
- {Deferred} A deferred that will create a new folder in the workspace
					
					{Deferred}
					createProject(url, projectName, serverPath, create)
					
					
					
						Adds a project to a workspace.
						
						
					
					
					
					
						
							- Parameters:
- {String} url
- The workspace location
- {String} projectName
- the human-readable name of the project
- {String} serverPath
- The optional path of the project on the server.
- {Boolean} create
- If true, the project is created on the server file system if it doesn't already exist
- Returns:
- {Deferred} A deferred that will create a new project in the workspace
					
					{Deferred}
					createWorkspace(workspaceName)
					
					
					
						Creates a new workspace with the given name. The resulting workspace is
passed as a parameter to the provided onCreate function.
						
						
					
					
					
					
						
							- Parameters:
- {String} workspaceName
- The name of the new workspace
- Returns:
- {Deferred} A deferred that will create a workspace with the given name
					
					{Deferred}
					deleteFile(deleteLocation, eventData)
					
					
					
						Deletes a file, directory, project or workspace.
						
						
					
					
					
					
						
							- Parameters:
- {String} deleteLocation
- The location of the file or directory to delete.
- {Object} eventData
- The event data that will be sent back.
- Returns:
- {Deferred} A deferred that will delete the given file
					
					{Deferred}
					fetchChildren(parentLocation)
					
					
					
						Obtains the children of a remote resource
						
						
					
					
					
					
						
							- Parameters:
- {string} parentLocation
- The location of the item to obtain children for
- Returns:
- {Deferred} A deferred that will provide the array of child objects when complete
					
					{String}
					fileServiceName(itemLocation)
					
					
					
						Returns the name of the file service managing this location
						
						
					
					
					
					
						
							- Parameters:
- {String} itemLocation
- The location of the item
- Returns:
- {String} The name of this file service
					
					{String}
					fileServiceRootURL(itemLocation)
					
					
					
						Returns the root url of the file service managing this location
						
						
					
					
					
					
						
							- Parameters:
- {String} itemLocation
- The location of the item
- Returns:
- {String} The root URL of the given item
					
					{Deferred}
					find(sourceLocation, findStr, option)
					
					
					
						Find a string inside a file
						
						
					
					
					
					
						
							- Parameters:
- {String} sourceLocation
- The location of the folder to export from
- {String} findStr
- The string to search
- option
- Returns:
- {Deferred} A deferred for chaining events after the export completes
					
					
					freezeChangeEvents()
					
					
					
					
					
					getProject(context)
					
					
					
						Computes the project context from the given location
						
						
					
					
					
					
						
							- Parameters:
- {String} context
- The resource context to find the project for
- Since:
- 14.0
					
					{FileClient}
					getService(itemLocation)
					
					
					
						Returns the file service managing this location
						
						
					
					
					
					
						
							- Parameters:
- {String} itemLocation
- The location of the item
- Returns:
- {FileClient} The service for the given item
					
					{Deferred}
					getWorkspace(resourceLocation)
					
					
					
						Gets the workspace of the specified resource location.
						
						
					
					
					
					
						
							- Parameters:
- resourceLocation
- the resource to lookup the workspace
- Returns:
- {Deferred} A deferred that will load the specified workspace
					
					
					isEventFrozen()
					
					
					
					
					{Deferred}
					loadWorkspace(workspaceLocation, onLoad)
					
					
					
						Loads the workspace with the given id and sets it to be the current
workspace for the IDE. The workspace is created if none already exists.
						
						
					
					
					
					
						
							- Parameters:
- {String} workspaceLocation
- the location of the workspace to load
- {Function} onLoad
- the function to invoke when the workspace is loaded
- Returns:
- {Deferred} A deferred that will load the specified workspace
					
					{Deferred}
					loadWorkspaces(systemLocation)
					
					
					
						Loads all the user's workspaces for the specified file system. Returns a deferred
that will provide the loaded workspaces when ready.
						
						
					
					
					
					
						
							- Parameters:
- systemLocation
- Returns:
- {Deferred} A deferred that will load all workspaces
					
					{Deferred}
					moveFile(sourceLocation, targetLocation, targetName)
					
					
					
						Moves a file or directory.
						
						
					
					
					
					
						
							- Parameters:
- {String} sourceLocation
- The location of the file or directory to move.
- {String} targetLocation
- The location of the target folder.
- {String} targetName
- The name of the destination file or directory in the case of a rename
- Returns:
- {Deferred} A deferred that will move the given file to its new location
					
					{Deferred}
					read(readLocation, isMetadata)
					
					
					
						Returns the contents or metadata of the file at the given location.
						
						
					
					
					
					
						
							- Parameters:
- {String} readLocation
- The location of the file to get contents for
- {Boolean} isMetadata Optional
- If defined and true, returns the file metadata, otherwise file contents are returned
- Returns:
- {Deferred} A deferred that will be provided with the contents or metadata when available
					
					{Deferred}
					readBlob(readLocation)
					
					
					
						Returns the blob contents of the file at the given location.
						
						
					
					
					
					
						
							- Parameters:
- {String} readLocation
- The location of the file to get contents for
- Returns:
- {Deferred} A deferred that will be provided with the blob contents when available
					
					{Deferred}
					remoteExport(sourceLocation, options)
					
					
					
						Exports file and directory contents to another server
						
						
					
					
					
					
						
							- Parameters:
- {String} sourceLocation
- The location of the folder to export from
- {Object} options
- An object specifying the export parameters
- Returns:
- {Deferred} A deferred for chaining events after the export completes
					
					{Deferred}
					remoteImport(targetLocation, options, parentLocation)
					
					
					
						Imports file and directory contents from another server
						
						
					
					
					
					
						
							- Parameters:
- {String} targetLocation
- The location of the folder to import into
- {Object} options
- An object specifying the import parameters
- parentLocation
- Returns:
- {Deferred} A deferred for chaining events after the import completes
					
					
					search(searchParams)
					
					
					
						Performs a search with the given search parameters.
						
						
					
					
					
					
						
							- Parameters:
- {Object} searchParams
- The JSON object that describes all the search parameters.
- {String} searchParams.resource
- Required. The location where search is performed. Required. Normally a sub folder of the file system. Empty string means the root of the file system.
- {String} searchParams.keyword
- The search keyword. Required but can be empty string. If fileType is a specific type and the keyword is empty, then list up all the files of that type. If searchParams.regEx is true then the keyword has to be a valid regular expression.
- {String} searchParams.sort
- Required. Defines the order of the return results. Should be either "Path asc" or "Name asc". Extensions are possible but not currently supported.
- {boolean} searchParams.nameSearch
- Optional. If true, the search performs only file name search.
- {String} searchParams.fileType
- Optional. The file type. If specified, search will be performed under this file type. E.g. "*.*" means all file types. "html" means html files.
- {Boolean} searchParams.regEx
- Optional. The option of regular expression search.
- {integer} searchParams.start
- Optional. The zero based start number for the range of the returned hits. E.g if there are 1000 hits in total, then 5 means the 6th hit.
- {integer} searchParams.rows
- Optional. The number of hits of the range. E.g if there are 1000 hits in total and start=5 and rows=40, then the return range is 6th-45th.
- {String} searchParams.fileNamePatterns
- Optional. The file name patterns within which to search. If specified, search will be performed under files which match the provided patterns. Patterns should be comma-separated and may use "*" and "?" as wildcards.
- {[String]} searchParams.exclude
- Optional. An array of file / folder names to exclude from searching
					
					
					thawChangeEvents()
					
					
					
					
					{Deferred}
					write(writeLocation, contents, args)
					
					
					
						Writes the contents or metadata of the file at the given location.
						
						
					
					
					
					
						
							- Parameters:
- {String} writeLocation
- The location of the file to set contents for
- {String|Object} contents
- The content string, or metadata object to write
- {String|Object} args
- Additional arguments used during write operation (i.e. ETag)
- Returns:
- {Deferred} A deferred for chaining events after the write completes with new metadata object