Skip to content

Commit 324cafa

Browse files
committed
Merge branch 'main' into development
2 parents 5578108 + b1796c1 commit 324cafa

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ name: Java CI
77

88
on:
99
push:
10-
branches: [main, dev]
10+
branches: [main, development]
1111
pull_request:
12-
branches: [main, dev]
12+
branches: [main, development]
1313

1414
jobs:
1515
build:

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ main, dev ]
16+
branches: [ main, development ]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
1919
branches: "*"

src/main/java/edu/kit/datamanager/mappingservice/plugins/PluginLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public static Map<String, IMappingPlugin> loadPlugins(File plugDir) throws IOExc
7474
List<IMappingPlugin> IMappingPluginList = PluginLoader.createPluggableObjects(plugClasses);
7575

7676
for (IMappingPlugin i : IMappingPluginList) {
77+
//TODO: Add error handling in case setup of one plugin fails
7778
i.setup();
7879
result.put(i.id(), i);
7980
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package edu.kit.datamanager.mappingservice.plugins.impl;
6+
7+
import edu.kit.datamanager.mappingservice.plugins.IMappingPlugin;
8+
import edu.kit.datamanager.mappingservice.plugins.MappingPluginException;
9+
import edu.kit.datamanager.mappingservice.plugins.MappingPluginState;
10+
import edu.kit.datamanager.mappingservice.util.ShellRunnerUtil;
11+
import java.io.FileNotFoundException;
12+
import java.io.FileOutputStream;
13+
import java.io.IOException;
14+
import java.nio.file.Path;
15+
import java.nio.file.Paths;
16+
import org.slf4j.Logger;
17+
import org.slf4j.LoggerFactory;
18+
import org.springframework.util.MimeType;
19+
20+
/**
21+
* Simple mapping service plugin calling image magick 'identify' to obtain image
22+
* metadata from a given image.
23+
*
24+
* @author jejkal
25+
*/
26+
public class IdentifyPlugin implements IMappingPlugin {
27+
28+
static Logger LOG = LoggerFactory.getLogger(IdentifyPlugin.class);
29+
30+
private boolean initialized = false;
31+
32+
@Override
33+
public String name() {
34+
return "Identify";
35+
}
36+
37+
@Override
38+
public String description() {
39+
return "Simple mapping service plugin calling image magick 'identify' to obtain image metadata from a given image.";
40+
}
41+
42+
@Override
43+
public String version() {
44+
return "1.0.0";
45+
}
46+
47+
@Override
48+
public String uri() {
49+
return "https://github.com/kit-data-manager/mapping-service";
50+
}
51+
52+
@Override
53+
public MimeType[] inputTypes() {
54+
return new MimeType[]{MimeType.valueOf("application/octet-stream")};
55+
}
56+
57+
@Override
58+
public MimeType[] outputTypes() {
59+
return new MimeType[]{MimeType.valueOf("application/octet-stream")};
60+
}
61+
62+
@Override
63+
public void setup() {
64+
if (Paths.get("/usr/bin/identify").toFile().exists()) {
65+
initialized = true;
66+
}
67+
}
68+
69+
@Override
70+
public MappingPluginState mapFile(Path mappingFile, Path inputFile, Path outputFile) throws MappingPluginException {
71+
try {
72+
FileOutputStream fout = new FileOutputStream(outputFile.toFile());
73+
ShellRunnerUtil.run(fout, fout, "/usr/bin/identify", "-verbose", inputFile.toAbsolutePath().toString());
74+
fout.flush();
75+
fout.close();
76+
} catch (IOException ex) {
77+
LOG.error("Failed to execute plugin.", ex);
78+
return MappingPluginState.EXECUTION_ERROR;
79+
}
80+
return MappingPluginState.SUCCESS;
81+
}
82+
83+
}

0 commit comments

Comments
 (0)