public class

ServerFolder

extends Object
java.lang.Object
   ↳ com.esri.core.map.ServerFolder

Class Overview

This class represents the directory structure of files on a server. It is intended to be used to retrieve the output of geoprocessing tools and offline tiled layers where a number of files are created and need to be downloaded. Initially a newly created instance of this class will only contain information on the top level folder: the files it contains and the names of any child folders. To access folders deeper inside the folder hierarchy, use the open(boolean) method. If the recursive parameter is false, only the next level of folder information will be retrieved. If it is true, the folder information for the entire folder hierarchy will be retrieved. This allows the structure to be browsed without opening everything unless needed.

To download the entire structure from the server, use the download(String) method. This will open all the folders and download all the files they contain.

Summary

Nested Classes
interface ServerFolder.ProgressListener  
Fields
protected long _totalFiles
Public Constructors
ServerFolder(String name)
Public Methods
void add(ServerFile file)
boolean deleteFolder(ServerFolder folder)
Delete folder.
void download(String parentPath)
Download this instance and all of its child items to the given location on disk.
ServerFile findFile(String filename)
Find the given file.
ServerFolder findFolder(String folderName)
Find folder.
static ServerFolder fromJson(JsonParser parser, String parentFolder, UserCredentials credentials)
Create an instance of this class from a JSON string.
ArrayList<ServerFolder> getChildFolders()
Gets the child folders.
ArrayList<ServerFile> getFiles()
Gets the files.
int getFolderLevel()
Gets the folder level.
String getName()
Gets the name of this folder.
ServerFolder getParent()
Gets the parent folder, or null if this is a top level item.
String getPath()
Gets the path to this folder.
String getUrl()
Gets the url of this folder on the server.
boolean hasFiles()
Checks for files.
boolean moveFolder(ServerFolder folderToMove, ServerFolder destination)
Move folder.
void open(boolean recursive)
Open this folder and get information on the child folders and files that it contains.
void setCredentials(UserCredentials userCredentials)
Sets the credentials.
void setProgressListener(ServerFolder.ProgressListener listener)
Used to set a listener that will be notified of the current download progress.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected long _totalFiles

Public Constructors

public ServerFolder (String name)

Parameters
name String

Public Methods

public void add (ServerFile file)

Parameters
file ServerFile

public boolean deleteFolder (ServerFolder folder)

Delete folder.

Parameters
folder ServerFolder: the folder
Returns
boolean true, if successful

public void download (String parentPath)

Download this instance and all of its child items to the given location on disk.

Parameters
parentPath String: the parent path to save this folder structure to
Throws
Exception
EsriSecurityException
Exception

public ServerFile findFile (String filename)

Find the given file. This will only return the first occurrence of a file with the given name.

Parameters
filename String: the filename to find
Returns
ServerFile the the file, if found, or null
Throws
Exception
EsriSecurityException
Exception

public ServerFolder findFolder (String folderName)

Find folder.

Parameters
folderName String: the folder name
Returns
ServerFolder the server folder
Throws
Exception
EsriSecurityException
Exception

public static ServerFolder fromJson (JsonParser parser, String parentFolder, UserCredentials credentials)

Create an instance of this class from a JSON string. This string will generally be returned by a query to a REST endpoint.

Parameters
parser JsonParser: the parser
parentFolder String: the parent folder
credentials UserCredentials: the credentials needed for server access or null if no authentication is required
Returns
ServerFolder the new server folder instance
Throws
JsonParseException the json parse exception
IOException Signals that an I/O exception has occurred.

public ArrayList<ServerFolder> getChildFolders ()

Gets the child folders.

Returns
ArrayList<ServerFolder> the child folders

public ArrayList<ServerFile> getFiles ()

Gets the files.

Returns
ArrayList<ServerFile> the files

public int getFolderLevel ()

Gets the folder level.

Returns
int the folder level

public String getName ()

Gets the name of this folder.

Returns
String the name

public ServerFolder getParent ()

Gets the parent folder, or null if this is a top level item.

Returns
ServerFolder the parent folder

public String getPath ()

Gets the path to this folder. If we haven't downloaded the structure to disk, this path will be relative to the top level ServerFolder. If we have downloaded the structure to disk, this path will be the absolute path on disk.

Returns
String the path to this folder

public String getUrl ()

Gets the url of this folder on the server.

Returns
String the url

public boolean hasFiles ()

Checks for files.

Returns
boolean true, if successful

public boolean moveFolder (ServerFolder folderToMove, ServerFolder destination)

Move folder.

Parameters
folderToMove ServerFolder: the folder to move
destination ServerFolder: the destination
Returns
boolean true, if successful

public void open (boolean recursive)

Open this folder and get information on the child folders and files that it contains. If recursive is false, only information on this folder's children will be accessed. If recursive is true, information on all child folders will be accessed.

Parameters
recursive boolean: true to open all folders, false to open this one only
Throws
Exception
EsriSecurityException
Exception

public void setCredentials (UserCredentials userCredentials)

Sets the credentials.

Parameters
userCredentials UserCredentials: the new credentials

public void setProgressListener (ServerFolder.ProgressListener listener)

Used to set a listener that will be notified of the current download progress.

Parameters
listener ServerFolder.ProgressListener: will be notified of the current download progress

public String toString ()

Returns
String