Skip to content

Commit 178d047

Browse files
committed
Bump RDF4j version to 2.3.2. Provide details on supported formats in sesamize.
1 parent 77b3aae commit 178d047

File tree

8 files changed

+59
-6
lines changed

8 files changed

+59
-6
lines changed

caching-sail/src/main/java/net/fortytwo/sesametools/caching/CachingSailConnection.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,9 @@ private void cacheStatements(final Resource subj, final IRI pred, final Value ob
231231
public SailConnection getBaseConnection() {
232232
return baseSailConnection;
233233
}
234+
235+
@Override
236+
public boolean pendingRemovals() {
237+
return false;
238+
}
234239
}

common/src/main/java/net/fortytwo/sesametools/SingleContextSailConnection.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ protected long sizeInternal(final Resource... contexts) throws SailException {
187187
}
188188
}
189189

190+
@Override
191+
public boolean pendingRemovals() {
192+
return false;
193+
}
194+
190195
private class SingleContextIteration implements CloseableIteration<Resource, SailException> {
191196
private Resource nextContext;
192197

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<junit.version>4.12</junit.version>
5555
<log4j.version>1.2.17</log4j.version>
5656
<restlet.version>2.2.2</restlet.version>
57-
<rdf4j.version>2.0M3</rdf4j.version>
57+
<rdf4j.version>2.3.2</rdf4j.version>
5858
<slf4j.version>1.7.10</slf4j.version>
5959
<httpcomponents.version>4.5.2</httpcomponents.version>
6060

readonly-sail/src/main/java/net/fortytwo/sesametools/readonly/ReadOnlySailConnection.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,9 @@ protected void clearNamespacesInternal() throws SailException {
104104
protected void startTransactionInternal() throws SailException {
105105
baseSailConnection.begin();
106106
}
107+
108+
@Override
109+
public boolean pendingRemovals() {
110+
return false;
111+
}
107112
}

replay-sail/src/main/java/net/fortytwo/sesametools/replay/RecorderSailConnection.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,9 @@ protected void startTransactionInternal() throws SailException {
207207
}
208208
baseSailConnection.begin();
209209
}
210+
211+
@Override
212+
public boolean pendingRemovals() {
213+
return false;
214+
}
210215
}

repository-sail/src/main/java/net/fortytwo/sesametools/reposail/RepositorySailConnection.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,9 @@ protected void startTransactionInternal() throws SailException {
178178
throw new SailException(e);
179179
}
180180
}
181+
182+
@Override
183+
public boolean pendingRemovals() {
184+
return false;
185+
}
181186
}

sesamize/src/main/java/net/fortytwo/sesametools/sesamize/SesamizeArgs.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.fortytwo.sesametools.sesamize;
22

33
import org.apache.commons.io.FilenameUtils;
4-
import org.eclipse.rdf4j.common.lang.FileFormat;
54
import org.eclipse.rdf4j.rio.RDFFormat;
65
import org.eclipse.rdf4j.rio.RDFParserRegistry;
76

@@ -23,12 +22,16 @@ public class SesamizeArgs {
2322
public final List<String> nonOptions;
2423

2524
private static final Map<String, RDFFormat> formatsByFileExtension;
25+
private static final Map<String, RDFFormat> formatsByName;
26+
2627
static {
2728
formatsByFileExtension = new HashMap<>();
29+
formatsByName = new HashMap<>();
2830
for (RDFFormat format : RDFParserRegistry.getInstance().getKeys()) {
2931
for (String ext : format.getFileExtensions()) {
3032
formatsByFileExtension.putIfAbsent(ext, format);
3133
}
34+
formatsByName.put(format.getName().toLowerCase(), format);
3235
}
3336
}
3437

@@ -119,21 +122,42 @@ public RDFFormat getRDFFormat(final File file,
119122
}
120123

121124
private RDFFormat findRDFFormat(final String s) {
125+
RDFFormat format = formatsByName.get(s.toLowerCase());
126+
if (null != format) {
127+
return format;
128+
}
129+
122130
Optional<RDFFormat> f;
123131

124-
f = RDFParserRegistry.getInstance().getFileFormatForMIMEType(s);
132+
RDFParserRegistry registry = RDFParserRegistry.getInstance();
133+
f = registry.getFileFormatForMIMEType(s);
125134

126135
if (!f.isPresent()) {
127-
f = RDFParserRegistry.getInstance().getFileFormatForFileName("example." + s);
136+
f = registry.getFileFormatForFileName("example." + s);
128137
}
129138

130139
if (!f.isPresent()) {
131-
throw new IllegalArgumentException("no matching RDF format for '" + s + "'");
140+
throw new IllegalArgumentException("no matching RDF format for '" + s + "' (" +
141+
"supported formats are: " + getFormats(registry) + ")");
132142
}
133143

134144
return f.get();
135145
}
136146

147+
private String getFormats(final RDFParserRegistry registry) {
148+
StringBuilder sb = new StringBuilder();
149+
boolean first = true;
150+
for (RDFFormat format : registry.getKeys()) {
151+
if (first) {
152+
first = false;
153+
} else {
154+
sb.append(", ");
155+
}
156+
sb.append(format.getName());
157+
}
158+
return sb.toString();
159+
}
160+
137161
private String getOptionName(final String option) {
138162
if (option.startsWith("--")) {
139163
return option.substring(2);
@@ -143,5 +167,4 @@ private String getOptionName(final String option) {
143167
return option;
144168
}
145169
}
146-
147170
}

writeonly-sail/src/main/java/net/fortytwo/sesametools/writeonly/WriteOnlySailConnection.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,9 @@ protected long sizeInternal(final Resource... contexts) throws SailException {
119119
protected void startTransactionInternal() throws SailException {
120120
// Does nothing.
121121
}
122+
123+
@Override
124+
public boolean pendingRemovals() {
125+
return false;
126+
}
122127
}

0 commit comments

Comments
 (0)