Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates libraries to work with latest Jira API REST (v3) #1

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,16 @@ repositories {

dependencies {
// Hack to handle dependencies with 'atlassian-plugin' extension
compile module('com.atlassian.jira:jira-rest-java-client-core:4.0.0') {
dependency 'com.atlassian.httpclient:atlassian-httpclient-plugin:0.23.4@jar'
dependency 'com.atlassian.sal:sal-api:3.1.0@jar'
dependency 'com.atlassian.jira:jira-rest-java-client-api:4.0.0'
dependency 'com.atlassian.event:atlassian-event:2.3.5'
dependency 'com.atlassian.util.concurrent:atlassian-util-concurrent:2.6.3'
dependency 'org.springframework:spring-beans:2.5.6'
dependency 'com.sun.jersey:jersey-client:1.19.4'
dependency 'com.sun.jersey:jersey-json:1.19.4'
dependency 'joda-time:joda-time:1.6.2'
dependency 'org.apache.httpcomponents:httpmime:4.5.3'
}
compile 'com.github.gustavkarlsson:rocketchat-outgoing-webhook-server:3.3.0'
compile 'com.atlassian.fugue:fugue:2.6.1'
compile 'com.atlassian.jira:jira-rest-java-client-app:5.2.0'
compile 'ch.qos.logback:logback-classic:1.2.3'
compile 'org.apache.commons:commons-lang3:3.6'
compile 'org.apache.commons:commons-text:1.8'
compile 'com.moandjiezana.toml:toml4j:0.7.1'
compile 'com.google.inject:guice:4.1.0'
compile 'com.google.code.findbugs:jsr305:3.0.2'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.sparkjava:spark-core:2.6.0'
compile 'org.slf4j:slf4j-api:1.7.25'
compileOnly 'com.google.code.findbugs:jsr305:1.3.9'
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.atlassian.jira.rest.client.api.domain.BasicPriority;
import com.atlassian.jira.rest.client.api.domain.Issue;
import org.apache.commons.text.StringEscapeUtils;
import se.gustavkarlsson.rocketchat.jira_trigger.messages.field_creators.FieldCreator;
import se.gustavkarlsson.rocketchat.models.to_rocket_chat.Field;
import se.gustavkarlsson.rocketchat.models.to_rocket_chat.ToRocketChatAttachment;
Expand All @@ -12,7 +13,6 @@
import java.util.Optional;
import java.util.stream.Collectors;

import static org.apache.commons.lang.StringEscapeUtils.unescapeHtml;
import static org.apache.commons.lang3.Validate.*;

public class AttachmentCreator {
Expand Down Expand Up @@ -101,7 +101,7 @@ private String trim(String cleaned) {
}

private static String cleanText(String summary) {
String unescaped = unescapeHtml(summary);
String unescaped = StringEscapeUtils.unescapeHtml4(summary);
return stripReservedLinkCharacters(unescaped);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package se.gustavkarlsson.rocketchat.jira_trigger.routes;

import com.atlassian.jira.rest.client.api.IssueRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.RestClientException;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.google.inject.Singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import com.atlassian.jira.rest.client.api.MetadataRestClient;
import com.atlassian.jira.rest.client.api.domain.ServerInfo;
import com.atlassian.util.concurrent.Promise;

import com.google.inject.Singleton;
import io.atlassian.util.concurrent.Promise;
import org.slf4j.Logger;

import javax.inject.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ class BotValidator implements Validator {

@Override
public boolean isValid(FromRocketChatMessage message) {
Boolean isBot = Optional.ofNullable(message.getBot()).orElse(false);
return !isBot || !ignoreBots;
Object isBot = Optional.ofNullable(message.getBot() != null).orElse(false);
return !isaBoolean(isBot) || !ignoreBots;
}

private boolean isaBoolean(Object isBot) {
return isBot instanceof Boolean && !Boolean.valueOf(isBot.toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
package se.gustavkarlsson.rocketchat.models.from_rocket_chat;

import com.google.gson.annotations.SerializedName;

import java.util.Date;
import java.util.Objects;

public final class FromRocketChatMessage {

@SerializedName("token")
private String token;

@SerializedName("channel_id")
private String channelId;

@SerializedName("channel_name")
private String channelName;

@SerializedName("user_id")
private String userId;

@SerializedName("user_name")
private String userName;

@SerializedName("text")
private String text;

@SerializedName("bot")
private Object bot;

@SerializedName("isEdited")
private Boolean edited;

@SerializedName("alias")
private String alias;

@SerializedName("message_id")
private String messageId;

@SerializedName("timestamp")
private Date timestamp;

@SerializedName("trigger_word")
private String triggerWord;

public FromRocketChatMessage() {
}

public FromRocketChatMessage(String token, String channelId, String channelName, String userId, String userName, String text, Object bot, Boolean edited, String alias, String messageId, Date timestamp, String triggerWord) {
this.token = token;
this.channelId = channelId;
this.channelName = channelName;
this.userId = userId;
this.userName = userName;
this.text = text;
this.bot = bot;
this.edited = edited;
this.alias = alias;
this.messageId = messageId;
this.timestamp = timestamp;
this.triggerWord = triggerWord;
}

public String getToken() {
return token;
}

public void setToken(String token) {
this.token = token;
}

public String getChannelId() {
return channelId;
}

public void setChannelId(String channelId) {
this.channelId = channelId;
}

public String getChannelName() {
return channelName;
}

public void setChannelName(String channelName) {
this.channelName = channelName;
}

public String getUserId() {
return userId;
}

public void setUserId(String userId) {
this.userId = userId;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}

public Object getBot() {
return bot;
}

public void setBot(Object bot) {
this.bot = bot;
}

public Boolean isEdited() {
return edited;
}

public void setEdited(Boolean edited) {
this.edited = edited;
}

public String getAlias() {
return alias;
}

public void setAlias(String alias) {
this.alias = alias;
}

public String getMessageId() {
return messageId;
}

public void setMessageId(String messageId) {
this.messageId = messageId;
}

public Date getTimestamp() {
return timestamp;
}

public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}

public String getTriggerWord() {
return triggerWord;
}

public void setTriggerWord(String triggerWord) {
this.triggerWord = triggerWord;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FromRocketChatMessage that = (FromRocketChatMessage) o;
return Objects.equals(token, that.token) &&
Objects.equals(channelId, that.channelId) &&
Objects.equals(channelName, that.channelName) &&
Objects.equals(userId, that.userId) &&
Objects.equals(userName, that.userName) &&
Objects.equals(text, that.text) &&
Objects.equals(bot, that.bot) &&
Objects.equals(edited, that.edited) &&
Objects.equals(alias, that.alias) &&
Objects.equals(messageId, that.messageId) &&
Objects.equals(timestamp, that.timestamp) &&
Objects.equals(triggerWord, that.triggerWord);
}

@Override
public int hashCode() {
return Objects.hash(token, channelId, channelName, userId, userName, text, bot, edited, alias, messageId, timestamp, triggerWord);
}

@Override
public String toString() {
return "FromRocketChatMessage{" +
"token='" + token + '\'' +
", channelId='" + channelId + '\'' +
", channelName='" + channelName + '\'' +
", userId='" + userId + '\'' +
", userName='" + userName + '\'' +
", text='" + text + '\'' +
", bot=" + bot +
", isEdited=" + edited +
", alias='" + alias + '\'' +
", messageId='" + messageId + '\'' +
", timestamp=" + timestamp +
", triggerWord='" + triggerWord + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package se.gustavkarlsson.rocketchat.models.to_rocket_chat;

import com.google.gson.annotations.SerializedName;

import java.util.Objects;

public final class Field {

@SerializedName("title")
private String title;

@SerializedName("value")
private String value;

@SerializedName("short")
private Boolean shortValue;

public Field() {
}

public Field(String title, String value, boolean shortValue) {
this.title = title;
this.value = value;
this.shortValue = shortValue;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public Boolean isAShort() {
return shortValue;
}

public void setAShort(Boolean aShort) {
this.shortValue = aShort;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Field field = (Field) o;
return Objects.equals(title, field.title) &&
Objects.equals(value, field.value) &&
Objects.equals(shortValue, field.shortValue);
}

@Override
public int hashCode() {
return Objects.hash(title, value, shortValue);
}

@Override
public String toString() {
return "Field{" +
"title='" + title + '\'' +
", value='" + value + '\'' +
", shortValue=" + shortValue +
'}';
}
}
Loading