com.gliffy.api.client
Interface RestClient

All Known Implementing Classes:
RestClientImpl

public interface RestClient

A simple interface around the Gliffy REST API. Instances of this class should be instantiated by the call RestClientFactory.getInstance


Nested Class Summary
static class RestClient.HttpAction
          Supported Http Verbs
 
Method Summary
 void authenticate(java.lang.String accountId, java.lang.String username, java.lang.String systemName, java.lang.String apiKey, java.lang.String apiSecret)
          Authenticates and authorizes the use of this RestClient instance.
 Document createDocument(java.lang.String name)
          Create a new document.
 Document createDocument(java.lang.String name, Document document)
          Create a new document from a copy.
 Document createDocument(java.lang.String name, Document document, java.lang.String path)
          Create a new document from a copy and place it in a folder.
 Document createDocument(java.lang.String name, java.lang.String path)
          Create a new document in a folder.
 void createFolder(java.lang.String path)
          Create a folder providing the path of this folder.
 void createUser(java.lang.String username)
          Creates a user with the provided username.
 void deleteDocument(Document document)
          Deletes a document.
 void deleteDocument(java.lang.Long id)
          Deletes a document by id.
 void deleteFolder(java.lang.String path)
          Delete a folder by it's path.
 void deleteUser(java.lang.String username)
          Deletes a user by username.
 void deleteUser(User user)
          Deletes a user.
 Account getAccountInfo(boolean showUsers)
          Returns an account object.
 User getAuthenticatedUser()
          Returns the user associated with this client.
 java.io.InputStream getDocumentAs(Document document, DocumentFileType fileType)
          Get the latest version of the document as a different file type.
 java.io.InputStream getDocumentAs(Document document, DocumentFileType fileType, DocumentSize documentSize)
          Get the latest version of the document as a different file type (scale it if possible).
 java.io.InputStream getDocumentAs(Document document, DocumentFileType fileType, DocumentSize documentSize, java.lang.Long version)
          Get a specific version of the document as a different file type (scale it if possible).
 java.io.InputStream getDocumentAs(Document document, DocumentFileType fileType, java.lang.Long version)
          Get a specific version of a document as a different file type.
 Document getDocumentDetails(Document document)
          Get a document with revision details.
 Document getDocumentDetails(java.lang.Long documentId)
          Get a document with revision details.
 java.util.List<Document> getDocuments()
          Get all documents in an account.
 java.util.List<Document> getDocuments(DocumentSecurity access)
          Get all documents in an account, filtered by public of private access.
 java.util.List<Document> getDocumentsByFolder(java.lang.String path)
          Get all documents found in the folder path.
 Folder getFolders()
          Get the root folder for all users in this account.
 Folder getFolders(java.lang.String username)
          Get the root folder that the following username has access to.
 Folder getFolders(User user)
          Get the root folder that this user has access to.
 java.lang.String getHost()
          Returns the host that this client points to.
 java.net.URL getLaunchLink(Document document, java.net.URL returnLink, java.lang.String returnButtonText)
          Creates an OAuth signed link to launch the Gliffy Editor with the given document.
 java.util.List<User> getUsers()
          Returns all users associated with the authenticated account.
 java.util.List<User> getUsersWithAccessToFolder(java.lang.String path)
          Returns a list of users that have access to a given folder path.
 boolean isSSLEnabled()
          Returns true if all calls will be encrypted.
 boolean isValid()
          Returns true if this client is authenticated.
 void moveDocument(Document document, java.lang.String path)
          Move a document to a new folder path.
 Response request(RestClient.HttpAction action, java.lang.String path)
          A convenience method to send any request to the REST API.
 void setHost(java.lang.String host)
          Sets the host that this client points to.
 void setSSLEnabled(boolean sslEnabled)
          Sets to true if you want all calls to be encrypted.
 void unauthenticate()
          Invalidates this GliffyClient by making a call to delete the API Token.
 void updateDocument(Document document)
          Updates any changes to the document meta-data.
 Document updateDocumentContent(Document document, java.lang.String xmlContent)
          Updates a document with changes provided by the Gliffy xml format.
 Document updateDocumentContent(java.lang.Long id, java.lang.String xmlContent)
          Updates a document by with changes provided by the Gliffy xml format.
 void updateUser(User user)
          Updates user information.
 void updateUserAccessToFolder(java.lang.String username, java.lang.String path, java.util.List<FolderSecurity> access)
          Update a user's access to a folder by username.
 void updateUserAccessToFolder(User user, java.lang.String path, java.util.List<FolderSecurity> access)
          Update a user's access to a folder.
 void updateUserPassword(User user, java.lang.String password)
          Update the password for this user.
 

