Package ome.services.blitz.impl
Class ScriptI
- java.lang.Object
-
- ome.services.blitz.impl.AbstractAmdServant
-
- ome.services.blitz.impl.ScriptI
-
- All Implemented Interfaces:
BlitzOnly,ServiceFactoryAware,_IScriptOperations,_ServiceInterfaceOperations,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class ScriptI extends AbstractAmdServant implements _IScriptOperations, ServiceFactoryAware, BlitzOnly
implementation of the IScript service interface.- Since:
- 3.0-Beta3
-
-
Field Summary
Fields Modifier and Type Field Description protected ome.security.ACLVoteraclVoterprotected ParamsCachecacheprotected ome.util.checksum.ChecksumProviderFactorycpfprotected ServiceFactoryIfactoryprotected ome.security.basic.OmeroInterceptorinterceptorprotected ome.services.scripts.ScriptRepoHelperscripts
-
Constructor Summary
Constructors Constructor Description ScriptI(BlitzExecutor be, ome.services.scripts.ScriptRepoHelper scripts, ome.security.ACLVoter aclVoter, ome.security.basic.OmeroInterceptor interceptor, ome.util.checksum.ChecksumProviderFactory cpf, ParamsCache cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ParamsHelper.Acquireracquirer()voidcanRunScript_async(AMD_IScript_canRunScript __cb, long scriptID, Ice.Current __current)Returns true if there is a processor which will run the given script.voiddeleteScript_async(AMD_IScript_deleteScript cb, long id, Ice.Current __current)Delete the script with id from the server.voideditScript_async(AMD_IScript_editScript __cb, OriginalFile fileObject, java.lang.String scriptText, Ice.Current __current)Modify the text for the given script object.voidgetParams_async(AMD_IScript_getParams __cb, long id, Ice.Current __current)Get the Parameters of the script.voidgetScriptID_async(AMD_IScript_getScriptID __cb, java.lang.String scriptPath, Ice.Current __current)Get the id of the official script with given path.voidgetScripts_async(AMD_IScript_getScripts __cb, Ice.Current __current)Get Scripts will return all the scripts by id and name available on the server.voidgetScriptsByMimetype_async(AMD_IScript_getScriptsByMimetype __cb, java.lang.String mimetype, Ice.Current __current)Get Scripts will return all the scripts by id and name available on the server.voidgetScriptText_async(AMD_IScript_getScriptText __cb, long id, Ice.Current __current)Return the script with the name to the user.voidgetScriptWithDetails_async(AMD_IScript_getScriptWithDetails __cb, long id, Ice.Current __current)Return the script with the name to the user.voidgetUserScripts_async(AMD_IScript_getUserScripts __cb, java.util.List<IObject> acceptsList, Ice.Current __current)Returns non-official scripts which have been uploaded by individual users.voidrunScript_async(AMD_IScript_runScript __cb, long scriptID, java.util.Map<java.lang.String,RType> inputs, RInt waitSecs, Ice.Current __current)IfResourceErroris thrown, then noProcessoris available.voidsetServiceFactory(ServiceFactoryI sf)voiduploadOfficialScript_async(AMD_IScript_uploadOfficialScript __cb, java.lang.String path, java.lang.String scriptText, Ice.Current __current)LikeuploadScriptbut is only callable by administrators.voiduploadScript_async(AMD_IScript_uploadScript __cb, java.lang.String path, java.lang.String scriptText, Ice.Current __current)Upload script to the server.voidvalidateScript_async(AMD_IScript_validateScript __cb, Job j, java.util.List<IObject> acceptsList, Ice.Current __current)Used internally by processor.py to check if the script attached to theJobhas a valid script attached, based on theacceptsListand the current security context.-
Methods inherited from class ome.services.blitz.impl.AbstractAmdServant
activate_async, applyHardWiredInterceptors, callInvokerOnMappedArgs, callInvokerOnRawArgs, executorWorkCall, getCurrentEventContext_async, onSetOmeroContext, passivate_async, runnableCall, safeRunnableCall, setApplicationContext, setHolder
-
-
-
-
Field Detail
-
factory
protected ServiceFactoryI factory
-
cache
protected ParamsCache cache
-
scripts
protected final ome.services.scripts.ScriptRepoHelper scripts
-
aclVoter
protected final ome.security.ACLVoter aclVoter
-
interceptor
protected final ome.security.basic.OmeroInterceptor interceptor
-
cpf
protected final ome.util.checksum.ChecksumProviderFactory cpf
-
-
Constructor Detail
-
ScriptI
public ScriptI(BlitzExecutor be, ome.services.scripts.ScriptRepoHelper scripts, ome.security.ACLVoter aclVoter, ome.security.basic.OmeroInterceptor interceptor, ome.util.checksum.ChecksumProviderFactory cpf, ParamsCache cache)
-
-
Method Detail
-
setServiceFactory
public void setServiceFactory(ServiceFactoryI sf) throws ServerError
- Specified by:
setServiceFactoryin interfaceServiceFactoryAware- Throws:
ServerError
-
acquirer
protected ParamsHelper.Acquirer acquirer() throws ServerError
- Throws:
ServerError
-
runScript_async
public void runScript_async(AMD_IScript_runScript __cb, long scriptID, java.util.Map<java.lang.String,RType> inputs, RInt waitSecs, Ice.Current __current) throws ServerError
Description copied from interface:_IScriptOperationsIfResourceErroris thrown, then noProcessoris available. UsescheduleJobto create aScriptJobin the Waiting state. AProcessormay become available.
Thetry: proc = scriptService.runScript(1, {}, None) except ResourceError: job = scriptService.scheduleScript(1, {}, None)ScriptProcessproxy MUST be closed before exiting. If you would like the script execution to continue in the background, passTrueas the argument.try: proc.poll() # See if process is finished finally: proc.close(True) # Detach and execution can continue # proc.close(False) # OR script is immediately stopped.- Specified by:
runScript_asyncin interface_IScriptOperations- Parameters:
__cb- The callback object for the operation.__current- The Current object for the invocation.- Throws:
ServerError
-
canRunScript_async
public void canRunScript_async(AMD_IScript_canRunScript __cb, long scriptID, Ice.Current __current) throws ServerError
Description copied from interface:_IScriptOperationsReturns true if there is a processor which will run the given script.Either the script is an official script and this method will return true (though an individual invocation may fail with an
ResourceErrorfor some reason) or this is a user script, and a usermode processor must be active which takes the scripts user or group.- Specified by:
canRunScript_asyncin interface_IScriptOperations- Parameters:
__cb- The callback object for the operation.__current- The Current object for the invocation.- Throws:
ServerError
-
getScriptID_async
public void getScriptID_async(AMD_IScript_getScriptID __cb, java.lang.String scriptPath, Ice.Current __current) throws ServerError
Get the id of the official script with given path.- Specified by:
getScriptID_asyncin interface_IScriptOperations- Parameters:
__cb- The script context.scriptPath-OriginalFile.getPath()of the script to find id for.__current- ice context.- Throws:
ServerError
-
uploadScript_async
public void uploadScript_async(AMD_IScript_uploadScript __cb, java.lang.String path, java.lang.String scriptText, Ice.Current __current) throws ServerError
Upload script to the server.- Specified by:
uploadScript_asyncin interface_IScriptOperations- Parameters:
path- the path to the scriptscriptText- the content for the new script__current- ice context.__cb- The callback object for the operation.- Throws:
ServerError
-
uploadOfficialScript_async
public void uploadOfficialScript_async(AMD_IScript_uploadOfficialScript __cb, java.lang.String path, java.lang.String scriptText, Ice.Current __current) throws ServerError
Description copied from interface:_IScriptOperationsLikeuploadScriptbut is only callable by administrators. The parameters for the script are also checked.- Specified by:
uploadOfficialScript_asyncin interface_IScriptOperations- Parameters:
__cb- The callback object for the operation.__current- The Current object for the invocation.- Throws:
ServerError
-
editScript_async
public void editScript_async(AMD_IScript_editScript __cb, OriginalFile fileObject, java.lang.String scriptText, Ice.Current __current) throws ServerError
Description copied from interface:_IScriptOperationsModify the text for the given script object.- Specified by:
editScript_asyncin interface_IScriptOperations- Parameters:
__cb- The callback object for the operation.fileObject- see above.__current- The Current object for the invocation.- Throws:
ServerError
-
getScriptWithDetails_async
public void getScriptWithDetails_async(AMD_IScript_getScriptWithDetails __cb, long id, Ice.Current __current) throws ServerError
Return the script with the name to the user.- Specified by:
getScriptWithDetails_asyncin interface_IScriptOperations- Parameters:
id- see above.__current- ice context.__cb- The callback object for the operation.- Throws:
ServerError- validation, api usage.
-
getScriptText_async
public void getScriptText_async(AMD_IScript_getScriptText __cb, long id, Ice.Current __current) throws ServerError
Return the script with the name to the user.- Specified by:
getScriptText_asyncin interface_IScriptOperations- Parameters:
id- see above.__current- ice context.__cb- The callback object for the operation.- Throws:
ServerError- validation, api usage.
-
getParams_async
public void getParams_async(AMD_IScript_getParams __cb, long id, Ice.Current __current) throws ServerError
Get the Parameters of the script.- Specified by:
getParams_asyncin interface_IScriptOperations- Parameters:
id- see above.__current- Ice context__cb- The callback object for the operation.- Throws:
ServerError- validation, api usage.
-
getScripts_async
public void getScripts_async(AMD_IScript_getScripts __cb, Ice.Current __current) throws ServerError
Get Scripts will return all the scripts by id and name available on the server.- Specified by:
getScripts_asyncin interface_IScriptOperations- Parameters:
__current- ice context,__cb- The callback object for the operation.- Throws:
ServerError- validation, api usage.
-
getScriptsByMimetype_async
public void getScriptsByMimetype_async(AMD_IScript_getScriptsByMimetype __cb, java.lang.String mimetype, Ice.Current __current) throws ServerError
Get Scripts will return all the scripts by id and name available on the server.- Specified by:
getScriptsByMimetype_asyncin interface_IScriptOperations- Parameters:
mimetype- The mimetype of the scripts to retrieve.__current- ice context,__cb- The callback object for the operation.- Throws:
ServerError- validation, api usage.
-
getUserScripts_async
public void getUserScripts_async(AMD_IScript_getUserScripts __cb, java.util.List<IObject> acceptsList, Ice.Current __current) throws ServerError
Description copied from interface:_IScriptOperationsReturns non-official scripts which have been uploaded by individual users. These scripts will not be run by the server, though a user can start a personal usermode processor which will allow the scripts to be executed. This is particularly useful for testing new scripts.- Specified by:
getUserScripts_asyncin interface_IScriptOperations- Parameters:
__cb- The callback object for the operation.__current- The Current object for the invocation.- Throws:
ServerError
-
validateScript_async
public void validateScript_async(AMD_IScript_validateScript __cb, Job j, java.util.List<IObject> acceptsList, Ice.Current __current) throws ServerError
Description copied from interface:_IScriptOperationsUsed internally by processor.py to check if the script attached to theJobhas a valid script attached, based on theacceptsListand the current security context. An example of an acceptsList might beExperimenter(myUserId, False)
, meaning that only scripts belonging to me should be trusted. An empty list implies that the server should return what it would by default trust. A valid script will be returned if it exists; otherwise null.- Specified by:
validateScript_asyncin interface_IScriptOperations- Parameters:
__cb- The callback object for the operation.__current- The Current object for the invocation.- Throws:
ServerError
-
deleteScript_async
public void deleteScript_async(AMD_IScript_deleteScript cb, long id, Ice.Current __current) throws ServerError
Delete the script with id from the server.- Specified by:
deleteScript_asyncin interface_IScriptOperations- Parameters:
id- the id of the script to delete.cb- The callback object for the operation.__current- The Current object for the invocation.- Throws:
ServerError
-
-