Skip to content

Commit

Permalink
Support for PATCH method in Rest DSL
Browse files Browse the repository at this point in the history
Added new verb to the Rest model, the PatchVerbDefinition and made made
the jaxb parser aware of this new file.
Added instructions in RestDefinition and VerbDefinition on how to handle
this new verb.
  • Loading branch information
spegelref authored and davsclaus committed Apr 7, 2016
1 parent cef2609 commit 18eef8c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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.camel.model.rest;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.camel.spi.Metadata;

/**
* Rest PATCH command
*/
@Metadata(label = "rest")
@XmlRootElement(name = "patch")
@XmlAccessorType(XmlAccessType.FIELD)
public class PatchVerbDefinition extends VerbDefinition {

}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ public RestDefinition put(String uri) {
return addVerb("put", uri);
}

public RestDefinition patch() {
return addVerb("patch", null);
}

public RestDefinition patch(String uri) {
return addVerb("patch", uri);
}

public RestDefinition delete() {
return addVerb("delete", null);
}
Expand Down Expand Up @@ -564,6 +572,8 @@ private RestDefinition addVerb(String verb, String uri) {
answer = new HeadVerbDefinition();
} else if ("put".equals(verb)) {
answer = new PutVerbDefinition();
} else if ("patch".equals(verb)) {
answer = new PatchVerbDefinition();
} else if ("options".equals(verb)) {
answer = new OptionsVerbDefinition();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ public String asVerb() {
return "post";
} else if (this instanceof PutVerbDefinition) {
return "put";
} else if (this instanceof PatchVerbDefinition) {
return "patch";
} else if (this instanceof DeleteVerbDefinition) {
return "delete";
} else if (this instanceof HeadVerbDefinition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ HeadVerbDefinition
OptionsVerbDefinition
PostVerbDefinition
PutVerbDefinition
PatchVerbDefinition
RestBindingDefinition
RestBindingMode
RestConfigurationDefinition
Expand All @@ -32,4 +33,4 @@ RestOperationResponseHeaderDefinition
RestParamType
RestPropertyDefinition
RestsDefinition
VerbDefinition
VerbDefinition

0 comments on commit 18eef8c

Please sign in to comment.