Skip to content

Commit a8ba47e

Browse files
committed
Upgrade to commons-rdf 0.5.0
Resolves #1
1 parent 978e67d commit a8ba47e

File tree

10 files changed

+26
-28
lines changed

10 files changed

+26
-28
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ subprojects {
6262
/* Dependencies */
6363
commonsCodecVersion = '1.11'
6464
commonsIoVersion = '2.6'
65-
commonsRdfVersion = '0.3.0-incubating'
65+
commonsRdfVersion = '0.5.0'
6666
javaxAnnotationsVersion = '1.3.1'
6767
javaxInjectVersion = '1_2'
6868
javaxJsonVersion = '1.1.2'

trellis-http/src/main/java/org/trellisldp/http/impl/GetHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private ResponseBuilder basicGetResponseBuilder(final Resource res, final Option
312312
if (isNull(req.getExt())) {
313313
syntax.ifPresent(s -> {
314314
builder.header(VARY, PREFER);
315-
builder.type(s.mediaType);
315+
builder.type(s.mediaType());
316316
});
317317

318318
model = res.getBinary().isPresent() && syntax.isPresent() ? LDP.RDFSource : res.getInteractionModel();

trellis-http/src/main/java/org/trellisldp/http/impl/MementoResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void write(final OutputStream out) throws IOException {
143143
}
144144
};
145145

146-
return builder.type(syntax.mediaType).entity(stream);
146+
return builder.type(syntax.mediaType()).entity(stream);
147147
}
148148

149149
return builder.type(APPLICATION_LINK_FORMAT)

trellis-http/src/main/java/org/trellisldp/http/impl/PatchHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public void write(final OutputStream out) throws IOException {
200200
}
201201
};
202202

203-
return builder.header(PREFERENCE_APPLIED, "return=representation").type(syntax.mediaType)
203+
return builder.header(PREFERENCE_APPLIED, "return=representation").type(syntax.mediaType())
204204
.entity(stream);
205205
}).orElseGet(() -> builder.status(NO_CONTENT));
206206
}

