Class Utils
- java.lang.Object
-
- es.bsc.dataclay.communication.grpc.Utils
-
public final class Utils extends Object
Utility class for communication.
-
-
Field Summary
Fields Modifier and Type Field Description protected static boolean
DEBUG_ENABLED
Indicates if debug is enabled.protected static char[]
hexArray
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Queue<String>
bytesToHex(byte[] bytes)
Get bytes to hexadecimal Stringsstatic void
checkIsExc(CommonMessages.ExceptionInfo response)
Verifies if response message isException and if this is the case print and raise it properlystatic AccountID
getAccountID(String idMsg)
Get AccountID ID from Protobuf IDstatic ContractID
getContractID(String idMsg)
Get ContractID from Protobuf IDstatic PasswordCredential
getCredential(CommonMessages.Credential cred)
Get password credentialstatic CommonMessages.Credential
getCredential(PasswordCredential cred)
Get password credentialstatic CredentialID
getCredentialID(String idMsg)
Get CredentialID from Protobuf IDstatic DataClayInstance
getDataClayInstance(CommonMessages.DataClayInstance dataClayInstanceMsg)
Return an object FROM grpc messagestatic CommonMessages.DataClayInstance
getDataClayInstance(DataClayInstance dataClayInstance)
Return a message for GRPC callstatic DataClayInstanceID
getDataClayInstanceID(String idMsg)
Get DataClayID from Protobuf IDstatic DataContractID
getDataContractID(String idMsg)
Get DataContractID from Protobuf IDstatic DataSetID
getDataSetID(String idMsg)
Get DataSetID from Protobuf IDstatic ECAID
getECAID(String idMsg)
Get ECAID from Protobuf IDstatic EventMessageID
getEventMessageID(String idMsg)
Get EventMessageID from Protobuf IDstatic EventObjsMeetConditionID
getEventObjsMeetConditionID(String idMsg)
Get EventObjsMeetConditionID from Protobuf IDstatic ExecutionEnvironment
getExecutionEnvironment(CommonMessages.ExecutionEnvironmentInfo msg)
Return an object FROM grpc messagestatic CommonMessages.ExecutionEnvironmentInfo
getExecutionEnvironment(ExecutionEnvironment object)
Return a message for GRPC callstatic ExecutionEnvironmentID
getExecutionEnvironmentID(String idMsg)
Get ExecutionEnvironmentID from Protobuf IDstatic ImmutableParamOrReturn
getImmutableParamOrReturn(CommonMessages.ImmutableParamOrReturn paramOrRet)
Return the immutable instance included in the specified messagestatic CommonMessages.ImmutableParamOrReturn
getImmutableParamOrReturn(ImmutableParamOrReturn paramOrRet)
Return a message including the specified immutable objectstatic ImplementationID
getImplementationID(String idMsg)
Get ImplementationID from Protobuf IDstatic InterfaceID
getInterfaceID(String idMsg)
Get InterfaceID from Protobuf IDstatic LanguageParamOrReturn
getLanguageParamOrReturn(CommonMessages.LanguageParamOrReturn paramOrRet)
Return an instance of language object included in the specified messagestatic CommonMessages.LanguageParamOrReturn
getLanguageParamOrReturn(LanguageParamOrReturn paramOrRet)
Return a message containing a language object (parameter or return)static MetaClassID
getMetaClassID(String idMsg)
Get MetaClassID from Protobuf IDstatic DataClayObjectMetaData
getMetaData(CommonMessages.DataClayObjectMetaData msg)
Retrieve the metadata from the specified msg objectstatic CommonMessages.DataClayObjectMetaData
getMetaData(DataClayObjectMetaData metadata)
Get MetaData GRPC message from DataClayMetaDatastatic MetaDataInfo
getMetaDataInfo(CommonMessages.MetaDataInfo msg)
Return an object FROM grpc messagestatic CommonMessages.MetaDataInfo
getMetaDataInfo(MetaDataInfo object)
Return a message for GRPC callstatic String
getMsgID(ID id)
Get string representation of IDstatic NamespaceID
getNamespaceID(String idMsg)
Get NamespaceID from Protobuf IDstatic int
getNumBytesNeededInVLQInt(int numNextBytes)
Get number of bytes needed for a GRPC tagstatic ObjectID
getObjectID(String idMsg)
Get ObjectID from Protobuf IDstatic ObjectWithDataParamOrReturn
getObjectWithDataParamOrReturn(CommonMessages.ObjectWithDataParamOrReturn volParamOrRet)
Obtain the object with data (parameter or return) from the specified messagestatic CommonMessages.ObjectWithDataParamOrReturn
getObjectWithDataParamOrReturn(ObjectWithDataParamOrReturn volParamOrRet)
Return a message containing an object with data (parameter or return)static OperationID
getOperationID(String idMsg)
Get OperationID from Protobuf IDstatic SerializedParametersOrReturn
getParamsOrReturn(CommonMessages.SerializedParametersOrReturn serParamsOrRetMsg)
Return a serialized param or return object from the specified messagestatic CommonMessages.SerializedParametersOrReturn
getParamsOrReturn(SerializedParametersOrReturn serParamsOrRet)
Return the message including the specified serialized param or return objectstatic PersistentParamOrReturn
getPersistentParamOrReturn(CommonMessages.PersistentParamOrReturn paramOrRet)
Return the param or return object included in the specified messagestatic CommonMessages.PersistentParamOrReturn
getPersistentParamOrReturn(PersistentParamOrReturn paramOrRet)
Return a message including the specified param or return objectstatic PropertyID
getPropertyID(String idMsg)
Get PropertyID from Protobuf IDstatic QualitativeRegistryID
getQualitativeRegistryID(String idMsg)
Get QualitativeRegistryID from Protobuf IDstatic ResourceID
getResourceID(String idMsg)
Get ResourceID from Protobuf IDstatic SessionID
getSessionID(String idMsg)
Get SessionID from Protobuf IDstatic StorageLocation
getStorageLocation(CommonMessages.StorageLocationInfo msg)
Return an object FROM grpc messagestatic CommonMessages.StorageLocationInfo
getStorageLocation(StorageLocation object)
Return a message for GRPC callstatic StorageLocationID
getStorageLocationID(String idMsg)
Get StorageLocationID from Protobuf IDstatic void
printBytesHeader(Queue<String> byteStr, int byteIndex)
Print bytes headerstatic void
printMsg(com.google.protobuf.GeneratedMessageV3 msg)
Print GRPC message (pretty)static void
returnExceptionInfoMessage(io.grpc.stub.StreamObserver<CommonMessages.ExceptionInfo> responseObserver)
Return ExceptionInfo messagestatic CommonMessages.ExceptionInfo
serializeException(Exception ex)
Serialize Exception
-
-
-
Method Detail
-
getMsgID
public static String getMsgID(ID id)
Get string representation of ID- Parameters:
id
- ID to get representation from- Returns:
- String represation or null if id is null
-
getCredential
public static PasswordCredential getCredential(CommonMessages.Credential cred)
Get password credential- Parameters:
cred
- Credential- Returns:
- Password credential
-
getAccountID
public static AccountID getAccountID(String idMsg)
Get AccountID ID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- AccountID
-
getContractID
public static ContractID getContractID(String idMsg)
Get ContractID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- ContractID
-
getCredentialID
public static CredentialID getCredentialID(String idMsg)
Get CredentialID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- CredentialID
-
getDataContractID
public static DataContractID getDataContractID(String idMsg)
Get DataContractID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- DataContractID
-
getDataSetID
public static DataSetID getDataSetID(String idMsg)
Get DataSetID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- DataSetID
-
getNamespaceID
public static NamespaceID getNamespaceID(String idMsg)
Get NamespaceID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- NamespaceID
-
getECAID
public static ECAID getECAID(String idMsg)
Get ECAID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- ECAID
-
getEventMessageID
public static EventMessageID getEventMessageID(String idMsg)
Get EventMessageID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- EventMessageID
-
getEventObjsMeetConditionID
public static EventObjsMeetConditionID getEventObjsMeetConditionID(String idMsg)
Get EventObjsMeetConditionID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- EventObjsMeetConditionID
-
getExecutionEnvironmentID
public static ExecutionEnvironmentID getExecutionEnvironmentID(String idMsg)
Get ExecutionEnvironmentID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- ExecutionEnvironmentID
-
getImplementationID
public static ImplementationID getImplementationID(String idMsg)
Get ImplementationID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- ImplementationID
-
getInterfaceID
public static InterfaceID getInterfaceID(String idMsg)
Get InterfaceID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- InterfaceID
-
getMetaClassID
public static MetaClassID getMetaClassID(String idMsg)
Get MetaClassID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- MetaClassID
-
getObjectID
public static ObjectID getObjectID(String idMsg)
Get ObjectID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- ObjectID
-
getOperationID
public static OperationID getOperationID(String idMsg)
Get OperationID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- OperationID
-
getPropertyID
public static PropertyID getPropertyID(String idMsg)
Get PropertyID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- PropertyID
-
getQualitativeRegistryID
public static QualitativeRegistryID getQualitativeRegistryID(String idMsg)
Get QualitativeRegistryID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- QualitativeRegistryID
-
getResourceID
public static ResourceID getResourceID(String idMsg)
Get ResourceID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- ResourceID
-
getSessionID
public static SessionID getSessionID(String idMsg)
Get SessionID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- SessionID
-
getStorageLocationID
public static StorageLocationID getStorageLocationID(String idMsg)
Get StorageLocationID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- StorageLocationID
-
getDataClayInstanceID
public static DataClayInstanceID getDataClayInstanceID(String idMsg)
Get DataClayID from Protobuf ID- Parameters:
idMsg
- Message ID- Returns:
- DataClayID
-
getCredential
public static CommonMessages.Credential getCredential(PasswordCredential cred)
Get password credential- Parameters:
cred
- Credential- Returns:
- Password credential
-
returnExceptionInfoMessage
public static void returnExceptionInfoMessage(io.grpc.stub.StreamObserver<CommonMessages.ExceptionInfo> responseObserver)
Return ExceptionInfo message- Parameters:
responseObserver
- Observer
-
getMetaData
public static CommonMessages.DataClayObjectMetaData getMetaData(DataClayObjectMetaData metadata)
Get MetaData GRPC message from DataClayMetaData- Parameters:
metadata
- DataClayMetaData- Returns:
- MetaData GRPC message
-
getMetaData
public static DataClayObjectMetaData getMetaData(CommonMessages.DataClayObjectMetaData msg)
Retrieve the metadata from the specified msg object- Parameters:
msg
- a message with metadata of a certain object- Returns:
- the metadata included within the message
-
getMetaDataInfo
public static CommonMessages.MetaDataInfo getMetaDataInfo(MetaDataInfo object)
Return a message for GRPC call- Parameters:
object
- object to convert- Returns:
- the resulting message
-
getMetaDataInfo
public static MetaDataInfo getMetaDataInfo(CommonMessages.MetaDataInfo msg)
Return an object FROM grpc message- Parameters:
msg
- object to convert- Returns:
- the resulting object
-
getExecutionEnvironment
public static CommonMessages.ExecutionEnvironmentInfo getExecutionEnvironment(ExecutionEnvironment object)
Return a message for GRPC call- Parameters:
object
- object to convert- Returns:
- the resulting message
-
getExecutionEnvironment
public static ExecutionEnvironment getExecutionEnvironment(CommonMessages.ExecutionEnvironmentInfo msg)
Return an object FROM grpc message- Parameters:
msg
- object to convert- Returns:
- the resulting object
-
getStorageLocation
public static CommonMessages.StorageLocationInfo getStorageLocation(StorageLocation object)
Return a message for GRPC call- Parameters:
object
- object to convert- Returns:
- the resulting message
-
getStorageLocation
public static StorageLocation getStorageLocation(CommonMessages.StorageLocationInfo msg)
Return an object FROM grpc message- Parameters:
msg
- object to convert- Returns:
- the resulting object
-
getDataClayInstance
public static CommonMessages.DataClayInstance getDataClayInstance(DataClayInstance dataClayInstance)
Return a message for GRPC call- Parameters:
dataClayInstance
- object to convert- Returns:
- the resulting message
-
getDataClayInstance
public static DataClayInstance getDataClayInstance(CommonMessages.DataClayInstance dataClayInstanceMsg)
Return an object FROM grpc message- Parameters:
dataClayInstanceMsg
- object to convert- Returns:
- the resulting message
-
getObjectWithDataParamOrReturn
public static CommonMessages.ObjectWithDataParamOrReturn getObjectWithDataParamOrReturn(ObjectWithDataParamOrReturn volParamOrRet)
Return a message containing an object with data (parameter or return)- Parameters:
volParamOrRet
- an object with data (parameter or return)- Returns:
- the resulting message
-
getObjectWithDataParamOrReturn
public static ObjectWithDataParamOrReturn getObjectWithDataParamOrReturn(CommonMessages.ObjectWithDataParamOrReturn volParamOrRet)
Obtain the object with data (parameter or return) from the specified message- Parameters:
volParamOrRet
- a message containing an object with data (parameter or return)- Returns:
- the instance of an object with data (parameter or return)
-
getLanguageParamOrReturn
public static CommonMessages.LanguageParamOrReturn getLanguageParamOrReturn(LanguageParamOrReturn paramOrRet)
Return a message containing a language object (parameter or return)- Parameters:
paramOrRet
- the language object- Returns:
- the resulting message
-
getLanguageParamOrReturn
public static LanguageParamOrReturn getLanguageParamOrReturn(CommonMessages.LanguageParamOrReturn paramOrRet)
Return an instance of language object included in the specified message- Parameters:
paramOrRet
- the message containing the language objet- Returns:
- the language object
-
getImmutableParamOrReturn
public static ImmutableParamOrReturn getImmutableParamOrReturn(CommonMessages.ImmutableParamOrReturn paramOrRet)
Return the immutable instance included in the specified message- Parameters:
paramOrRet
- the message- Returns:
- the resulting immutable instance
-
getImmutableParamOrReturn
public static CommonMessages.ImmutableParamOrReturn getImmutableParamOrReturn(ImmutableParamOrReturn paramOrRet)
Return a message including the specified immutable object- Parameters:
paramOrRet
- the immutable object- Returns:
- the resulting message
-
getPersistentParamOrReturn
public static CommonMessages.PersistentParamOrReturn getPersistentParamOrReturn(PersistentParamOrReturn paramOrRet)
Return a message including the specified param or return object- Parameters:
paramOrRet
- the object to be included within the message- Returns:
- the resulting message
-
getPersistentParamOrReturn
public static PersistentParamOrReturn getPersistentParamOrReturn(CommonMessages.PersistentParamOrReturn paramOrRet)
Return the param or return object included in the specified message- Parameters:
paramOrRet
- the message- Returns:
- the resulting param or return object
-
getParamsOrReturn
public static CommonMessages.SerializedParametersOrReturn getParamsOrReturn(SerializedParametersOrReturn serParamsOrRet)
Return the message including the specified serialized param or return object- Parameters:
serParamsOrRet
- a serialized param or return object- Returns:
- the resulting message
-
getParamsOrReturn
public static SerializedParametersOrReturn getParamsOrReturn(CommonMessages.SerializedParametersOrReturn serParamsOrRetMsg)
Return a serialized param or return object from the specified message- Parameters:
serParamsOrRetMsg
- the message- Returns:
- the serialized param or return object from the message
-
bytesToHex
public static Queue<String> bytesToHex(byte[] bytes)
Get bytes to hexadecimal Strings- Parameters:
bytes
- Bytes- Returns:
- Hexadecimal strings
-
getNumBytesNeededInVLQInt
public static int getNumBytesNeededInVLQInt(int numNextBytes)
Get number of bytes needed for a GRPC tag- Parameters:
numNextBytes
- Number of bytes to represent- Returns:
- Number of bytes needed for a GRPC tag.
-
printBytesHeader
public static void printBytesHeader(Queue<String> byteStr, int byteIndex)
Print bytes header
-
printMsg
public static void printMsg(com.google.protobuf.GeneratedMessageV3 msg)
Print GRPC message (pretty)- Parameters:
msg
- GRPC message
-
serializeException
public static CommonMessages.ExceptionInfo serializeException(Exception ex)
Serialize Exception- Parameters:
ex
- Exception to serialize- Returns:
- Serialized exception
-
checkIsExc
public static void checkIsExc(CommonMessages.ExceptionInfo response)
Verifies if response message isException and if this is the case print and raise it properly- Parameters:
response
- ExceptionInfo response message
-
-