You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2014/02/25 20:50:37 UTC

[3/6] git commit: MARMOTTA-440: Some minor refactoring and javadoc

MARMOTTA-440: Some minor refactoring and javadoc


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/679ac561
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/679ac561
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/679ac561

Branch: refs/heads/ldp
Commit: 679ac561fde85a139d2ac60411798b518a237cd5
Parents: ca0d8c0
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Feb 25 19:11:12 2014 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Feb 25 19:11:12 2014 +0100

----------------------------------------------------------------------
 .../InvalidModificationException.java           |  7 +-
 .../patch/InvalidPatchDocumentException.java    |  3 +-
 .../platform/ldp/patch/RdfPatchUtil.java        | 73 ++++++++++++++++----
 .../platform/ldp/patch/model/PatchLine.java     | 15 ++--
 .../ldp/patch/model/WildcardStatement.java      |  3 +-
 .../ldp/patch/parser/RdfPatchParser.java        | 47 +++++++++++++
 .../platform/ldp/services/LdpServiceImpl.java   |  4 +-
 .../platform/ldp/util/LdpWebServiceUtils.java   | 12 +++-
 .../platform/ldp/webservices/LdpWebService.java |  7 +-
 .../platform/ldp/webservices/PATCH.java         | 18 ++++-
 .../marmotta-ldp/src/main/javacc/rdf-patch.jj   |  6 +-
 .../ldp/patch/parser/RdfPatchParserTest.java    |  4 +-
 12 files changed, 164 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/exceptions/InvalidModificationException.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/exceptions/InvalidModificationException.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/exceptions/InvalidModificationException.java
