You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2009/03/19 14:05:13 UTC
svn commit: r755981 [3/3] - in /lenya/contributions/2_0_X/modules: atom/
atom/config/ atom/config/cocoon-xconf/ atom/java/ atom/java/src/
atom/java/src/org/ atom/java/src/org/apache/
atom/java/src/org/apache/lenya/ atom/java/src/org/apache/lenya/module...
Added: lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestHandler.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestHandler.java?rev=755981&view=auto
==============================================================================
--- lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestHandler.java (added)
+++ lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestHandler.java Thu Mar 19 13:05:10 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.lenya.modules.rest;
+
+public interface RestHandler {
+
+ RestView get() throws Exception;
+
+ RestView put() throws Exception;
+
+ RestView post() throws Exception;
+
+ RestView delete() throws Exception;
+
+}
Added: lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestView.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestView.java?rev=755981&view=auto
==============================================================================
--- lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestView.java (added)
+++ lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/RestView.java Thu Mar 19 13:05:10 2009
@@ -0,0 +1,9 @@
+package org.apache.lenya.modules.rest;
+
+public interface RestView {
+
+ public int getStatusCode();
+
+ public String getUri();
+
+}
Added: lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/SimpleRestView.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/SimpleRestView.java?rev=755981&view=auto
==============================================================================
--- lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/SimpleRestView.java (added)
+++ lenya/contributions/2_0_X/modules/rest/java/src/org/apache/lenya/modules/rest/SimpleRestView.java Thu Mar 19 13:05:10 2009
@@ -0,0 +1,33 @@
+package org.apache.lenya.modules.rest;
+
+import org.apache.lenya.util.Assert;
+
+public class SimpleRestView implements RestView {
+
+ int statusCode;
+ String uri;
+
+ public SimpleRestView(String uri, int statusCode) {
+ setUri(uri);
+ setStatusCode(statusCode);
+ }
+
+ public int getStatusCode() {
+ return this.statusCode;
+ }
+
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ public String getUri() {
+ Assert.notNull("view URI", this.uri);
+ return this.uri;
+ }
+
+ public void setUri(String uri) {
+ Assert.notNull("view URI", uri);
+ this.uri = uri;
+ }
+
+}
Added: lenya/contributions/2_0_X/modules/rest/rest.js
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/rest/rest.js?rev=755981&view=auto
==============================================================================
--- lenya/contributions/2_0_X/modules/rest/rest.js (added)
+++ lenya/contributions/2_0_X/modules/rest/rest.js Thu Mar 19 13:05:10 2009
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ */
+
+function handleRequest() {
+
+ var handler;
+ try {
+ var role = cocoon.parameters["handler"];
+ var lastDot = role.lastIndexOf(".");
+ var className = role.substring(lastDot + 1);
+ var firstChar = className.substring(0, 1).toUpperCase();
+ role = role.substring(0, lastDot + 1) + firstChar + className.substring(1);
+
+ var method = cocoon.request.getMethod().toLowerCase();
+ handler = cocoon.getComponent(role);
+ var view = eval("handler['" + method + "']()");
+ cocoon.sendPage("view/" + view.getUri(), { "view" : view });
+ } finally {
+ if (handler) {
+ cocoon.releaseComponent(handler);
+ }
+ }
+}
+
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org