Commit 8dcf5c8c authored by acoburn's avatar acoburn
Browse files

make GET and DELETE methods work properly

parent 7424a5fc
......@@ -42,11 +42,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-jdbc</artifactId>-->
<!--<version>${spring.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
......
......@@ -13,6 +13,9 @@
*/
package edu.amherst.acdc.idiomatic;
import static org.apache.camel.builder.PredicateBuilder.not;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.PropertyInject;
import org.apache.camel.RuntimeCamelException;
......@@ -89,18 +92,22 @@ public class EventRouter extends RouteBuilder {
from("direct:update")
.routeId("IdMappingUpdateRouter")
.to("sql:UPDATE uris SET fedora=:#fedora WHERE public=:#public")
.setHeader(Exchange.HTTP_RESPONSE_CODE).constant(204)
.filter(simple("${body} == 0"))
.to("sql:INSERT INTO uris (fedora, public) VALUES (:#fedora, :#public)");
from("direct:get")
.routeId("IdMappingFetchRouter")
.log("${headers}")
.to("sql:SELECT fedora FROM uris WHERE public=:#public");
.to("sql:SELECT fedora FROM uris WHERE public=:#id?outputType=SelectOne")
.removeHeader("id")
.filter(not(header("CamelSqlRowCount").isEqualTo(1)))
.setHeader(Exchange.HTTP_RESPONSE_CODE).constant(404);
from("direct:delete")
.routeId("IdMappingDeleteRouter")
.log("${headers}")
.to("sql:DELETE FROM uris WHERE public=:#public");
.to("sql:DELETE FROM uris WHERE public=:#id")
.removeHeader("id")
.setHeader(Exchange.HTTP_RESPONSE_CODE).constant(204);
}
}
......@@ -13,8 +13,6 @@
<feature version="${camel.version}">camel</feature>
<feature version="${camel.version}">camel-blueprint</feature>
<feature version="${camel.version}">camel-jetty</feature>
<feature version="${camel.version}">camel-jdbc</feature>
<feature version="${camel.version}">camel-restlet</feature>
<feature version="${camel.version}">camel-jackson</feature>
<feature version="${camel.version}">camel-sql</feature>
......
......@@ -60,11 +60,6 @@
<artifactId>camel-restlet</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment