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

Commit 99c3e1a

Browse files
rkw613tomasbjerre
authored andcommitted
Fixed deprecated dependencies so plugin will work with BitBucket Server 6; removed Optional HTTP Headers section (#336)
1 parent d1e319f commit 99c3e1a

File tree

12 files changed

+9
-319
lines changed

12 files changed

+9
-319
lines changed

pom.xml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@
130130
<version>6.0.2.RELEASE</version>
131131
<scope>test</scope>
132132
</dependency>
133-
<dependency>
134-
<groupId>com.jayway.restassured</groupId>
135-
<artifactId>rest-assured</artifactId>
136-
<scope>test</scope>
137-
</dependency>
138133
</dependencies>
139134
<build>
140135
<plugins>
@@ -330,9 +325,9 @@ Changelog of Pull Request Notifier for Bitbucket.
330325
<changelog.version>1.54</changelog.version>
331326
<fmt.version>2.5.1</fmt.version>
332327
<violations.version>1.13</violations.version>
333-
<bitbucket.version>5.13.1</bitbucket.version>
328+
<bitbucket.version>6.1.2</bitbucket.version>
334329
<bitbucket.data.version>${bitbucket.version}</bitbucket.data.version>
335330
<quick.reload.version>2.0.0</quick.reload.version>
336-
<amps.version>6.3.6</amps.version>
331+
<amps.version>8.0.0</amps.version>
337332
</properties>
338-
</project>
333+
</project>

src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import se.bjurr.prnfb.service.SettingsService;
5353
import se.bjurr.prnfb.service.VariablesContext;
5454
import se.bjurr.prnfb.service.VariablesContext.VariablesContextBuilder;
55-
import se.bjurr.prnfb.settings.PrnfbHeader;
5655
import se.bjurr.prnfb.settings.PrnfbNotification;
5756
import se.bjurr.prnfb.settings.PrnfbSettingsData;
5857
import se.bjurr.prnfb.settings.TRIGGER_IF_MERGE;
@@ -312,13 +311,6 @@ public NotificationResponse notify(
312311
.withMethod(notification.getMethod()) //
313312
.withPostContent(postContent) //
314313
.appendBasicAuth(notification);
315-
for (final PrnfbHeader header : notification.getHeaders()) {
316-
urlInvoker //
317-
.withHeader(
318-
header.getName(),
319-
renderer.render(
320-
header.getValue(), ENCODE_FOR.NONE, clientKeyStore, shouldAcceptAnyCertificate));
321-
}
322314
final HttpResponse httpResponse =
323315
createInvoker()
324316
.invoke(

src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
public class NotificationDTO implements Comparable<NotificationDTO>, Restricted {
1818
private String filterRegexp;
1919
private String filterString;
20-
private List<HeaderDTO> headers;
2120
private String injectionUrl;
2221
private String injectionUrlRegexp;
2322
private String variableName;
@@ -78,13 +77,6 @@ public boolean equals(final Object obj) {
7877
} else if (!filterString.equals(other.filterString)) {
7978
return false;
8079
}
81-
if (headers == null) {
82-
if (other.headers != null) {
83-
return false;
84-
}
85-
} else if (!headers.equals(other.headers)) {
86-
return false;
87-
}
8880
if (httpVersion == null) {
8981
if (other.httpVersion != null) {
9082
return false;
@@ -248,10 +240,6 @@ public String getFilterString() {
248240
return this.filterString;
249241
}
250242

251-
public List<HeaderDTO> getHeaders() {
252-
return this.headers;
253-
}
254-
255243
public String getInjectionUrl() {
256244
return this.injectionUrl;
257245
}
@@ -344,7 +332,6 @@ public int hashCode() {
344332
int result = 1;
345333
result = prime * result + (filterRegexp == null ? 0 : filterRegexp.hashCode());
346334
result = prime * result + (filterString == null ? 0 : filterString.hashCode());
347-
result = prime * result + (headers == null ? 0 : headers.hashCode());
348335
result = prime * result + (httpVersion == null ? 0 : httpVersion.hashCode());
349336
result = prime * result + (injectionUrl == null ? 0 : injectionUrl.hashCode());
350337
result = prime * result + (injectionUrlRegexp == null ? 0 : injectionUrlRegexp.hashCode());
@@ -381,10 +368,6 @@ public void setFilterString(final String filterString) {
381368
this.filterString = filterString;
382369
}
383370

384-
public void setHeaders(final List<HeaderDTO> headers) {
385-
this.headers = headers;
386-
}
387-
388371
public void setInjectionUrl(final String injectionUrl) {
389372
this.injectionUrl = injectionUrl;
390373
}
@@ -495,8 +478,6 @@ public String toString() {
495478
+ filterRegexp
496479
+ ", filterString="
497480
+ filterString
498-
+ ", headers="
499-
+ headers
500481
+ ", injectionUrl="
501482
+ injectionUrl
502483
+ ", injectionUrlRegexp="

src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class PrnfbNotification implements HasUuid, Restricted {
2626
private static final String DEFAULT_NAME = "Notification";
2727
private final String filterRegexp;
2828
private final String filterString;
29-
private final List<PrnfbHeader> headers;
3029
private final String injectionUrl;
3130
private final String injectionUrlRegexp;
3231
private final String variableName;
@@ -59,7 +58,6 @@ public PrnfbNotification(final PrnfbNotificationBuilder builder) throws Validati
5958
this.proxyServer = emptyToNull(nullToEmpty(builder.getProxyServer()).trim());
6059
this.proxySchema = emptyToNull(nullToEmpty(builder.getProxySchema()).trim());
6160
this.proxyPort = builder.getProxyPort();
62-
this.headers = checkNotNull(builder.getHeaders());
6361
this.postContent = emptyToNull(nullToEmpty(builder.getPostContent()).trim());
6462
this.method = firstNonNull(builder.getMethod(), GET);
6563
this.triggerIfCanMerge = firstNonNull(builder.getTriggerIfCanMerge(), ALWAYS);
@@ -128,13 +126,6 @@ public boolean equals(final Object obj) {
128126
} else if (!filterString.equals(other.filterString)) {
129127
return false;
130128
}
131-
if (headers == null) {
132-
if (other.headers != null) {
133-
return false;
134-
}
135-
} else if (!headers.equals(other.headers)) {
136-
return false;
137-
}
138129
if (httpVersion == null) {
139130
if (other.httpVersion != null) {
140131
return false;
@@ -298,10 +289,6 @@ public Optional<String> getFilterString() {
298289
return fromNullable(this.filterString);
299290
}
300291

301-
public List<PrnfbHeader> getHeaders() {
302-
return this.headers;
303-
}
304-
305292
public Optional<String> getInjectionUrl() {
306293
return fromNullable(this.injectionUrl);
307294
}
@@ -399,7 +386,6 @@ public int hashCode() {
399386
int result = 1;
400387
result = prime * result + (filterRegexp == null ? 0 : filterRegexp.hashCode());
401388
result = prime * result + (filterString == null ? 0 : filterString.hashCode());
402-
result = prime * result + (headers == null ? 0 : headers.hashCode());
403389
result = prime * result + (httpVersion == null ? 0 : httpVersion.hashCode());
404390
result = prime * result + (injectionUrl == null ? 0 : injectionUrl.hashCode());
405391
result = prime * result + (injectionUrlRegexp == null ? 0 : injectionUrlRegexp.hashCode());
@@ -434,8 +420,6 @@ public String toString() {
434420
+ filterRegexp
435421
+ ", filterString="
436422
+ filterString
437-
+ ", headers="
438-
+ headers
439423
+ ", injectionUrl="
440424
+ injectionUrl
441425
+ ", injectionUrlRegexp="

src/main/java/se/bjurr/prnfb/settings/PrnfbNotificationBuilder.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder() {
2121
public PrnfbNotificationBuilder(
2222
final String filterRegexp,
2323
final String filterString,
24-
final List<PrnfbHeader> headers,
2524
final String injectionUrl,
2625
final String injectionUrlRegexp,
2726
final String variableName,
@@ -48,7 +47,6 @@ public PrnfbNotificationBuilder(
4847
final String httpVersion) {
4948
this.filterRegexp = filterRegexp;
5049
this.filterString = filterString;
51-
this.headers = headers;
5250
this.injectionUrl = injectionUrl;
5351
this.injectionUrlRegexp = injectionUrlRegexp;
5452
this.variableName = variableName;
@@ -88,7 +86,6 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(final PrnfbNotif
8886
b.filterString = from.getFilterString().orNull();
8987
b.method = from.getMethod();
9088
b.postContent = from.getPostContent().orNull();
91-
b.headers = from.getHeaders();
9289
b.triggerIgnoreStateList = from.getTriggerIgnoreStateList();
9390
b.proxyUser = from.getProxyUser().orNull();
9491
b.proxyPassword = from.getProxyPassword().orNull();
@@ -110,7 +107,6 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(final PrnfbNotif
110107

111108
private String filterRegexp;
112109
private String filterString;
113-
private List<PrnfbHeader> headers = newArrayList();
114110
private String injectionUrl;
115111
private String injectionUrlRegexp;
116112
private String variableName;
@@ -156,10 +152,6 @@ public String getFilterString() {
156152
return this.filterString;
157153
}
158154

159-
public List<PrnfbHeader> getHeaders() {
160-
return this.headers;
161-
}
162-
163155
public String getInjectionUrl() {
164156
return this.injectionUrl;
165157
}
@@ -252,11 +244,6 @@ public UUID getUUID() {
252244
return this.uuid;
253245
}
254246

255-
public PrnfbNotificationBuilder setHeaders(final List<PrnfbHeader> headers) {
256-
this.headers = headers;
257-
return this;
258-
}
259-
260247
public PrnfbNotificationBuilder setTriggerIgnoreState(
261248
final List<PullRequestState> triggerIgnoreStateList) {
262249
this.triggerIgnoreStateList = triggerIgnoreStateList;
@@ -283,11 +270,6 @@ public PrnfbNotificationBuilder withFilterString(final String filterString) {
283270
return this;
284271
}
285272

286-
public PrnfbNotificationBuilder withHeader(final String name, final String value) {
287-
this.headers.add(new PrnfbHeader(name, value));
288-
return this;
289-
}
290-
291273
public PrnfbNotificationBuilder withInjectionUrl(final String injectionUrl) {
292274
this.injectionUrl = emptyToNull(injectionUrl);
293275
return this;

src/main/java/se/bjurr/prnfb/transformer/NotificationTransformer.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package se.bjurr.prnfb.transformer;
22

3-
import static com.google.common.base.Strings.isNullOrEmpty;
43
import static com.google.common.collect.Lists.newArrayList;
54
import static se.bjurr.prnfb.settings.PrnfbNotificationBuilder.prnfbNotificationBuilder;
65
import static se.bjurr.prnfb.settings.PrnfbSettings.UNCHANGED;
76

87
import com.atlassian.bitbucket.pull.PullRequestState;
98
import java.util.List;
109
import se.bjurr.prnfb.listener.PrnfbPullRequestAction;
11-
import se.bjurr.prnfb.presentation.dto.HeaderDTO;
1210
import se.bjurr.prnfb.presentation.dto.NotificationDTO;
13-
import se.bjurr.prnfb.settings.PrnfbHeader;
1411
import se.bjurr.prnfb.settings.PrnfbNotification;
1512
import se.bjurr.prnfb.settings.ValidationException;
1613

@@ -28,7 +25,6 @@ public static NotificationDTO toNotificationDto(final PrnfbNotification from) {
2825
to.setVariableRegex(from.getVariableRegex().orNull());
2926
to.setMethod(from.getMethod());
3027
to.setName(from.getName());
31-
to.setHeaders(toHeaders(from.getHeaders()));
3228
to.setPostContent(from.getPostContent().orNull());
3329
to.setPostContentEncoding(from.getPostContentEncoding());
3430
to.setProxyPort(from.getProxyPort());
@@ -64,7 +60,6 @@ public static PrnfbNotification toPrnfbNotification(final NotificationDTO from)
6460
return prnfbNotificationBuilder() //
6561
.withFilterRegexp(from.getFilterRegexp()) //
6662
.withFilterString(from.getFilterString()) //
67-
.setHeaders(toHeaders(from)) //
6863
.withInjectionUrl(from.getInjectionUrl()) //
6964
.withInjectionUrlRegexp(from.getInjectionUrlRegexp()) //
7065
.withVariableName(from.getVariableName()) //
@@ -92,31 +87,6 @@ public static PrnfbNotification toPrnfbNotification(final NotificationDTO from)
9287
.build();
9388
}
9489

95-
private static List<HeaderDTO> toHeaders(final List<PrnfbHeader> headers) {
96-
final List<HeaderDTO> to = newArrayList();
97-
if (headers != null) {
98-
for (final PrnfbHeader h : headers) {
99-
final HeaderDTO t = new HeaderDTO();
100-
t.setName(h.getName());
101-
t.setValue(h.getValue());
102-
to.add(t);
103-
}
104-
}
105-
return to;
106-
}
107-
108-
private static List<PrnfbHeader> toHeaders(final NotificationDTO from) {
109-
final List<PrnfbHeader> to = newArrayList();
110-
if (from.getHeaders() != null) {
111-
for (final HeaderDTO headerDto : from.getHeaders()) {
112-
if (!isNullOrEmpty(headerDto.getName()) && !isNullOrEmpty(headerDto.getValue())) {
113-
to.add(new PrnfbHeader(headerDto.getName(), headerDto.getValue()));
114-
}
115-
}
116-
}
117-
return to;
118-
}
119-
12090
private static List<PrnfbPullRequestAction> toPrnfbPullRequestActions(
12191
final List<String> strings) {
12292
final List<PrnfbPullRequestAction> to = newArrayList();

src/main/resources/admin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
define('plugin/prnfb/admin', [
22
'jquery',
3-
'aui',
3+
'@atlassian/aui',
44
'plugin/prnfb/utils'
55
], function($, AJS, utils) {
66
var settingsAdminUrlPostUrl = AJS.contextPath() + "/rest/prnfb-admin/1.0/settings";

src/main/resources/admin.vm

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -648,23 +648,6 @@
648648
</div>
649649
</fieldset>
650650

651-
<h4>Headers</h4>
652-
<p>Optional HTTP headers to send with URL.</p>
653-
<fieldset class="group">
654-
<legend>
655-
<span>Headers</span>
656-
</legend>
657-
<script type="text/x-template" title="header-template">
658-
<div class="field-group listfield">
659-
<input class="text text-field" type="text" name="headers[][name]" value="{name}">
660-
<input class="text text-field" type="text" name="headers[][value]" value="{value}">
661-
</div>
662-
</script>
663-
<div class="listfields template" data-template="header-template" data-field="headers" data-target=".listfields" data-empty="{'name':'','value':''}">
664-
665-
</div>
666-
</fieldset>
667-
668651
<div class="aui-buttons">
669652
<button class="aui-button aui-button-primary">Save</button>
670653
<button class="aui-button aui-button" name="delete">Delete</button>
@@ -674,4 +657,4 @@
674657

675658
</body>
676659

677-
</html>
660+
</html>

src/main/resources/atlassian-plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<resource type="download" name="utils.js" location="utils.js" />
6767
<resource type="download" name="pr-triggerbutton.js" location="/pr-triggerbutton.js" />
6868
<dependency>com.atlassian.bitbucket.bitbucket-web-plugin:global</dependency>
69+
<dependency>com.atlassian.auiplugin:ajs</dependency>
6970
<context>bitbucket.page.pullRequest.view</context>
7071
</web-resource>
71-
</atlassian-plugin>
72+
</atlassian-plugin>

src/main/resources/pr-triggerbutton.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
define('plugin/prnfb/pr-triggerbutton', [
22
'jquery',
3-
'aui',
3+
'@atlassian/aui',
44
'bitbucket/util/state',
55
'underscore',
66
'plugin/prnfb/3rdparty'
@@ -304,8 +304,6 @@ define('plugin/prnfb/pr-triggerbutton', [
304304
});
305305
});
306306

307-
require(['bitbucket/util/events'], function(events) {
308-
events.on('bitbucket.internal.feature.repositories.recent.loaded', function() {
307+
AJS.$(document).ready(function() {
309308
require('plugin/prnfb/pr-triggerbutton');
310-
});
311309
});

0 commit comments

Comments
 (0)