Method Detail

isSSLEnabled

boolean isSSLEnabled()
Returns true if all calls will be encrypted.

Returns:
true if SSL is enabled

setSSLEnabled

void setSSLEnabled(boolean sslEnabled)
Sets to true if you want all calls to be encrypted. Defaults to false.

Parameters:
sslEnabled - true if the default protocol is https

getHost

java.lang.String getHost()
Returns the host that this client points to.

Returns:
The active host for this client.

setHost

void setHost(java.lang.String host)
Sets the host that this client points to.

Parameters:
host - the host address to point the client to.

getAuthenticatedUser

User getAuthenticatedUser()
Returns the user associated with this client.

Returns:
the authenticated user

isValid

boolean isValid()
Returns true if this client is authenticated.

Returns:
true if this GliffyClient is available to make calls

authenticate

void authenticate(java.lang.String accountId,
                  java.lang.String username,
                  java.lang.String systemName,
                  java.lang.String apiKey,
                  java.lang.String apiSecret)
                  throws ClientException
Authenticates and authorizes the use of this RestClient instance. The system must authenticate the RestClient using the credentials provided by Gliffy. If any functional call is made against this client before authenticating, a ClientException will be thrown. This is an administrative API (B2B), you are performing actions as an admin on behalf of a user.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#createusertoken

Parameters:
accountId - the account id provided to you by Gliffy
username - the administrative user that is logging in
systemName - a short description of the calling application
apiKey - the OAuth key that was provided by Gliffy
apiSecret - the OAuth secret that was provided by Gliffy
Throws:
ClientException - functional errors

unauthenticate

void unauthenticate()
                    throws ClientException
Invalidates this GliffyClient by making a call to delete the API Token.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#deleteusertoken

Throws:
ClientException - functional errors

getAccountInfo

Account getAccountInfo(boolean showUsers)
                       throws ClientException
Returns an account object. Indiciate whether or not you want the user list returned with the account information.

http://www.gliffy.com/developer/apidocs/rest/account.shtml#getinfo

Parameters:
showUsers - return the list of users true/false
Returns:
the account object
Throws:
ClientException - functional errors

getUsers

java.util.List<User> getUsers()
                              throws ClientException
Returns all users associated with the authenticated account.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#getusers

Returns:
the list of users associated with the authenticated account
Throws:
ClientException - functional errors

createUser

void createUser(java.lang.String username)
                throws ClientException
Creates a user with the provided username.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#createuser

Parameters:
username - create a new user with the following username
Throws:
ClientException - functional errors

updateUser

void updateUser(User user)
                throws ClientException
Updates user information.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#updateuser

Parameters:
user - the user to update
Throws:
ClientException - functional errors

updateUserPassword

void updateUserPassword(User user,
                        java.lang.String password)
                        throws ClientException
Update the password for this user.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#updateuser

Parameters:
user - the user to update
password - the new password
Throws:
ClientException - functional errors

deleteUser

void deleteUser(User user)
                throws ClientException
Deletes a user.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#deleteuser

Parameters:
user - the user object to delete
Throws:
ClientException - functional errors

deleteUser

void deleteUser(java.lang.String username)
                throws ClientException
Deletes a user by username.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#deleteuser

Parameters:
username - the username of the user to delete
Throws:
ClientException - functional errors

getFolders

Folder getFolders(User user)
                  throws ClientException
Get the root folder that this user has access to. The Folder object will contain all child folders.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#getfolders

Parameters:
user - the user to filter on
Returns:
the ROOT folder object
Throws:
ClientException - functional errors

getFolders

Folder getFolders(java.lang.String username)
                  throws ClientException
Get the root folder that the following username has access to. The Folder object will contain all child folders.

http://www.gliffy.com/developer/apidocs/rest/user.shtml#getfolders

