类 ScriptingController
- java.lang.Object
-
- org.elastos.hive.vault.scripting.ScriptingController
-
public class ScriptingController extends java.lang.ObjectThe wrapper class to access the scripting APIs of the hive node.
-
-
构造器概要
构造器 构造器 说明 ScriptingController(NodeRPCConnection connection, boolean anonymous)Create by the RPC connection.
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 <T> TcallScript(java.lang.String name, com.fasterxml.jackson.databind.JsonNode params, java.lang.String targetDid, java.lang.String targetAppDid, java.lang.Class<T> resultType)Run the registered script.<T> TcallScriptUrl(java.lang.String name, java.lang.String params, java.lang.String targetDid, java.lang.String targetAppDid, java.lang.Class<T> resultType)Call the script by the URL parameters.<T> TdownloadFile(java.lang.String transactionId, java.lang.Class<T> resultType)Download file really by transaction ID.static <T> TdownloadFileByHiveUrl(java.lang.String hiveUrl, java.lang.Class<T> resultType, AppContext context)java.util.List<ScriptContent>getScripts(java.lang.String name, int skip, int limit)Get the registered scripts.voidregisterScript(java.lang.String name, Condition condition, Executable executable, boolean allowAnonymousUser, boolean allowAnonymousApp)Register a script on the hive node.voidunregisterScript(java.lang.String name)Unregister the script.<T> TuploadFile(java.lang.String transactionId, java.lang.Class<T> resultType)Upload file really by transaction ID.
-
-
-
构造器详细资料
-
ScriptingController
public ScriptingController(NodeRPCConnection connection, boolean anonymous)
Create by the RPC connection.- 参数:
connection- The RPC connection.anonymous- whether access anonymously.
-
-
方法详细资料
-
registerScript
public void registerScript(java.lang.String name, Condition condition, Executable executable, boolean allowAnonymousUser, boolean allowAnonymousApp) throws HiveExceptionRegister a script on the hive node.- 参数:
name- The name of the script.condition- The condition of the script. To run the script normally, the condition must be matched.executable- The executable represents an executed action.allowAnonymousUser- If allow the anonymous user to run the script.allowAnonymousApp- If allow the anonymous application to run the script.- 抛出:
HiveException- The error comes from the hive node.
-
getScripts
public java.util.List<ScriptContent> getScripts(java.lang.String name, int skip, int limit) throws HiveException
Get the registered scripts.- 参数:
name- the specific script nameskip- skip, default 0limit- limit, default 0- 返回:
- the list of the scripts.
- 抛出:
HiveException- The error comes from the hive node.
-
callScript
public <T> T callScript(java.lang.String name, com.fasterxml.jackson.databind.JsonNode params, java.lang.String targetDid, java.lang.String targetAppDid, java.lang.Class<T> resultType) throws HiveExceptionRun the registered script. The runner is not the owner of the script normally.- 类型参数:
T- Same as result type.- 参数:
name- The name of the script.params- The parameters to run the script.targetDid- The owner of the script.targetAppDid- The application DID owns the script.resultType- Supported type: String, byte[], JsonNode, Reader, other Json relating types.- 返回:
- The instance of the result type.
- 抛出:
HiveException- SeeHiveException
-
callScriptUrl
public <T> T callScriptUrl(java.lang.String name, java.lang.String params, java.lang.String targetDid, java.lang.String targetAppDid, java.lang.Class<T> resultType) throws HiveExceptionCall the script by the URL parameters. Same ascallScript(String, JsonNode, String, String, Class).- 类型参数:
T- Same as resultType.- 参数:
name- The name of the script.params- The parameters to run the script.targetDid- The owner of the script.targetAppDid- The application DID owns the script.resultType- Supported type: String, byte[], JsonNode, Reader, other Json relating types.- 返回:
- The instance of the result type.
- 抛出:
HiveException- SeeHiveException
-
uploadFile
public <T> T uploadFile(java.lang.String transactionId, java.lang.Class<T> resultType) throws HiveExceptionUpload file really by transaction ID.- 类型参数:
T- The result type.- 参数:
transactionId- The transaction ID got by calling script.resultType- Supported type:OutputStream,OutputStreamWriter- 返回:
- The instance of the result type.
- 抛出:
HiveException- SeeHiveException
-
downloadFile
public <T> T downloadFile(java.lang.String transactionId, java.lang.Class<T> resultType) throws HiveExceptionDownload file really by transaction ID.- 类型参数:
T- The result type.- 参数:
transactionId- The transaction ID got by calling script.resultType- Supported type:InputStream,InputStreamReader- 返回:
- The instance of the result type.
- 抛出:
HiveException- SeeHiveException
-
downloadFileByHiveUrl
public static <T> T downloadFileByHiveUrl(java.lang.String hiveUrl, java.lang.Class<T> resultType, AppContext context) throws HiveException- 抛出:
HiveException
-
unregisterScript
public void unregisterScript(java.lang.String name) throws HiveExceptionUnregister the script.- 参数:
name- The name of the script.- 抛出:
HiveException- SeeHiveException
-
-