diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 0000000..5372706 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,48 @@ +# Build & Deploy on Tag & Push +name: Github Package +on: + push: + tags: + - 'v*.*.*' + branches: + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + pull_request: + branches: + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + +jobs: + build-deploy-github: + name: Build & Deploy to GitHub + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: 11 + distribution: 'temurin' + server-id: github + server-username: GITHUB_USERNAME + server-password: GITHUB_TOKEN + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + + - name: Delete package specific version + uses: smartsquaregmbh/delete-old-packages@v0.4.0 + with: + version: 2.1.0 # This should be same as in the pom.xml file, + # to delete only the pom specified version, not the other older versions + names: | + com.uci.message-rosa + token: ${{ secrets.TOKEN }} + + - name: Deploy + run: mvn clean install -Pgithub deploy + env: + GITHUB_USERNAME: ${{ secrets.USERNAME }} + GITHUB_TOKEN: ${{ secrets.TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..34fe9d6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +# Build on Push & Pull Request +name: Maven Build +on: + push: + branches: + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + pull_request: + branches: + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: 11 + distribution: 'temurin' + + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build and analyze + run: mvn clean install diff --git a/README.md b/README.md new file mode 100644 index 0000000..4438692 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +![Maven Build](https://github.com/samagra-comms/message-rosa/actions/workflows/build.yml/badge.svg) +![Github Package](https://github.com/samagra-comms/message-rosa/actions/workflows/build-deploy.yml/badge.svg) + +# Overview +Message Rosa holds all the core models for XMessage & its property fields. + +# Getting Started + +## Prerequisites + +* java 11 or above +* docker +* kafka +* lombok plugin for IDE +* maven + +## Build +* build with tests run using command **mvn clean install -U** +* or build without tests run using command **mvn clean install -DskipTests** + +# Detailed Documentation +[Click here](https://uci.sunbird.org/use/developer/uci-basics) \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index b3c9829..577b428 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ spring-boot-starter-parent org.springframework.boot - 2.3.0.RELEASE + 2.5.7 pom.xml 4.0.0 @@ -16,7 +16,7 @@ maven-shade-plugin - 2.3 + 3.2.4 package @@ -29,6 +29,12 @@ + + org.springframework.boot + spring-boot-starter-validation + 2.5.7 + provided + org.projectlombok lombok @@ -62,7 +68,7 @@ junit junit - 4.13 + 4.13.2 test @@ -100,7 +106,7 @@ org.apache.httpcomponents httpclient - 4.5.12 + 4.5.13 provided @@ -109,9 +115,14 @@ + + org.jetbrains + annotations + RELEASE + provided + 11 - diff --git a/message-rosa.iml b/message-rosa.iml deleted file mode 100644 index 74f3f13..0000000 --- a/message-rosa.iml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index dbfa784..71bf827 100644 --- a/pom.xml +++ b/pom.xml @@ -5,19 +5,41 @@ org.springframework.boot spring-boot-starter-parent - 2.3.0.RELEASE + 2.5.7 com.uci message-rosa - 0.0.1-SNAPSHOT + 2.1.0 + message-rosa message-rosa for messages 11 - + + + github + + + useGitHubPackages + true + + + + + github + GitHub Packages + https://maven.pkg.github.com/samagra-comms/message-rosa + + + + + + org.springframework.boot + spring-boot-starter-validation + org.projectlombok lombok @@ -51,7 +73,6 @@ org.junit.jupiter junit-jupiter-api - 5.6.2 test @@ -63,6 +84,12 @@ org.apache.httpcomponents httpclient + + org.jetbrains + annotations + RELEASE + compile + @@ -70,7 +97,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.3 + 3.2.4 diff --git a/src/main/java/messagerosa/core/model/ButtonChoice.java b/src/main/java/messagerosa/core/model/ButtonChoice.java index f87dec2..e8ed955 100644 --- a/src/main/java/messagerosa/core/model/ButtonChoice.java +++ b/src/main/java/messagerosa/core/model/ButtonChoice.java @@ -10,4 +10,5 @@ public class ButtonChoice { private String key; private String text; + private Boolean backmenu; } diff --git a/src/main/java/messagerosa/core/model/Data.java b/src/main/java/messagerosa/core/model/Data.java new file mode 100644 index 0000000..3e9ab88 --- /dev/null +++ b/src/main/java/messagerosa/core/model/Data.java @@ -0,0 +1,14 @@ +package messagerosa.core.model; + + +import lombok.*; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class Data { + private String key; + private String value; +} diff --git a/src/main/java/messagerosa/core/model/DeviceType.java b/src/main/java/messagerosa/core/model/DeviceType.java new file mode 100644 index 0000000..630c7e2 --- /dev/null +++ b/src/main/java/messagerosa/core/model/DeviceType.java @@ -0,0 +1,26 @@ +package messagerosa.core.model; + +public enum DeviceType { + PHONE("phone"), + FCM("fcm"), + PHONE_PWA("ucipwa"), + PHONE_FCM("phonefcm"); + + + private String name; + + DeviceType(String deviceType) { + name=deviceType; + } + + public String toString(){ + return name; + } + + public static String getEnumByString(String code){ + for(DeviceType e : DeviceType.values()){ + if(e.name.equals(code)) return e.name(); + } + return null; + } +} diff --git a/src/main/java/messagerosa/core/model/LocationParams.java b/src/main/java/messagerosa/core/model/LocationParams.java index cd8eec7..a4b9a61 100644 --- a/src/main/java/messagerosa/core/model/LocationParams.java +++ b/src/main/java/messagerosa/core/model/LocationParams.java @@ -12,4 +12,7 @@ public class LocationParams { private double longitude; private double latitude; + private String address; + private String url; + private String name; } diff --git a/src/main/java/messagerosa/core/model/MediaCategory.java b/src/main/java/messagerosa/core/model/MediaCategory.java new file mode 100644 index 0000000..22726ca --- /dev/null +++ b/src/main/java/messagerosa/core/model/MediaCategory.java @@ -0,0 +1,26 @@ +package messagerosa.core.model; + +public enum MediaCategory { + IMAGE("image"), + AUDIO("audio"), + VIDEO("video"), + VOICE("voice"), + FILE("file"); + + private String name; + + MediaCategory(String mediaCategory) { + name=mediaCategory; + } + + public String toString(){ + return name; + } + + public static String getEnumByString(String code){ + for(MediaCategory e : MediaCategory.values()){ + if(e.name.equals(code)) return e.name(); + } + return null; + } +} diff --git a/src/main/java/messagerosa/core/model/MessageMedia.java b/src/main/java/messagerosa/core/model/MessageMedia.java index c4b8616..15c02de 100644 --- a/src/main/java/messagerosa/core/model/MessageMedia.java +++ b/src/main/java/messagerosa/core/model/MessageMedia.java @@ -10,7 +10,9 @@ @NoArgsConstructor @AllArgsConstructor public class MessageMedia { - private String category; //category list {image, audio, document, video} + private MediaCategory category; //category list {image, audio, document, video} private String text; //caption, if applicable private String url; + private MessageMediaError messageMediaError; + private Double size; } diff --git a/src/main/java/messagerosa/core/model/MessageMediaError.java b/src/main/java/messagerosa/core/model/MessageMediaError.java new file mode 100644 index 0000000..0803329 --- /dev/null +++ b/src/main/java/messagerosa/core/model/MessageMediaError.java @@ -0,0 +1,23 @@ +package messagerosa.core.model; + +public enum MessageMediaError { + PAYLOAD_TO_LARGE("payloadTooLarge"), + EMPTY_RESPONSE("emptyResponse"); + private String name; + + MessageMediaError(String name) { + this.name = name; + } + + @Override + public String toString() {return name;} + + public static MessageMediaError getErrorByText(String text){ + for (MessageMediaError e : MessageMediaError.values()){ + if(e.name.equals(text)) + return e; + } + return null; + } +} + diff --git a/src/main/java/messagerosa/core/model/SenderReceiverInfo.java b/src/main/java/messagerosa/core/model/SenderReceiverInfo.java index 5b9315b..aa97151 100644 --- a/src/main/java/messagerosa/core/model/SenderReceiverInfo.java +++ b/src/main/java/messagerosa/core/model/SenderReceiverInfo.java @@ -18,13 +18,14 @@ public class SenderReceiverInfo { // persist - private String userID; - + private String userID; //PhoneNo private ArrayList groups; - private String campaignID; private String formID; private boolean bot; private boolean broadcast; private Map meta; + private DeviceType deviceType; + private String deviceID; //UUID + private String encryptedDeviceID; //Encrypted Device String } diff --git a/src/main/java/messagerosa/core/model/StylingTag.java b/src/main/java/messagerosa/core/model/StylingTag.java new file mode 100644 index 0000000..0633348 --- /dev/null +++ b/src/main/java/messagerosa/core/model/StylingTag.java @@ -0,0 +1,29 @@ +package messagerosa.core.model; + +public enum StylingTag { + LIST("list"), + QUICKREPLYBTN("buttonsForListItems"), + IMAGE("image"), + AUDIO("audio"), + VIDEO("video"), + FILE("file"), + TEXT("text"); + + private String name; + + StylingTag(String stylingTag) { + name=stylingTag; + } + + public String toString() { + return name; + } + + public static StylingTag getEnumByText(String code) { + for (StylingTag e : StylingTag.values()) { + if (e.name.equals(code)) + return e; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/messagerosa/core/model/XMessage.java b/src/main/java/messagerosa/core/model/XMessage.java index 284d63e..e3a187d 100644 --- a/src/main/java/messagerosa/core/model/XMessage.java +++ b/src/main/java/messagerosa/core/model/XMessage.java @@ -4,6 +4,9 @@ import java.io.StringWriter; import java.time.Instant; import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -44,6 +47,14 @@ public enum MessageType { BROADCAST_TEXT } + private UUID sessionId; + + private String ownerOrgId; + + private String ownerId; + + private UUID botId; + //Persist private String app; @@ -71,6 +82,8 @@ public enum MessageType { @NotNull private Long timestamp; + private List tags; + private String userState; private String encryptionProtocol; @@ -80,6 +93,8 @@ public enum MessageType { private ConversationStage conversationStage; + private ArrayList conversationLevel; + @NotNull private ArrayList transformers; // -1 no transfer like ms3 transforms msg to next msg diff --git a/src/main/java/messagerosa/core/model/XMessagePayload.java b/src/main/java/messagerosa/core/model/XMessagePayload.java index 163822b..b674fc5 100644 --- a/src/main/java/messagerosa/core/model/XMessagePayload.java +++ b/src/main/java/messagerosa/core/model/XMessagePayload.java @@ -19,4 +19,10 @@ public class XMessagePayload { private LocationParams location; private ContactCard contactCard; private ArrayList buttonChoices; + private StylingTag stylingTag; + private String flow; + private Integer questionIndex; + private String mediaCaption; + private String title; + private ArrayList data; } diff --git a/src/test/java/messagerosa/xml/XMessageParserTest.java b/src/test/java/messagerosa/xml/XMessageParserTest.java new file mode 100644 index 0000000..7133273 --- /dev/null +++ b/src/test/java/messagerosa/xml/XMessageParserTest.java @@ -0,0 +1,22 @@ +package messagerosa.xml; + +import messagerosa.core.model.XMessage; +import org.junit.jupiter.api.Test; + +import javax.xml.bind.JAXBException; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +import static org.junit.jupiter.api.Assertions.*; + +class XMessageParserTest { + + @Test + void parse() throws FileNotFoundException, JAXBException { + InputStream inputStream = new FileInputStream("~/message-rosa/src/test/java/messagerosa/xml/" + "testMessage.xml"); + XMessage message = XMessageParser.parse(inputStream); + System.out.println(message.toXML()); + assertEquals(1, 1); + } +} \ No newline at end of file