Skip to content

Commit

Permalink
Merge pull request #72 from lucasponce/HWKALERTS-67
Browse files Browse the repository at this point in the history
HWKALERTS-67 Migrate gson dependencies with jackson libraries
  • Loading branch information
jshaughn committed Jul 16, 2015
2 parents 0e2159b + 2872c56 commit ea3db1e
Show file tree
Hide file tree
Showing 29 changed files with 629 additions and 355 deletions.
6 changes: 6 additions & 0 deletions hawkular-actions-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import java.util.Map;

import com.google.gson.annotations.Expose;
import org.hawkular.bus.common.BasicMessage;

import com.fasterxml.jackson.annotation.JsonInclude;
/**
* A action message generated from the alerts engine through alert-bus subsystem.
* Action plugins must listen per actionPlugin of message in the filter.
Expand All @@ -30,25 +30,25 @@
*/
public class ActionMessage extends BasicMessage {

@Expose
@JsonInclude
String tenantId;

@Expose
@JsonInclude
String actionPlugin;

@Expose
@JsonInclude
String actionId;

@Expose
@JsonInclude
String message;

@Expose
@JsonInclude
String alert;

@Expose
@JsonInclude
Map<String, String> properties;

@Expose
@JsonInclude
Map<String, String> defaultProperties;

public ActionMessage() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.hawkular.bus.common.BasicMessage;

import com.google.gson.annotations.Expose;
import com.fasterxml.jackson.annotation.JsonInclude;

/**
* An action plugin registration message.
Expand All @@ -39,16 +39,16 @@
*/
public class ActionPluginMessage extends BasicMessage {

@Expose
@JsonInclude
String op;

@Expose
@JsonInclude
String actionPlugin;

@Expose
@JsonInclude
Set<String> properties;

@Expose
@JsonInclude
Map<String, String> defaultProperties;

public ActionPluginMessage() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import org.hawkular.actions.api.log.MsgLogger;
import org.hawkular.actions.api.model.ActionMessage;
import org.hawkular.alerts.api.json.GsonUtil;
import org.hawkular.alerts.api.json.JsonUtil;
import org.hawkular.alerts.api.model.condition.Alert;
import org.hawkular.bus.common.consumer.BasicMessageListener;

Expand Down Expand Up @@ -76,7 +76,7 @@ private boolean isBlank(String value) {
private String prepareMessage(ActionMessage msg) {
String preparedMsg = null;
if (msg != null) {
Alert alert = msg.getAlert() != null ? GsonUtil.fromJson(msg.getAlert(), Alert.class) : null;
Alert alert = msg.getAlert() != null ? JsonUtil.fromJson(msg.getAlert(), Alert.class) : null;
if (alert != null) {
preparedMsg = "Alert : " + alert.getTriggerId() + " at " + alert.getCtime() + " -- Severity: " +
alert.getSeverity().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.hawkular.actions.api.model.ActionMessage;
import org.hawkular.actions.email.EmailPlugin;
import org.hawkular.actions.email.template.EmailTemplate;
import org.hawkular.alerts.api.json.GsonUtil;
import org.hawkular.alerts.api.json.JsonUtil;
import org.hawkular.alerts.api.model.condition.Alert;
import org.hawkular.bus.common.consumer.BasicMessageListener;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -79,7 +79,7 @@ protected Message createMimeMessage(ActionMessage msg) throws Exception {
Map<String, String> props = msg.getProperties();
Map<String, String> defaultProps = msg.getDefaultProperties();
String message = msg.getMessage();
Alert alert = msg.getAlert() != null ? GsonUtil.fromJson(msg.getAlert(), Alert.class) : null;
Alert alert = msg.getAlert() != null ? JsonUtil.fromJson(msg.getAlert(), Alert.class) : null;
Alert.Status status = alert != null && alert.getStatus() != null ? alert.getStatus() : Alert.Status.OPEN;

String from = getProp(props, defaultProps, EmailPlugin.PROP_FROM + "." + status.name().toLowerCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.Set;
import javax.mail.Message;
import org.hawkular.actions.api.model.ActionMessage;
import org.hawkular.alerts.api.json.GsonUtil;
import org.hawkular.alerts.api.json.JsonUtil;
import org.hawkular.alerts.api.model.condition.Alert;
import org.hawkular.alerts.api.model.condition.AvailabilityCondition;
import org.hawkular.alerts.api.model.condition.AvailabilityConditionEval;
Expand Down Expand Up @@ -113,15 +113,15 @@ public static void prepareMessages() {
props.put("template.hawkular.url", "http://www.hawkular.org");

openThresholdMsg = new ActionMessage(tenantId, "email", "email-to-test", "Threshold Alert",
GsonUtil.toJson(rtAlert));
JsonUtil.toJson(rtAlert));
openThresholdMsg.setProperties(props);

rtAlert.setStatus(Status.ACKNOWLEDGED);
rtAlert.setAckBy("Test ACK user");
rtAlert.setAckTime(System.currentTimeMillis() + 10000);
rtAlert.setAckNotes("Test ACK notes");
ackThresholdMsg = new ActionMessage(tenantId, "email", "email-to-test", "Threshold Alert",
GsonUtil.toJson(rtAlert));
JsonUtil.toJson(rtAlert));
ackThresholdMsg.setProperties(props);

/*
Expand All @@ -136,7 +136,7 @@ public static void prepareMessages() {
rtAlert.setResolvedEvalSets(getEvalList(rtResolveCondition, rtGoodData));

resolvedThresholdMsg = new ActionMessage(tenantId, "email", "email-to-test", "Threshold Alert",
GsonUtil.toJson(rtAlert));
JsonUtil.toJson(rtAlert));
resolvedThresholdMsg.setProperties(props);


Expand Down Expand Up @@ -178,15 +178,15 @@ public static void prepareMessages() {
props.put("template.hawkular.url", "http://www.hawkular.org");

openAvailMsg = new ActionMessage(tenantId, "email", "email-to-test", "Availability Alert",
GsonUtil.toJson(avAlert));
JsonUtil.toJson(avAlert));
openAvailMsg.setProperties(props);

avAlert.setStatus(Status.ACKNOWLEDGED);
avAlert.setAckBy("Test ACK user");
avAlert.setAckTime(System.currentTimeMillis() + 10000);
avAlert.setAckNotes("Test ACK notes");
ackAvailMsg = new ActionMessage(tenantId, "email", "email-to-test", "Availability Alert",
GsonUtil.toJson(avAlert));
JsonUtil.toJson(avAlert));
ackAvailMsg.setProperties(props);

/*
Expand All @@ -201,7 +201,7 @@ public static void prepareMessages() {
avAlert.setResolvedEvalSets(getEvalList(avResolveCondition, avGoodData));

resolvedAvailMsg = new ActionMessage(tenantId, "email", "email-to-test", "Availability Alert",
GsonUtil.toJson(avAlert));
JsonUtil.toJson(avAlert));
resolvedAvailMsg.setProperties(props);

/*
Expand Down Expand Up @@ -253,15 +253,15 @@ public static void prepareMessages() {
props.put("template.hawkular.url", "http://www.hawkular.org");

openTwoCondMsg = new ActionMessage(tenantId, "email", "email-to-test", "Response Time and Availability Alert",
GsonUtil.toJson(mixAlert));
JsonUtil.toJson(mixAlert));
openTwoCondMsg.setProperties(props);

mixAlert.setStatus(Status.ACKNOWLEDGED);
mixAlert.setAckBy("Test ACK user");
mixAlert.setAckTime(System.currentTimeMillis() + 10000);
mixAlert.setAckNotes("Test ACK notes");
ackTwoCondMsg = new ActionMessage(tenantId, "email", "email-to-test", "Availability Alert",
GsonUtil.toJson(mixAlert));
JsonUtil.toJson(mixAlert));
ackTwoCondMsg.setProperties(props);

/*
Expand All @@ -284,7 +284,7 @@ public static void prepareMessages() {
mixAlert.setResolvedEvalSets(getEvalList(mixResolveConditions, mixGoodData));

resolvedTwoCondMsg = new ActionMessage(tenantId, "email", "email-to-test", "Availability Alert",
GsonUtil.toJson(mixAlert));
JsonUtil.toJson(mixAlert));
resolvedTwoCondMsg.setProperties(props);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import org.hawkular.actions.api.log.MsgLogger;
import org.hawkular.actions.api.model.ActionMessage;
import org.hawkular.alerts.api.json.GsonUtil;
import org.hawkular.alerts.api.json.JsonUtil;
import org.hawkular.alerts.api.model.condition.Alert;
import org.hawkular.bus.common.consumer.BasicMessageListener;

Expand Down Expand Up @@ -120,7 +120,7 @@ private boolean isBlank(String value) {
private String prepareMessage(ActionMessage msg) {
String preparedMsg = null;
if (msg != null) {
Alert alert = msg.getAlert() != null ? GsonUtil.fromJson(msg.getAlert(), Alert.class) : null;
Alert alert = msg.getAlert() != null ? JsonUtil.fromJson(msg.getAlert(), Alert.class) : null;
if (alert != null) {
preparedMsg = "Alert : " + alert.getTriggerId() + " at " + alert.getCtime() + " -- Severity: " +
alert.getSeverity().toString();
Expand Down
5 changes: 2 additions & 3 deletions hawkular-actions-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${version.com.google.code.gson}</version>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
7 changes: 0 additions & 7 deletions hawkular-alerts-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${version.com.google.code.gson}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down

This file was deleted.

0 comments on commit ea3db1e

Please sign in to comment.