Parameters:
username - the username of the user
Returns:
the root folder for this user
Throws:
ClientException - functional errors

getFolders

Folder getFolders()
                  throws ClientException
Get the root folder for all users in this account. The Folder object will contain all child folders.

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#list

Returns:
the ROOT folder object
Throws:
ClientException - functional errors

createFolder

void createFolder(java.lang.String path)
                  throws ClientException
Create a folder providing the path of this folder.

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#create

Parameters:
path - the full path to the folder
Throws:
ClientException - functional errors

deleteFolder

void deleteFolder(java.lang.String path)
                  throws ClientException
Delete a folder by it's path.

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#delete

Parameters:
path - the full path to the folder
Throws:
ClientException - functional errors

getUsersWithAccessToFolder

java.util.List<User> getUsersWithAccessToFolder(java.lang.String path)
                                                throws ClientException
Returns a list of users that have access to a given folder path.

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#listusers

Parameters:
path - the full path to the folder
Returns:
a list of users
Throws:
ClientException - functional errors

updateUserAccessToFolder

void updateUserAccessToFolder(User user,
                              java.lang.String path,
                              java.util.List<FolderSecurity> access)
                              throws ClientException
Update a user's access to a folder.

Folder access is granted or revoked by the properties found in FolderSecurity. A list of desired properties are included. Any exclusion of a property means that that property is revoked.

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#grantuser

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#revokeuser

Parameters:
user - the user who desires access
path - the full path to the folder
access - the security access to provide
Throws:
ClientException - functional errors

updateUserAccessToFolder

void updateUserAccessToFolder(java.lang.String username,
                              java.lang.String path,
                              java.util.List<FolderSecurity> access)
                              throws ClientException
Update a user's access to a folder by username.

Folder access is granted or revoked by the properties found in FolderSecurity. A list of desired properties are included. Any exclusion of a property means that that property is revoked.

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#grantuser

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#revokeuser

Parameters:
username - the username of the user
path - the full path to the folder
access - the security access to provide
Throws:
ClientException - functional errors

getDocumentsByFolder

java.util.List<Document> getDocumentsByFolder(java.lang.String path)
                                              throws ClientException
Get all documents found in the folder path.

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

http://www.gliffy.com/developer/apidocs/rest/folder.shtml#listdiagrams

Parameters:
path - folder path
Returns:
a list of documents
Throws:
ClientException - functional errors

getDocuments

java.util.List<Document> getDocuments()
                                      throws ClientException
Get all documents in an account.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#list

Returns:
a list of documents
Throws:
ClientException - functional errors

getDocuments

java.util.List<Document> getDocuments(DocumentSecurity access)
                                      throws ClientException
Get all documents in an account, filtered by public of private access.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#list

Parameters:
access - the security access to filter by
Returns:
a list of documents
Throws:
ClientException - functional errors

getDocumentDetails

Document getDocumentDetails(Document document)
                            throws ClientException
Get a document with revision details.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#get

Parameters:
document - the document
Returns:
more details about this document
Throws:
ClientException - functional errors

getDocumentDetails

Document getDocumentDetails(java.lang.Long documentId)
                            throws ClientException
Get a document with revision details.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#get

Parameters:
documentId - the document id
Returns:
more details about this document
Throws:
ClientException - functional errors

createDocument

Document createDocument(java.lang.String name)
                        throws ClientException
Create a new document.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#create

Parameters:
name - the document name
Returns:
a new document
Throws:
ClientException - functional errors

createDocument

Document createDocument(java.lang.String name,
                        java.lang.String path)
                        throws ClientException
Create a new document in a folder.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#create

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

Parameters:
name - the document name
path - the full folder path
Returns:
a new document
Throws:
ClientException - functional errors

createDocument

Document createDocument(java.lang.String name,
                        Document document)
                        throws ClientException
Create a new document from a copy.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#create

Parameters:
name - the document name
document - the document to copy from
Returns:
a new document
Throws:
ClientException - functional errors

createDocument

Document createDocument(java.lang.String name,
                        Document document,
                        java.lang.String path)
                        throws ClientException
Create a new document from a copy and place it in a folder.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#create

Parameters:
name - the document name
document - the document to copy from
path - the full folder path
Returns:
a new document
Throws:
ClientException - functional errors

getDocumentAs

