Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Fixed deprecated dependencies so plugin will work with BitBucket Serv…
Browse files Browse the repository at this point in the history
…er 6; removed Optional HTTP Headers section (#336)
  • Loading branch information
rkw613 authored and tomasbjerre committed May 13, 2019
1 parent d1e319f commit 99c3e1a
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 319 deletions.
11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@
<version>6.0.2.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -330,9 +325,9 @@ Changelog of Pull Request Notifier for Bitbucket.
<changelog.version>1.54</changelog.version>
<fmt.version>2.5.1</fmt.version>
<violations.version>1.13</violations.version>
<bitbucket.version>5.13.1</bitbucket.version>
<bitbucket.version>6.1.2</bitbucket.version>
<bitbucket.data.version>${bitbucket.version}</bitbucket.data.version>
<quick.reload.version>2.0.0</quick.reload.version>
<amps.version>6.3.6</amps.version>
<amps.version>8.0.0</amps.version>
</properties>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import se.bjurr.prnfb.service.SettingsService;
import se.bjurr.prnfb.service.VariablesContext;
import se.bjurr.prnfb.service.VariablesContext.VariablesContextBuilder;
import se.bjurr.prnfb.settings.PrnfbHeader;
import se.bjurr.prnfb.settings.PrnfbNotification;
import se.bjurr.prnfb.settings.PrnfbSettingsData;
import se.bjurr.prnfb.settings.TRIGGER_IF_MERGE;
Expand Down Expand Up @@ -312,13 +311,6 @@ public NotificationResponse notify(
.withMethod(notification.getMethod()) //
.withPostContent(postContent) //
.appendBasicAuth(notification);
for (final PrnfbHeader header : notification.getHeaders()) {
urlInvoker //
.withHeader(
header.getName(),
renderer.render(
header.getValue(), ENCODE_FOR.NONE, clientKeyStore, shouldAcceptAnyCertificate));
}
final HttpResponse httpResponse =
createInvoker()
.invoke(
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
public class NotificationDTO implements Comparable<NotificationDTO>, Restricted {
private String filterRegexp;
private String filterString;
private List<HeaderDTO> headers;
private String injectionUrl;
private String injectionUrlRegexp;
private String variableName;
Expand Down Expand Up @@ -78,13 +77,6 @@ public boolean equals(final Object obj) {
} else if (!filterString.equals(other.filterString)) {
return false;
}
if (headers == null) {
if (other.headers != null) {
return false;
}
} else if (!headers.equals(other.headers)) {
return false;
}
if (httpVersion == null) {
if (other.httpVersion != null) {
return false;
Expand Down Expand Up @@ -248,10 +240,6 @@ public String getFilterString() {
return this.filterString;
}

public List<HeaderDTO> getHeaders() {
return this.headers;
}

public String getInjectionUrl() {
return this.injectionUrl;
}
Expand Down Expand Up @@ -344,7 +332,6 @@ public int hashCode() {
int result = 1;
result = prime * result + (filterRegexp == null ? 0 : filterRegexp.hashCode());
result = prime * result + (filterString == null ? 0 : filterString.hashCode());
result = prime * result + (headers == null ? 0 : headers.hashCode());
result = prime * result + (httpVersion == null ? 0 : httpVersion.hashCode());
result = prime * result + (injectionUrl == null ? 0 : injectionUrl.hashCode());
result = prime * result + (injectionUrlRegexp == null ? 0 : injectionUrlRegexp.hashCode());
Expand Down Expand Up @@ -381,10 +368,6 @@ public void setFilterString(final String filterString) {
this.filterString = filterString;
}

public void setHeaders(final List<HeaderDTO> headers) {
this.headers = headers;
}

public void setInjectionUrl(final String injectionUrl) {
this.injectionUrl = injectionUrl;
}
Expand Down Expand Up @@ -495,8 +478,6 @@ public String toString() {
+ filterRegexp
+ ", filterString="
+ filterString
+ ", headers="
+ headers
+ ", injectionUrl="
+ injectionUrl
+ ", injectionUrlRegexp="
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class PrnfbNotification implements HasUuid, Restricted {
private static final String DEFAULT_NAME = "Notification";
private final String filterRegexp;
private final String filterString;
private final List<PrnfbHeader> headers;
private final String injectionUrl;
private final String injectionUrlRegexp;
private final String variableName;
Expand Down Expand Up @@ -59,7 +58,6 @@ public PrnfbNotification(final PrnfbNotificationBuilder builder) throws Validati
this.proxyServer = emptyToNull(nullToEmpty(builder.getProxyServer()).trim());
this.proxySchema = emptyToNull(nullToEmpty(builder.getProxySchema()).trim());
this.proxyPort = builder.getProxyPort();
this.headers = checkNotNull(builder.getHeaders());
this.postContent = emptyToNull(nullToEmpty(builder.getPostContent()).trim());
this.method = firstNonNull(builder.getMethod(), GET);
this.triggerIfCanMerge = firstNonNull(builder.getTriggerIfCanMerge(), ALWAYS);
Expand Down Expand Up @@ -128,13 +126,6 @@ public boolean equals(final Object obj) {
} else if (!filterString.equals(other.filterString)) {
return false;
}
if (headers == null) {
if (other.headers != null) {
return false;
}
} else if (!headers.equals(other.headers)) {
return false;
}
if (httpVersion == null) {
if (other.httpVersion != null) {
return false;
Expand Down Expand Up @@ -298,10 +289,6 @@ public Optional<String> getFilterString() {
return fromNullable(this.filterString);
}

public List<PrnfbHeader> getHeaders() {
return this.headers;
}

public Optional<String> getInjectionUrl() {
return fromNullable(this.injectionUrl);
}
Expand Down Expand Up @@ -399,7 +386,6 @@ public int hashCode() {
int result = 1;
result = prime * result + (filterRegexp == null ? 0 : filterRegexp.hashCode());
result = prime * result + (filterString == null ? 0 : filterString.hashCode());
result = prime * result + (headers == null ? 0 : headers.hashCode());
result = prime * result + (httpVersion == null ? 0 : httpVersion.hashCode());
result = prime * result + (injectionUrl == null ? 0 : injectionUrl.hashCode());
result = prime * result + (injectionUrlRegexp == null ? 0 : injectionUrlRegexp.hashCode());
Expand Down Expand Up @@ -434,8 +420,6 @@ public String toString() {
+ filterRegexp
+ ", filterString="
+ filterString
+ ", headers="
+ headers
+ ", injectionUrl="
+ injectionUrl
+ ", injectionUrlRegexp="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder() {
public PrnfbNotificationBuilder(
final String filterRegexp,
final String filterString,
final List<PrnfbHeader> headers,
final String injectionUrl,
final String injectionUrlRegexp,
final String variableName,
Expand All @@ -48,7 +47,6 @@ public PrnfbNotificationBuilder(
final String httpVersion) {
this.filterRegexp = filterRegexp;
this.filterString = filterString;
this.headers = headers;
this.injectionUrl = injectionUrl;
this.injectionUrlRegexp = injectionUrlRegexp;
this.variableName = variableName;
Expand Down Expand Up @@ -88,7 +86,6 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(final PrnfbNotif
b.filterString = from.getFilterString().orNull();
b.method = from.getMethod();
b.postContent = from.getPostContent().orNull();
b.headers = from.getHeaders();
b.triggerIgnoreStateList = from.getTriggerIgnoreStateList();
b.proxyUser = from.getProxyUser().orNull();
b.proxyPassword = from.getProxyPassword().orNull();
Expand All @@ -110,7 +107,6 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(final PrnfbNotif

private String filterRegexp;
private String filterString;
private List<PrnfbHeader> headers = newArrayList();
private String injectionUrl;
private String injectionUrlRegexp;
private String variableName;
Expand Down Expand Up @@ -156,10 +152,6 @@ public String getFilterString() {
return this.filterString;
}

public List<PrnfbHeader> getHeaders() {
return this.headers;
}

public String getInjectionUrl() {
return this.injectionUrl;
}
Expand Down Expand Up @@ -252,11 +244,6 @@ public UUID getUUID() {
return this.uuid;
}

public PrnfbNotificationBuilder setHeaders(final List<PrnfbHeader> headers) {
this.headers = headers;
return this;
}

public PrnfbNotificationBuilder setTriggerIgnoreState(
final List<PullRequestState> triggerIgnoreStateList) {
this.triggerIgnoreStateList = triggerIgnoreStateList;
Expand All @@ -283,11 +270,6 @@ public PrnfbNotificationBuilder withFilterString(final String filterString) {
return this;
}

public PrnfbNotificationBuilder withHeader(final String name, final String value) {
this.headers.add(new PrnfbHeader(name, value));
return this;
}

public PrnfbNotificationBuilder withInjectionUrl(final String injectionUrl) {
this.injectionUrl = emptyToNull(injectionUrl);
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package se.bjurr.prnfb.transformer;

import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.Lists.newArrayList;
import static se.bjurr.prnfb.settings.PrnfbNotificationBuilder.prnfbNotificationBuilder;
import static se.bjurr.prnfb.settings.PrnfbSettings.UNCHANGED;

import com.atlassian.bitbucket.pull.PullRequestState;
import java.util.List;
import se.bjurr.prnfb.listener.PrnfbPullRequestAction;
import se.bjurr.prnfb.presentation.dto.HeaderDTO;
import se.bjurr.prnfb.presentation.dto.NotificationDTO;
import se.bjurr.prnfb.settings.PrnfbHeader;
import se.bjurr.prnfb.settings.PrnfbNotification;
import se.bjurr.prnfb.settings.ValidationException;

Expand All @@ -28,7 +25,6 @@ public static NotificationDTO toNotificationDto(final PrnfbNotification from) {
to.setVariableRegex(from.getVariableRegex().orNull());
to.setMethod(from.getMethod());
to.setName(from.getName());
to.setHeaders(toHeaders(from.getHeaders()));
to.setPostContent(from.getPostContent().orNull());
to.setPostContentEncoding(from.getPostContentEncoding());
to.setProxyPort(from.getProxyPort());
Expand Down Expand Up @@ -64,7 +60,6 @@ public static PrnfbNotification toPrnfbNotification(final NotificationDTO from)
return prnfbNotificationBuilder() //
.withFilterRegexp(from.getFilterRegexp()) //
.withFilterString(from.getFilterString()) //
.setHeaders(toHeaders(from)) //
.withInjectionUrl(from.getInjectionUrl()) //
.withInjectionUrlRegexp(from.getInjectionUrlRegexp()) //
.withVariableName(from.getVariableName()) //
Expand Down Expand Up @@ -92,31 +87,6 @@ public static PrnfbNotification toPrnfbNotification(final NotificationDTO from)
.build();
}

private static List<HeaderDTO> toHeaders(final List<PrnfbHeader> headers) {
final List<HeaderDTO> to = newArrayList();
if (headers != null) {
for (final PrnfbHeader h : headers) {
final HeaderDTO t = new HeaderDTO();
t.setName(h.getName());
t.setValue(h.getValue());
to.add(t);
}
}
return to;
}

private static List<PrnfbHeader> toHeaders(final NotificationDTO from) {
final List<PrnfbHeader> to = newArrayList();
if (from.getHeaders() != null) {
for (final HeaderDTO headerDto : from.getHeaders()) {
if (!isNullOrEmpty(headerDto.getName()) && !isNullOrEmpty(headerDto.getValue())) {
to.add(new PrnfbHeader(headerDto.getName(), headerDto.getValue()));
}
}
}
return to;
}

private static List<PrnfbPullRequestAction> toPrnfbPullRequestActions(
final List<String> strings) {
final List<PrnfbPullRequestAction> to = newArrayList();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define('plugin/prnfb/admin', [
'jquery',
'aui',
'@atlassian/aui',
'plugin/prnfb/utils'
], function($, AJS, utils) {
var settingsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings";
Expand Down
19 changes: 1 addition & 18 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -648,23 +648,6 @@
</div>
</fieldset>

<h4>Headers</h4>
<p>Optional HTTP headers to send with URL.</p>
<fieldset class="group">
<legend>
<span>Headers</span>
</legend>
<script type="text/x-template" title="header-template">
<div class="field-group listfield">
<input class="text text-field" type="text" name="headers[][name]" value="{name}">
<input class="text text-field" type="text" name="headers[][value]" value="{value}">
</div>
</script>
<div class="listfields template" data-template="header-template" data-field="headers" data-target=".listfields" data-empty="{'name':'','value':''}">

</div>
</fieldset>

<div class="aui-buttons">
<button class="aui-button aui-button-primary">Save</button>
<button class="aui-button aui-button" name="delete">Delete</button>
Expand All @@ -674,4 +657,4 @@

</body>

</html>
</html>
3 changes: 2 additions & 1 deletion src/main/resources/atlassian-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<resource type="download" name="utils.js" location="utils.js" />
<resource type="download" name="pr-triggerbutton.js" location="/pr-triggerbutton.js" />
<dependency>com.atlassian.bitbucket.bitbucket-web-plugin:global</dependency>
<dependency>com.atlassian.auiplugin:ajs</dependency>
<context>bitbucket.page.pullRequest.view</context>
</web-resource>
</atlassian-plugin>
</atlassian-plugin>
6 changes: 2 additions & 4 deletions src/main/resources/pr-triggerbutton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define('plugin/prnfb/pr-triggerbutton', [
'jquery',
'aui',
'@atlassian/aui',
'bitbucket/util/state',
'underscore',
'plugin/prnfb/3rdparty'
Expand Down Expand Up @@ -304,8 +304,6 @@ define('plugin/prnfb/pr-triggerbutton', [
});
});

require(['bitbucket/util/events'], function(events) {
events.on('bitbucket.internal.feature.repositories.recent.loaded', function() {
AJS.$(document).ready(function() {
require('plugin/prnfb/pr-triggerbutton');
});
});
15 changes: 0 additions & 15 deletions src/main/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,6 @@ define('plugin/prnfb/utils', [
}
$(formSelector).populate(data);

$(formSelector).find('.template').each(function(index, el) {
var template = $(el).data('template');
var field = $(el).data('field');
var target = $(el).data('target');
var emptyJson = $(el).data('empty').replace(/\'/g, '"');
var empty = JSON.parse(emptyJson);
var rendered = "";
if (data[field]) {
for (var i = 0; i < data[field].length; i++) {
rendered += AJS.template.load(template).fill(data[field][i]);
}
}
rendered += AJS.template.load(template).fill(empty);
$(target).html(rendered);
});
}

function clearForm(formSelector) {
Expand Down
Loading

0 comments on commit 99c3e1a

Please sign in to comment.