Initial sketch of codecs and REST API approach.
FIxed typos and defects.
ONOS-81
Change-Id: I789444a181abea509c354966545c927e305710d1
diff --git a/utils/misc/src/main/java/org/onlab/api/ItemNotFoundException.java b/utils/misc/src/main/java/org/onlab/api/ItemNotFoundException.java
new file mode 100644
index 0000000..fe484d4
--- /dev/null
+++ b/utils/misc/src/main/java/org/onlab/api/ItemNotFoundException.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onlab.api;
+
+/**
+ * Represents condition where an item is not found or not available.
+ */
+public class ItemNotFoundException extends RuntimeException {
+
+ /**
+ * Creates a new exception with no message.
+ */
+ public ItemNotFoundException() {
+ }
+
+ /**
+ * Creates a new exception with the supplied message.
+ * @param message error message
+ */
+ public ItemNotFoundException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a new exception with the supplied message and cause.
+ * @param message error message
+ * @param cause cause of the error
+ */
+ public ItemNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/utils/pom.xml b/utils/pom.xml
index 54a5467..f46bc61 100644
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -38,7 +38,7 @@
<module>nio</module>
<module>osgi</module>
<module>rest</module>
- <module>thirdparty</module>
+ <module>thirdparty</module>
</modules>
<dependencies>
diff --git a/utils/rest/src/main/java/org/onlab/rest/BaseResource.java b/utils/rest/src/main/java/org/onlab/rest/BaseResource.java
index 5886afe..50b4d0f 100644
--- a/utils/rest/src/main/java/org/onlab/rest/BaseResource.java
+++ b/utils/rest/src/main/java/org/onlab/rest/BaseResource.java
@@ -18,6 +18,8 @@
import org.onlab.osgi.DefaultServiceDirectory;
import org.onlab.osgi.ServiceDirectory;
+import javax.ws.rs.core.Response;
+
/**
* Base abstraction of a JAX-RS resource.
*/
@@ -44,8 +46,12 @@
* @param <T> type of service
* @return service implementation
*/
- protected static <T> T get(Class<T> service) {
+ public <T> T get(Class<T> service) {
return services.get(service);
}
+ protected static Response.ResponseBuilder ok(Object obj) {
+ return Response.ok(obj);
+ }
+
}