java.io.InputStream getDocumentAs(Document document,
                                  DocumentFileType fileType)
                                  throws ClientException
Get the latest version of the document as a different file type.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#view

Parameters:
document - the document
fileType - the new file type
Returns:
the document as an inputstream
Throws:
ClientException - functional errors

getDocumentAs

java.io.InputStream getDocumentAs(Document document,
                                  DocumentFileType fileType,
                                  java.lang.Long version)
                                  throws ClientException
Get a specific version of a document as a different file type.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#view

Parameters:
document - the document
fileType - the new file type
version - the version to get
Returns:
the document as an inputstream
Throws:
ClientException - functional errors

getDocumentAs

java.io.InputStream getDocumentAs(Document document,
                                  DocumentFileType fileType,
                                  DocumentSize documentSize)
                                  throws ClientException
Get the latest version of the document as a different file type (scale it if possible).

http://www.gliffy.com/developer/apidocs/rest/document.shtml#view

Parameters:
document - the document
fileType - the new file type
documentSize - the compressed size
Returns:
the document as an inputstream
Throws:
ClientException - functional errors

getDocumentAs

java.io.InputStream getDocumentAs(Document document,
                                  DocumentFileType fileType,
                                  DocumentSize documentSize,
                                  java.lang.Long version)
                                  throws ClientException
Get a specific version of the document as a different file type (scale it if possible).

http://www.gliffy.com/developer/apidocs/rest/document.shtml#view

Parameters:
document - the document
fileType - the new file type
documentSize - the compressed size
version - the version to get
Returns:
the document as an inputstream
Throws:
ClientException - functional errors

updateDocument

void updateDocument(Document document)
                    throws ClientException
Updates any changes to the document meta-data. NOTE: Only two properties will be observed for changes in a document. The document name and public visibility. Document.setName() and Document.setIsPublic()

http://www.gliffy.com/developer/apidocs/rest/document.shtml#update

Parameters:
document - the document to act on
Throws:
ClientException - functional errors

updateDocumentContent

Document updateDocumentContent(Document document,
                               java.lang.String xmlContent)
                               throws ClientException
Updates a document with changes provided by the Gliffy xml format.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#update

Parameters:
document - the document to act on
xmlContent - document changes in gliffy xml format
Returns:
the updated document meta data
Throws:
ClientException - functional errors

updateDocumentContent

Document updateDocumentContent(java.lang.Long id,
                               java.lang.String xmlContent)
                               throws ClientException
Updates a document by with changes provided by the Gliffy xml format.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#update

Parameters:
id - the document id
xmlContent - document changes in gliffy xml format
Returns:
the updated document meta data
Throws:
ClientException - functional errors

deleteDocument

void deleteDocument(Document document)
                    throws ClientException
Deletes a document.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#delete

Parameters:
document - the document to act on
Throws:
ClientException - functional errors

deleteDocument

void deleteDocument(java.lang.Long id)
                    throws ClientException
Deletes a document by id.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#delete

Parameters:
id - the document id
Throws:
ClientException - functional errors

moveDocument

void moveDocument(Document document,
                  java.lang.String path)
                  throws ClientException
Move a document to a new folder path.

All folder paths must begin with the folder named ROOT. The folder seperator to be used is a forward slash. The following is a valid folder path: "ROOT/my new folder/my sub folder". Note, an exception will be thrown if the folder "my new folder" does not exist.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#putfolder

Parameters:
document - the document to act on
path - the destination folder path
Throws:
ClientException - functional errors

getLaunchLink

java.net.URL getLaunchLink(Document document,
                           java.net.URL returnLink,
                           java.lang.String returnButtonText)
Creates an OAuth signed link to launch the Gliffy Editor with the given document.

http://www.gliffy.com/developer/apidocs/rest/document.shtml#putfolder

Parameters:
document - the document to launch
returnLink - the url to return the user to
returnButtonText - the text on the button that returns the user
Returns:
the url for launching the Gliffy editor

request

Response request(RestClient.HttpAction action,
                 java.lang.String path)
                 throws ClientException
A convenience method to send any request to the REST API.

Parameters:
action - http verb
path - the portion of the URL immediately following the API ROOT. This path must begin with a forward slash '/'
Returns:
Response object
Throws:
ClientException - functional errors