Skip to content

Commit 2b64748

Browse files
committed
Adjust controllers
- Remove swagger related annotations from the controllers (as the documentation layer is moved to the interface level)
1 parent 3324bc6 commit 2b64748

File tree

5 files changed

+29
-84
lines changed

5 files changed

+29
-84
lines changed

src/main/java/org/phoebus/channelfinder/rest/controller/ChannelController.java

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package org.phoebus.channelfinder.rest.controller;
22

3-
import static org.phoebus.channelfinder.common.CFResourceDescriptors.SEARCH_PARAM_DESCRIPTION;
4-
53
import com.google.common.collect.FluentIterable;
64
import com.google.common.collect.Lists;
7-
import io.swagger.v3.oas.annotations.Parameter;
85
import java.text.MessageFormat;
96
import java.util.List;
107
import java.util.Map;
@@ -32,9 +29,6 @@
3229
import org.springframework.security.core.context.SecurityContextHolder;
3330
import org.springframework.util.MultiValueMap;
3431
import org.springframework.web.bind.annotation.CrossOrigin;
35-
import org.springframework.web.bind.annotation.PathVariable;
36-
import org.springframework.web.bind.annotation.RequestBody;
37-
import org.springframework.web.bind.annotation.RequestParam;
3832
import org.springframework.web.bind.annotation.RestController;
3933
import org.springframework.web.server.ResponseStatusException;
4034

