You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2014/03/06 18:48:05 UTC
[1/6] git commit: MARMOTTA-449: added missing triples
Repository: marmotta
Updated Branches:
refs/heads/ldp 3c1962b6c -> 679e99f26
MARMOTTA-449: added missing triples
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/529f4e6d
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/529f4e6d
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/529f4e6d
Branch: refs/heads/ldp
Commit: 529f4e6dbe534ad99de992b62bc3163b84dc4e9d
Parents: 3c1962b
Author: Sergio Fernández <wi...@apache.org>
Authored: Mon Mar 3 16:19:49 2014 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Mon Mar 3 16:19:49 2014 +0100
----------------------------------------------------------------------
.../apache/marmotta/commons/vocabulary/LDP.java | 156 ++++++++++---------
.../platform/ldp/services/LdpServiceImpl.java | 7 +-
2 files changed, 89 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/529f4e6d/commons/marmotta-sesame-tools/marmotta-model-vocabs/src/main/java/org/apache/marmotta/commons/vocabulary/LDP.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-model-vocabs/src/main/java/org/apache/marmotta/commons/vocabulary/LDP.java b/commons/marmotta-sesame-tools/marmotta-model-vocabs/src/main/java/org/apache/marmotta/commons/vocabulary/LDP.java
index 1599c02..967d1c9 100644
--- a/commons/marmotta-sesame-tools/marmotta-model-vocabs/src/main/java/org/apache/marmotta/commons/vocabulary/LDP.java
+++ b/commons/marmotta-sesame-tools/marmotta-model-vocabs/src/main/java/org/apache/marmotta/commons/vocabulary/LDP.java
@@ -20,27 +20,27 @@ import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.impl.ValueFactoryImpl;
-/**
+/**
* Namespace LDP
*/
public class LDP {
- public static final String NAMESPACE = "http://www.w3.org/ns/ldp#";
+ public static final String NAMESPACE = "http://www.w3.org/ns/ldp#";
- public static final String PREFIX = "ldp";
+ public static final String PREFIX = "ldp";
- /**
- * A Linked Data Platform Container (LDPC) that also conforms to
- * additional patterns and conventions for managing members. It is distinguished from
- * CompositeContainer by the following behaviors:
+ /**
+ * A Linked Data Platform Container (LDPC) that also conforms to
+ * additional patterns and conventions for managing members. It is distinguished from
+ * CompositeContainer by the following behaviors:
* <ol>
- * <li>Clients cannot assume that an AggregateContainer, when deleted, deletes its members.
+ * <li>Clients cannot assume that an AggregateContainer, when deleted, deletes its members.
* </ol>
- *
- * While every attempt is made to be complete in this list, readers should also refer
- * to the specification defining this ontology.
- */
- public static final URI AggregateContainer;
+ * <p/>
+ * While every attempt is made to be complete in this list, readers should also refer
+ * to the specification defining this ontology.
+ */
+ public static final URI AggregateContainer;
/**
* FIXME: Not yet part of the official vocab, but used in the Spec. (2014-02-18)
@@ -48,35 +48,45 @@ public class LDP {
public static final URI BasicContainer;
/**
- * A Linked Data Platform Container (LDPC) that also conforms to
- * additional patterns and conventions for managing members. It is distinguished from
- * AggregateContainer by the following behaviors:
+ * A Linked Data Platform Container (LDPC) that also conforms to
+ * additional patterns and conventions for managing members. It is distinguished from
+ * AggregateContainer by the following behaviors:
* <ol>
- * <li>An CompositeContainer, when deleted, must delete all its members.
+ * <li>An CompositeContainer, when deleted, must delete all its members.
* </ol>
- *
- * While every attempt is made to be complete in this list, readers should also
- * refer to the specification defining this ontology.
- */
- public static final URI CompositeContainer;
-
- /**
- * A Linked Data Platform Resource (LDPR) that also conforms to
- * additional patterns and conventions for managing membership.
- * Readers should refer to the specification defining this ontology for the list of
- * behaviors associated with it.
- */
- public static final URI Container;
-
- /**
- * A resource that represents a limited set of members of a LDP Container.
- */
- public static final URI Page;
-
- /**
- * A HTTP-addressable resource with a linked data representation.
- */
- public static final URI Resource;
+ * <p/>
+ * While every attempt is made to be complete in this list, readers should also
+ * refer to the specification defining this ontology.
+ */
+ public static final URI CompositeContainer;
+
+ /**
+ * A Linked Data Platform Resource (LDPR) that also conforms to
+ * additional patterns and conventions for managing membership.
+ * Readers should refer to the specification defining this ontology for the list of
+ * behaviors associated with it.
+ */
+ public static final URI Container;
+
+ /**
+ * A resource that represents a limited set of members of a LDP Container.
+ */
+ public static final URI Page;
+
+ /**
+ * A HTTP-addressable resource with a linked data representation.
+ */
+ public static final URI Resource;
+
+ /**
+ * A HTTP-addressable resource with a RDF Source representation.
+ */
+ public static final URI RdfResource;
+
+ /**
+ * A HTTP-addressable resource with a Non-RDF Source representation.
+ */
+ public static final URI NonRdfResource;
/**
* FIXME: Not yet part of the vocab, but used in the spec. (2014-02-24)
@@ -84,9 +94,9 @@ public class LDP {
public static final URI contains;
/**
- * List of predicates that indicate the ascending order of the members in a page.
- */
- public static final URI containerSortPredicates;
+ * List of predicates that indicate the ascending order of the members in a page.
+ */
+ public static final URI containerSortPredicates;
/**
* FIXME: Not yet part of the vocab, but used in the spec. (2014-02-18)
@@ -94,41 +104,43 @@ public class LDP {
public static final URI member;
/**
- * Indicates which predicate of the container should be used to determine the membership.
- */
- public static final URI membershipPredicate;
+ * Indicates which predicate of the container should be used to determine the membership.
+ */
+ public static final URI membershipPredicate;
- /**
- * Indicates which resource is the subject for the members of the container.
- */
- public static final URI membershipSubject;
+ /**
+ * Indicates which resource is the subject for the members of the container.
+ */
+ public static final URI membershipSubject;
- /**
- * From a known page, how to indicate the next or last page as rdf:nil.
- */
- public static final URI nextPage;
+ /**
+ * From a known page, how to indicate the next or last page as rdf:nil.
+ */
+ public static final URI nextPage;
- /**
- * Associated a page with its container.
- */
- public static final URI pageOf;
+ /**
+ * Associated a page with its container.
+ */
+ public static final URI pageOf;
- static{
- ValueFactory factory = ValueFactoryImpl.getInstance();
- AggregateContainer = factory.createURI(LDP.NAMESPACE, "AggregateContainer");
+ static {
+ ValueFactory factory = ValueFactoryImpl.getInstance();
+ AggregateContainer = factory.createURI(LDP.NAMESPACE, "AggregateContainer");
BasicContainer = factory.createURI(LDP.NAMESPACE, "BasicContainer");
- CompositeContainer = factory.createURI(LDP.NAMESPACE, "CompositeContainer");
- Container = factory.createURI(LDP.NAMESPACE, "Container");
- Page = factory.createURI(LDP.NAMESPACE, "Page");
- Resource = factory.createURI(LDP.NAMESPACE, "Resource");
+ CompositeContainer = factory.createURI(LDP.NAMESPACE, "CompositeContainer");
+ Container = factory.createURI(LDP.NAMESPACE, "Container");
+ Page = factory.createURI(LDP.NAMESPACE, "Page");
+ Resource = factory.createURI(LDP.NAMESPACE, "Resource");
+ RdfResource = factory.createURI(LDP.NAMESPACE, "RdfResource"); //TODO: missing term in the vocab
+ NonRdfResource = factory.createURI(LDP.NAMESPACE, "NonRdfResource"); //TODO: missing term in the vocab
contains = factory.createURI(LDP.NAMESPACE, "contains");
- containerSortPredicates = factory.createURI(LDP.NAMESPACE, "containerSortPredicates");
- member = factory.createURI(LDP.NAMESPACE, "member");
- membershipPredicate = factory.createURI(LDP.NAMESPACE, "membershipPredicate");
- membershipSubject = factory.createURI(LDP.NAMESPACE, "membershipSubject");
- nextPage = factory.createURI(LDP.NAMESPACE, "nextPage");
- pageOf = factory.createURI(LDP.NAMESPACE, "pageOf");
- }
+ containerSortPredicates = factory.createURI(LDP.NAMESPACE, "containerSortPredicates");
+ member = factory.createURI(LDP.NAMESPACE, "member");
+ membershipPredicate = factory.createURI(LDP.NAMESPACE, "membershipPredicate");
+ membershipSubject = factory.createURI(LDP.NAMESPACE, "membershipSubject");
+ nextPage = factory.createURI(LDP.NAMESPACE, "nextPage");
+ pageOf = factory.createURI(LDP.NAMESPACE, "pageOf");
+ }
}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/529f4e6d/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
index e5eea4e..fffa16a 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
@@ -173,14 +173,15 @@ public class LdpServiceImpl implements LdpService {
connection.add(container, DCTERMS.modified, now, ldpContext);
// Add the bodyContent
- log.trace("Content ({}) for new resource <{}>", type, resource);
+ connection.add(resource, RDF.TYPE, LDP.Resource, ldpContext);
final RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(type.toString());
if (rdfFormat == null) {
log.debug("POST creates new LDP-BR, because no RDF parser found for type {}", type);
Literal format = valueFactory.createLiteral(type.toString());
URI binaryResource = valueFactory.createURI(resource.stringValue() + LdpUtils.getExtension(type.toString()));
- //connection.add(resource, RDF.TYPE, LDP.NonRdfResource, ldpContext); //TODO:
+ connection.add(resource, RDF.TYPE, LDP.Resource, ldpContext);
+ connection.add(resource, RDF.TYPE, LDP.NonRdfResource, ldpContext);
connection.add(binaryResource, DCTERMS.created, now, ldpContext);
connection.add(binaryResource, DCTERMS.modified, now, ldpContext);
@@ -188,6 +189,7 @@ public class LdpServiceImpl implements LdpService {
//TODO: check conformance with 6.2.3.12
connection.add(binaryResource, DCTERMS.format, format, ldpContext); //nie:mimeType ?
connection.add(binaryResource, DCTERMS.isFormatOf, resource, ldpContext);
+ connection.add(resource, DCTERMS.hasFormat, binaryResource, ldpContext);
//TODO: something else?
@@ -198,6 +200,7 @@ public class LdpServiceImpl implements LdpService {
log.debug("POST creates new LDP-RR, data provided as {}", rdfFormat.getName());
connection.add(resource, RDF.TYPE, LDP.Resource, ldpContext);
+ connection.add(resource, RDF.TYPE, LDP.RdfResource, ldpContext);
connection.add(resource, DCTERMS.created, now, ldpContext);
connection.add(resource, DCTERMS.modified, now, ldpContext);
[6/6] git commit: MARMOTTA-449: added binary test resource
Posted by wi...@apache.org.
MARMOTTA-449: added binary test resource
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/679e99f2
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/679e99f2
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/679e99f2
Branch: refs/heads/ldp
Commit: 679e99f26e692011fa79221279f07844f3fb3ab9
Parents: 8320963
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Mar 6 16:59:48 2014 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Mar 6 16:59:48 2014 +0100
----------------------------------------------------------------------
platform/marmotta-ldp/src/test/resources/test.png | Bin 0 -> 5063 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/679e99f2/platform/marmotta-ldp/src/test/resources/test.png
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/resources/test.png b/platform/marmotta-ldp/src/test/resources/test.png
new file mode 100644
index 0000000..18d9c62
Binary files /dev/null and b/platform/marmotta-ldp/src/test/resources/test.png differ
[4/6] git commit: MARMOTTA-449: cosmetic details
Posted by wi...@apache.org.
MARMOTTA-449: cosmetic details
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/2f3fbdd8
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/2f3fbdd8
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/2f3fbdd8
Branch: refs/heads/ldp
Commit: 2f3fbdd8f84c48d3e1000e53ace7b662ced2351e
Parents: 424bc33
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Mar 6 16:46:15 2014 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Mar 6 16:46:15 2014 +0100
----------------------------------------------------------------------
.../platform/ldp/webservices/LdpWebService.java | 46 +++++++++-----------
1 file changed, 21 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/2f3fbdd8/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
index f10da48..75515a1 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
@@ -83,29 +83,25 @@ public class LdpWebService {
@GET
public Response GET(@Context final UriInfo uriInfo, @Context Request r, @HeaderParam(HttpHeaders.ACCEPT) MediaType type) throws RepositoryException {
final String resource = getResourceUri(uriInfo);
- if (log.isDebugEnabled()) {
- log.debug("GET to LDPR <{}>", resource);
- }
+ log.debug("GET to LDPR <{}>", resource);
return buildGetResponse(resource, r, type).build();
}
@HEAD
public Response HEAD(@Context final UriInfo uriInfo, @Context Request r, @HeaderParam(HttpHeaders.ACCEPT) MediaType type) throws RepositoryException {
final String resource = getResourceUri(uriInfo);
- if (log.isDebugEnabled()) {
- log.debug("HEAD to LDPR <{}>", resource);
- }
+ log.debug("HEAD to LDPR <{}>", resource);
return buildGetResponse(resource, r, type).entity(null).build();
}
private Response.ResponseBuilder buildGetResponse(final String resource, Request r, MediaType type) throws RepositoryException {
- final RepositoryConnection con = sesameService.getConnection();
+ final RepositoryConnection conn = sesameService.getConnection();
try {
- con.begin();
+ conn.begin();
- if (!ldpService.exists(con, resource)) {
- final Response.ResponseBuilder resp = createResponse(con, Response.Status.NOT_FOUND, resource);
- con.rollback();
+ if (!ldpService.exists(conn, resource)) {
+ final Response.ResponseBuilder resp = createResponse(conn, Response.Status.NOT_FOUND, resource);
+ conn.rollback();
return resp;
}
@@ -119,14 +115,14 @@ public class LdpWebService {
@Override
public void write(OutputStream out) throws IOException, WebApplicationException {
try {
- ldpService.exportResource(con, resource, out);
+ ldpService.exportResource(conn, resource, out);
} catch (RepositoryException | IOException e) {
throw new WebApplicationException(e, createResponse(Response.status(Response.Status.INTERNAL_SERVER_ERROR)).entity(e).build());
}
}
};
- final Response.ResponseBuilder resp = createResponse(con, Response.Status.OK, resource).entity(entity).type(format.getDefaultMIMEType());
- con.commit();
+ final Response.ResponseBuilder resp = createResponse(conn, Response.Status.OK, resource).entity(entity).type(format.getDefaultMIMEType());
+ conn.commit();
return resp;
} else {
// Deliver all triples with <subject> as subject.
@@ -134,34 +130,34 @@ public class LdpWebService {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
try {
- final RepositoryConnection outputCon = sesameService.getConnection();;
+ final RepositoryConnection outputConn = sesameService.getConnection();;
try {
- outputCon.begin();
- ldpService.exportResource(outputCon, resource, output, format);
- outputCon.commit();
+ outputConn.begin();
+ ldpService.exportResource(outputConn, resource, output, format);
+ outputConn.commit();
} catch (RDFHandlerException e) {
- outputCon.rollback();
+ outputConn.rollback();
throw new NoLogWebApplicationException(e, createResponse(Response.status(Response.Status.INTERNAL_SERVER_ERROR)).entity(e.getMessage()).build());
} catch (final Throwable t) {
- outputCon.rollback();
+ outputConn.rollback();
throw t;
} finally {
- outputCon.close();
+ outputConn.close();
}
} catch (RepositoryException e) {
throw new WebApplicationException(e, createResponse(Response.status(Response.Status.INTERNAL_SERVER_ERROR)).entity(e).build());
}
}
};
- final Response.ResponseBuilder resp = createResponse(con, Response.Status.OK, resource).entity(entity).type(format.getDefaultMIMEType());
- con.commit();
+ final Response.ResponseBuilder resp = createResponse(conn, Response.Status.OK, resource).entity(entity).type(format.getDefaultMIMEType());
+ conn.commit();
return resp;
}
} catch (final Throwable t) {
- con.rollback();
+ conn.rollback();
throw t;
} finally {
- con.close();
+ conn.close();
}
}
[2/6] git commit: improved errors readability when checking
statements matching
Posted by wi...@apache.org.
improved errors readability when checking statements matching
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/bf8e739d
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/bf8e739d
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/bf8e739d
Branch: refs/heads/ldp
Commit: bf8e739d4a1514519a3899fca7a0f917c7e7a3ec
Parents: 529f4e6
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Mar 6 16:38:18 2014 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Mar 6 16:38:18 2014 +0100
----------------------------------------------------------------------
.../commons/sesame/test/connection/HasStatementMatcher.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/bf8e739d/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java
index 282937e..e04a7aa 100644
--- a/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java
+++ b/commons/marmotta-sesame-tools/marmotta-sesame-matchers/src/main/java/org/apache/marmotta/commons/sesame/test/connection/HasStatementMatcher.java
@@ -51,7 +51,7 @@ public class HasStatementMatcher<T extends RepositoryConnection> extends Abstrac
@Override
public void describeTo(Description description) {
- description.appendText(" to contain Statement(")
+ description.appendText("\n to contain Statement(")
.appendValue(subject).appendText(" ")
.appendValue(predicate).appendText(" ")
.appendValue(object).appendText(")");
[5/6] git commit: MARMOTTA-449: added some LDP-NR testing
Posted by wi...@apache.org.
MARMOTTA-449: added some LDP-NR testing
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/83209635
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/83209635
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/83209635
Branch: refs/heads/ldp
Commit: 83209635c184ceec2003efed230cb5a0ecd48ccd
Parents: 2f3fbdd
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Mar 6 16:47:00 2014 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Mar 6 16:47:00 2014 +0100
----------------------------------------------------------------------
.../ldp/webservices/LdpWebServiceTest.java | 77 +++++++++++++++++++-
1 file changed, 74 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/83209635/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
index 4883e8b..f1e6751 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
@@ -76,7 +76,7 @@ public class LdpWebServiceTest {
@Test
public void testCRUD() {
- final String testBase = "test1";
+ final String testBase = "test";
final String containerName = "container1";
final String resourceName = "resource1";
@@ -115,7 +115,7 @@ public class LdpWebServiceTest {
SesameMatchers.hasStatement(new URIImpl(baseUrl + container), DCTERMS.MODIFIED, null),
SesameMatchers.hasStatement(new URIImpl(baseUrl + container), RDF.TYPE, LDP.BasicContainer)
))
- .get(container);
+ .get(container);
// also the new resource exists
RestAssured
@@ -154,7 +154,78 @@ public class LdpWebServiceTest {
}
- @AfterClass
+ @Test
+ public void testNR() throws IOException {
+ final String testBase = "test";
+ final String containerName = "container2";
+ final String resourceName = "resource1";
+
+ // The container
+ final String container = UriBuilder.fromPath(LdpWebService.PATH).path(testBase).path(containerName).build().toString();
+ final String newResource = UriBuilder.fromUri(container).path(resourceName).build().toString();
+ final String mimeType = "image/png";
+
+ RestAssured.expect().statusCode(404).get(container);
+
+ // Create
+ RestAssured
+ .given()
+ .header("Slug", resourceName)
+ .body(IOUtils.toByteArray(LdpWebServiceTest.class.getResourceAsStream("/test.png")))
+ .contentType(mimeType)
+ .expect()
+ .statusCode(201)
+ .header("Location", baseUrl + newResource + ".png")
+ .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIST header...
+ HeaderMatchers.isLink(baseUrl + newResource, "describedby"),
+ HeaderMatchers.isLink("http://wiki.apache.org/marmotta/LDPImplementationReport", "describedby"),
+ HeaderMatchers.isLink(LDP.BasicContainer.stringValue(), "type"))
+ )
+ .post(container);
+
+ // now the container exists
+ RestAssured
+ .given()
+ .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+ .expect()
+ .statusCode(200)
+ .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIST header...
+ HeaderMatchers.isLink("http://wiki.apache.org/marmotta/LDPImplementationReport", "describedby"),
+ HeaderMatchers.isLink(LDP.BasicContainer.stringValue(), "type"))
+ )
+ .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific here
+ .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
+ .body(SesameMatchers.rdfStringMatches(RDFFormat.TURTLE.getDefaultMIMEType(), baseUrl + container,
+ SesameMatchers.hasStatement(new URIImpl(baseUrl + container), RDF.TYPE, LDP.BasicContainer),
+ SesameMatchers.hasStatement(new URIImpl(baseUrl + container), DCTERMS.MODIFIED, null),
+ SesameMatchers.hasStatement(new URIImpl(baseUrl + container), LDP.contains, new URIImpl(baseUrl + newResource))
+ ))
+ .get(container);
+
+
+ // now the resource exists
+ RestAssured
+ .given()
+ .header("Accept", RDFFormat.TURTLE.getDefaultMIMEType())
+ .expect()
+ .statusCode(200)
+ .header("Link", CoreMatchers.anyOf( //TODO: RestAssured only checks the FIST header...
+ HeaderMatchers.isLink("http://wiki.apache.org/marmotta/LDPImplementationReport", "describedby"),
+ HeaderMatchers.isLink(LDP.Resource.stringValue(), "type"),
+ HeaderMatchers.isLink(LDP.NonRdfResource.stringValue(), "type"))
+ )
+ .header("ETag", HeaderMatchers.hasEntityTag(true)) // FIXME: be more specific here
+ .contentType(RDFFormat.TURTLE.getDefaultMIMEType())
+ .body(SesameMatchers.rdfStringMatches(RDFFormat.TURTLE.getDefaultMIMEType(), baseUrl + newResource,
+ SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), RDF.TYPE, LDP.Resource),
+ SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), RDF.TYPE, LDP.NonRdfResource),
+ SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), DCTERMS.MODIFIED, null),
+ SesameMatchers.hasStatement(new URIImpl(baseUrl + newResource), DCTERMS.HAS_FORMAT, new URIImpl(baseUrl + newResource + ".png"))
+ ))
+ .get(newResource);
+ }
+
+ @AfterClass
public static void tearDown() {
marmotta.shutdown();
}
[3/6] git commit: MARMOTTA-449: evolving the implementation wit the
latest details
Posted by wi...@apache.org.
MARMOTTA-449: evolving the implementation wit the latest details
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/424bc334
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/424bc334
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/424bc334
Branch: refs/heads/ldp
Commit: 424bc334555f5bc55e1b94220fad3bd9eed69172
Parents: bf8e739
Author: Sergio Fernández <wi...@apache.org>
Authored: Thu Mar 6 16:43:39 2014 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Thu Mar 6 16:43:39 2014 +0100
----------------------------------------------------------------------
.../platform/ldp/services/LdpServiceImpl.java | 19 ++++++++-----------
.../marmotta/platform/ldp/util/LdpUtils.java | 8 +++++---
2 files changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/424bc334/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
index fffa16a..f7724f2 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/services/LdpServiceImpl.java
@@ -139,7 +139,7 @@ public class LdpServiceImpl implements LdpService {
if (in != null) {
IOUtils.copy(in, out);
} else {
- throw new IOException("Cannot read reosurce " + resource);
+ throw new IOException("Cannot read resource " + resource);
}
}
@@ -172,16 +172,18 @@ public class LdpServiceImpl implements LdpService {
connection.add(container, LDP.contains, resource, ldpContext);
connection.add(container, DCTERMS.modified, now, ldpContext);
- // Add the bodyContent
connection.add(resource, RDF.TYPE, LDP.Resource, ldpContext);
+ connection.add(resource, RDF.TYPE, LDP.NonRdfResource, ldpContext);
+ connection.add(resource, DCTERMS.created, now, ldpContext);
+ connection.add(resource, DCTERMS.modified, now, ldpContext);
+
+ // Add the bodyContent
final RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(type.toString());
if (rdfFormat == null) {
- log.debug("POST creates new LDP-BR, because no RDF parser found for type {}", type);
+ log.debug("POST creates new LDP-NR, because no suitable RDF parser found for type {}", type);
Literal format = valueFactory.createLiteral(type.toString());
- URI binaryResource = valueFactory.createURI(resource.stringValue() + LdpUtils.getExtension(type.toString()));
+ URI binaryResource = valueFactory.createURI(resource.stringValue() + LdpUtils.getExtension(type));
- connection.add(resource, RDF.TYPE, LDP.Resource, ldpContext);
- connection.add(resource, RDF.TYPE, LDP.NonRdfResource, ldpContext);
connection.add(binaryResource, DCTERMS.created, now, ldpContext);
connection.add(binaryResource, DCTERMS.modified, now, ldpContext);
@@ -199,11 +201,6 @@ public class LdpServiceImpl implements LdpService {
} else {
log.debug("POST creates new LDP-RR, data provided as {}", rdfFormat.getName());
- connection.add(resource, RDF.TYPE, LDP.Resource, ldpContext);
- connection.add(resource, RDF.TYPE, LDP.RdfResource, ldpContext);
- connection.add(resource, DCTERMS.created, now, ldpContext);
- connection.add(resource, DCTERMS.modified, now, ldpContext);
-
// FIXME: We are (are we?) allowed to filter out server-managed properties here
connection.add(stream, resource.stringValue(), rdfFormat, resource);
http://git-wip-us.apache.org/repos/asf/marmotta/blob/424bc334/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
index dc565b4..d16035e 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
@@ -31,6 +31,8 @@ import org.openrdf.repository.RepositoryException;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFWriter;
+import javax.ws.rs.core.MediaType;
+
/**
* Various Util-Methods for the {@link org.apache.marmotta.platform.ldp.api.LdpService}.
*/
@@ -51,11 +53,12 @@ public class LdpUtils {
/**
* Get the preferred file extension for the content type
*
- * @param contentType content type
+ * @param mediaType content type
* @return file extension (already including '.')
* @throws MimeTypeException
*/
- public static String getExtension(String contentType) {
+ public static String getExtension(MediaType mediaType) {
+ String contentType = String.format("%s/%s", mediaType.getType(), mediaType.getSubtype());
MimeTypes allTypes = MimeTypes.getDefaultMimeTypes();
try {
MimeType mimeType = allTypes.forName(contentType);
@@ -63,7 +66,6 @@ public class LdpUtils {
} catch (MimeTypeException e) {
return null; //FIXME
}
-
}
/**