public final class DDPUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static Message |
buildProtobuf(java.lang.String msgName,
byte[] encodedMsg)
Build a protobuf with the given message name
|
static Message |
buildProtobuf(java.lang.String msgName,
JsonObject msgJson)
Build a protobuf with the given message name from the input json object
|
static Response |
convertProtoMessageToResponse(Message protomsg)
Convert a response protomsg into a DDP Response object
|
static JsonObject |
convertProtoToJsonObject(Message protomsg)
Converts a proto message into a JsonObject
|
static java.lang.String |
getAMQPConnectionURL()
Get the DDP AMQP connection URL
Use Shared.set("dev_ddp_cloud_id", "id") and Shared.set("dev_ddp_cloud_key", "key")
to set the AMQP credentials
|
static java.lang.String |
getMessageName(Message protomsg)
Get the message name from a proto message
|
static java.lang.Class<?> |
getProtobufClass(java.lang.String msgName)
Get the protobuf class with the given message name
|
static RequestMeta.Builder |
getRequestMeta()
Generate a random id for a request meta protobuf message
|
static java.lang.Object |
getValueFromMessage(Message msg,
java.lang.String accessString)
Get a field value from protobuf message
for example if you have a protomsg with format
{
meta {
"id": "a5"
"owner": {
"name": "rado",
"position": "OG"
}
}
"color": "blue"
}
calling getValueFromMessage(msg, "color")
will return "blue"
and calling getValueFromMessage(msg, "meta.owner.name")
will return "rado"
|
static boolean |
isResponseUpdate(Message responseMsg)
Checks if the response message is an update message
|
static CloudPaymentInitiated |
parseCloudPaymentJsonToProto(JsonObject paymentData,
java.lang.String paymentDataId)
Parse data from a cloud payment to an appropriate protobuf message
|
static java.lang.String |
readFile(java.lang.String file)
Read in a file and return a string of the text in that file
|
public static RequestMeta.Builder getRequestMeta()
public static java.lang.String readFile(java.lang.String file)
throws java.io.IOException,
java.io.FileNotFoundException
file - The file path of the file to readjava.io.IOException - thrown if an error occurs while readinging in the filejava.io.FileNotFoundException - thrown if the file is not foundpublic static JsonObject convertProtoToJsonObject(Message protomsg)
protomsg - The proto message to convert to a json objectpublic static Response convertProtoMessageToResponse(Message protomsg)
protomsg - the response protomsgpublic static java.lang.String getMessageName(Message protomsg)
protomsg - the proto messagepublic static java.lang.Class<?> getProtobufClass(java.lang.String msgName)
throws java.lang.ClassNotFoundException
msgName - the message namejava.lang.ClassNotFoundExceptionpublic static Message buildProtobuf(java.lang.String msgName,
byte[] encodedMsg)
msgName - the message name corresponding to the the message associated with the given
encoded message bytesencodedMsg - the raw message byte arraypublic static Message buildProtobuf(java.lang.String msgName,
JsonObject msgJson)
msgName - the message name corresponding to the the message associated with the given
encoded message bytesmsgJson - a JsonObject describing the given protobufpublic static boolean isResponseUpdate(Message responseMsg)
responseMsg - protobuf message to be checkedpublic static java.lang.Object getValueFromMessage(Message msg,
java.lang.String accessString)
msg - the protoaccessString - a string that defines how to access the protomsg: use periods to separate
embedded fields (see above example)public static CloudPaymentInitiated parseCloudPaymentJsonToProto(JsonObject paymentData, java.lang.String paymentDataId)
paymentData - paymentDataId - public static java.lang.String getAMQPConnectionURL()