trellis-http/src/main/java/org/trellisldp/http/impl/RdfUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import static java.util.Optional.of;
2020
import static java.util.Optional.ofNullable;
2121
import static java.util.stream.Stream.concat;
22-
import static org.apache.commons.rdf.api.RDFSyntax.RDFA_HTML;
22+
import static org.apache.commons.rdf.api.RDFSyntax.RDFA;
2323
import static org.apache.commons.rdf.api.RDFSyntax.TURTLE;
2424
import static org.slf4j.LoggerFactory.getLogger;
2525
import static org.trellisldp.api.RDFUtils.getInstance;
@@ -261,7 +261,7 @@ public static Boolean isDeleted(final Resource res) {
261261
* @return a profile IRI usable by the output streamer
262262
*/
263263
public static IRI getDefaultProfile(final RDFSyntax syntax, final IRI identifier) {
264-
return RDFA_HTML.equals(syntax) ? identifier : expanded;
264+
return RDFA.equals(syntax) ? identifier : expanded;
265265
}
266266

267267
private RdfUtils() {

trellis-http/src/test/java/org/trellisldp/http/HttpBasedBinaryServiceTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public class HttpBasedBinaryServiceTest {
6060

6161
private static final RDF rdf = new SimpleRDF();
6262

63-
private static final IRI resource = rdf.createIRI("http://www.trellisldp.org/ns/trellis.ttl");
64-
private static final IRI sslResource = rdf.createIRI("https://s3.amazonaws.com/www.trellisldp.org/ns/trellis.ttl");
63+
private static final IRI resource = rdf.createIRI("https://www.trellisldp.org/ns/trellis.ttl");
6564
private static final IdentifierService idService = new UUIDGenerator();
6665

6766
@Mock
@@ -101,7 +100,6 @@ public void testExists() {
101100
final BinaryService resolver = new HttpBasedBinaryService(idService.getSupplier("http://example.org/"));
102101

103102
assertTrue(resolver.exists(resource));
104-
assertTrue(resolver.exists(sslResource));
105103
assertFalse(resolver.exists(rdf.createIRI("http://www.trellisldp.org/ns/non-existent.ttl")));
106104
}
107105

@@ -136,8 +134,8 @@ public void testGetContent() {
136134
public void testGetSslContent() {
137135
final BinaryService resolver = new HttpBasedBinaryService(idService.getSupplier("http://example.org/"));
138136

139-
assertTrue(resolver.getContent(sslResource).isPresent());
140-
assertTrue(resolver.getContent(sslResource).map(this::uncheckedToString).get()
137+
assertTrue(resolver.getContent(resource).isPresent());
138+
assertTrue(resolver.getContent(resource).map(this::uncheckedToString).get()
141139
.contains("owl:Ontology"));
142140
}
143141

@@ -147,7 +145,7 @@ public void testSetContent() {
147145
final BinaryService resolver = new HttpBasedBinaryService(idService.getSupplier("http://example.org/"));
148146

149147
final InputStream inputStream = new ByteArrayInputStream(contents.getBytes(UTF_8));
150-
assertThrows(RuntimeTrellisException.class, () -> resolver.setContent(sslResource, inputStream));
148+
assertThrows(RuntimeTrellisException.class, () -> resolver.setContent(resource, inputStream));
151149
}
152150

153151
@Test
@@ -156,7 +154,7 @@ public void testMockedClient() throws IOException {
156154
mockClient);
157155
final String contents = "A new resource";
158156
final InputStream inputStream = new ByteArrayInputStream(contents.getBytes(UTF_8));
159-
resolver.setContent(sslResource, inputStream);
157+
resolver.setContent(resource, inputStream);
160158

161159
verify(mockInvocationBuilder).put(any(Entity.class));
162160
}
@@ -165,7 +163,7 @@ public void testMockedClient() throws IOException {
165163
public void testMockedDelete() throws IOException {
166164
final BinaryService resolver = new HttpBasedBinaryService(idService.getSupplier("http://example.org/"),
167165
mockClient);
168-
resolver.purgeContent(sslResource);
166+
resolver.purgeContent(resource);
169167

170168
verify(mockInvocationBuilder).delete();
171169
}
@@ -176,7 +174,7 @@ public void testMockedDeleteException() {
176174
when(mockStatusType.toString()).thenReturn("BAD REQUEST");
177175
final BinaryService resolver = new HttpBasedBinaryService(idService.getSupplier("http://example.org/"),
178176
mockClient);
179-
assertThrows(RuntimeTrellisException.class, () -> resolver.purgeContent(sslResource));
177+
assertThrows(RuntimeTrellisException.class, () -> resolver.purgeContent(resource));
180178
}
181179

182180
@Test

trellis-http/src/test/java/org/trellisldp/http/impl/GetHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import static javax.ws.rs.core.Response.Status.OK;
3939
import static javax.ws.rs.core.Response.notModified;
4040
import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
41-
import static org.apache.commons.rdf.api.RDFSyntax.RDFA_HTML;
41+
import static org.apache.commons.rdf.api.RDFSyntax.RDFA;
4242
import static org.junit.jupiter.api.Assertions.assertEquals;
4343
import static org.junit.jupiter.api.Assertions.assertFalse;
4444
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -410,7 +410,7 @@ public void testGetLdpc() {
410410
@Test
411411
public void testGetHTML() {
412412
when(mockResource.getInteractionModel()).thenReturn(LDP.Container);
413-
when(mockHeaders.getAcceptableMediaTypes()).thenReturn(singletonList(MediaType.valueOf(RDFA_HTML.mediaType)));
413+
when(mockHeaders.getAcceptableMediaTypes()).thenReturn(singletonList(MediaType.valueOf(RDFA.mediaType())));
414414

415415
final GetHandler getHandler = new GetHandler(mockLdpRequest, mockResourceService,
416416
mockIoService, mockBinaryService, null);

trellis-http/src/test/java/org/trellisldp/http/impl/PatchHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static javax.ws.rs.core.Response.Status.NO_CONTENT;
2424
import static javax.ws.rs.core.Response.Status.OK;
2525
import static javax.ws.rs.core.Response.status;
26-
import static org.apache.commons.rdf.api.RDFSyntax.RDFA_HTML;
26+
import static org.apache.commons.rdf.api.RDFSyntax.RDFA;
2727
import static org.junit.jupiter.api.Assertions.assertEquals;
2828
import static org.junit.jupiter.api.Assertions.assertFalse;
2929
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -203,7 +203,7 @@ public void testPreferHTMLRepresentation() {
203203
when(mockLdpRequest.getPath()).thenReturn("resource");
204204
when(mockLdpRequest.getPrefer()).thenReturn(Prefer.valueOf("return=representation"));
205205
when(mockLdpRequest.getHeaders().getAcceptableMediaTypes())
206-
.thenReturn(singletonList(MediaType.valueOf(RDFA_HTML.mediaType)));
206+
.thenReturn(singletonList(MediaType.valueOf(RDFA.mediaType())));
207207

208208
final PatchHandler patchHandler = new PatchHandler(mockLdpRequest, insert,
209209
mockResourceService, mockIoService, null);

trellis-io-jena/src/main/java/org/trellisldp/io/JenaIOService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import static java.util.stream.Collectors.toMap;
2424
import static java.util.stream.Collectors.toSet;
2525
import static java.util.stream.Stream.of;
26-
import static org.apache.commons.rdf.api.RDFSyntax.RDFA_HTML;
26+
import static org.apache.commons.rdf.api.RDFSyntax.RDFA;
2727
import static org.apache.jena.graph.Factory.createDefaultGraph;
2828
import static org.apache.jena.riot.Lang.JSONLD;
2929
import static org.apache.jena.riot.RDFFormat.JSONLD_COMPACT_FLAT;
@@ -144,11 +144,11 @@ public void write(final Stream<? extends Triple> triples, final OutputStream out
144144
requireNonNull(syntax, "The RDF syntax value may not be null!");
145145

146146
try {
147-
if (RDFA_HTML.equals(syntax)) {
147+
if (RDFA.equals(syntax)) {
148148
htmlSerializer.write(output, triples, profiles.length > 0 ? profiles[0] : null);
149149
} else {
150150
final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
151-
new RuntimeTrellisException("Invalid content type: " + syntax.mediaType));
151+
new RuntimeTrellisException("Invalid content type: " + syntax.mediaType()));
152152

153153
final RDFFormat format = defaultSerialization(lang);
154154

@@ -227,7 +227,7 @@ public Stream<? extends Triple> read(final InputStream input, final String base,
227227
try {
228228
final org.apache.jena.graph.Graph graph = createDefaultGraph();
229229
final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
230-
new RuntimeTrellisException("Unsupported RDF Syntax: " + syntax.mediaType));
230+
new RuntimeTrellisException("Unsupported RDF Syntax: " + syntax.mediaType()));
231231

232232
RDFParser.source(input).lang(lang).base(base).parse(graph);
233233

trellis-io-jena/src/test/java/org/trellisldp/io/IOServiceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import static java.util.stream.Stream.of;
2121
import static org.apache.commons.rdf.api.RDFSyntax.JSONLD;
2222
import static org.apache.commons.rdf.api.RDFSyntax.NTRIPLES;
23-
import static org.apache.commons.rdf.api.RDFSyntax.RDFA_HTML;
23+
import static org.apache.commons.rdf.api.RDFSyntax.RDFA;
2424
import static org.apache.commons.rdf.api.RDFSyntax.RDFXML;
2525
import static org.apache.commons.rdf.api.RDFSyntax.TURTLE;
2626
import static org.apache.jena.graph.Factory.createDefaultGraph;
@@ -335,7 +335,7 @@ public void testTurtleReaderWithContext() {
335335
@Test
336336
public void testHtmlSerializer() {
337337
final ByteArrayOutputStream out = new ByteArrayOutputStream();
338-
service.write(getComplexTriples(), out, RDFA_HTML);
338+
service.write(getComplexTriples(), out, RDFA);
339339
final String html = new String(out.toByteArray(), UTF_8);
340340
assertTrue(html.contains("<title>A title</title>"));
341341
assertTrue(html.contains("_:B"));
@@ -349,7 +349,7 @@ public void testHtmlSerializer() {
349349
@Test
350350
public void testHtmlSerializer2() {
351351
final ByteArrayOutputStream out = new ByteArrayOutputStream();
352-
service.write(getComplexTriples(), out, RDFA_HTML, rdf.createIRI("http://example.org/"));
352+
service.write(getComplexTriples(), out, RDFA, rdf.createIRI("http://example.org/"));
353353
final String html = new String(out.toByteArray(), UTF_8);
354354
assertTrue(html.contains("<title>A title</title>"));
355355
assertTrue(html.contains("_:B"));
@@ -372,7 +372,7 @@ public void testHtmlSerializer3() {
372372
final IOService service4 = new JenaIOService(mockNamespaceService, properties);
373373

374374
final ByteArrayOutputStream out = new ByteArrayOutputStream();
375-
service.write(getComplexTriples(), out, RDFA_HTML, rdf.createIRI("http://example.org/"));
375+
service.write(getComplexTriples(), out, RDFA, rdf.createIRI("http://example.org/"));
376376
final String html = new String(out.toByteArray(), UTF_8);
377377
assertTrue(html.contains("<title>A title</title>"));
378378
assertTrue(html.contains("_:B"));
@@ -395,7 +395,7 @@ public void testHtmlSerializer4() throws Exception {
395395
final IOService service4 = new JenaIOService(mockNamespaceService, properties);
396396

397397
final ByteArrayOutputStream out = new ByteArrayOutputStream();
398-
service.write(getComplexTriples(), out, RDFA_HTML, rdf.createIRI("http://example.org/"));
398+
service.write(getComplexTriples(), out, RDFA, rdf.createIRI("http://example.org/"));
399399
final String html = new String(out.toByteArray(), UTF_8);
400400
assertTrue(html.contains("<title>A title</title>"));
401401
assertTrue(html.contains("_:B"));

0 commit comments

Comments
 (0)