Skip to content

Commit 8c350c9

Browse files
authored
Update sample plugin (sdk 3.4.1) (#19)
* Update project manifest and dependencies (sdk 3.4.1) - update project version to 3.1.0 (minor bump) - update dicoogle-sdk to 3.4.1 (latest SDK) - update build dependency maven-compiler-plugin to the latest version - update license-maven-plugin to v2.9 * Update ghactions CI workflow - update actions/checkout to v4 - update actions/setup-java to v4 - use temurin for the JDK distro * Fix URI creation logic at RSIQuery - URIs always use forward slashes regardless of platform OS * Use maven-shade-plugin instead of maven-assembly-plugin - better practice * Update README - Update URLs - Ask user to have Java 8 or 11 installed - Suggest to use `mvn package` instead of `mvn install` - Update the resulting jar file name - Refer to Dicoogle learning pack - Suggest adding dicoogle-plugin-sample to the list of DIM providers - Tweak formatting a bit * Remove JsonWebService, extend RSIWebResource instead * Remove unused imports * Fix reported scheme of RSIStorage - scheme should not include the "://" part * Refactor RSIStorage - do not use raw types - save byte arrays instead of dangling output streams * Update webplugin - Instead of hello world, provide Dicoogle Health Check, the tutorial webplugin - use parcel to build the plugin
1 parent bea4970 commit 8c350c9

File tree

19 files changed

+4193
-274
lines changed

19 files changed

+4193
-274
lines changed

.github/workflows/maven.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
java-version: ['8', '11']
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- name: Set up Java (JDK ${{ matrix.java-version }})
24-
uses: actions/setup-java@v3
24+
uses: actions/setup-java@v4
2525
with:
26-
distribution: 'zulu'
26+
distribution: 'temurin'
2727
java-version: ${{ matrix.java-version }}
2828
cache: 'maven'
2929
- name: Build with Maven

README.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Getting Started
99

1010
### Installing and running Dicoogle
1111

12-
1. Go to http://www.dicoogle.com/downloads
13-
2. Download version 2 (or later) of Dicoogle
12+
1. Make sure that you have Java installed in your system. Versions 8 and 11 are known to work.
13+
1. Go to https://www.dicoogle.com/downloads and get version 3 of Dicoogle
1414
3. Extract your contents to its own directory (e.g. "~/dicoogle" or "C:\dicoogle", depending on the platform).
1515
4. Run Dicoogle with: sh DicoogleClient.sh (OSX / Linux) or DicoogleClient.bat (Windows).
1616
5. You should see your web browser opening the Dicoogle user interface. Is it running? You're ok!
@@ -21,33 +21,39 @@ Maven is required in order to build the project. An IDE with Maven support such
2121

2222
1. Clone the git repository at https://github.com/bioinformatics-ua/dicoogle-plugin-sample.git
2323

24-
2. Go to the project's base directory in a command line and run `mvn install`. Alternatively, open
25-
the Maven project of the plugin with your IDE, then force it to build your project.
24+
2. Go to the project's base directory in a command line and run `mvn package`.
25+
Alternatively, open the Maven project of the plugin with your IDE, then force it to build your project.
2626

27-
3. If the building task is successful, you will have a new jar with dependencies in the target
28-
folder (target/dicoogle-plugin-sample-2.0-jar-with-dependencies.jar).
27+
3. If the building task is successful, you will have a new shaded jar (with the necessary dependencies)
28+
in the `target` folder (e.g. `target/dicoogle-plugin-sample-3.1.0.jar`)
2929

3030
### Developing your own plugin based on this sample
3131

32-
The first class to look into is RSIPluginSet. It is the main entry point for everything else.
32+
The first class to look into is [`RSIPluginSet`][pluginset].
33+
It is the main entry point for everything else.
3334
Once modified to suit your needs, build the plugin again and re-deploy it to Dicoogle (see below).
3435

36+
Be sure to consult the [Dicoogle Learning Pack][learningpack] for more information.
37+
38+
[pluginset]: src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIPluginSet.java
39+
[learningpack]: https://bioinformatics-ua.github.io/dicoogle-learning-pack/docs/developing-plugins/
40+
3541
### Using your plugin
3642

37-
1. Copy your plugin's package with dependencies (target/dicoogle-plugin-sample-2.0-jar-with-dependencies.jar)
43+
1. Copy your plugin's built jar (`target/dicoogle-plugin-sample-3.1.0.jar`)
3844
to the "Plugins" folder inside the root folder of Dicoogle.
3945

4046
2. Run Dicoogle. The plugin will be automatically included.
4147

4248
Available content
4349
-----------------
4450

45-
- _RSIIndexer_ : a sample indexer, only logs the DIM contents of files
46-
- _RSIStorage_ : a sample storage service, keeps files in memory buffers
47-
- _RSIQuery_ : a sample query provider, returns random data on request
48-
- _RSIJettyPlugin_ : a sample plugin for providing web services, holds `RSIWebService`
49-
- _RSIWebService_ : a sample web service in the form of a servlet, serves a web page and a few other services
50-
- _RSIRestPlugin_ : a sample Restlet server resource, provides dummy data
51+
- `RSIIndexer` : a sample indexer, only logs the DIM contents of files
52+
- `RSIStorage` : a sample storage service, keeps files in memory buffers
53+
- `RSIQuery` : a sample query provider, returns random data on request
54+
- `RSIJettyPlugin` : a sample plugin for providing web services, holds `RSIWebService`
55+
- `RSIWebService` : a sample web service in the form of a servlet, serves a web page and a few other services
56+
- `RSIRestPlugin` : a sample Restlet server resource, provides dummy data
5157
- Sample HTML5 content and consuming web service: helps you to build a web app
5258

5359
Web service plugin sample and Web App:
@@ -62,6 +68,23 @@ To test the webservice plugin, you may open your browser and navigate to these U
6268
You may also use the built-in Dicoogle services for testing other plugins:
6369

6470
- GET `http://localhost:8080/search?query=test&provider=dicoogle-plugin-sample` to test the query provider
71+
- Note: You will need to record `dicoogle-plugin-sample`
72+
as a DIM provider first. In `confs/server.xml`,
73+
add the query provider in `config/archive/dim-providers`
74+
like this:
75+
```xml
76+
<config>
77+
<!-- ... -->
78+
<archive>
79+
<!-- ... -->
80+
<dim-providers>
81+
<dim-provider>dicoogle-plugin-sample</dim-provider>
82+
</dim-providers>
83+
<!-- ... -->
84+
```
85+
Then restart Dicoogle.
86+
Remember to remove the provider from the list after testing
87+
if you do not want to keep it.
6588
- POST `http://localhost:8080/management/tasks/index?plugin=dicoogle-plugin-sample&uri=<file:/path/to/DICOM/dir>` to test the indexer
6689

6790
Platforms
@@ -73,5 +96,5 @@ Dicoogle has been tested in:
7396
- Linux
7497
- Mac OS X
7598

76-
For more information, please visit http://www.dicoogle.com
99+
For more information, please visit https://www.dicoogle.com
77100

pom.xml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<groupId>pt.ua.dicoogle.demo</groupId>
55
<artifactId>dicoogle-plugin-sample</artifactId>
66
<name>dicoogle-plugin-sample</name>
7-
<version>3.0.0</version>
7+
<version>3.1.0</version>
88
<packaging>jar</packaging>
99

1010
<properties>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1212

1313
<!-- Dicoogle SDK version here -->
14-
<dicoogle.version>3.2.2</dicoogle.version>
14+
<dicoogle.version>3.4.1</dicoogle.version>
1515

1616
<!-- Jetty server version here -->
1717
<jetty.version>9.0.3.v20130506</jetty.version>
@@ -24,7 +24,7 @@
2424
<directory>src/main/resources/html5/</directory>
2525
</resource>
2626
<resource>
27-
<directory>src/main/resources/webplugin-sample</directory>
27+
<directory>src/main/resources/webplugin-sample/dist</directory>
2828
<targetPath>WebPlugins/webplugin-sample</targetPath>
2929
<filtering>false</filtering>
3030
<includes>
@@ -38,37 +38,46 @@
3838
<plugin>
3939
<groupId>org.apache.maven.plugins</groupId>
4040
<artifactId>maven-compiler-plugin</artifactId>
41-
<version>2.3.2</version>
41+
<version>3.13.0</version>
4242
<configuration>
4343
<source>1.8</source>
4444
<target>1.8</target>
4545
</configuration>
4646
</plugin>
4747
<plugin>
48-
<artifactId>maven-assembly-plugin</artifactId>
49-
<configuration>
50-
<descriptorRefs>
51-
<descriptorRef>jar-with-dependencies</descriptorRef>
52-
</descriptorRefs>
53-
<archive>
54-
</archive>
55-
</configuration>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-shade-plugin</artifactId>
50+
<version>3.6.0</version>
5651
<executions>
5752
<execution>
58-
<id>make-assembly</id>
5953
<phase>package</phase>
6054
<goals>
61-
<goal>single</goal>
55+
<goal>shade</goal>
6256
</goals>
57+
<configuration>
58+
<filters>
59+
<filter>
60+
<artifact>*:*</artifact>
61+
<excludes>
62+
<exclude>**/*.SF</exclude>
63+
<exclude>**/*.DSA</exclude>
64+
<exclude>**/*.RSA</exclude>
65+
<exclude>**/module-info.class</exclude>
66+
<exclude>**/module-info.java</exclude>
67+
</excludes>
68+
</filter>
69+
</filters>
70+
<minimizeJar>true</minimizeJar>
71+
</configuration>
6372
</execution>
6473
</executions>
6574
</plugin>
6675
<plugin>
6776
<groupId>com.mycila</groupId>
6877
<artifactId>license-maven-plugin</artifactId>
69-
<version>2.4</version>
78+
<version>2.9</version>
7079
<configuration>
71-
<header>./short-license.txt</header>
80+
<header>short-license.txt</header>
7281
<includes>
7382
<include>**/*.java</include>
7483
</includes>
@@ -140,7 +149,5 @@
140149
<artifactId>jetty-webapp</artifactId>
141150
<version>${jetty.version}</version>
142151
</dependency>
143-
144-
145152
</dependencies>
146153
</project>

src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/JsonWebService.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIJettyPlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package pt.ieeta.dicoogle.plugin.demo.dicooglepluginsample;
2020

2121
import java.net.URL;
22-
import javax.servlet.http.HttpServlet;
2322
import org.eclipse.jetty.server.handler.HandlerList;
2423
import org.eclipse.jetty.servlet.ServletContextHandler;
2524
import org.eclipse.jetty.servlet.ServletHolder;

src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIQuery.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package pt.ieeta.dicoogle.plugin.demo.dicooglepluginsample;
2121

22-
import java.io.File;
2322
import java.net.URI;
2423
import java.util.ArrayList;
2524
import java.util.HashMap;
@@ -61,7 +60,7 @@ private SearchResult generateSearchResult()
6160
map.put("SeriesDate","20150120");
6261

6362
SearchResult r = new SearchResult(
64-
URI.create("file:" + File.separatorChar + UUID.randomUUID().toString() ), 1, map);
63+
URI.create("file://" + UUID.randomUUID().toString() ), 1, map);
6564
return r;
6665
}
6766

src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIStorage.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
import pt.ua.dicoogle.sdk.StorageInputStream;
2929
import pt.ua.dicoogle.sdk.StorageInterface;
3030
import pt.ua.dicoogle.sdk.settings.ConfigurationHolder;
31-
import java.util.ArrayList;
32-
import java.util.Collection;
31+
import java.util.Collections;
3332
import java.util.HashMap;
3433
import java.util.Iterator;
3534
import java.util.Map;
@@ -45,13 +44,13 @@
4544
public class RSIStorage implements StorageInterface {
4645
private static final Logger logger = LoggerFactory.getLogger(RSIStorage.class);
4746

48-
private final Map<String, ByteArrayOutputStream> mem = new HashMap<>();
47+
private final Map<String, byte[]> mem = new HashMap<>();
4948
private boolean enabled = true;
5049
private ConfigurationHolder settings;
5150

5251
@Override
5352
public String getScheme() {
54-
return "mem://";
53+
return "mem";
5554
}
5655

5756
@Override
@@ -67,7 +66,6 @@ public Iterable<StorageInputStream> at(final URI location, Object... objects) {
6766

6867
@Override
6968
public Iterator<StorageInputStream> iterator() {
70-
Collection c2 = new ArrayList<>();
7169
StorageInputStream s = new StorageInputStream() {
7270

7371
@Override
@@ -77,18 +75,17 @@ public URI getURI() {
7775

7876
@Override
7977
public InputStream getInputStream() throws IOException {
80-
ByteArrayOutputStream bos = mem.get(location.toString());
81-
ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
78+
byte[] data = mem.get(location.toString());
79+
ByteArrayInputStream bin = new ByteArrayInputStream(data);
8280
return bin;
8381
}
8482

8583
@Override
8684
public long getSize() throws IOException {
87-
return mem.get(location.toString()).size();
85+
return mem.get(location.toString()).length;
8886
}
8987
};
90-
c2.add(s);
91-
return c2.iterator();
88+
return Collections.singletonList(s).iterator();
9289
}
9390
};
9491
return c;
@@ -97,16 +94,14 @@ public long getSize() throws IOException {
9794
@Override
9895
public URI store(DicomObject dicomObject, Object... objects) {
9996
ByteArrayOutputStream bos = new ByteArrayOutputStream();
100-
DicomOutputStream dos = new DicomOutputStream(bos);
101-
try {
97+
try (DicomOutputStream dos = new DicomOutputStream(bos)) {
10298
dos.writeDicomFile(dicomObject);
10399
} catch (IOException ex) {
104100
logger.warn("Failed to store object", ex);
105101
}
106-
bos.toByteArray();
107102
URI uri = URI.create("mem://" + UUID.randomUUID().toString());
108-
mem.put(uri.toString(), bos);
109-
103+
mem.put(uri.toString(), bos.toByteArray());
104+
110105
return uri;
111106
}
112107

0 commit comments

Comments
 (0)