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 booleanDEBUG_ENABLEDIndicates 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 voidcheckIsExc(CommonMessages.ExceptionInfo response)Verifies if response message isException and if this is the case print and raise it properlystatic AccountIDgetAccountID(String idMsg)Get AccountID ID from Protobuf IDstatic ContractIDgetContractID(String idMsg)Get ContractID from Protobuf IDstatic PasswordCredentialgetCredential(CommonMessages.Credential cred)Get password credentialstatic CommonMessages.CredentialgetCredential(PasswordCredential cred)Get password credentialstatic CredentialIDgetCredentialID(String idMsg)Get CredentialID from Protobuf IDstatic DataClayInstancegetDataClayInstance(CommonMessages.DataClayInstance dataClayInstanceMsg)Return an object FROM grpc messagestatic CommonMessages.DataClayInstancegetDataClayInstance(DataClayInstance dataClayInstance)Return a message for GRPC callstatic DataClayInstanceIDgetDataClayInstanceID(String idMsg)Get DataClayID from Protobuf IDstatic DataContractIDgetDataContractID(String idMsg)Get DataContractID from Protobuf IDstatic DataSetIDgetDataSetID(String idMsg)Get DataSetID from Protobuf IDstatic ECAIDgetECAID(String idMsg)Get ECAID from Protobuf IDstatic EventMessageIDgetEventMessageID(String idMsg)Get EventMessageID from Protobuf IDstatic EventObjsMeetConditionIDgetEventObjsMeetConditionID(String idMsg)Get EventObjsMeetConditionID from Protobuf IDstatic ExecutionEnvironmentgetExecutionEnvironment(CommonMessages.ExecutionEnvironmentInfo msg)Return an object FROM grpc messagestatic CommonMessages.ExecutionEnvironmentInfogetExecutionEnvironment(ExecutionEnvironment object)Return a message for GRPC callstatic ExecutionEnvironmentIDgetExecutionEnvironmentID(String idMsg)Get ExecutionEnvironmentID from Protobuf IDstatic ImmutableParamOrReturngetImmutableParamOrReturn(CommonMessages.ImmutableParamOrReturn paramOrRet)Return the immutable instance included in the specified messagestatic CommonMessages.ImmutableParamOrReturngetImmutableParamOrReturn(ImmutableParamOrReturn paramOrRet)Return a message including the specified immutable objectstatic ImplementationIDgetImplementationID(String idMsg)Get ImplementationID from Protobuf IDstatic InterfaceIDgetInterfaceID(String idMsg)Get InterfaceID from Protobuf IDstatic LanguageParamOrReturngetLanguageParamOrReturn(CommonMessages.LanguageParamOrReturn paramOrRet)Return an instance of language object included in the specified messagestatic CommonMessages.LanguageParamOrReturngetLanguageParamOrReturn(LanguageParamOrReturn paramOrRet)Return a message containing a language object (parameter or return)static MetaClassIDgetMetaClassID(String idMsg)Get MetaClassID from Protobuf IDstatic DataClayObjectMetaDatagetMetaData(CommonMessages.DataClayObjectMetaData msg)Retrieve the metadata from the specified msg objectstatic CommonMessages.DataClayObjectMetaDatagetMetaData(DataClayObjectMetaData metadata)Get MetaData GRPC message from DataClayMetaDatastatic MetaDataInfogetMetaDataInfo(CommonMessages.MetaDataInfo msg)Return an object FROM grpc messagestatic CommonMessages.MetaDataInfogetMetaDataInfo(MetaDataInfo object)Return a message for GRPC callstatic StringgetMsgID(ID id)Get string representation of IDstatic NamespaceIDgetNamespaceID(String idMsg)Get NamespaceID from Protobuf IDstatic intgetNumBytesNeededInVLQInt(int numNextBytes)Get number of bytes needed for a GRPC tagstatic ObjectIDgetObjectID(String idMsg)Get ObjectID from Protobuf IDstatic ObjectWithDataParamOrReturngetObjectWithDataParamOrReturn(CommonMessages.ObjectWithDataParamOrReturn volParamOrRet)Obtain the object with data (parameter or return) from the specified messagestatic CommonMessages.ObjectWithDataParamOrReturngetObjectWithDataParamOrReturn(ObjectWithDataParamOrReturn volParamOrRet)Return a message containing an object with data (parameter or return)static OperationIDgetOperationID(String idMsg)Get OperationID from Protobuf IDstatic SerializedParametersOrReturngetParamsOrReturn(CommonMessages.SerializedParametersOrReturn serParamsOrRetMsg)Return a serialized param or return object from the specified messagestatic CommonMessages.SerializedParametersOrReturngetParamsOrReturn(SerializedParametersOrReturn serParamsOrRet)Return the message including the specified serialized param or return objectstatic PersistentParamOrReturngetPersistentParamOrReturn(CommonMessages.PersistentParamOrReturn paramOrRet)Return the param or return object included in the specified messagestatic CommonMessages.PersistentParamOrReturngetPersistentParamOrReturn(PersistentParamOrReturn paramOrRet)Return a message including the specified param or return objectstatic PropertyIDgetPropertyID(String idMsg)Get PropertyID from Protobuf IDstatic QualitativeRegistryIDgetQualitativeRegistryID(String idMsg)Get QualitativeRegistryID from Protobuf IDstatic ResourceIDgetResourceID(String idMsg)Get ResourceID from Protobuf IDstatic SessionIDgetSessionID(String idMsg)Get SessionID from Protobuf IDstatic StorageLocationgetStorageLocation(CommonMessages.StorageLocationInfo msg)Return an object FROM grpc messagestatic CommonMessages.StorageLocationInfogetStorageLocation(StorageLocation object)Return a message for GRPC callstatic StorageLocationIDgetStorageLocationID(String idMsg)Get StorageLocationID from Protobuf IDstatic voidprintBytesHeader(Queue<String> byteStr, int byteIndex)Print bytes headerstatic voidprintMsg(com.google.protobuf.GeneratedMessageV3 msg)Print GRPC message (pretty)static voidreturnExceptionInfoMessage(io.grpc.stub.StreamObserver<CommonMessages.ExceptionInfo> responseObserver)Return ExceptionInfo messagestatic CommonMessages.ExceptionInfoserializeException(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
-
-