Skip to content

Commit

Permalink
Change Json library to Gson and resolve the project snapshot version
Browse files Browse the repository at this point in the history
Directly throw the exceptions without using fault sequence
Add bundled dependencies
  • Loading branch information
RusJaI committed Sep 11, 2023
1 parent c875f42 commit c6e46b9
Show file tree
Hide file tree
Showing 127 changed files with 251 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>business-adaptors</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/business-adaptors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>mi-component-parent</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>crypto-service</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>crypto-service</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/crypto-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>mi-component-parent</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>data-services</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>data-services</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>data-services</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>data-services</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>data-services</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/data/data-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>data</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>mi-component-parent</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/javax.cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>mi-component-parent</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>data-publishers</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>data-publishers</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>data-publishers</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/mediation/data-publishers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>mediation</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>org.wso2.micro.integrator.security.handlers</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.ei</groupId>
<artifactId>extensions</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion components/mediation/extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>mediation</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>inbound-endpoints</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>inbound-endpoints</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>inbound-endpoints</artifactId>
<groupId>org.wso2.ei</groupId>
<version>4.2.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -170,6 +170,10 @@
<groupId>org.apache.axis2.transport</groupId>
<artifactId>axis2-transport-rabbitmq-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.debezium</groupId>
<artifactId>debezium</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
Expand All @@ -181,24 +185,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.mediation</groupId>
<artifactId>org.wso2.carbon.inbound.endpoint.persistence</artifactId>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-embedded</artifactId>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-api</artifactId>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-connector-mysql</artifactId>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.securevault</artifactId>
</dependency>
</dependencies>
<build>
Expand Down Expand Up @@ -232,7 +224,8 @@
</Private-Package>
<Import-Package>
org.wso2.carbon.inbound.endpoint.persistence,
org.wso2.carbon.inbound.endpoint.osgi.service;
org.wso2.carbon.inbound.endpoint.osgi.service,
*;resolution:=optional
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
<Fragment-Host>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

package org.wso2.carbon.inbound.endpoint.protocol.cdc;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.debezium.engine.ChangeEvent;
import org.json.JSONObject;

import static org.wso2.carbon.inbound.endpoint.protocol.cdc.InboundCDCConstants.AFTER;
import static org.wso2.carbon.inbound.endpoint.protocol.cdc.InboundCDCConstants.BEFORE;
Expand All @@ -32,52 +34,43 @@

public class CDCEventOutput {

private JSONObject payload;
private JsonObject payload;

private enum operations {c, r, u, d};

CDCEventOutput(ChangeEvent event) {
String valueString = event.value().toString();
JSONObject value = new JSONObject(valueString);
this.payload = value.getJSONObject(PAYLOAD);
JsonObject value = new Gson().fromJson(valueString, JsonObject.class);
this.payload = value.getAsJsonObject(PAYLOAD);
}

public Object getJsonPayloadBeforeEvent() {
Object beforeObject = null;
if (payload.has(BEFORE)) {
beforeObject = payload.get(BEFORE);
}
return beforeObject;

public JsonElement getJsonPayloadBeforeEvent() {
return payload.get(BEFORE);
}

public Object getJsonPayloadAfterEvent() {
Object afterObject = null;
if (payload.has(AFTER)) {
afterObject = payload.get(AFTER);
}
return afterObject;
public JsonElement getJsonPayloadAfterEvent() {
return payload.get(AFTER);
}

public Long getTs_ms() {
if (payload.has(TS_MS)) {
return payload.getLong(TS_MS);
return payload.get(TS_MS).getAsLong();
}
return null;
}

public String getDatabase() {
if (getSource() != null) {
if (getSource().has(DB)) {
return getSource().getString(DB);
return getSource().get(DB).getAsString();
}
return null;
}
return null;
}

public Object getTable() {
Object tableObject = null;
public JsonElement getTable() {
JsonElement tableObject = null;
if (getSource() != null) {
if (getSource().has(TABLE)) {
tableObject = getSource().get(TABLE);
Expand All @@ -86,16 +79,16 @@ public Object getTable() {
return tableObject;
}

private JSONObject getSource () {
private JsonObject getSource () {
if (payload.has(SOURCE)) {
return payload.getJSONObject(SOURCE);
return payload.getAsJsonObject(SOURCE);
}
return null;
}

public String getOp() {
if (payload.has(OP)) {
return getOpString(payload.getString(OP));
return getOpString(payload.get(OP).getAsString());
}
return null;
}
Expand All @@ -116,14 +109,14 @@ private String getOpString(String op) {
return null;
}

public JSONObject getOutputJsonPayload () {
public JsonObject getOutputJsonPayload () {
if (payload == null) {
return null;
}
JSONObject jsonPayload = new JSONObject();
jsonPayload.put(OP, getOp());
jsonPayload.put(BEFORE, getJsonPayloadBeforeEvent());
jsonPayload.put(AFTER, getJsonPayloadAfterEvent());
JsonObject jsonPayload = new JsonObject();
jsonPayload.addProperty(OP, getOp());
jsonPayload.add(BEFORE, getJsonPayloadBeforeEvent());
jsonPayload.add(AFTER, getJsonPayloadAfterEvent());
return jsonPayload;
}
}
Loading

0 comments on commit c6e46b9

Please sign in to comment.