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/develop Commit: 424bc334555f5bc55e1b94220fad3bd9eed69172 Parents: bf8e739 Author: Sergio Fernández <[email protected]> Authored: Thu Mar 6 16:43:39 2014 +0100 Committer: Sergio Fernández <[email protected]> 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 } - } /**
