import org.eclipse.swt.graphics.Image;
import org.oic.simulator.IAutomation;
import org.oic.simulator.ILogger.Level;
+import org.oic.simulator.InvalidArgsException;
import org.oic.simulator.ResourceAttribute;
import org.oic.simulator.ResourceAttribute.Range;
import org.oic.simulator.ResourceAttribute.Type;
orderedResourceUriMap.remove(resourceType);
}
}
- } else if (null != resourceURI) {
+ } else if (null != resourceType) {
orderedResourceUriMap.remove(resourceType);
} else {
orderedResourceUriMap.clear();
if (null != resourceServerN) {
try {
resourceServerN.stopAutomation(autoId);
- } catch (SimulatorException e) {
+ } catch (InvalidArgsException e) {
+ Activator
+ .getDefault()
+ .getLogManager()
+ .log(Level.ERROR.ordinal(),
+ new Date(),
+ "[" + e.getClass().getSimpleName() + "]"
+ + e.code().toString() + "-"
+ + e.message());
+ return;
+ }catch (SimulatorException e) {
Activator
.getDefault()
.getLogManager()
// Call native method
try {
resourceServer.stopAutomation(autoId);
+ } catch (InvalidArgsException e) {
+ Activator
+ .getDefault()
+ .getLogManager()
+ .log(Level.ERROR.ordinal(),
+ new Date(),
+ "[" + e.getClass().getSimpleName() + "]"
+ + e.code().toString() + "-"
+ + e.message());
+ return false;
} catch (SimulatorException e) {
Activator
.getDefault()
public static SimulatorResourceServer createResource(String configPath,
IResourceModelChangedListener listener)
throws InvalidArgsException, SimulatorException {
+ if (configPath.isEmpty() || null == listener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
SimulatorResourceServer simulatorResourceServerObj;
simulatorResourceServerObj = SimulatorManagerNativeInterface
.createResource(configPath, listener);
public static SimulatorResourceServer[] createResource(String configPath,
int count, IResourceModelChangedListener listener)
throws InvalidArgsException, SimulatorException {
+ if (configPath.isEmpty() || count < 0 || null == listener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
SimulatorResourceServer[] simulatorResourceServers;
simulatorResourceServers = SimulatorManagerNativeInterface
.createResources(configPath, count, listener);
import org.oic.simulator.OperationInProgressException;
import org.oic.simulator.SimulatorException;
import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.SimulatorResult;
/**
* SimulatorRemoteResource represents a Resource running in the remote Simulator
public void get(Map<String, String> queryParamsMap,
IGetListener onGetListener) throws InvalidArgsException,
NoSupportException, SimulatorException {
+ if (null == onGetListener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
this.get(null, queryParamsMap, onGetListener);
}
* @throws SimulatorException
* This exception will be thrown for other errors.
*/
- public native void get(String resourceInterface,
+ public void get(String resourceInterface,
+ Map<String, String> queryParamsMap, IGetListener onGetListener)
+ throws InvalidArgsException, NoSupportException, SimulatorException {
+ if (resourceInterface.isEmpty() || null == onGetListener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
+ this.get(resourceInterface, queryParamsMap, onGetListener);
+ }
+
+ private native void nativeGet(String resourceInterface,
Map<String, String> queryParamsMap, IGetListener onGetListener)
throws InvalidArgsException, NoSupportException, SimulatorException;
public void put(SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPutListener onPutListener)
throws InvalidArgsException, NoSupportException, SimulatorException {
+ if (null == representation || null == onPutListener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
this.put(null, representation, queryParamsMap, onPutListener);
}
* @throws SimulatorException
* This exception will be thrown for other errors.
*/
- private native void put(String resourceInterface,
+ public void put(String resourceInterface,
+ SimulatorResourceModel representation,
+ Map<String, String> queryParamsMap, IPutListener onPutListener)
+ throws InvalidArgsException, NoSupportException, SimulatorException {
+ if (resourceInterface.isEmpty() || null == representation || null == onPutListener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
+ this.put(resourceInterface, representation, queryParamsMap, onPutListener);
+ }
+
+ private native void nativePut(String resourceInterface,
SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPutListener onPutListener)
throws InvalidArgsException, NoSupportException, SimulatorException;
public void post(SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPostListener onPostListener)
throws InvalidArgsException, NoSupportException, SimulatorException {
+ if (null == representation || null == onPostListener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
this.post(null, representation, queryParamsMap, onPostListener);
}
* @throws SimulatorException
* This exception will be thrown for other errors.
*/
- public native void post(String resourceInterface,
+ public void post(String resourceInterface,
+ SimulatorResourceModel representation,
+ Map<String, String> queryParamsMap, IPostListener onPostListener)
+ throws InvalidArgsException, NoSupportException, SimulatorException {
+ if (resourceInterface.isEmpty() || null == representation || null == onPostListener)
+ throw new InvalidArgsException(
+ SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
+ "Parameter passed in invalid");
+ this.post(resourceInterface, representation, queryParamsMap, onPostListener);
+ }
+
+ private native void nativePost(String resourceInterface,
SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPostListener onPostListener)
throws InvalidArgsException, NoSupportException, SimulatorException;