@@ -60,28 +54,22 @@ public class ChannelController implements IChannel {
6054
@Autowired ChannelProcessorService channelProcessorService;
6155

6256
@Override
63-
public List<Channel> query(
64-
@Parameter(description = SEARCH_PARAM_DESCRIPTION) @RequestParam
65-
MultiValueMap<String, String> allRequestParams) {
57+
public List<Channel> query(MultiValueMap<String, String> allRequestParams) {
6658
return channelRepository.search(allRequestParams).channels();
6759
}
6860

6961
@Override
70-
public SearchResult combinedQuery(
71-
@Parameter(description = SEARCH_PARAM_DESCRIPTION) @RequestParam
72-
MultiValueMap<String, String> allRequestParams) {
62+
public SearchResult combinedQuery(MultiValueMap<String, String> allRequestParams) {
7363
return channelRepository.search(allRequestParams);
7464
}
7565

7666
@Override
77-
public long queryCount(
78-
@Parameter(description = SEARCH_PARAM_DESCRIPTION) @RequestParam
79-
MultiValueMap<String, String> allRequestParams) {
67+
public long queryCount(MultiValueMap<String, String> allRequestParams) {
8068
return channelRepository.count(allRequestParams);
8169
}
8270

8371
@Override
84-
public Channel read(@PathVariable("channelName") String channelName) {
72+
public Channel read(String channelName) {
8573
channelManagerAudit.log(
8674
Level.INFO, () -> MessageFormat.format(TextUtil.FIND_CHANNEL, channelName));
8775

@@ -95,8 +83,7 @@ public Channel read(@PathVariable("channelName") String channelName) {
9583
}
9684

9785
@Override
98-
public Channel create(
99-
@PathVariable("channelName") String channelName, @RequestBody Channel channel) {
86+
public Channel create(String channelName, Channel channel) {
10087
// check if authorized role
10188
if (authorizationService.isAuthorizedRole(
10289
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_CHANNEL)) {
@@ -147,7 +134,7 @@ public Channel create(
147134
}
148135

149136
@Override
150-
public Iterable<Channel> create(@RequestBody Iterable<Channel> channels) {
137+
public Iterable<Channel> create(Iterable<Channel> channels) {
151138
// check if authorized role
152139
if (authorizationService.isAuthorizedRole(
153140
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_CHANNEL)) {
@@ -238,8 +225,7 @@ private void resetOwnersToExisting(Iterable<Channel> channels) {
238225
}
239226

240227
@Override
241-
public Channel update(
242-
@PathVariable("channelName") String channelName, @RequestBody Channel channel) {
228+
public Channel update(String channelName, Channel channel) {
243229
if (authorizationService.isAuthorizedRole(
244230
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_CHANNEL)) {
245231
long start = System.currentTimeMillis();
@@ -308,7 +294,7 @@ public Channel update(
308294
}
309295

310296
@Override
311-
public Iterable<Channel> update(@RequestBody Iterable<Channel> channels) {
297+
public Iterable<Channel> update(Iterable<Channel> channels) {
312298
// check if authorized role
313299
if (authorizationService.isAuthorizedRole(
314300
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_CHANNEL)) {
@@ -368,7 +354,7 @@ public Iterable<Channel> update(@RequestBody Iterable<Channel> channels) {
368354
}
369355

370356
@Override
371-
public void remove(@PathVariable("channelName") String channelName) {
357+
public void remove(String channelName) {
372358
// check if authorized role
373359
if (authorizationService.isAuthorizedRole(
374360
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_CHANNEL)) {

src/main/java/org/phoebus/channelfinder/rest/controller/ChannelProcessorController.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package org.phoebus.channelfinder.rest.controller;
22

3-
import static org.phoebus.channelfinder.common.CFResourceDescriptors.SEARCH_PARAM_DESCRIPTION;
4-
5-
import io.swagger.v3.oas.annotations.Parameter;
63
import java.util.List;
74
import java.util.logging.Level;
85
import java.util.logging.Logger;
@@ -20,8 +17,6 @@
2017
import org.springframework.security.core.context.SecurityContextHolder;
2118
import org.springframework.util.LinkedMultiValueMap;
2219
import org.springframework.util.MultiValueMap;
23-
import org.springframework.web.bind.annotation.PathVariable;
24-
import org.springframework.web.bind.annotation.RequestParam;
2520
import org.springframework.web.bind.annotation.RestController;
2621
import org.springframework.web.server.ResponseStatusException;
2722

@@ -72,9 +67,7 @@ public long processAllChannels() {
7267
}
7368

7469
@Override
75-
public long processChannels(
76-
@Parameter(description = SEARCH_PARAM_DESCRIPTION) @RequestParam
77-
MultiValueMap<String, String> allRequestParams) {
70+
public long processChannels(MultiValueMap<String, String> allRequestParams) {
7871
long channelCount = 0;
7972
Scroll scrollResult = channelScroll.query(allRequestParams);
8073
channelCount += scrollResult.getChannels().size();
@@ -93,11 +86,7 @@ public void processChannels(List<Channel> channels) {
9386
}
9487

9588
@Override
96-
public void setProcessorEnabled(
97-
@PathVariable("processorName") String processorName,
98-
@Parameter(description = "Value of enabled to set, default value: true")
99-
@RequestParam(required = false, name = "enabled", defaultValue = "true")
100-
Boolean enabled) {
89+
public void setProcessorEnabled(String processorName, Boolean enabled) {
10190
channelProcessorService.setProcessorEnabled(processorName, enabled);
10291
}
10392
}

src/main/java/org/phoebus/channelfinder/rest/controller/ChannelScrollController.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import co.elastic.clients.elasticsearch.core.SearchRequest;
99
import co.elastic.clients.elasticsearch.core.SearchResponse;
1010
import co.elastic.clients.elasticsearch.core.search.Hit;
11-
import io.swagger.v3.oas.annotations.Parameter;
1211
import java.text.MessageFormat;
1312
import java.util.Comparator;
1413
import java.util.List;
@@ -17,7 +16,6 @@
1716
import java.util.logging.Level;
1817
import java.util.logging.Logger;
1918
import java.util.stream.Collectors;
20-
import org.phoebus.channelfinder.common.CFResourceDescriptors;
2119
import org.phoebus.channelfinder.common.TextUtil;
2220
import org.phoebus.channelfinder.configuration.ElasticConfig;
2321
import org.phoebus.channelfinder.entity.Channel;
@@ -28,8 +26,6 @@
2826
import org.springframework.http.HttpStatus;
2927
import org.springframework.util.MultiValueMap;
3028
import org.springframework.web.bind.annotation.CrossOrigin;
31-
import org.springframework.web.bind.annotation.PathVariable;
32-
import org.springframework.web.bind.annotation.RequestParam;
3329
import org.springframework.web.bind.annotation.RestController;
3430
import org.springframework.web.server.ResponseStatusException;
3531

@@ -47,18 +43,12 @@ public class ChannelScrollController implements org.phoebus.channelfinder.rest.a
4743
ElasticsearchClient client;
4844

4945
@Override
50-
public Scroll query(
51-
@Parameter(description = CFResourceDescriptors.SEARCH_PARAM_DESCRIPTION) @RequestParam
52-
MultiValueMap<String, String> allRequestParams) {
46+
public Scroll query(MultiValueMap<String, String> allRequestParams) {
5347
return search(null, allRequestParams);
5448
}
5549

5650
@Override
57-
public Scroll query(
58-
@Parameter(description = "Scroll ID from previous query") @PathVariable("scrollId")
59-
String scrollId,
60-
@Parameter(description = CFResourceDescriptors.SEARCH_PARAM_DESCRIPTION) @RequestParam
61-
MultiValueMap<String, String> searchParameters) {
51+
public Scroll query(String scrollId, MultiValueMap<String, String> searchParameters) {
6252
return search(scrollId, searchParameters);
6353
}
6454

src/main/java/org/phoebus/channelfinder/rest/controller/PropertyController.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
import org.springframework.http.HttpStatus;
2626
import org.springframework.security.core.context.SecurityContextHolder;
2727
import org.springframework.web.bind.annotation.CrossOrigin;
28-
import org.springframework.web.bind.annotation.PathVariable;
29-
import org.springframework.web.bind.annotation.RequestBody;
30-
import org.springframework.web.bind.annotation.RequestParam;
3128
import org.springframework.web.bind.annotation.RestController;
3229
import org.springframework.web.server.ResponseStatusException;
3330

@@ -54,9 +51,7 @@ public Iterable<Property> list() {
5451
}
5552

5653
@Override
57-
public Property read(
58-
@PathVariable("propertyName") String propertyName,
59-
@RequestParam(value = "withChannels", defaultValue = "true") boolean withChannels) {
54+
public Property read(String propertyName, boolean withChannels) {
6055
propertyManagerAudit.log(
6156
Level.INFO, () -> MessageFormat.format(TextUtil.FIND_PROPERTY, propertyName));
6257

@@ -76,8 +71,7 @@ public Property read(
7671
}
7772

7873
@Override
79-
public Property create(
80-
@PathVariable("propertyName") String propertyName, @RequestBody Property property) {
74+
public Property create(String propertyName, Property property) {
8175
// check if authorized role
8276
if (authorizationService.isAuthorizedRole(
8377
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_PROPERTY)) {
@@ -128,7 +122,7 @@ public Property create(
128122
}
129123

130124
@Override
131-
public Iterable<Property> create(@RequestBody Iterable<Property> properties) {
125+
public Iterable<Property> create(Iterable<Property> properties) {
132126
// check if authorized role
133127
if (authorizationService.isAuthorizedRole(
134128
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_PROPERTY)) {
@@ -183,10 +177,7 @@ public Iterable<Property> create(@RequestBody Iterable<Property> properties) {
183177
}
184178

185179
@Override
186-
public Property addSingle(
187-
@PathVariable("propertyName") String propertyName,
188-
@PathVariable("channelName") String channelName,
189-
@RequestBody Property property) {
180+
public Property addSingle(String propertyName, String channelName, Property property) {
190181
// check if authorized role
191182
if (authorizationService.isAuthorizedRole(
192183
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_PROPERTY)) {
@@ -236,8 +227,7 @@ public Property addSingle(
236227
}
237228

238229
@Override
239-
public Property update(
240-
@PathVariable("propertyName") String propertyName, @RequestBody Property property) {
230+
public Property update(String propertyName, Property property) {
241231
// check if authorized role
242232
if (!authorizationService.isAuthorizedRole(
243233
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_PROPERTY)) {
@@ -329,7 +319,7 @@ public Property update(
329319
}
330320

331321
@Override
332-
public Iterable<Property> update(@RequestBody Iterable<Property> properties) {
322+
public Iterable<Property> update(Iterable<Property> properties) {
333323
// check if authorized role
334324
if (authorizationService.isAuthorizedRole(
335325
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_PROPERTY)) {
@@ -425,7 +415,7 @@ private void checkPropertyAuthorization(Optional<Property> existingProperty) {
425415
}
426416

427417
@Override
428-
public void remove(@PathVariable("propertyName") String propertyName) {
418+
public void remove(String propertyName) {
429419
// check if authorized role
430420
if (authorizationService.isAuthorizedRole(
431421
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_PROPERTY)) {
@@ -455,9 +445,7 @@ public void remove(@PathVariable("propertyName") String propertyName) {
455445
}
456446

457447
@Override
458-
public void removeSingle(
459-
@PathVariable("propertyName") final String propertyName,
460-
@PathVariable("channelName") String channelName) {
448+
public void removeSingle(final String propertyName, String channelName) {
461449
// check if authorized role
462450
if (authorizationService.isAuthorizedRole(
463451
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_PROPERTY)) {

src/main/java/org/phoebus/channelfinder/rest/controller/TagController.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
import org.springframework.http.HttpStatus;
2626
import org.springframework.security.core.context.SecurityContextHolder;
2727
import org.springframework.web.bind.annotation.CrossOrigin;
28-
import org.springframework.web.bind.annotation.PathVariable;
29-
import org.springframework.web.bind.annotation.RequestBody;
30-
import org.springframework.web.bind.annotation.RequestParam;
3128
import org.springframework.web.bind.annotation.RestController;
3229
import org.springframework.web.server.ResponseStatusException;
3330

@@ -52,9 +49,7 @@ public Iterable<Tag> list() {
5249
}
5350

5451
@Override
55-
public Tag read(
56-
@PathVariable("tagName") String tagName,
57-
@RequestParam(value = "withChannels", defaultValue = "true") boolean withChannels) {
52+
public Tag read(String tagName, boolean withChannels) {
5853
tagManagerAudit.log(Level.INFO, () -> MessageFormat.format(TextUtil.FIND_TAG, tagName));
5954

6055
if (withChannels) {
@@ -79,7 +74,7 @@ public Tag read(
7974
}
8075

8176
@Override
82-
public Tag create(@PathVariable("tagName") String tagName, @RequestBody Tag tag) {
77+
public Tag create(String tagName, Tag tag) {
8378
// check if authorized role
8479
if (authorizationService.isAuthorizedRole(
8580
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_TAG)) {
@@ -135,7 +130,7 @@ public Tag create(@PathVariable("tagName") String tagName, @RequestBody Tag tag)
135130
}
136131

137132
@Override
138-
public Iterable<Tag> create(@RequestBody Iterable<Tag> tags) {
133+
public Iterable<Tag> create(Iterable<Tag> tags) {
139134
// check if authorized role
140135
if (authorizationService.isAuthorizedRole(
141136
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_TAG)) {
@@ -211,8 +206,7 @@ public Iterable<Tag> create(@RequestBody Iterable<Tag> tags) {
211206
}
212207

213208
@Override
214-
public Tag addSingle(
215-
@PathVariable("tagName") String tagName, @PathVariable("channelName") String channelName) {
209+
public Tag addSingle(String tagName, String channelName) {
216210
// check if authorized role
217211
if (authorizationService.isAuthorizedRole(
218212
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_TAG)) {
@@ -256,7 +250,7 @@ public Tag addSingle(
256250
}
257251

258252
@Override
259-
public Tag update(@PathVariable("tagName") String tagName, @RequestBody Tag tag) {
253+
public Tag update(String tagName, Tag tag) {
260254
// check if authorized role
261255
if (authorizationService.isAuthorizedRole(
262256
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_TAG)) {
@@ -332,7 +326,7 @@ public Tag update(@PathVariable("tagName") String tagName, @RequestBody Tag tag)
332326
}
333327

334328
@Override
335-
public Iterable<Tag> update(@RequestBody Iterable<Tag> tags) {
329+
public Iterable<Tag> update(Iterable<Tag> tags) {
336330
// check if authorized role
337331
if (authorizationService.isAuthorizedRole(
338332
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_TAG)) {
@@ -401,7 +395,7 @@ public Iterable<Tag> update(@RequestBody Iterable<Tag> tags) {
401395
}
402396

403397
@Override
404-
public void remove(@PathVariable("tagName") String tagName) {
398+
public void remove(String tagName) {
405399
// check if authorized role
406400
if (authorizationService.isAuthorizedRole(
407401
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_TAG)) {
@@ -430,9 +424,7 @@ public void remove(@PathVariable("tagName") String tagName) {
430424
}
431425

432426
@Override
433-
public void removeSingle(
434-
@PathVariable("tagName") final String tagName,
435-
@PathVariable("channelName") String channelName) {
427+
public void removeSingle(final String tagName, String channelName) {
436428
// check if authorized role
437429
if (authorizationService.isAuthorizedRole(
438430
SecurityContextHolder.getContext().getAuthentication(), ROLES.CF_TAG)) {

0 commit comments

Comments
 (0)