index 32e1bde..e529ae8 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/exceptions/InvalidModificationException.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/exceptions/InvalidModificationException.java
@@ -18,9 +18,14 @@
 package org.apache.marmotta.platform.ldp.exceptions;
 
 /**
- * Created by jakob on 2/25/14.
+ * Exception to be thrown if a client operation tries to modify server-controlled data, and the operation should not be ignored.
+ *
+ * @author Jakob Frank
+ *
+ * @see <a href="https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp.html#ldpr-put-servermanagedprops">LDP Spec, Sec. 5.5.2</a>
  */
 public class InvalidModificationException extends Exception {
+
     public InvalidModificationException() {
         super();
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/InvalidPatchDocumentException.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/InvalidPatchDocumentException.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/InvalidPatchDocumentException.java
index 7e5a873..a5128a7 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/InvalidPatchDocumentException.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/InvalidPatchDocumentException.java
@@ -18,7 +18,8 @@
 package org.apache.marmotta.platform.ldp.patch;
 
 /**
- * Created by jakob on 2/25/14.
+ * Exception thrown if a PatchDocument (i.e. a List of {@link org.apache.marmotta.platform.ldp.patch.model.PatchLine}s)
+ * cannot be evauated, e.g. because a wildcard ({@code R}) was never defined before.
  */
 public class InvalidPatchDocumentException extends Exception {
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/RdfPatchUtil.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/RdfPatchUtil.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/RdfPatchUtil.java
index 8be7652..e4d073b 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/RdfPatchUtil.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/RdfPatchUtil.java
@@ -18,11 +18,10 @@
 package org.apache.marmotta.platform.ldp.patch;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.ObjectUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.platform.ldp.patch.model.PatchLine;
 import org.apache.marmotta.platform.ldp.patch.parser.ParseException;
 import org.apache.marmotta.platform.ldp.patch.parser.RdfPatchParser;
+import org.apache.marmotta.platform.ldp.patch.parser.RdfPatchParserImpl;
 import org.openrdf.model.Resource;
 import org.openrdf.model.Statement;
 import org.openrdf.model.URI;
@@ -36,24 +35,67 @@ import java.io.InputStream;
 import java.util.List;
 
 /**
- * Created by jakob on 2/25/14.
+ * RdfPatchUtil - Util-Class to apply rdf-patches on a {@link Repository} or {@link org.openrdf.repository.RepositoryConnection}
+ *
+ * @author Jakob Frank
  */
 public class RdfPatchUtil {
 
+    /**
+     * Apply the provided patch to the repository
+     * @param repository the {@link org.openrdf.repository.Repository} to patch
+     * @param patch the patch to apply
+     * @param contexts restrict changes to these contexts (leave empty to apply to <em>all</em> contexts)
+     * @throws ParseException if the patch could not be parsed
+     * @throws InvalidPatchDocumentException if the patch is invalid
+     */
     public static void applyPatch(Repository repository, String patch, Resource... contexts) throws RepositoryException, ParseException, InvalidPatchDocumentException {
         applyPatch(repository, getPatch(patch), contexts);
     }
 
+    /**
+     * Apply the provided patch to the repository
+     * @param repository the {@link org.openrdf.repository.Repository} to patch
+     * @param patchSource the patch to apply
+     * @param contexts restrict changes to these contexts (leave empty to apply to <em>all</em> contexts)
+     * @throws ParseException if the patch could not be parsed
+     * @throws InvalidPatchDocumentException if the patch is invalid
+     */
     public static void applyPatch(Repository repository, InputStream patchSource, Resource... contexts) throws RepositoryException, ParseException, InvalidPatchDocumentException {
         applyPatch(repository, getPatch(patchSource), contexts);
     }
-    public static void applyPatch(RepositoryConnection con, String patch, Resource... contexts) throws RepositoryException, ParseException, InvalidPatchDocumentException {
-        applyPatch(con, getPatch(patch), contexts);
+
+    /**
+     * Apply the provided patch to the repository
+     * @param connection the {@link org.openrdf.repository.RepositoryConnection} to patch
+     * @param patch the patch to apply
+     * @param contexts restrict changes to these contexts (leave empty to apply to <em>all</em> contexts)
+     * @throws ParseException if the patch could not be parsed
+     * @throws InvalidPatchDocumentException if the patch is invalid
+     */
+    public static void applyPatch(RepositoryConnection connection, String patch, Resource... contexts) throws RepositoryException, ParseException, InvalidPatchDocumentException {
+        applyPatch(connection, getPatch(patch), contexts);
     }
-    public static void applyPatch(RepositoryConnection con, InputStream patchSource, Resource... contexts) throws RepositoryException, ParseException, InvalidPatchDocumentException {
-        applyPatch(con, getPatch(patchSource), contexts);
+
+    /**
+     * Apply the provided patch to the repository
+     * @param connection the {@link org.openrdf.repository.RepositoryConnection} to patch
+     * @param patchSource the patch to apply
+     * @param contexts restrict changes to these contexts (leave empty to apply to <em>all</em> contexts)
+     * @throws ParseException if the patch could not be parsed
+     * @throws InvalidPatchDocumentException if the patch is invalid
+     */
+    public static void applyPatch(RepositoryConnection connection, InputStream patchSource, Resource... contexts) throws RepositoryException, ParseException, InvalidPatchDocumentException {
+        applyPatch(connection, getPatch(patchSource), contexts);
     }
 
+    /**
+     * Apply the provided patch to the repository
+     * @param repository the {@link org.openrdf.repository.Repository} to patch
+     * @param patch the patch to apply
+     * @param contexts restrict changes to these contexts (leave empty to apply to <em>all</em> contexts)
+     * @throws InvalidPatchDocumentException if the patch is invalid
+     */
     public static void applyPatch(Repository repository, List<PatchLine> patch, Resource... contexts) throws RepositoryException, InvalidPatchDocumentException {
         RepositoryConnection con = repository.getConnection();
         try {
@@ -68,7 +110,14 @@ public class RdfPatchUtil {
         }
     }
 
-    public static void applyPatch(RepositoryConnection con, List<PatchLine> patch, Resource... contexts) throws RepositoryException, InvalidPatchDocumentException {
+    /**
+     * Apply the provided patch to the repository
+     * @param connection the {@link org.openrdf.repository.RepositoryConnection} to patch
+     * @param patch the patch to apply
+     * @param contexts restrict changes to these contexts (leave empty to apply to <em>all</em> contexts)
+     * @throws InvalidPatchDocumentException if the patch is invalid
+     */
+    public static void applyPatch(RepositoryConnection connection, List<PatchLine> patch, Resource... contexts) throws RepositoryException, InvalidPatchDocumentException {
         Resource subject = null;
         URI predicate = null;
         Value object = null;
@@ -93,10 +142,10 @@ public class RdfPatchUtil {
 
             switch (patchLine.getOperator()) {
                 case ADD:
-                    con.add(subject, predicate, object, contexts);
+                    connection.add(subject, predicate, object, contexts);
                     break;
-                case DEL:
-                    con.remove(subject, predicate, object, contexts);
+                case DELETE:
+                    connection.remove(subject, predicate, object, contexts);
                     break;
                 default:
                     throw new IllegalArgumentException("Unknown patch operation: " + patchLine.getOperator());
@@ -105,7 +154,7 @@ public class RdfPatchUtil {
     }
 
     private static List<PatchLine> getPatch(InputStream is) throws ParseException {
-        RdfPatchParser parser = new RdfPatchParser(is);
+        RdfPatchParser parser = new RdfPatchParserImpl(is);
         return parser.parsePatch();
     }
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/PatchLine.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/PatchLine.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/PatchLine.java
index 4e0da28..83c6651 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/PatchLine.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/PatchLine.java
@@ -20,19 +20,25 @@ package org.apache.marmotta.platform.ldp.patch.model;
 import org.openrdf.model.Statement;
 
 /**
- * Created by jakob on 2/24/14.
+ * A single PatchLine, i.e. a operation of a Patch.
+ * Can be either a {@code ADD} od {@code DELETE}
  */
 public class PatchLine {
     public enum Operator {
-        DEL("D"),
-        ADD("A");
+        ADD("A"),
+        DELETE("D");
+
 
         private final String cmd;
 
-        Operator(String cmd) {
+        private Operator(String cmd) {
             this.cmd = cmd;
         }
 
+        public String getCommand() {
+            return cmd;
+        }
+
         public static Operator fromCommand(String cmd) {
             for (Operator op: values()) {
                 if (op.cmd.equalsIgnoreCase(cmd)) {
@@ -48,7 +54,6 @@ public class PatchLine {
     private final Statement statement;
 
     public PatchLine(Operator operator, Statement statement) {
-
         this.operator = operator;
         this.statement = statement;
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/WildcardStatement.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/WildcardStatement.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/WildcardStatement.java
index a243d34..4180a23 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/WildcardStatement.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/model/WildcardStatement.java
@@ -24,7 +24,8 @@ import org.openrdf.model.URI;
 import org.openrdf.model.Value;
 
 /**
- * Created by jakob on 2/25/14.
+ * The Statement in a RdfPatch.
+ * {@code null}-Values represent {@code R}epeat from the <a href="http://afs.github.io/rdf-patch/#rdf-patch-details">Spec</a>.
  */
 public class WildcardStatement implements Statement {
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParser.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParser.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParser.java
new file mode 100644
index 0000000..d78d7c5
--- /dev/null
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParser.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.platform.ldp.patch.parser;
+
+import org.apache.marmotta.platform.ldp.patch.model.PatchLine;
+
+import java.util.List;
+
+/**
+ * Parser for the {@code application/rdf-patch} format.
+ *
+ * @see <a href="http://afs.github.io/rdf-patch/">http://afs.github.io/rdf-patch/</a>
+ */
+public interface RdfPatchParser {
+
+    /**
+     * Mime-Type: {@value}
+     */
+    public static final String MIME_TYPE = "application/rdf-patch";
+
+    /**
+     * Default File extension for rdf-patch: {@value}
+     */
+    public static final String FILE_EXTENSION = "rdfp";
+
+    /**
+     * Parse the rdf-patch
+     * @return a List of {@link org.apache.marmotta.platform.ldp.patch.model.PatchLine}s
+     * @throws ParseException if the patch could not be parsed.
+     */
+    public List<PatchLine> parsePatch() throws ParseException;
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/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 030d930..421f088 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
@@ -29,6 +29,7 @@ import org.apache.marmotta.platform.ldp.patch.RdfPatchUtil;
 import org.apache.marmotta.platform.ldp.patch.model.PatchLine;
 import org.apache.marmotta.platform.ldp.patch.parser.ParseException;
 import org.apache.marmotta.platform.ldp.patch.parser.RdfPatchParser;
+import org.apache.marmotta.platform.ldp.patch.parser.RdfPatchParserImpl;
 import org.apache.marmotta.platform.ldp.util.LdpWebServiceUtils;
 import org.openrdf.model.Literal;
 import org.openrdf.model.Statement;
@@ -57,6 +58,7 @@ import java.util.List;
  * LDP Service default implementation
  *
  * @author Sergio Fernández
+ * @author Jakob Frank
  */
 @ApplicationScoped
 public class LdpServiceImpl implements LdpService {
@@ -250,7 +252,7 @@ public class LdpServiceImpl implements LdpService {
 
 
         log.trace("parsing patch");
-        List<PatchLine> patch = new RdfPatchParser(patchData).parsePatch();
+        List<PatchLine> patch = new RdfPatchParserImpl(patchData).parsePatch();
 
         // we are allowed to restrict the patch contents (Sec. ???)
         log.trace("checking for invalid patch statements");

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpWebServiceUtils.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpWebServiceUtils.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpWebServiceUtils.java
index a537538..1116879 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpWebServiceUtils.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpWebServiceUtils.java
@@ -31,14 +31,14 @@ import org.openrdf.rio.RDFHandlerException;
 import org.openrdf.rio.RDFWriter;
 
 /**
- * Created by jakob on 2/18/14.
+ * Various Util-Methods for the {@link org.apache.marmotta.platform.ldp.webservices.LdpWebService}.
  */
 public class LdpWebServiceUtils {
 
     /**
      * Urify the Slug: header value, i.e. replace all non-url chars with a single dash.
      *
-     * @param slugHeaderValue
+     * @param slugHeaderValue the client-provided Slug-header
      * @return the slugHeaderValue "urified"
      */
     public static String urify(String slugHeaderValue) {
@@ -47,6 +47,14 @@ public class LdpWebServiceUtils {
                 .replaceAll("[^\\w]+", "-");
     }
 
+    /**
+     * LDP-Style to serialize a resource.
+     * @param writer the writer to serialize to
+     * @param subject the resource to serialize
+     * @param iteration the Iteration containing the data
+     * @throws RDFHandlerException
+     * @throws RepositoryException
+     */
     public static void exportIteration(RDFWriter writer, URI subject, CloseableIteration<Statement, RepositoryException> iteration) throws RDFHandlerException, RepositoryException {
         writer.startRDF();
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/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 9163b67..32994db 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
@@ -24,6 +24,7 @@ import org.apache.marmotta.platform.ldp.api.LdpService;
 import org.apache.marmotta.platform.ldp.exceptions.InvalidModificationException;
 import org.apache.marmotta.platform.ldp.patch.InvalidPatchDocumentException;
 import org.apache.marmotta.platform.ldp.patch.parser.ParseException;
+import org.apache.marmotta.platform.ldp.patch.parser.RdfPatchParser;
 import org.apache.marmotta.platform.ldp.util.EntityTagUtils;
 import org.apache.marmotta.platform.ldp.util.LdpWebServiceUtils;
 import org.openrdf.model.Statement;
@@ -63,8 +64,6 @@ public class LdpWebService {
 
     public static final String PATH = "ldp"; //FIXME: imho this should be root '/' (jakob)
 
-    public static final String APPLICATION_RDF_PATCH = "application/rdf-patch";
-
     private Logger log = org.slf4j.LoggerFactory.getLogger(this.getClass());
 
     @Inject
@@ -239,7 +238,7 @@ public class LdpWebService {
         }
 
         // Check for the supported mime-type
-        if (!type.toString().equals(APPLICATION_RDF_PATCH)) {
+        if (!type.toString().equals(RdfPatchParser.MIME_TYPE)) {
             log.trace("Incompatible Content-Type for PATCH: {}", type);
             return createResponse(Response.Status.UNSUPPORTED_MEDIA_TYPE, uriInfo).entity("Unknown Content-Type: " + type + "\n").build();
         }
@@ -276,7 +275,7 @@ public class LdpWebService {
         builder.header("Accept-Post", "text/turtle");
 
         // Sec. 5.8.2
-        builder.header("Accept-Patch", APPLICATION_RDF_PATCH);
+        builder.header("Accept-Patch", RdfPatchParser.MIME_TYPE);
 
 
         // TODO: Sec. 6.9.1

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/PATCH.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/PATCH.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/PATCH.java
index d9b65b0..4d8a5b8 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/PATCH.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/PATCH.java
@@ -17,8 +17,20 @@
  */
 package org.apache.marmotta.platform.ldp.webservices;
 
-@java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD})
-@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
-@javax.ws.rs.HttpMethod("PATCH")
+import javax.ws.rs.HttpMethod;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that the annotated method responds to HTTP PATCH requests.
+ *
+ * @author Jakob Frank (jakob@apache.org)
+ * @see HttpMethod
+ */
+@Target({java.lang.annotation.ElementType.METHOD})
+@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@HttpMethod("PATCH")
+@Documented
 public @interface PATCH {
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/main/javacc/rdf-patch.jj
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/javacc/rdf-patch.jj b/platform/marmotta-ldp/src/main/javacc/rdf-patch.jj
index 93047cf..33b41fc 100644
--- a/platform/marmotta-ldp/src/main/javacc/rdf-patch.jj
+++ b/platform/marmotta-ldp/src/main/javacc/rdf-patch.jj
@@ -26,7 +26,7 @@
   //DEBUG_LOOKAHEAD=true;
 }
 
-PARSER_BEGIN(RdfPatchParser)
+PARSER_BEGIN(RdfPatchParserImpl)
 package org.apache.marmotta.platform.ldp.patch.parser;
 
 import org.openrdf.model.*;
@@ -39,7 +39,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 
-public class RdfPatchParser {
+public class RdfPatchParserImpl implements RdfPatchParser {
 
     private HashMap<String, String> namespaces = new HashMap<String, String>();
 
@@ -82,7 +82,7 @@ public class RdfPatchParser {
     }
 
 }
-PARSER_END(RdfPatchParser)
+PARSER_END(RdfPatchParserImpl)
 
 SKIP : {
  	" "

http://git-wip-us.apache.org/repos/asf/marmotta/blob/679ac561/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParserTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParserTest.java b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParserTest.java
index 6ebcc58..b543061 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParserTest.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/patch/parser/RdfPatchParserTest.java
@@ -65,7 +65,7 @@ public class RdfPatchParserTest {
         Iterator<PatchLine> it = patchLines.iterator();
 
         Assert.assertTrue(it.hasNext());
-        checkPatchLine(it.next(), PatchLine.Operator.DEL, bob, FOAF.name, lcBob);
+        checkPatchLine(it.next(), PatchLine.Operator.DELETE, bob, FOAF.name, lcBob);
 
         Assert.assertTrue(it.hasNext());
         checkPatchLine(it.next(), PatchLine.Operator.ADD, bob, FOAF.name, ucBob);
@@ -74,7 +74,7 @@ public class RdfPatchParserTest {
         checkPatchLine(it.next(), PatchLine.Operator.ADD, null, FOAF.knows, alice);
 
         Assert.assertTrue(it.hasNext());
-        checkPatchLine(it.next(), PatchLine.Operator.DEL, null, null, charlie);
+        checkPatchLine(it.next(), PatchLine.Operator.DELETE, null, null, charlie);
     }
 
     private void checkPatchLine(PatchLine line, PatchLine.Operator operator, Resource subejct, URI predicate, Value object) {