|
eXo JCR :: Component :: Extension Service 1.16.0-CR2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader
public class GroovyScript2RestLoader
GroovyScript2RestLoader allows to save a Groovy script in JCR.
| Nested Class Summary | |
|---|---|
protected static class |
GroovyScript2RestLoader.InnerGroovyJaxrsPublisher
|
static class |
GroovyScript2RestLoader.ScriptList
Script list, used for pass script list as JSON. |
static class |
GroovyScript2RestLoader.ScriptMetadata
Script meta-data, used for pass script meta-data as JSON. |
| Field Summary | |
|---|---|
protected List<GroovyScriptAddRepoPlugin> |
addRepoPlugins
|
protected org.exoplatform.container.configuration.ConfigurationManager |
configurationManager
See ConfigurationManager. |
protected org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher |
groovyPublisher
|
protected org.exoplatform.container.xml.InitParams |
initParams
See InitParams. |
protected List<GroovyScript2RestLoaderPlugin> |
loadPlugins
|
protected RegistryService |
registryService
See RegistryService. |
protected RepositoryService |
repositoryService
See RepositoryService. |
protected SessionProviderService |
sessionProviderService
See SessionProviderService |
| Constructor Summary | |
|---|---|
GroovyScript2RestLoader(org.exoplatform.services.rest.impl.ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService,
SessionProviderService sessionProviderService,
org.exoplatform.container.configuration.ConfigurationManager configurationManager,
Handler jcrUrlHandler,
org.exoplatform.container.xml.InitParams params)
|
|
GroovyScript2RestLoader(org.exoplatform.services.rest.impl.ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService,
SessionProviderService sessionProviderService,
org.exoplatform.container.configuration.ConfigurationManager configurationManager,
RegistryService registryService,
org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher groovyPublisher,
Handler jcrUrlHandler,
org.exoplatform.container.xml.InitParams params)
|
|
GroovyScript2RestLoader(org.exoplatform.services.rest.impl.ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService,
SessionProviderService sessionProviderService,
org.exoplatform.container.configuration.ConfigurationManager configurationManager,
RegistryService registryService,
Handler jcrUrlHandler,
org.exoplatform.container.xml.InitParams params)
|
|
| Method Summary | |
|---|---|
void |
addPlugin(org.exoplatform.container.component.ComponentPlugin cp)
|
javax.ws.rs.core.Response |
addScript(InputStream stream,
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
This method is useful for clients that can send script in request body without form-data. |
javax.ws.rs.core.Response |
addScript(Iterator<org.apache.commons.fileupload.FileItem> items,
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
This method is useful for clients that send scripts as file in 'multipart/*' request body. |
protected void |
addScripts()
Add scripts that specified in configuration. |
javax.ws.rs.core.Response |
autoload(String repository,
String workspace,
String path,
boolean state)
Change exo:autoload property. |
protected javax.jcr.Node |
createScript(javax.jcr.Node parent,
String name,
boolean autoload,
InputStream stream)
Create JCR node. |
javax.ws.rs.core.Response |
deleteScript(String repository,
String workspace,
String path)
Remove node that contains groovy script. |
protected String |
getAttributeSmart(Element element,
String attr)
Get attribute value. |
protected static String |
getName(String fullPath)
Extract node's name from full node path. |
String |
getNodeType()
Get node type for store scripts, may throw IllegalStateException
if nodeType not initialized yet. |
protected static String |
getPath(String fullPath)
Extract path to node's parent from full path. |
javax.ws.rs.core.Response |
getScript(String repository,
String workspace,
String path)
Get source code of groovy script. |
javax.ws.rs.core.Response |
getScriptMetadata(String repository,
String workspace,
String path)
Get groovy script's meta-information. |
javax.ws.rs.core.Response |
list(String repository,
String workspace,
String name)
Returns the list of all groovy-scripts found in workspace. |
javax.ws.rs.core.Response |
load(String repository,
String workspace,
String path,
boolean state,
List<String> sources,
List<String> files,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
Deploy groovy script as REST service. |
javax.ws.rs.core.Response |
load(String repository,
String workspace,
String path,
boolean state,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
org.exoplatform.services.rest.ext.groovy.SourceFolder[] src,
org.exoplatform.services.rest.ext.groovy.SourceFile[] files)
Deploy groovy script as REST service. |
protected void |
readParamsFromFile()
Read parameters from file. |
protected void |
readParamsFromRegistryService(SessionProvider sessionProvider)
Read parameters from RegistryService. |
protected void |
setAttributeSmart(Element element,
String attr,
String value)
Set attribute value. |
void |
start()
|
void |
stop()
|
javax.ws.rs.core.Response |
updateScript(InputStream stream,
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
This method is useful for clients that can send script in request body without form-data. |
javax.ws.rs.core.Response |
updateScript(Iterator<org.apache.commons.fileupload.FileItem> items,
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
This method is useful for clients that send scripts as file in 'multipart/*' request body. |
javax.ws.rs.core.Response |
validateScript(String name,
InputStream script,
List<String> sources,
List<String> files)
Check is specified source script contains valid Groovy source
code. |
void |
validateScript(String name,
InputStream script,
org.exoplatform.services.rest.ext.groovy.SourceFolder[] src,
org.exoplatform.services.rest.ext.groovy.SourceFile[] files)
Check is specified source script contains valid Groovy source
code. |
protected void |
writeParamsToRegistryService(SessionProvider sessionProvider)
Write parameters to RegistryService. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher groovyPublisher
protected org.exoplatform.container.xml.InitParams initParams
InitParams.
protected RepositoryService repositoryService
RepositoryService.
protected org.exoplatform.container.configuration.ConfigurationManager configurationManager
ConfigurationManager.
protected RegistryService registryService
RegistryService.
protected SessionProviderService sessionProviderService
SessionProviderService
protected List<GroovyScript2RestLoaderPlugin> loadPlugins
protected List<GroovyScriptAddRepoPlugin> addRepoPlugins
| Constructor Detail |
|---|
public GroovyScript2RestLoader(org.exoplatform.services.rest.impl.ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService,
SessionProviderService sessionProviderService,
org.exoplatform.container.configuration.ConfigurationManager configurationManager,
Handler jcrUrlHandler,
org.exoplatform.container.xml.InitParams params)
binder - binder for RESTful servicesgroovyScriptInstantiator - instantiate groovy scriptsrepositoryService - See RepositoryServicesessionProviderService - See SessionProviderServiceconfigurationManager - for solve resource loading issue in common wayparams - initialized parameters
public GroovyScript2RestLoader(org.exoplatform.services.rest.impl.ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService,
SessionProviderService sessionProviderService,
org.exoplatform.container.configuration.ConfigurationManager configurationManager,
RegistryService registryService,
Handler jcrUrlHandler,
org.exoplatform.container.xml.InitParams params)
binder - binder for RESTful servicesgroovyScriptInstantiator - instantiates Groovy scriptsrepositoryService - See RepositoryServicesessionProviderService - See SessionProviderServiceconfigurationManager - for solve resource loading issue in common wayregistryService - See RegistryServiceparams - initialized parameters
public GroovyScript2RestLoader(org.exoplatform.services.rest.impl.ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator groovyScriptInstantiator,
RepositoryService repositoryService,
SessionProviderService sessionProviderService,
org.exoplatform.container.configuration.ConfigurationManager configurationManager,
RegistryService registryService,
org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher groovyPublisher,
Handler jcrUrlHandler,
org.exoplatform.container.xml.InitParams params)
| Method Detail |
|---|
public String getNodeType()
IllegalStateException
if nodeType not initialized yet.
public void start()
start in interface org.picocontainer.StartableStartable.start()public void stop()
stop in interface org.picocontainer.StartableStartable.stop()public void addPlugin(org.exoplatform.container.component.ComponentPlugin cp)
protected void addScripts()
protected javax.jcr.Node createScript(javax.jcr.Node parent,
String name,
boolean autoload,
InputStream stream)
throws Exception
parent - parent nodename - name of node to be createdstream - data stream for property jcr:data
Exception - if any errors occurs
protected void readParamsFromRegistryService(SessionProvider sessionProvider)
throws javax.jcr.PathNotFoundException,
javax.jcr.RepositoryException
sessionProvider - the SessionProvider
javax.jcr.RepositoryException
javax.jcr.PathNotFoundException
protected void writeParamsToRegistryService(SessionProvider sessionProvider)
throws IOException,
SAXException,
ParserConfigurationException,
javax.jcr.RepositoryException
sessionProvider - the SessionProvider
ParserConfigurationException
SAXException
IOException
javax.jcr.RepositoryException
protected String getAttributeSmart(Element element,
String attr)
element - The element to get attribute valueattr - The attribute name
protected void setAttributeSmart(Element element,
String attr,
String value)
element - The element to set attribute valueattr - The attribute namevalue - The value of attributeprotected void readParamsFromFile()
public javax.ws.rs.core.Response addScript(InputStream stream,
@Context
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
stream - the stream that contains groovy source codeuriInfo - see {{code language=java}}{{/code}}repository - repository nameworkspace - workspace namepath - path to resource to be created
public javax.ws.rs.core.Response addScript(Iterator<org.apache.commons.fileupload.FileItem> items,
@Context
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
items - iterator {{code language=java}}{{/code}}uriInfo - see {{code language=java}}{{/code}}repository - repository nameworkspace - workspace namepath - path to resource to be created
public javax.ws.rs.core.Response validateScript(String name,
InputStream script,
List<String> sources,
List<String> files)
script contains valid Groovy source
code.
name - script name. This name will be used by GroovyClassLoader to
identify script, e.g. specified name will be used in error
message in compilation of Groovy fails. If this parameter is
null then GroovyClassLoader will use automatically
generated namescript - Groovy source streamsources - locations (string representation of URL) of source folders
that should be add in class path when compile Groovy script.
NOTE : To be able load Groovy source files from specified
folders the following rules must be observed:
- Groovy source files must be located in folder with respect
to package structure
- Name of Groovy source files must be the same as name of
class located in file
- Groovy source file must have extension '.groovy'
Example: If source stream that we want validate contains the
following code:
package c.b.a
import a.b.c.A
class B extends A {
// Do something.
}
Assume we store dependencies in JCR then URL of folder with
Groovy sources may be like this:
jcr://repository/workspace#/groovy-library. Then
absolute path to JCR node that contains Groovy source must be as
following: /groovy-library/a/b/c/A.groovyfiles - locations (string representation of URL) of source files that
should be add in class path when compile Groovy script. Each
location must point directly to file that contains Groovy
source. Source file can have any name and extension
public void validateScript(String name,
InputStream script,
org.exoplatform.services.rest.ext.groovy.SourceFolder[] src,
org.exoplatform.services.rest.ext.groovy.SourceFile[] files)
throws org.exoplatform.services.rest.ext.groovy.MalformedScriptException
script contains valid Groovy source
code.
name - script name. This name will be used by GroovyClassLoader to
identify script, e.g. specified name will be used in error
message in compilation of Groovy fails. If this parameter is
null then GroovyClassLoader will use automatically
generated namescript - Groovy source streamsrc - set of folders that contains Groovy source files that should be
add in class-path when validate script, see
ClassPathEntry.getPath(). NOTE To be able load
Groovy source files from specified folders the following rules
must be observed:
files - set of groovy source files that should be add in class-path
when validate script. Each item must point directly
to file that contains Groovy source, see
ClassPathEntry.getPath() . Source file can have any name and
extension
org.exoplatform.services.rest.ext.groovy.MalformedScriptException - if script contains not valid
source code
public javax.ws.rs.core.Response updateScript(InputStream stream,
@Context
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
stream - the stream that contains groovy source codeuriInfo - see {{code language=java}}{{/code}}repository - repository nameworkspace - workspace namepath - path to resource to be created
public javax.ws.rs.core.Response updateScript(Iterator<org.apache.commons.fileupload.FileItem> items,
@Context
javax.ws.rs.core.UriInfo uriInfo,
String repository,
String workspace,
String path)
items - iterator {{code language=java}}{{/code}}uriInfo - see {{code language=java}}{{/code}}repository - repository nameworkspace - workspace namepath - path to resource to be created
@RolesAllowed(value="administrators")
public javax.ws.rs.core.Response load(String repository,
String workspace,
String path,
boolean state,
List<String> sources,
List<String> files,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
repository - repository nameworkspace - workspace namepath - the path to JCR node that contains groovy script to be
deployedstate - true if resource should be loaded and
false otherwise. If this attribute is not present
in HTTP request then it will be considered as truesources - locations (string representation of URL) of source folders
that should be add in class path when compile Groovy script.
NOTE: To be able load Groovy source files from specified
folders the following rules must be observed:
- Groovy source files must be located in folder with respect
to package structure
- Name of Groovy source files must be the same as name of
class located in file
- Groovy source file must have extension '.groovy'
Example: If source stream that we want validate contains the
following code:
package c.b.a
import a.b.c.A
class B extends A {
// Do something.
}
Assume we store dependencies in JCR then URL of folder with
Groovy sources may be like this:
jcr://repository/workspace#/groovy-library. Then
absolute path to JCR node that contains Groovy source must be as
following: /groovy-library/a/b/c/A.groovyfiles - locations (string representation of URL) of source files that
should be add in class path when compile Groovy script. Each
location must point directly to file that contains Groovy
source. Source file can have any name and extensionproperties - optional properties to be applied to loaded resource.
Ignored if state parameter is false
public javax.ws.rs.core.Response load(String repository,
String workspace,
String path,
boolean state,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
org.exoplatform.services.rest.ext.groovy.SourceFolder[] src,
org.exoplatform.services.rest.ext.groovy.SourceFile[] files)
repository - repository nameworkspace - workspace namepath - the path to JCR node that contains groovy script to be
deployedstate - true if resource should be loaded and
false otherwise. If this attribute is not present
in HTTP request then it will be considered as trueproperties - optional properties to be applied to loaded resource.
Ignored if state parameter is falsesrc - set of folders that contains Groovy source files that should be
add in class-path when compile file located at path
. NOTE To be able load Groovy source files from specified
folders the following rules must be observed:
files - set of groovy source files that should be add in class-path
when compile file located at path. Each item must
point directly to file that contains Groovy source, see
ClassPathEntry.getPath() . Source file can have any name and
extension
public javax.ws.rs.core.Response deleteScript(String repository,
String workspace,
String path)
repository - repository nameworkspace - workspace namepath - JCR path to node that contains script
public javax.ws.rs.core.Response autoload(String repository,
String workspace,
String path,
boolean state)
repository - repository nameworkspace - workspace namepath - JCR path to node that contains scriptstate - value for property exo:autoload, if it is not specified then
'true' will be used as default.
Example: .../scripts/groovy/test1.groovy/load is the same to
.../scripts/groovy/test1.groovy/load?state=true
public javax.ws.rs.core.Response getScript(String repository,
String workspace,
String path)
repository - repository nameworkspace - workspace namepath - JCR path to node that contains script
public javax.ws.rs.core.Response getScriptMetadata(String repository,
String workspace,
String path)
repository - repository nameworkspace - workspace namepath - JCR path to node that contains script
public javax.ws.rs.core.Response list(String repository,
String workspace,
String name)
repository - repository nameworkspace - workspace namename - additional search parameter. If not empty method returns the
list of script names matching wildcard else returns all the
scripts found in workspace.
protected static String getPath(String fullPath)
fullPath - full path to node
protected static String getName(String fullPath)
fullPath - full path to node
|
eXo JCR :: Component :: Extension Service 1.16.0-CR2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||