Skip to content

Commit

Permalink
Merge Code and Update Build Version 2.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajjangid05 committed Jul 18, 2023
2 parents 65a48e3 + e1b8a1c commit fbb517a
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 129 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.uci</groupId>
<artifactId>message-rosa</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<!-- On changing, Set version in deploy.xml to delete the previous packages if exists and deploy new package for the specified version -->
<name>message-rosa</name>
<description>message-rosa for messages</description>
Expand Down
259 changes: 131 additions & 128 deletions src/main/java/messagerosa/core/model/XMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,157 +25,160 @@
@XmlRootElement
@ToString
public class XMessage implements Serializable {
public enum MessageState {
NOT_SENT,
FAILED_TO_DELIVER,
DELIVERED,
READ,
REPLIED,
ENQUEUED,
SENT,
OPTED_IN,
OPTED_OUT
}
public enum MessageState {
NOT_SENT,
FAILED_TO_DELIVER,
DELIVERED,
READ,
REPLIED,
ENQUEUED,
SENT,
OPTED_IN,
OPTED_OUT
}

public enum MessageType {
HSM,
TEXT,
HSM_WITH_BUTTON,
BROADCAST_TEXT
}
public enum MessageType {
HSM,
TEXT,
HSM_WITH_BUTTON,
BROADCAST_TEXT
}

private UUID sessionId;
private UUID sessionId;

private String ownerOrgId;
private String ownerOrgId;

private String ownerId;
private String ownerId;

private UUID botId;
private UUID botId;

//Persist
private String app;
//Persist
private String app;

private MessageType messageType;
private MessageType messageType;

private String adapterId;
private String adapterId;

//Persist
private MessageId messageId;
//Persist
private MessageId messageId;

@NotNull
private SenderReceiverInfo to;
@NotNull
private SenderReceiverInfo from;
@NotNull
@NotNull
private SenderReceiverInfo to;
@NotNull
private SenderReceiverInfo from;
@NotNull

//Persist
private String channelURI; // whatsapp
@NotNull
//Persist
private String channelURI; // whatsapp
@NotNull

//Persist
private String providerURI; // gupshup
//Persist
private String providerURI; // gupshup

//Persist
@NotNull
private Long timestamp;
//Persist
@NotNull
private Long timestamp;

private List<String> tags;
private List<String> tags;

private String userState;
private String encryptionProtocol;
private String userState;
private String encryptionProtocol;

private MessageState messageState;
private MessageState messageState;

private String lastMessageID;
private String lastMessageID;

private ConversationStage conversationStage;
private ConversationStage conversationStage;

private ArrayList<Integer> conversationLevel;
private ArrayList<Integer> conversationLevel;

@NotNull
private ArrayList<Transformer> transformers; // -1 no transfer like ms3 transforms msg to next msg
@NotNull
private ArrayList<Transformer> transformers; // -1 no transfer like ms3 transforms msg to next msg

private XMessageThread thread;
private XMessagePayload payload;
private XMessageThread thread;
private XMessagePayload payload;

private static JAXBContext context;
private static JAXBContext context;

static {
try {
context = JAXBContext.newInstance(XMessage.class);
static {
try {
context = JAXBContext.newInstance(XMessage.class);
// marshaller = context.createMarshaller();
// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
} catch (JAXBException e) {
e.printStackTrace();
}
}


public String toXML() throws JAXBException {
StringWriter stringWriter = new StringWriter();
/** Marshaller object created here because of it is not thread safe.
* So that we are getting exceptions like NullPointer, ArrayOutOfBounds,
* EmptyStack Exception.
*/
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(this, stringWriter);
return stringWriter.toString();
}

public void completeTransform() {
transformers.remove(0);
}

public String getChannel(){
return channelURI;
}

public String getProvider(){
return providerURI;
}

public long secondsSinceLastMessage(){
if(this.timestamp != null){
long messageTime = this.timestamp;
long currentTimestamp = Instant.now().getEpochSecond();
return currentTimestamp - messageTime;
}else{
return Long.MAX_VALUE;
}
}

public void setChannel(String channel){
this.channelURI = channel;
}

public void setProvider(String provider){
this.providerURI = provider;
}

public void setNextDestination(String destination){
System.out.println("SetNextDestination Called");
if(destination.equals("Outbound")){
this.transformers = new ArrayList<>();
}else{
Transformer transformer = new Transformer();
transformer.setId(TransformerRegistry.getID(destination));
ArrayList<Transformer> oldTransformers;
if(this.getTransformers() == null){
oldTransformers = new ArrayList<>();
}else{
oldTransformers = this.transformers;
}
oldTransformers.add(transformer);
this.setTransformers(oldTransformers);
}
}

public String getCampaign(){
return this.getApp();
}

public String getMessageStateString(){
return this.messageState.name();
}
} catch (JAXBException e) {
e.printStackTrace();
}
}


public String toXML() throws JAXBException {
StringWriter stringWriter = new StringWriter();
/** Marshaller object created here because of it is not thread safe.
* So that we are getting exceptions like NullPointer, ArrayOutOfBounds,
* EmptyStack Exception.
*/
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(this, stringWriter);
return stringWriter.toString();
}

public void completeTransform() {
transformers.remove(0);
}

public String getChannel() {
return channelURI;
}

public String getProvider() {
return providerURI;
}

public long secondsSinceLastMessage() {
if (this.timestamp != null) {
long messageTime = this.timestamp;
long currentTimestamp = Instant.now().getEpochSecond();
return currentTimestamp - messageTime;
} else {
return Long.MAX_VALUE;
}
}

public void setChannel(String channel) {
this.channelURI = channel;
}

public void setProvider(String provider) {
this.providerURI = provider;
}

public void setNextDestination(String destination) {
System.out.println("SetNextDestination Called");
if (destination.equals("Outbound")) {
this.transformers = new ArrayList<>();
} else {
Transformer transformer = new Transformer();
transformer.setId(TransformerRegistry.getID(destination));
ArrayList<Transformer> oldTransformers;
if (this.getTransformers() == null) {
oldTransformers = new ArrayList<>();
} else {
oldTransformers = this.transformers;
}
oldTransformers.add(transformer);
this.setTransformers(oldTransformers);
}
}

public String getCampaign() {
return this.getApp();
}

public String getMessageStateString() {
return this.messageState.name();
}

private String respMsgId;
private String remarks;
}

0 comments on commit fbb517a

Please sign in to comment.