Skip to content

Commit 9b08922

Browse files
authored
Merge pull request #55 from ChannelFinder/elastic8
Elastic8
2 parents ff8f896 + 1349f7d commit 9b08922

32 files changed

+1748
-1802
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
java -jar ChannelFinder-4.0.0.jar
2222
"
2323
elasticsearch:
24-
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.3
24+
image: docker.elastic.co/elasticsearch/elasticsearch:8.2.0
2525
hostname: elasticsearch-cf
2626
networks:
2727
- channelfinder-net

pom.xml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
35
<modelVersion>4.0.0</modelVersion>
46

57
<artifactId>ChannelFinder</artifactId>
@@ -35,8 +37,8 @@
3537
</developers>
3638
<properties>
3739
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38-
<spring.boot-version>2.1.1.RELEASE</spring.boot-version>
39-
<elasticsearch.version>6.8.4</elasticsearch.version>
40+
<spring.boot-version>2.6.7</spring.boot-version>
41+
<elasticsearch.version>8.2.0</elasticsearch.version>
4042
</properties>
4143
<dependencyManagement>
4244
<dependencies>
@@ -91,8 +93,24 @@
9193
<artifactId>junit</artifactId>
9294
</dependency>
9395
<dependency>
94-
<groupId>org.elasticsearch.client</groupId>
95-
<artifactId>elasticsearch-rest-high-level-client</artifactId>
96+
<groupId>co.elastic.clients</groupId>
97+
<artifactId>elasticsearch-java</artifactId>
98+
<version>8.2.0</version>
99+
</dependency>
100+
<dependency>
101+
<groupId>com.fasterxml.jackson.core</groupId>
102+
<artifactId>jackson-databind</artifactId>
103+
<version>2.12.3</version>
104+
</dependency>
105+
<dependency>
106+
<groupId>com.fasterxml.jackson.core</groupId>
107+
<artifactId>jackson-core</artifactId>
108+
<version>2.12.3</version>
109+
</dependency>
110+
<dependency>
111+
<groupId>jakarta.json</groupId>
112+
<artifactId>jakarta.json-api</artifactId>
113+
<version>2.0.1</version>
96114
</dependency>
97115
<dependency>
98116
<groupId>com.google.guava</groupId>

src/main/java/org/phoebus/channelfinder/Application.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2626
import org.springframework.boot.autoconfigure.SpringBootApplication;
2727
import org.springframework.context.annotation.ComponentScan;
28+
import org.springframework.context.annotation.PropertySource;
2829
import org.springframework.util.FileCopyUtils;
2930

3031
@EnableAutoConfiguration

src/main/java/org/phoebus/channelfinder/ChannelManager.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import javax.servlet.ServletContext;
1212

13+
import co.elastic.clients.elasticsearch._types.Refresh;
14+
import com.google.common.collect.Lists;
1315
import org.phoebus.channelfinder.AuthorizationService.ROLES;
1416
import org.springframework.beans.factory.annotation.Autowired;
1517
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -187,7 +189,7 @@ public Iterable<XmlChannel> create(@RequestBody Iterable<XmlChannel> channels) {
187189
});
188190

189191
// create new channels
190-
return channelRepository.indexAll(channels);
192+
return channelRepository.indexAll(Lists.newArrayList(channels));
191193
} else {
192194
log.log(Level.SEVERE, "User does not have the proper authorization to perform an operation on this channel: " + channels, new ResponseStatusException(HttpStatus.UNAUTHORIZED));
193195
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
@@ -220,20 +222,34 @@ public XmlChannel update(@PathVariable("channelName") String channelName, @Reque
220222
}
221223
Optional<XmlChannel> existingChannel = channelRepository.findById(channelName);
222224
boolean present = existingChannel.isPresent();
225+
226+
XmlChannel newChannel;
223227
if(present) {
224228
if(!authorizationService.isAuthorizedOwner(SecurityContextHolder.getContext().getAuthentication(), existingChannel.get())) {
225229
log.log(Level.SEVERE, "User does not have the proper authorization to perform an operation on this channel: " + existingChannel.get().toLog(), new ResponseStatusException(HttpStatus.UNAUTHORIZED));
226230
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,
227231
"User does not have the proper authorization to perform an operation on this channel: " + existingChannel.get(), null);
228232
}
229-
}
233+
newChannel = existingChannel.get();
234+
newChannel.setOwner(channel.getOwner());
235+
newChannel.addProperties(channel.getProperties());
236+
newChannel.addTags(channel.getTags());
237+
// Is an existing channel being renamed
238+
if (!channel.getName().equalsIgnoreCase(existingChannel.get().getName())) {
239+
// Since this is a rename operation we will need to remove the old channel.
240+
channelRepository.deleteById(existingChannel.get().getName());
241+
newChannel.setName(channel.getName());
242+
}
243+
} else {
244+
newChannel = channel;
245+
}
230246

231247
// reset owners of attached tags/props back to existing owners
232248
channel.getProperties().forEach(prop -> prop.setOwner(propertyRepository.findById(prop.getName()).get().getOwner()));
233249
channel.getTags().forEach(tag -> tag.setOwner(tagRepository.findById(tag.getName()).get().getOwner()));
234250

235251
// update channel
236-
return channelRepository.save(channelName,channel);
252+
return channelRepository.save(newChannel);
237253
} else {
238254
log.log(Level.SEVERE, "User does not have the proper authorization to perform an operation on this channel: " + channelName, new ResponseStatusException(HttpStatus.UNAUTHORIZED));
239255
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED,

0 commit comments

Comments
 (0)