public final class JsonRestClient extends Object implements IRestClient
JsonRestClient
class is an implementation of IRestClient
that works with the ModeShape REST
server that uses JSON as its interface protocol.Constructor and Description |
---|
JsonRestClient() |
Modifier and Type | Method and Description |
---|---|
protected org.modeshape.web.jcr.rest.client.json.JsonRestClient.Version |
determineVersion(String getRepositoriesResponse) |
boolean |
fileExists(File file,
Workspace workspace,
String path)
Checks if the given file exists or not on the server, by issuing a GET request.
|
Map<String,NodeType> |
getNodeTypes(Repository repository)
Obtains the ModeShape node types defined within the specified workspace.
|
Collection<Repository> |
getRepositories(Server server)
Obtains the ModeShape repositories defined within the specified server.
|
URL |
getUrl(File file,
String path,
Workspace workspace)
Returns a url string, representing a "server recognizable" url for a the given file.
|
Collection<Workspace> |
getWorkspaces(Repository repository)
Obtains the workspaces defined within the specified ModeShape respository.
|
static void |
main(String[] args) |
Status |
markAsPublishArea(Workspace workspace,
String path,
String title,
String description)
Marks the last folder of the given path as a publish area, by adding the
mode:publishArea mixin. |
boolean |
pathExists(Workspace workspace,
String path,
File file) |
String |
planForQuery(Workspace workspace,
String language,
String statement,
int offset,
int limit,
Map<String,String> variables)
Compute the plan for the supplied query in the workspace.
|
Status |
publish(Workspace workspace,
String path,
File file)
Publishes, or uploads, a local file to the workspace at the specified path.
|
Status |
publish(Workspace workspace,
String path,
File file,
boolean useVersioning)
Publishes, or uploads, a local file to the workspace at the specified path.
|
List<QueryRow> |
query(Workspace workspace,
String language,
String statement)
Executes the given query in the workspace.
|
List<QueryRow> |
query(Workspace workspace,
String language,
String statement,
int offset,
int limit)
Executes the given query in the workspace.
|
List<QueryRow> |
query(Workspace workspace,
String language,
String statement,
int offset,
int limit,
Map<String,String> variables)
Executes the given query in the workspace.
|
Status |
unmarkAsPublishArea(Workspace workspace,
String path)
Unmarks the last folder of the given path as a publish area, by removing the
mode:publishArea mixin. |
Status |
unpublish(Workspace workspace,
String path,
File file)
Unpublishes, or deletes, the resource at the specified path in the workspace.
|
Server |
validate(Server server)
Determines whether the specified server is valid and can be used to establish a connection.
|
public Server validate(Server server) throws Exception
IRestClient
validate
in interface IRestClient
server
- the server (never null
)null
)Exception
- if there is a problem validating the serverprotected org.modeshape.web.jcr.rest.client.json.JsonRestClient.Version determineVersion(String getRepositoriesResponse) throws Exception
Exception
public Collection<Repository> getRepositories(Server server) throws Exception
IRestClient
getRepositories
in interface IRestClient
server
- the server whose repositories are being requested (never null
)null
)Exception
- if there is a problem obtaining the repositoriespublic Map<String,NodeType> getNodeTypes(Repository repository) throws Exception
IRestClient
getNodeTypes
in interface IRestClient
repository
- for whose node types are being requested (never null
)null
)Exception
- if there is a problem obtaining the node typespublic URL getUrl(File file, String path, Workspace workspace) throws Exception
IRestClient
getUrl
in interface IRestClient
file
- the file whose URL is being requested (never null
)path
- the path in the ModeShape workspace where the file is/could be located (never null
)workspace
- the workspace where the file is/could be located (never null
)null
)Exception
- if there is a problem obtaining the URL or if the file is a directorypublic Collection<Workspace> getWorkspaces(Repository repository) throws Exception
IRestClient
getWorkspaces
in interface IRestClient
repository
- the repository whose workspaces are being requested (never null
)null
)Exception
- if there is a problem obtaining the workspacespublic boolean pathExists(Workspace workspace, String path, File file) throws Exception
workspace
- the workspace being checked (never null
)path
- the path in workspace (never null
)file
- the file being checked (never null
)true
if the file exists in the workspace at the specified pathException
- if there is a problem checking the existence of the filepublic Status publish(Workspace workspace, String path, File file)
IRestClient
"publish(workspace,path,file,false)
".publish
in interface IRestClient
workspace
- the workspace where the resource will be published (never null
)path
- the unencoded path to the folder where the file will be published (never null
)file
- the resource being published (never null
)null
)public boolean fileExists(File file, Workspace workspace, String path) throws Exception
IRestClient
fileExists
in interface IRestClient
file
- the file whose existence is checked, (never null
)workspace
- the workspace where the file is/could be located (never null
)path
- the path in the ModeShape workspace to the parent of the file (never null
)true
if the file exists on the server, or false
otherwise.Exception
- if there is a problem while performing the checkpublic Status publish(Workspace workspace, String path, File file, boolean useVersioning)
IRestClient
publish
in interface IRestClient
workspace
- the workspace where the resource will be published (never null
)path
- the unencoded path to the folder where the file will be published (never null
)file
- the resource being published (never null
)useVersioning
- true if the uploaded file should be versioned, or false if no JCR versioning be usednull
)public Status unpublish(Workspace workspace, String path, File file)
IRestClient
info status
is returned.unpublish
in interface IRestClient
workspace
- the workspace where the resource will be unpublished (never null
)path
- the unencoded path to the folder where the file is published (never null
)file
- the file being unpublished (never null
)null
)public Status markAsPublishArea(Workspace workspace, String path, String title, String description)
IRestClient
mode:publishArea
mixin.
The path is made up of folder segments. If any folder segment does not exist, it will be created.
The folder corresponding to the last path segment will become the publish area.
If the last folder already is a publish area, the title and/or description will be updated.markAsPublishArea
in interface IRestClient
workspace
- the workspace where the operation will be performed (never null
)path
- the unencoded path to the folder which will become the publish area (never null
).title
- an optional String
representing the title of the area (can be null
)description
- an optional String
representing the description of the area (can be null
)null
).public Status unmarkAsPublishArea(Workspace workspace, String path)
IRestClient
mode:publishArea
mixin.
The path is made up of folder segments. If any folder segment does not exist, no changes will be performed
If the last folder segment from the path is not a publish area, no changes will be performed.unmarkAsPublishArea
in interface IRestClient
workspace
- the workspace where the operation will be performed (never null
)path
- the unencoded path to the folder which will be cleared as a publish area (never null
).null
).public List<QueryRow> query(Workspace workspace, String language, String statement) throws Exception
IRestClient
query
in interface IRestClient
workspace
- the workspace where the resource will be unpublished (never null
)language
- the JCR query language to use (never null
)statement
- the query itself (never null
)null
)Exception
- if there is a problem obtaining the workspacespublic List<QueryRow> query(Workspace workspace, String language, String statement, int offset, int limit) throws Exception
IRestClient
query
in interface IRestClient
workspace
- the workspace where the resource will be unpublished (never null
)language
- the JCR query language to use (never null
)statement
- the query itself (never null
)offset
- the first row to be returned; if this value is negative, rows are returned starting with the first rowlimit
- the maximum number of rows to be returned; if this value is negative, all rows are returnednull
)Exception
- if there is a problem obtaining the workspacespublic List<QueryRow> query(Workspace workspace, String language, String statement, int offset, int limit, Map<String,String> variables) throws Exception
IRestClient
query
in interface IRestClient
workspace
- the workspace where the resource will be unpublished (never null
)language
- the JCR query language to use (never null
)statement
- the query itself (never null
)offset
- the first row to be returned; if this value is negative, rows are returned starting with the first rowlimit
- the maximum number of rows to be returned; if this value is negative, all rows are returnedvariables
- the query variables; may be nullnull
)Exception
- if there is a problem obtaining the workspacespublic String planForQuery(Workspace workspace, String language, String statement, int offset, int limit, Map<String,String> variables) throws Exception
IRestClient
planForQuery
in interface IRestClient
workspace
- the workspace where the resource will be unpublished (never null
)language
- the JCR query language to use (never null
)statement
- the query itself (never null
)offset
- the first row to be returned; if this value is negative, rows are returned starting with the first rowlimit
- the maximum number of rows to be returned; if this value is negative, all rows are returnedvariables
- the query variables; may be nullException
- if there is a problem obtaining the workspacespublic static void main(String[] args)
Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.