*/
/**
- * This file contains a class which has a set of native methods for
- * communicating with a remote resource.
+ * This file contains a class which has a set of native methods for
+ * communicating with a remote resource.
*/
package org.oic.simulator.clientcontroller;
-import java.util.List;
+import java.util.LinkedList;
import java.util.Map;
-import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+import org.oic.simulator.SimulatorResourceModel;
/**
* SimulatorRemoteResource represents a Resource running in the remote Simulator
public class SimulatorRemoteResource {
private SimulatorRemoteResource(long nativeHandle) {
- this.mNativeHandle = nativeHandle;
+ this.nativeHandle = nativeHandle;
}
/**
* Method to get the URI for this resource
- *
+ *
* @return resource URI
*/
- public native String getUri();
+ public String getUri() {
+ return mUri;
+ }
+
+ /**
+ * Method to get the observe capability of this resource
+ *
+ * @return true if the resource is observable, otherwise false.
+ */
+ public boolean getIsObservable() {
+ return mIsObservable;
+ }
+
+ /**
+ * Method to get the connectivity type for this resource
+ *
+ * @return Connectivity type.
+ */
+ public String getConnectivityType() {
+ return mConnType;
+ }
/**
* Method to get the list of resource types
- *
+ *
* @return List of resource types
*/
- public native List<String> getResourceTypes();
+ public LinkedList<String> getResourceTypes() {
+ return mResTypes;
+ }
/**
* Method to get the list of resource interfaces
- *
+ *
* @return List of resource interface
*/
- public native List<String> getResourceInterfaces();
+ public LinkedList<String> getResourceInterfaces() {
+ return mResInterfaces;
+ }
/**
* Method to get a string representation of the resource's server ID. This
* is unique per-server independent on how it was discovered.
- *
+ *
* @return server ID
*/
- public native String getServerId();
+ public String getServerId() {
+ return mSid;
+ }
+
+ /**
+ * Method to get a unique Id of the resource.
+ *
+ * @return Unique ID.
+ */
+ public String getUid() {
+ return mUid;
+ }
/**
* Method to set observation on the resource
- *
+ *
* @param observeType
* allows the client to specify how it wants to observe
* @param queryParamsMap
* @param onObserveListener
* event handler The handler method will be invoked with a map of
* attribute name and values.
- *
+ *
*/
public native void observe(SimulatorObserveType observeType,
Map<String, String> queryParamsMap,
/**
* Method to cancel the observation on the resource
- *
*/
public native void cancelObserve();
/**
* Method to get the attributes of a resource.
- *
+ *
* @param queryParamsMap
* map which can have the query parameter name and value
* @param onGetListener
* and values. The event handler will also have the result from
* this Get operation This will have error codes
*/
- public native void get(Map<String, String> queryParamsMap,
- IGetListener onGetListener);
+ public void get(Map<String, String> queryParamsMap,
+ IGetListener onGetListener) {
+ this.get(null, queryParamsMap, onGetListener);
+ }
/**
* Method to get the attributes of a resource.
- *
- * @param resourceType
- * resourceType of the resource to operate on
+ *
* @param resourceInterface
* interface type of the resource to operate on
* @param queryParamsMap
* and values. The event handler will also have the result from
* this Get operation This will have error codes
*/
- public void get(String resourceType, String resourceInterface,
- Map<String, String> queryParamsMap, IGetListener onGetListener) {
- this.get2(resourceType, resourceInterface, queryParamsMap,
- onGetListener);
- }
-
- private native void get2(String resourceType, String resourceInterface,
+ public native void get(String resourceInterface,
Map<String, String> queryParamsMap, IGetListener onGetListener);
/**
* Method to set the representation of a resource (via PUT)
- *
+ *
* @param representation
* representation of the resource
* @param queryParamsMap
* event handler The event handler will be invoked with a map of
* attribute name and values.
*/
- public native void put(SimulatorResourceModel representation,
- Map<String, String> queryParamsMap, IPutListener onPutListener);
+ public void put(SimulatorResourceModel representation,
+ Map<String, String> queryParamsMap, IPutListener onPutListener) {
+ this.put(null, representation, queryParamsMap, onPutListener);
+ }
/**
* Method to set the representation of a resource (via PUT)
- *
- * @param resourceType
- * resource type of the resource to operate on
+ *
* @param resourceInterface
* interface type of the resource to operate on
* @param representation
* event handler The event handler will be invoked with a map of
* attribute name and values.
*/
- public void put(String resourceType, String resourceInterface,
- SimulatorResourceModel representation,
- Map<String, String> queryParamsMap, IPutListener onPutListener) {
- this.put2(resourceType, resourceInterface, representation,
- queryParamsMap, onPutListener);
- }
-
- private native void put2(String resourceType, String resourceInterface,
+ private native int put(String resourceInterface,
SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPutListener onPutListener);
/**
* Method to POST on a resource
- *
+ *
* @param representation
* representation of the resource
* @param queryParamsMap
* event handler The event handler will be invoked with a map of
* attribute name and values.
*/
- public native void post(SimulatorResourceModel representation,
- Map<String, String> queryParamsMap, IPostListener onPostListener);
+ public void post(SimulatorResourceModel representation,
+ Map<String, String> queryParamsMap, IPostListener onPostListener) {
+ this.post(null, representation, queryParamsMap, onPostListener);
+ }
/**
* Method to POST on a resource
- *
- * @param resourceType
- * resource type of the resource to operate on
+ *
* @param resourceInterface
* interface type of the resource to operate on
* @param representation
* event handler The event handler will be invoked with a map of
* attribute name and values.
*/
- public void post(String resourceType, String resourceInterface,
- SimulatorResourceModel representation,
- Map<String, String> queryParamsMap, IPostListener onPostListener) {
- this.post2(resourceType, resourceInterface, representation,
- queryParamsMap, onPostListener);
- }
-
- private native void post2(String resourceType, String resourceInterface,
+ private native int post(String resourceInterface,
SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPostListener onPostListener);
+ /**
+ * Method to set the RAML file path from application
+ *
+ * @param ramlPath
+ * RAML configuration file path
+ */
+ public native void configureRAMLPath(String ramlPath);
+
+ /**
+ * Method to start verification of a resource using automation
+ *
+ * @param requestType
+ * request type to verify
+ *
+ * @param onVerifyListener
+ * event handler The event handler will be invoked with the
+ * automation ID.
+ *
+ * @return Automation ID.
+ *
+ */
+ public native int startVerification(int requestType,
+ IVerificationListener onVerifyListener);
+
+ /**
+ * Method to stop verification of a resource previously started.
+ *
+ * @param id
+ * Automation ID.
+ *
+ */
+ public native void stopVerification(int id);
+
@Override
protected void finalize() throws Throwable {
super.finalize();
private native void dispose();
- private long mNativeHandle;
+ private long nativeHandle;
+ private String mUri;
+ private String mConnType;
+ private String mSid;
+ private String mUid;
+ private boolean mIsObservable;
+ private LinkedList<String> mResTypes;
+ private LinkedList<String> mResInterfaces;
}