Java SDK and Eclipse plugin for simulator.
authorG S Senthil Kumar <senthil.gs@samsung.com>
Mon, 14 Sep 2015 17:10:13 +0000 (22:40 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 16 Sep 2015 00:36:11 +0000 (00:36 +0000)
1. Java APIs for service provider and client controller.
2. Added client controller eclipse plug-in.
3. Minor changes in service provider eclipse plug-in for
   config file handling.
4. Included RAML configuration file for light resource in plug-in.
5. Handled exceptions till plug-ins.
6. Included license header and javadoc comments in plug-ins.
7. Updated the java sdk method names in platform and device info classes.
8. Handled review comments [Added license header and included comments in all
   the source files of plug-in, and updated comments in Java APIs]

Change-Id: I17181691a48b2f54cf3b9f46435fe7f09f8076cb
Signed-off-by: G S Senthil Kumar <senthil.gs@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2493
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
149 files changed:
service/simulator/java/eclipse-plugin/ClientControllerPlugin/.classpath [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/.project [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/META-INF/MANIFEST.MF [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/build.properties [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/checked.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_d.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/debug_log.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_d.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/error_log.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_d.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_d.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/info_log.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/light_16x16.png [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_d.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/log_details_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_16x16.png [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_32x32.png [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_64x64.png [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_d.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/sample.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/trash_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_d.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_e.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unchecked.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unknown_log.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/warning_log.gif [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/plugin.xml [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/Activator.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IConfigurationUpload.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IFindResourceUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IGetUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/ILogUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IObserveUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IPostUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IPutUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IResourceSelectionChangedUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IVerificationUIListener.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ImageManager.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/LogManager.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ResourceManager.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/perspective/PerspectiveFactory.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/MetaProperty.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/PutPostAttributeModel.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/RemoteResource.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/RemoteResourceAttribute.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/Constants.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/Utility.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/AttributeView.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/LogView.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/MetaPropertiesView.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/MultiResourceOrchestrationView.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/ResourceManagerView.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FilterDialog.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FindResourcePage.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FindResourceWizard.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/LoadRAMLDialog.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/LogDetailsDialog.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PostRequestDialog.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PutRequestDialog.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/ResourceWizardDialog.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/VerificationDialog.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogContentProvider.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogEntry.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogLabelProvider.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LoggerCallback.java [new file with mode: 0644]
service/simulator/java/eclipse-plugin/README.txt [moved from service/simulator/java/eclipse-plugin/ServiceProviderPlugin/README.txt with 94% similarity]
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/build.properties
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light-error.json [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light.json [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light.raml [new file with mode: 0644]
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/light.raml [deleted file]
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/oic.light.json [deleted file]
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogContentProvider.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogEntry.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LogLabelProvider.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/logger/LoggerCallback.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/Activator.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IAutomationUIListener.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/ILogUIListener.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IObserverListChangedUIListener.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceListChangedUIListener.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceModelChangedUIListener.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/listener/IResourceSelectionChangedUIListener.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ImageManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/LogManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/perspective/PerspectiveFactory.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/AutomationSettingHelper.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/DeleteCategory.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/LocalResourceAttribute.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/MetaProperty.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ModelChangeNotificationType.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/ObserverDetail.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/SimulatorResource.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/resource/StandardConfiguration.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Constants.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeEditingSupport.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/AttributeView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MultiResourceOrchestrationView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceObserverView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/AutomationSettingDialog.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourcePage.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/CreateResourceWizard.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourcePage.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourceWizard.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/FilterDialog.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/LogDetailsDialog.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/ResourceWizardDialog.java
service/simulator/java/sdk/src/org/oic/simulator/DeviceInfo.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/IAutomation.java
service/simulator/java/sdk/src/org/oic/simulator/IDeviceInfo.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/ILogger.java
service/simulator/java/sdk/src/org/oic/simulator/IPlatformInfo.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/InvalidArgsException.java [moved from service/simulator/java/sdk/src/org/oic/simulator/AutomationType.java with 71% similarity]
service/simulator/java/sdk/src/org/oic/simulator/NoSupportException.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/OCSimulatorResult.java [deleted file]
service/simulator/java/sdk/src/org/oic/simulator/OperationInProgressException.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/PlatformInfo.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/ResourceAttribute.java
service/simulator/java/sdk/src/org/oic/simulator/SimulatorException.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/SimulatorManager.java
service/simulator/java/sdk/src/org/oic/simulator/SimulatorManagerNativeInterface.java
service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceModel.java
service/simulator/java/sdk/src/org/oic/simulator/SimulatorResult.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IFindResourceListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IGetListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IObserveListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPostListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IPutListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/IVerificationListener.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorConnectivityType.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorObserveType.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorRemoteResource.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorVerificationType.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/AutomationType.java [new file with mode: 0644]
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IObserver.java
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/IResourceModelChangedListener.java
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/ObserverInfo.java
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceServer.java

diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/.classpath b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/.classpath
new file mode 100644 (file)
index 0000000..89756a7
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+    <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+    <classpathentry kind="src" path="src"/>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+    <classpathentry kind="lib" path="libs/Simulator.jar"/>
+    <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/.project b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/.project
new file mode 100644 (file)
index 0000000..f865f6c
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+    <name>ClientControllerPlugin</name>
+    <comment></comment>
+    <projects>
+    </projects>
+    <buildSpec>
+        <buildCommand>
+            <name>org.eclipse.jdt.core.javabuilder</name>
+            <arguments>
+            </arguments>
+        </buildCommand>
+        <buildCommand>
+            <name>org.eclipse.pde.ManifestBuilder</name>
+            <arguments>
+            </arguments>
+        </buildCommand>
+        <buildCommand>
+            <name>org.eclipse.pde.SchemaBuilder</name>
+            <arguments>
+            </arguments>
+        </buildCommand>
+    </buildSpec>
+    <natures>
+        <nature>org.eclipse.pde.PluginNature</nature>
+        <nature>org.eclipse.jdt.core.javanature</nature>
+    </natures>
+</projectDescription>
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/META-INF/MANIFEST.MF b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..4366174
--- /dev/null
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ClientControllerPlugin
+Bundle-SymbolicName: ClientControllerPlugin;singleton:=true
+Bundle-Version: 0.1.0
+Bundle-Activator: oic.simulator.clientcontroller.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Bundle-NativeCode: libs/libSimulatorManager.so
+Bundle-ClassPath: libs/Simulator.jar,
+ .
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/build.properties b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/build.properties
new file mode 100644 (file)
index 0000000..100c21d
--- /dev/null
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               icons/,\
+               libs/Simulator.jar,\
+               libs/libSimulatorManager.so
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/checked.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/checked.gif
new file mode 100644 (file)
index 0000000..e556e7d
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/checked.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_d.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_d.gif
new file mode 100644 (file)
index 0000000..6775edf
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_d.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_e.gif
new file mode 100644 (file)
index 0000000..af30a42
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/clear_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/debug_log.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/debug_log.gif
new file mode 100644 (file)
index 0000000..d90a29f
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/debug_log.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_d.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_d.gif
new file mode 100644 (file)
index 0000000..9e14298
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_d.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_e.gif
new file mode 100644 (file)
index 0000000..b6922ac
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/delete_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/error_log.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/error_log.gif
new file mode 100644 (file)
index 0000000..9b048d6
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/error_log.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_d.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_d.gif
new file mode 100644 (file)
index 0000000..030b93e
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_d.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_e.gif
new file mode 100644 (file)
index 0000000..5a0837d
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/export_log_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_d.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_d.gif
new file mode 100644 (file)
index 0000000..ba6d891
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_d.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_e.gif
new file mode 100644 (file)
index 0000000..1492b4e
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/filter_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/info_log.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/info_log.gif
new file mode 100644 (file)
index 0000000..3679f84
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/info_log.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/light_16x16.png b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/light_16x16.png
new file mode 100644 (file)
index 0000000..8b3abbd
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/light_16x16.png differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_d.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_d.gif
new file mode 100644 (file)
index 0000000..b776478
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_d.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_e.gif
new file mode 100644 (file)
index 0000000..68fd6cf
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/lock_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/log_details_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/log_details_e.gif
new file mode 100644 (file)
index 0000000..7ccc6a7
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/log_details_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_16x16.png b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_16x16.png
new file mode 100644 (file)
index 0000000..e6bbc36
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_16x16.png differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_32x32.png b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_32x32.png
new file mode 100644 (file)
index 0000000..d02a216
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_32x32.png differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_64x64.png b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_64x64.png
new file mode 100644 (file)
index 0000000..4fe3cbb
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/oic_logo_64x64.png differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_d.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_d.gif
new file mode 100644 (file)
index 0000000..ec394d6
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_d.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_e.gif
new file mode 100644 (file)
index 0000000..d11c996
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/prop_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/sample.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/sample.gif
new file mode 100644 (file)
index 0000000..34fb3c9
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/sample.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/trash_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/trash_e.gif
new file mode 100644 (file)
index 0000000..bf961b3
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/trash_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_d.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_d.gif
new file mode 100644 (file)
index 0000000..62bdbe2
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_d.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_e.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_e.gif
new file mode 100644 (file)
index 0000000..dda8bae
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/tree_mode_e.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unchecked.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unchecked.gif
new file mode 100644 (file)
index 0000000..342fa9d
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unchecked.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unknown_log.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unknown_log.gif
new file mode 100644 (file)
index 0000000..a54ccfe
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/unknown_log.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/warning_log.gif b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/warning_log.gif
new file mode 100644 (file)
index 0000000..14009e9
Binary files /dev/null and b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/icons/warning_log.gif differ
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/plugin.xml b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/plugin.xml
new file mode 100644 (file)
index 0000000..1bc294b
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.perspectives">
+        <perspective
+             class="oic.simulator.clientcontroller.perspective.PerspectiveFactory"
+             icon="icons/oic_logo_16x16.png"
+             id="oic.simulator.clientcontroller.perspective"
+             name="Client Controller">
+        </perspective>
+   </extension>
+   <extension
+         point="org.eclipse.ui.views">
+        <category
+            id="oic.simulator.clientcontroller.category"
+            name="Client Controller">
+        </category>
+        <view category="oic.simulator.clientcontroller.category"
+            class="oic.simulator.clientcontroller.view.ResourceManagerView"
+            icon="icons/oic_logo_16x16.png"
+            id="oic.simulator.clientcontroller.view.resourcemanager"
+            name="Resource Manager"
+            restorable="true">
+        </view>
+        <view category="oic.simulator.clientcontroller.category"
+            class="oic.simulator.clientcontroller.view.MetaPropertiesView"
+            icon="icons/oic_logo_16x16.png"
+            id="oic.simulator.clientcontroller.view.metaproperties"
+            name="Properties"
+            restorable="true">
+        </view>
+        <view category="oic.simulator.clientcontroller.category"
+            class="oic.simulator.clientcontroller.view.AttributeView"
+            icon="icons/oic_logo_16x16.png"
+            id="oic.simulator.clientcontroller.view.attribute"
+            name="Attribute Manager"
+            restorable="true">
+        </view>
+        <view category="oic.simulator.clientcontroller.category"
+            class="oic.simulator.clientcontroller.view.MultiResourceOrchestrationView"
+            icon="icons/oic_logo_16x16.png"
+            id="oic.simulator.clientcontroller.view.orchestration"
+            name="Multi-Resource Automation"
+            restorable="true">
+        </view>
+        <view category="oic.simulator.clientcontroller.category"
+            class="oic.simulator.clientcontroller.view.LogView"
+            icon="icons/oic_logo_16x16.png"
+            id="oic.simulator.clientcontroller.view.log"
+            name="Simulator Log"
+            restorable="true">
+        </view>
+   </extension>
+   <extension
+         point="org.eclipse.ui.perspectiveExtensions">
+        <perspectiveExtension targetID="*">
+            <perspectiveShortcut 
+                 id="oic.simulator.clientcontroller.perspective">
+             </perspectiveShortcut>
+        </perspectiveExtension>
+        <perspectiveExtension targetID="oic.simulator.clientcontroller.perspective">
+            <viewShortcut
+                id="oic.simulator.clientcontroller.view.resourcemanager">
+            </viewShortcut>
+            <viewShortcut
+                id="oic.simulator.clientcontroller.view.metaproperties">
+            </viewShortcut>
+            <viewShortcut
+                id="oic.simulator.clientcontroller.view.attribute">
+            </viewShortcut>
+            <viewShortcut
+                id="oic.simulator.clientcontroller.view.orchestration">
+            </viewShortcut>
+            <viewShortcut
+                id="oic.simulator.clientcontroller.view.log">
+            </viewShortcut>
+        </perspectiveExtension>
+   </extension>
+</plugin>
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/Activator.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/Activator.java
new file mode 100644 (file)
index 0000000..5f22400
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller;
+
+import oic.simulator.clientcontroller.manager.ImageManager;
+import oic.simulator.clientcontroller.manager.LogManager;
+import oic.simulator.clientcontroller.manager.ResourceManager;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class Activator extends AbstractUIPlugin {
+
+    // The plug-in ID
+    public static final String     PLUGIN_ID = "ClientControllerPlugin";
+
+    // The shared instance
+    private static Activator       plugin;
+
+    private static ResourceManager resourceManager;
+
+    private static LogManager      logManager;
+
+    private static ImageManager    imageManager;
+
+    static {
+        System.loadLibrary("SimulatorManager");
+    }
+
+    public Activator() {
+    }
+
+    public void start(BundleContext context) throws Exception {
+        super.start(context);
+        plugin = this;
+        setResourceManager(new ResourceManager());
+        setLogManager(new LogManager());
+        imageManager = ImageManager.getInstance();
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        plugin = null;
+        // Stopping Resource Manager
+        if (null != resourceManager) {
+            resourceManager.shutdown();
+            resourceManager = null;
+        }
+        // Stopping Log Manager
+        if (null != logManager) {
+            logManager.shutdown();
+            logManager = null;
+        }
+        super.stop(context);
+    }
+
+    public static Activator getDefault() {
+        return plugin;
+    }
+
+    public ResourceManager getResourceManager() {
+        return resourceManager;
+    }
+
+    private static void setResourceManager(ResourceManager manager) {
+        Activator.resourceManager = manager;
+    }
+
+    public LogManager getLogManager() {
+        return logManager;
+    }
+
+    private static void setLogManager(LogManager logManager) {
+        Activator.logManager = logManager;
+    }
+
+    public ImageManager getImageManager() {
+        return imageManager;
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IConfigurationUpload.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IConfigurationUpload.java
new file mode 100644 (file)
index 0000000..3b8f6fd
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the configuration uploaded event is notified to the
+ * UI listeners.
+ */
+public interface IConfigurationUpload {
+    public void onConfigurationUploaded(RemoteResource resource);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IFindResourceUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IFindResourceUIListener.java
new file mode 100644 (file)
index 0000000..684fe89
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the resource found notification is sent to the UI
+ * listeners.
+ */
+public interface IFindResourceUIListener {
+    public void onNewResourceFound(RemoteResource resource);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IGetUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IGetUIListener.java
new file mode 100644 (file)
index 0000000..6d752c5
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the GET responses are notified to the UI listeners.
+ */
+public interface IGetUIListener {
+    public void onGetCompleted(RemoteResource resource);
+
+    public void onGetFailed(RemoteResource resource);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/ILogUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/ILogUIListener.java
new file mode 100644 (file)
index 0000000..0afea77
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import java.util.List;
+
+import oic.simulator.logger.LogEntry;
+
+/**
+ * Interface through which the log events are notified to the UI listeners.
+ */
+public interface ILogUIListener {
+    public void logAdded(LogEntry added);
+
+    public void logChanged(List<LogEntry> entry);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IObserveUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IObserveUIListener.java
new file mode 100644 (file)
index 0000000..ca5f838
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the observe responses are notified to the UI
+ * listeners.
+ */
+public interface IObserveUIListener {
+    public void onObserveCompleted(RemoteResource resource);
+
+    public void onObserveFailed(RemoteResource resource);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IPostUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IPostUIListener.java
new file mode 100644 (file)
index 0000000..793eb76
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the POST responses are notified to the UI listeners.
+ */
+public interface IPostUIListener {
+    public void onPostCompleted(RemoteResource resource);
+
+    public void onPostFailed(RemoteResource resource);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IPutUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IPutUIListener.java
new file mode 100644 (file)
index 0000000..28eb3ff
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the PUT responses are notified to the UI listeners.
+ */
+public interface IPutUIListener {
+    public void onPutCompleted(RemoteResource resource);
+
+    public void onPutFailed(RemoteResource resource);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IResourceSelectionChangedUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IResourceSelectionChangedUIListener.java
new file mode 100644 (file)
index 0000000..51586cd
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the resource selection UI event is notified to the UI
+ * listeners.
+ */
+public interface IResourceSelectionChangedUIListener {
+    public void onResourceSelectionChange(RemoteResource resource);
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IVerificationUIListener.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/listener/IVerificationUIListener.java
new file mode 100644 (file)
index 0000000..0956a68
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.listener;
+
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+/**
+ * Interface through which the automatic verification status events are sent to
+ * the UI listeners.
+ */
+public interface IVerificationUIListener {
+    public void onVerificationStarted(RemoteResource resource, int autoType);
+
+    public void onVerificationAborted(RemoteResource resource, int autoType);
+
+    public void onVerificationCompleted(RemoteResource resource, int autoType);
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ImageManager.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ImageManager.java
new file mode 100644 (file)
index 0000000..ec37672
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.manager;
+
+import java.net.URL;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.utils.Constants;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
+
+/**
+ * Class which loads the icons/images into the image registry, and has methods
+ * to handle the image related requests from other UI modules.
+ */
+public class ImageManager {
+
+    private static ImageManager imageManager;
+
+    public static ImageManager getInstance() {
+        if (null == imageManager) {
+            imageManager = new ImageManager();
+        }
+        return imageManager;
+    }
+
+    static {
+        ImageRegistry r = Activator.getDefault().getImageRegistry();
+        Bundle bundle = Activator.getDefault().getBundle();
+
+        r.put(Constants.CHECKED, ImageDescriptor.createFromURL(bundle
+                .getEntry("icons/checked.gif")));
+        r.put(Constants.UNCHECKED, ImageDescriptor.createFromURL(bundle
+                .getEntry("icons/unchecked.gif")));
+
+        // Resource icons based on the resource type
+        r.put(Constants.OIC_R_LIGHT, ImageDescriptor.createFromURL(bundle
+                .getEntry("/icons/light_16x16.png")));
+
+        // Log View related icons
+        r.put(Constants.DEBUG_LOG, ImageDescriptor.createFromURL(bundle
+                .getEntry("/icons/debug_log.gif")));
+        r.put(Constants.INFO_LOG, ImageDescriptor.createFromURL(bundle
+                .getEntry("/icons/info_log.gif")));
+        r.put(Constants.WARNING_LOG, ImageDescriptor.createFromURL(bundle
+                .getEntry("/icons/warning_log.gif")));
+        r.put(Constants.ERROR_LOG, ImageDescriptor.createFromURL(bundle
+                .getEntry("/icons/error_log.gif")));
+        r.put(Constants.UNKNOWN_LOG, ImageDescriptor.createFromURL(bundle
+                .getEntry("/icons/unknown_log.gif")));
+    }
+
+    public static Image getImage(String imagePath) {
+        Image img = null;
+        if (null == imagePath || imagePath.length() < 1) {
+            return img;
+        }
+        URL imageURL = Activator.getDefault().getBundle().getEntry(imagePath);
+        ImageDescriptor descriptor = ImageDescriptor.createFromURL(imageURL);
+        return descriptor.createImage();
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/LogManager.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/LogManager.java
new file mode 100644 (file)
index 0000000..03700e4
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.manager;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.listener.ILogUIListener;
+import oic.simulator.clientcontroller.utils.Constants;
+import oic.simulator.logger.LogEntry;
+import oic.simulator.logger.LoggerCallback;
+
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.oic.simulator.ILogger;
+import org.oic.simulator.ILogger.Level;
+import org.oic.simulator.SimulatorManager;
+
+/**
+ * Class which handles the native logs, maintains log entries and updates the
+ * UI.
+ */
+public class LogManager {
+    private LinkedList<LogEntry>         entries           = new LinkedList<LogEntry>();
+    private ArrayList<ILogUIListener>    listeners         = new ArrayList<ILogUIListener>();
+    private LinkedList<LogEntry>         visibleEntries    = new LinkedList<LogEntry>();
+    private HashMap<Integer, Boolean>    visibleSeverities = new HashMap<Integer, Boolean>();
+
+    private ILogger                      logger;
+    private LogManagerSynchronizerThread synchronizerThread;
+    private Thread                       threadHandle;
+
+    public LogManager() {
+        synchronizerThread = new LogManagerSynchronizerThread();
+        threadHandle = new Thread(synchronizerThread);
+        threadHandle.setName("OIC Simulator event queue");
+        threadHandle.start();
+
+        // Set the logger callback with the native layer
+        logger = new LoggerCallback();
+        SimulatorManager.setLogger(logger);
+    }
+
+    private static class LogManagerSynchronizerThread implements Runnable {
+
+        LinkedList<Runnable> eventQueue = new LinkedList<Runnable>();
+
+        @Override
+        public void run() {
+            while (!Thread.interrupted()) {
+
+                synchronized (this) {
+                    try {
+                        while (eventQueue.isEmpty()) {
+                            this.wait();
+                            break;
+                        }
+                    } catch (InterruptedException e) {
+                        return;
+                    }
+                }
+
+                Runnable pop;
+                synchronized (this) {
+                    pop = eventQueue.pop();
+                }
+                try {
+                    pop.run();
+                } catch (Exception e) {
+                    if (e instanceof InterruptedException) {
+                        return;
+                    }
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        public void addToQueue(Runnable event) {
+            synchronized (this) {
+                eventQueue.add(event);
+                this.notify();
+            }
+        }
+    }
+
+    public void log(int severity, Date date, String msg) {
+        final LogEntry logEntry = new LogEntry(severity, date, msg);
+        synchronizerThread.addToQueue(new Runnable() {
+            @Override
+            public void run() {
+                boolean notify = false;
+                synchronized (entries) {
+                    entries.add(logEntry);
+                    Boolean showEntry = LogManager.this.visibleSeverities
+                            .get(logEntry.getSeverity());
+                    if (showEntry != null) {
+                        if (showEntry) {
+                            visibleEntries.add(logEntry);
+                            notify = true;
+                        }
+                    }
+                    if (entries.size() > Constants.LOG_SIZE) {
+                        entries.pop();
+                    }
+                    if (visibleEntries.size() > Constants.LOG_SIZE) {
+                        visibleEntries.pop();
+                        notify = true;
+                    }
+                }
+                if (notify) {
+                    notifyListeners(logEntry);
+                }
+            }
+        });
+    }
+
+    public void applyFilter(final HashMap<Integer, Boolean> visibleSeverities) {
+        synchronizerThread.addToQueue(new Runnable() {
+
+            @Override
+            public void run() {
+                LinkedList<LogEntry> newLogs = new LinkedList<LogEntry>();
+                synchronized (entries) {
+                    LogManager.this.visibleSeverities = visibleSeverities;
+                    for (LogEntry logEntry : entries) {
+                        if (LogManager.this.visibleSeverities.get(logEntry
+                                .getSeverity())) {
+                            newLogs.add(logEntry);
+                        }
+                    }
+                }
+                visibleEntries = newLogs;
+                notifyListeners();
+            }
+        });
+
+    }
+
+    private void notifyListeners() {
+        for (ILogUIListener l : listeners) {
+            l.logChanged(new ArrayList<LogEntry>(visibleEntries));
+        }
+    }
+
+    private void notifyListeners(LogEntry added) {
+        for (ILogUIListener l : listeners) {
+            l.logAdded(added);
+        }
+    }
+
+    public void clearLog() {
+        synchronizerThread.addToQueue(new Runnable() {
+
+            @Override
+            public void run() {
+                synchronized (entries) {
+                    entries = new LinkedList<LogEntry>();
+                    visibleEntries = new LinkedList<LogEntry>();
+                }
+                notifyListeners();
+            }
+        });
+    }
+
+    public void removeEntry(final LogEntry element) {
+        synchronizerThread.addToQueue(new Runnable() {
+
+            @Override
+            public void run() {
+                synchronized (entries) {
+                    entries.remove(element);
+                    visibleEntries.remove(element);
+                }
+                notifyListeners();
+            }
+        });
+    }
+
+    public ArrayList<LogEntry> getLogEntries() {
+        synchronized (entries) {
+            return new ArrayList<LogEntry>(entries);
+        }
+    }
+
+    public void addLogListener(final ILogUIListener listener) {
+        synchronizerThread.addToQueue(new Runnable() {
+            @Override
+            public void run() {
+                if (!listeners.contains(listener)) {
+                    listeners.add(listener);
+                }
+            }
+        });
+    }
+
+    public void removeLogListener(final ILogUIListener listener) {
+        synchronizerThread.addToQueue(new Runnable() {
+            @Override
+            public void run() {
+                if (!listeners.contains(listener)) {
+                    listeners.remove(listener);
+                }
+            }
+        });
+    }
+
+    public void shutdown() {
+        threadHandle.interrupt();
+    }
+
+    public static String getSeverityName(int severity) {
+        if (severity == Level.INFO.ordinal()) {
+            return Constants.INFO;
+        } else if (severity == Level.WARNING.ordinal()) {
+            return Constants.WARNING;
+        } else if (severity == Level.ERROR.ordinal()) {
+            return Constants.ERROR;
+        } else if (severity == Level.DEBUG.ordinal()) {
+            return Constants.DEBUG;
+        } else {
+            return Constants.UNKNOWN;
+        }
+    }
+
+    public static Image getSeverityIcon(int severity) {
+        ImageRegistry r = Activator.getDefault().getImageRegistry();
+        if (severity == Level.INFO.ordinal()) {
+            return r.get(Constants.INFO_LOG);
+        } else if (severity == Level.WARNING.ordinal()) {
+            return r.get(Constants.WARNING_LOG);
+        } else if (severity == Level.ERROR.ordinal()) {
+            return r.get(Constants.ERROR_LOG);
+        } else if (severity == Level.DEBUG.ordinal()) {
+            return r.get(Constants.DEBUG_LOG);
+        } else {
+            return r.get(Constants.UNKNOWN_LOG);
+        }
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ResourceManager.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ResourceManager.java
new file mode 100644 (file)
index 0000000..392888f
--- /dev/null
@@ -0,0 +1,1442 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.manager;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.listener.IConfigurationUpload;
+import oic.simulator.clientcontroller.listener.IFindResourceUIListener;
+import oic.simulator.clientcontroller.listener.IGetUIListener;
+import oic.simulator.clientcontroller.listener.IObserveUIListener;
+import oic.simulator.clientcontroller.listener.IPostUIListener;
+import oic.simulator.clientcontroller.listener.IPutUIListener;
+import oic.simulator.clientcontroller.listener.IResourceSelectionChangedUIListener;
+import oic.simulator.clientcontroller.listener.IVerificationUIListener;
+import oic.simulator.clientcontroller.remoteresource.MetaProperty;
+import oic.simulator.clientcontroller.remoteresource.PutPostAttributeModel;
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+import oic.simulator.clientcontroller.remoteresource.RemoteResourceAttribute;
+import oic.simulator.clientcontroller.utils.Constants;
+import oic.simulator.clientcontroller.utils.Utility;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.oic.simulator.ILogger.Level;
+import org.oic.simulator.ResourceAttribute;
+import org.oic.simulator.ResourceAttribute.Range;
+import org.oic.simulator.ResourceAttribute.Type;
+import org.oic.simulator.SimulatorException;
+import org.oic.simulator.SimulatorManager;
+import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.clientcontroller.IFindResourceListener;
+import org.oic.simulator.clientcontroller.IGetListener;
+import org.oic.simulator.clientcontroller.IObserveListener;
+import org.oic.simulator.clientcontroller.IPostListener;
+import org.oic.simulator.clientcontroller.IPutListener;
+import org.oic.simulator.clientcontroller.IVerificationListener;
+import org.oic.simulator.clientcontroller.SimulatorObserveType;
+import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
+import org.oic.simulator.clientcontroller.SimulatorVerificationType;
+
+/**
+ * This class acts as an interface between the simulator java SDK and the
+ * various UI modules. It maintains all the details of resources and provides
+ * other UI modules with the information required. It also handles responses for find,
+ * GET, PUT, POST, Observe and automatic verification operations from native layer and propagates
+ * those events to the registered UI listeners.
+ */
+public class ResourceManager {
+
+    private Set<String>                               lastKnownSearchTypes;
+
+    private RemoteResource                            currentResourceInSelection;
+
+    private IFindResourceListener                     findResourceListener;
+    private IGetListener                              getListener;
+    private IPutListener                              putListener;
+    private IPostListener                             postListener;
+    private IObserveListener                          observeListener;
+    private IVerificationListener                     verifyListener;
+
+    private ResponseSynchronizerThread                synchronizerThread;
+
+    private Thread                                    threadHandle;
+
+    private List<IFindResourceUIListener>             findResourceUIListeners;
+    private List<IResourceSelectionChangedUIListener> resourceSelectionChangedUIListeners;
+    private List<IGetUIListener>                      getUIListeners;
+    private List<IPutUIListener>                      putUIListeners;
+    private List<IPostUIListener>                     postUIListeners;
+    private List<IObserveUIListener>                  observeUIListeners;
+    private List<IVerificationUIListener>             verificationUIListeners;
+    private List<IConfigurationUpload>                configUploadUIListeners;
+
+    // Map with Server ID as key and the complete object as the value
+    private Map<String, RemoteResource>               resourceMap;
+    private List<RemoteResource>                      favoriteResources;
+    // TODO: Temporarily maintaining a list of favorite resource URIs.
+    private List<String>                              favoriteURIList;
+
+    public ResourceManager() {
+        resourceMap = new HashMap<String, RemoteResource>();
+        favoriteResources = new ArrayList<RemoteResource>();
+        favoriteURIList = new ArrayList<String>();
+        findResourceUIListeners = new ArrayList<IFindResourceUIListener>();
+        resourceSelectionChangedUIListeners = new ArrayList<IResourceSelectionChangedUIListener>();
+        getUIListeners = new ArrayList<IGetUIListener>();
+        putUIListeners = new ArrayList<IPutUIListener>();
+        postUIListeners = new ArrayList<IPostUIListener>();
+        observeUIListeners = new ArrayList<IObserveUIListener>();
+        verificationUIListeners = new ArrayList<IVerificationUIListener>();
+        configUploadUIListeners = new ArrayList<IConfigurationUpload>();
+
+        findResourceListener = new IFindResourceListener() {
+
+            @Override
+            public void onResourceCallback(
+                    final SimulatorRemoteResource resourceN) {
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                        System.out.println("onResourceCallback() entry");
+                        if (null == resourceN) {
+                            return;
+                        }
+                        // If resource already exist, then ignore it.
+                        String uid = resourceN.getId();
+                        if (null == uid) {
+                            return;
+                        }
+                        boolean exist = isUidExist(uid);
+                        if (exist) {
+                            System.out.println("Duplicate resource found: ["
+                                    + uid + "]");
+                            return;
+                        }
+
+                        // Fetch the resource data
+                        RemoteResource resource = fetchResourceDetails(resourceN);
+                        if (null == resource) {
+                            return;
+                        }
+
+                        resource.setResource(resourceN);
+
+                        // Add the resource in local data structure
+                        addResourceDetails(resource);
+
+                        // Add resource to favorite list
+                        String uri = resource.getResourceURI();
+                        if (null != uri) {
+                            if (favoriteURIList.contains(uri)) {
+                                addResourcetoFavorites(resource);
+                            }
+                        }
+                        // Notify the UI listener
+                        newResourceFoundNotification(resource);
+
+                        // Send an initial GET request to get the resource
+                        // attributes
+                        try {
+                            resourceN.get(null, getListener);
+                        } catch (SimulatorException e) {
+                            Activator
+                                    .getDefault()
+                                    .getLogManager()
+                                    .log(Level.ERROR.ordinal(),
+                                            new Date(),
+                                            "[" + e.getClass().getSimpleName()
+                                                    + "]" + e.code().toString()
+                                                    + "-" + e.message());
+                        }
+                    }
+                });
+            }
+        };
+
+        getListener = new IGetListener() {
+            @Override
+            public void onGetCompleted(final String uid,
+                    final SimulatorResourceModel resourceModelN) {
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                        // Handling the response which includes retrieving the
+                        // attributes and updating the local model.
+                        RemoteResource resource = handleResponse(uid,
+                                resourceModelN);
+                        if (null != resource) {
+                            // Notify the UI listeners
+                            getCompleteNotification(resource);
+                        }
+                    }
+                });
+            }
+
+            @Override
+            public void onGetFailed(Throwable th) {
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                    }
+                });
+            }
+        };
+
+        putListener = new IPutListener() {
+
+            @Override
+            public void onPutCompleted(final String uid,
+                    final SimulatorResourceModel resourceModelN) {
+                synchronizerThread.addToQueue(new Thread() {
+                    @Override
+                    public void run() {
+                        // Handling the response which includes retrieving the
+                        // attributes and updating the local model.
+                        RemoteResource resource = handleResponse(uid,
+                                resourceModelN);
+                        if (null != resource) {
+                            // Notify the UI listeners
+                            putCompleteNotification(resource);
+                        }
+                    }
+                });
+            }
+
+            @Override
+            public void onPutFailed(Throwable th) {
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                    }
+                });
+            }
+        };
+
+        postListener = new IPostListener() {
+            @Override
+            public void onPostCompleted(final String uid,
+                    final SimulatorResourceModel resourceModelN) {
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                        // Handling the response which includes retrieving the
+                        // attributes and updating the local model.
+                        RemoteResource resource = handleResponse(uid,
+                                resourceModelN);
+                        if (null != resource) {
+                            // Notify the UI listeners
+                            postCompleteNotification(resource);
+                        }
+                    }
+                });
+            }
+
+            @Override
+            public void onPostFailed(Throwable th) {
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                    }
+                });
+            }
+        };
+
+        observeListener = new IObserveListener() {
+
+            @Override
+            public void onObserveCompleted(final String uid,
+                    final SimulatorResourceModel resourceModelN, final int seq) {
+                System.out.println("ResourceManager: onObserveCallback()");
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                        // Handling the response which includes retrieving the
+                        // attributes and updating the local model.
+                        RemoteResource resource = handleResponse(uid,
+                                resourceModelN);
+                        if (null != resource) {
+                            // Notify the UI listeners
+                            observeCompleteNotification(resource);
+                        }
+                    }
+                });
+            }
+
+            @Override
+            public void onObserveFailed(Throwable th) {
+                // TODO Auto-generated method stub
+            }
+        };
+
+        verifyListener = new IVerificationListener() {
+
+            @Override
+            public void onVerificationStarted(final String uid, final int autoId) {
+                System.out.println("onVefificationStarted: " + autoId);
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                        RemoteResource resource = getResource(uid);
+                        if (null == resource) {
+                            return;
+                        }
+                        // Update the automation status.
+                        resource.updateAutomationStatus(autoId, true);
+
+                        int autoType = resource.getAutomationtype(autoId);
+
+                        // Notify the listeners.
+                        verificationStartedNotification(resource, autoType);
+                    }
+                });
+            }
+
+            @Override
+            public void onVerificationCompleted(final String uid,
+                    final int autoId) {
+                System.out.println("onVefificationCompleted: " + autoId);
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                        RemoteResource resource = getResource(uid);
+                        if (null == resource) {
+                            return;
+                        }
+                        // Update the automation status.
+                        resource.updateAutomationStatus(autoId, false);
+
+                        int autoType = resource.getAutomationtype(autoId);
+
+                        // Notify the listeners.
+                        verificationCompletedNotification(resource, autoType);
+                    }
+                });
+            }
+
+            @Override
+            public void onVerificationAborted(final String uid, final int autoId) {
+                System.out.println("onVefificationAborted: " + autoId);
+                synchronizerThread.addToQueue(new Runnable() {
+                    @Override
+                    public void run() {
+                        RemoteResource resource = getResource(uid);
+                        if (null == resource) {
+                            return;
+                        }
+                        // Update the automation status.
+                        resource.updateAutomationStatus(autoId, false);
+
+                        int autoType = resource.getAutomationtype(autoId);
+
+                        // Notify the listeners.
+                        verificationAbortedNotification(resource, autoType);
+                    }
+                });
+            }
+        };
+
+        synchronizerThread = new ResponseSynchronizerThread();
+        threadHandle = new Thread(synchronizerThread);
+        threadHandle.setName("Simulator Client Controller Event Queue");
+        threadHandle.start();
+    }
+
+    private RemoteResource handleResponse(String uid,
+            SimulatorResourceModel resourceModelN) {
+        if (null == uid || null == resourceModelN) {
+            return null;
+        }
+
+        // Update the local model
+        RemoteResource resource;
+        resource = getResource(uid);
+        if (null == resource) {
+            return null;
+        }
+
+        resource.setResourceModel(resourceModelN);
+        Map<String, RemoteResourceAttribute> attributeMap = fetchResourceAttributesFromModel(resourceModelN);
+
+        // TODO: For debugging
+        RemoteResourceAttribute.printAttributes(attributeMap);
+        System.out.println("Attributes found: " + (null != attributeMap));
+        System.out.println("No of attributes: " + attributeMap.size());
+
+        resource.setResourceAttributesMap(attributeMap);
+        return resource;
+    }
+
+    private static class ResponseSynchronizerThread implements Runnable {
+
+        LinkedList<Runnable> responseQueue = new LinkedList<Runnable>();
+
+        @Override
+        public void run() {
+            while (!Thread.interrupted()) {
+                synchronized (this) {
+                    try {
+                        while (responseQueue.isEmpty()) {
+                            this.wait();
+                            break;
+                        }
+                    } catch (InterruptedException e) {
+                        return;
+                    }
+                }
+
+                Runnable thread;
+                synchronized (this) {
+                    thread = responseQueue.pop();
+                }
+                try {
+                    thread.run();
+                } catch (Exception e) {
+                    if (e instanceof InterruptedException) {
+                        return;
+                    }
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        public void addToQueue(Runnable event) {
+            synchronized (this) {
+                responseQueue.add(event);
+                this.notify();
+            }
+        }
+    }
+
+    public void addResourceSelectionChangedUIListener(
+            IResourceSelectionChangedUIListener resourceSelectionChangedUIListener) {
+        synchronized (resourceSelectionChangedUIListeners) {
+            resourceSelectionChangedUIListeners
+                    .add(resourceSelectionChangedUIListener);
+        }
+    }
+
+    public void addGetUIListener(IGetUIListener getUIListener) {
+        synchronized (getUIListeners) {
+            getUIListeners.add(getUIListener);
+        }
+    }
+
+    public void addPutUIListener(IPutUIListener putUIListener) {
+        synchronized (putUIListeners) {
+            putUIListeners.add(putUIListener);
+        }
+    }
+
+    public void addPostUIListener(IPostUIListener postUIListener) {
+        synchronized (postUIListeners) {
+            postUIListeners.add(postUIListener);
+        }
+    }
+
+    public void addObserveUIListener(IObserveUIListener observeUIListener) {
+        synchronized (observeUIListeners) {
+            observeUIListeners.add(observeUIListener);
+        }
+    }
+
+    public void addVerificationUIListener(
+            IVerificationUIListener verificationUIListener) {
+        synchronized (verificationUIListeners) {
+            verificationUIListeners.add(verificationUIListener);
+        }
+    }
+
+    public void addConfigUploadUIListener(IConfigurationUpload configListener) {
+        synchronized (configUploadUIListeners) {
+            configUploadUIListeners.add(configListener);
+        }
+    }
+
+    public void removeResourceSelectionChangedUIListener(
+            IResourceSelectionChangedUIListener listener) {
+        synchronized (resourceSelectionChangedUIListeners) {
+            if (null != listener
+                    && resourceSelectionChangedUIListeners.size() > 0) {
+                resourceSelectionChangedUIListeners.remove(listener);
+            }
+        }
+    }
+
+    public void removeGetUIListener(IGetUIListener getUIListener) {
+        synchronized (getUIListeners) {
+            getUIListeners.remove(getUIListener);
+        }
+    }
+
+    public void removePutUIListener(IPutUIListener putUIListener) {
+        synchronized (putUIListeners) {
+            putUIListeners.remove(putUIListener);
+        }
+    }
+
+    public void removePostUIListener(IPostUIListener postUIListener) {
+        synchronized (postUIListeners) {
+            postUIListeners.remove(postUIListener);
+        }
+    }
+
+    public void removeObserveUIListener(IObserveUIListener observeUIListener) {
+        synchronized (observeUIListeners) {
+            observeUIListeners.remove(observeUIListener);
+        }
+    }
+
+    public void removeVerificationUIListener(
+            IVerificationUIListener verificationUIListener) {
+        synchronized (verificationUIListeners) {
+            verificationUIListeners.remove(verificationUIListener);
+        }
+    }
+
+    public void removeConfigUploadUIListener(IConfigurationUpload configListener) {
+        synchronized (configUploadUIListeners) {
+            configUploadUIListeners.remove(configListener);
+        }
+    }
+
+    public void addResourcetoFavorites(RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        resource.setFavorite(true);
+        synchronized (favoriteResources) {
+            favoriteResources.add(resource);
+            favoriteURIList.add(resource.getResourceURI());
+        }
+    }
+
+    public void removeResourceFromFavorites(RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        resource.setFavorite(false);
+        synchronized (favoriteResources) {
+            favoriteResources.remove(resource);
+        }
+    }
+
+    public void removeResourceURIFromFavorites(RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        synchronized (favoriteURIList) {
+            favoriteURIList.remove(resource.getResourceURI());
+        }
+    }
+
+    public synchronized RemoteResource getCurrentResourceInSelection() {
+        return currentResourceInSelection;
+    }
+
+    public synchronized void setCurrentResourceInSelection(
+            RemoteResource resource) {
+        this.currentResourceInSelection = resource;
+    }
+
+    private void addResourceDetails(RemoteResource remoteResource) {
+        if (null != remoteResource) {
+            synchronized (resourceMap) {
+                resourceMap.put(remoteResource.getuId(), remoteResource);
+            }
+        }
+    }
+
+    public void addFindresourceUIListener(IFindResourceUIListener listener) {
+        if (null == listener) {
+            return;
+        }
+        synchronized (findResourceUIListeners) {
+            findResourceUIListeners.add(listener);
+        }
+    }
+
+    public void removeFindresourceUIListener(IFindResourceUIListener listener) {
+        if (null == listener) {
+            return;
+        }
+        synchronized (findResourceUIListeners) {
+            findResourceUIListeners.remove(listener);
+        }
+    }
+
+    private RemoteResource fetchResourceDetails(
+            SimulatorRemoteResource remoteResourceN) {
+        if (null == remoteResourceN) {
+            return null;
+        }
+        RemoteResource remoteResource = new RemoteResource();
+        remoteResource.setuId(remoteResourceN.getId());
+        remoteResource.setResourceURI(remoteResourceN.getUri());
+        remoteResource.setHost(remoteResourceN.getHost());
+        remoteResource.setResourceTypes(remoteResourceN.getResourceTypes());
+        remoteResource.setResourceInterfaces(remoteResourceN
+                .getResourceInterfaces());
+        remoteResource.setConnectivityType(remoteResourceN
+                .getConnectivityType());
+        remoteResource.setObservable(remoteResourceN.getIsObservable());
+        return remoteResource;
+    }
+
+    private boolean isUidExist(String uid) {
+        boolean exist;
+        synchronized (resourceMap) {
+            exist = resourceMap.containsKey(uid);
+        }
+        return exist;
+    }
+
+    private RemoteResource getResource(String uid) {
+        if (null == uid) {
+            return null;
+        }
+        RemoteResource resource;
+        synchronized (resourceMap) {
+            resource = resourceMap.get(uid);
+        }
+        return resource;
+    }
+
+    private Map<String, RemoteResourceAttribute> fetchResourceAttributesFromModel(
+            SimulatorResourceModel resourceModelN) {
+        Map<String, RemoteResourceAttribute> resourceAttributeMap = null;
+        if (null != resourceModelN) {
+            Map<String, ResourceAttribute> attributeMapN;
+            attributeMapN = resourceModelN.getAttributes();
+            if (null != attributeMapN) {
+                resourceAttributeMap = new HashMap<String, RemoteResourceAttribute>();
+
+                Set<String> attNameSet = attributeMapN.keySet();
+                String attName;
+                Object attValueObj;
+                ResourceAttribute attributeN;
+                RemoteResourceAttribute attribute;
+                Iterator<String> attNameItr = attNameSet.iterator();
+                while (attNameItr.hasNext()) {
+                    attName = attNameItr.next();
+                    attributeN = attributeMapN.get(attName);
+                    if (null != attributeN) {
+                        attribute = new RemoteResourceAttribute();
+                        attribute.setResourceAttribute(attributeN);
+                        attribute.setAttributeName(attName);
+
+                        attValueObj = attributeN.getValue();
+                        if (null != attValueObj) {
+                            attribute.setAttributeValue(attValueObj);
+                        }
+
+                        // Set the attribute type
+                        attribute.setAttValBaseType(attributeN.getBaseType());
+                        attribute.setAttValType(attributeN.getType());
+
+                        // Set the range and allowed values
+                        Range range = attributeN.getRange();
+                        if (null != range) {
+                            attribute.setMinValue(range.getMin());
+                            attribute.setMaxValue(range.getMax());
+                        } else {
+                            Object[] values = attributeN.getAllowedValues();
+                            if (null != values && values.length > 0) {
+                                List<Object> valueList = new ArrayList<Object>();
+                                for (Object obj : values) {
+                                    valueList.add(obj);
+                                }
+                                attribute.setAllowedValues(valueList);
+                            }
+                            /*
+                             * Type baseType = attribute.getAttValBaseType();
+                             * 
+                             * if(baseType == Type.INT) { //int[] values =
+                             * attributeN.getAllowedValues();
+                             * attribute.setAllowedValues
+                             * (attributeN.getAllowedValues()); } else
+                             * if(baseType == Type.DOUBLE) { double[] values =
+                             * attributeN.getAllowedValues();
+                             * attribute.setAllowedValues
+                             * (Utility.converArrayToList(values)); } else
+                             * if(baseType == Type.BOOL) { //boolean[] values =
+                             * attributeN.getAllowedValues(); List<Object> obj =
+                             * new ArrayList<Object>(); obj.add(true);
+                             * obj.add(false); attribute.setAllowedValues(obj);
+                             * } else if(baseType == Type.STRING) { String[]
+                             * values = attributeN.getAllowedValues();
+                             * attribute.
+                             * setAllowedValues(Utility.converArrayToList
+                             * (values)); }
+                             */
+                        }
+                        resourceAttributeMap.put(attName, attribute);
+                    }
+                }
+            }
+        }
+        return resourceAttributeMap;
+    }
+
+    private void newResourceFoundNotification(RemoteResource resource) {
+        synchronized (findResourceUIListeners) {
+            if (findResourceUIListeners.size() > 0) {
+                IFindResourceUIListener listener;
+                Iterator<IFindResourceUIListener> listenerItr = findResourceUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onNewResourceFound(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    private void resourceSelectionChangedUINotification(RemoteResource resource) {
+        synchronized (resourceSelectionChangedUIListeners) {
+            if (resourceSelectionChangedUIListeners.size() > 0) {
+                IResourceSelectionChangedUIListener listener;
+                Iterator<IResourceSelectionChangedUIListener> listenerItr = resourceSelectionChangedUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onResourceSelectionChange(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    private void getCompleteNotification(RemoteResource resource) {
+        synchronized (getUIListeners) {
+            if (getUIListeners.size() > 0) {
+                IGetUIListener listener;
+                Iterator<IGetUIListener> listenerItr = getUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onGetCompleted(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    private void putCompleteNotification(RemoteResource resource) {
+        synchronized (putUIListeners) {
+            if (putUIListeners.size() > 0) {
+                IPutUIListener listener;
+                Iterator<IPutUIListener> listenerItr = putUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onPutCompleted(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    private void postCompleteNotification(RemoteResource resource) {
+        synchronized (postUIListeners) {
+            if (postUIListeners.size() > 0) {
+                IPostUIListener listener;
+                Iterator<IPostUIListener> listenerItr = postUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onPostCompleted(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    private void observeCompleteNotification(RemoteResource resource) {
+        synchronized (observeUIListeners) {
+            if (observeUIListeners.size() > 0) {
+                IObserveUIListener listener;
+                Iterator<IObserveUIListener> listenerItr = observeUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onObserveCompleted(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    private void verificationStartedNotification(RemoteResource resource,
+            int autoType) {
+        synchronized (verificationUIListeners) {
+            if (verificationUIListeners.size() > 0) {
+                IVerificationUIListener listener;
+                Iterator<IVerificationUIListener> listenerItr = verificationUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onVerificationStarted(resource, autoType);
+                    }
+                }
+            }
+        }
+    }
+
+    private void verificationAbortedNotification(RemoteResource resource,
+            int autoType) {
+        synchronized (verificationUIListeners) {
+            if (verificationUIListeners.size() > 0) {
+                IVerificationUIListener listener;
+                Iterator<IVerificationUIListener> listenerItr = verificationUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onVerificationAborted(resource, autoType);
+                    }
+                }
+            }
+        }
+    }
+
+    private void verificationCompletedNotification(RemoteResource resource,
+            int autoType) {
+        synchronized (verificationUIListeners) {
+            if (verificationUIListeners.size() > 0) {
+                IVerificationUIListener listener;
+                Iterator<IVerificationUIListener> listenerItr = verificationUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onVerificationCompleted(resource, autoType);
+                    }
+                }
+            }
+        }
+    }
+
+    private void configUploadedNotification(RemoteResource resource) {
+        synchronized (configUploadUIListeners) {
+            if (configUploadUIListeners.size() > 0) {
+                IConfigurationUpload listener;
+                Iterator<IConfigurationUpload> listenerItr = configUploadUIListeners
+                        .iterator();
+                while (listenerItr.hasNext()) {
+                    listener = listenerItr.next();
+                    if (null != listener) {
+                        listener.onConfigurationUploaded(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    // TODO: Temporarily used to display the resource in the UI
+    public List<String> getURIList() {
+        List<String> list = new ArrayList<String>();
+        synchronized (resourceMap) {
+            /*
+             * Set<String> idSet = resourceMap.keySet(); Iterator<String> idItr
+             * = idSet.iterator(); String sId; RemoteResource resource;
+             * while(idItr.hasNext()) { sId = idItr.next(); resource =
+             * resourceMap.get(sId); if(null == resource) { continue; }
+             * list.add(resource.getResourceURI()); }
+             */
+            Set<String> uriSet = resourceMap.keySet();
+            Iterator<String> uriItr = uriSet.iterator();
+            String uri;
+            while (uriItr.hasNext()) {
+                uri = uriItr.next();
+                if (null != uri) {
+                    list.add(uri);
+                }
+            }
+
+            // Sort the types
+            Collections.sort(list);
+        }
+        return list;
+    }
+
+    public synchronized Set<String> getLastKnownSearchTypes() {
+        return lastKnownSearchTypes;
+    }
+
+    public synchronized void setLastKnownSearchTypes(
+            Set<String> lastKnownSearchTypes) {
+        this.lastKnownSearchTypes = lastKnownSearchTypes;
+    }
+
+    public boolean findResourceRequest(Set<String> searchTypes) {
+        if (null == searchTypes || searchTypes.size() < 1) {
+            return false;
+        }
+        boolean result = false;
+        Iterator<String> searchItr = searchTypes.iterator();
+        String rType;
+        while (searchItr.hasNext()) {
+            rType = searchItr.next();
+            try {
+                SimulatorManager.findResources(rType, findResourceListener);
+                result = true;
+            } catch (SimulatorException e) {
+                Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(),
+                                new Date(),
+                                "[" + e.getClass().getSimpleName() + "]"
+                                        + e.code().toString() + "-"
+                                        + e.message());
+            }
+        }
+        return result;
+    }
+
+    public void deleteResources(final Set<String> searchTypes) {
+        if (null == searchTypes || searchTypes.size() < 1) {
+            return;
+        }
+        new Thread() {
+            public void run() {
+                Iterator<String> typeItr = searchTypes.iterator();
+                String resType;
+                while (typeItr.hasNext()) {
+                    resType = typeItr.next();
+                    deleteResourcesByType(resType);
+
+                    // Change the current resource in selection
+                    updateCurrentResourceInSelection(searchTypes);
+                }
+            }
+        }.start();
+    }
+
+    private void updateCurrentResourceInSelection(Set<String> searchTypes) {
+        if (null == searchTypes || searchTypes.size() < 1) {
+            return;
+        }
+        RemoteResource resourceInSelection = getCurrentResourceInSelection();
+        if (null == resourceInSelection) {
+            return;
+        }
+        List<String> typesOfSelection = resourceInSelection.getResourceTypes();
+        if (null == typesOfSelection || typesOfSelection.size() < 1) {
+            return;
+        }
+        Iterator<String> itr = typesOfSelection.iterator();
+        String type;
+        while (itr.hasNext()) {
+            type = itr.next();
+            if (searchTypes.contains(type)) {
+                setCurrentResourceInSelection(null);
+                resourceSelectionChangedUINotification(null);
+                break;
+            }
+        }
+    }
+
+    private void deleteResourcesByType(String resourceType) {
+        if (null == resourceType) {
+            return;
+        }
+        synchronized (resourceMap) {
+            Set<String> keySet = resourceMap.keySet();
+            if (null == keySet) {
+                return;
+            }
+            Iterator<String> keyItr = keySet.iterator();
+            String uId;
+            RemoteResource resource;
+            boolean exist;
+            List<String> types;
+            while (keyItr.hasNext()) {
+                uId = keyItr.next();
+                resource = resourceMap.get(uId);
+                if (null == resource) {
+                    continue;
+                }
+                types = resource.getResourceTypes();
+                if (null != types) {
+                    exist = types.contains(resourceType);
+                    if (exist) {
+                        // Remove the resource
+                        keyItr.remove();
+                        removeResourceFromFavorites(resource);
+                    }
+                }
+            }
+        }
+    }
+
+    public void resourceSelectionChanged(final RemoteResource resource) {
+        new Thread() {
+            @Override
+            public void run() {
+                setCurrentResourceInSelection(resource);
+                // Notify all observers for resource selection change event
+                resourceSelectionChangedUINotification(resource);
+            }
+        }.start();
+    }
+
+    public List<MetaProperty> getMetaProperties(RemoteResource resource) {
+        if (null != resource) {
+            String propName;
+            String propValue;
+
+            List<MetaProperty> metaPropertyList = new ArrayList<MetaProperty>();
+
+            for (int index = 0; index < Constants.META_PROPERTY_COUNT; index++) {
+                propName = Constants.META_PROPERTIES[index];
+                if (propName.equals(Constants.RESOURCE_URI)) {
+                    propValue = resource.getResourceURI();
+                } else if (propName.equals(Constants.CONNECTIVITY_TYPE)) {
+                    propValue = resource.getConnectivityType().toString();
+                } else if (propName.equals(Constants.OBSERVABLE)) {
+                    propValue = Utility.getObservableInString(resource
+                            .isObservable());
+                    // see in UI
+                } else if (propName.equals(Constants.RESOURCE_TYPES)) {
+                    List<String> types = resource.getResourceTypes();
+                    if (null != types) {
+                        propValue = types.toString();
+                    } else {
+                        propValue = Constants.NOT_AVAILABLE;
+                    }
+                } else if (propName.equals(Constants.RESOURCE_INTERFACES)) {
+                    List<String> interfaces = resource.getResourceInterfaces();
+                    if (null != interfaces) {
+                        propValue = interfaces.toString();
+                    } else {
+                        propValue = Constants.NOT_AVAILABLE;
+                    }
+                } else {
+                    propValue = null;
+                }
+                if (null != propValue) {
+                    metaPropertyList.add(new MetaProperty(propName, propValue));
+                }
+            }
+
+            return metaPropertyList;
+        }
+        return null;
+    }
+
+    public Map<String, Boolean> getAutomationStatus(RemoteResource resource) {
+        if (null == resource) {
+            return null;
+        }
+        Map<String, Boolean> autoStatus = new HashMap<String, Boolean>();
+        autoStatus.put(Constants.GET, resource.isGetAutomtnInProgress());
+        autoStatus.put(Constants.PUT, resource.isPutAutomtnInProgress());
+        autoStatus.put(Constants.POST, resource.isPostAutomtnInProgress());
+        return autoStatus;
+    }
+
+    public Map<String, String> getDummyAttributes() {
+        Map<String, String> attributes = new HashMap<String, String>();
+        attributes.put("intensity", "1");
+        attributes.put("power", "off");
+        return attributes;
+    }
+
+    public List<RemoteResource> getResourceList() {
+        List<RemoteResource> resourceList = new ArrayList<RemoteResource>();
+        synchronized (resourceMap) {
+            Set<String> idSet = resourceMap.keySet();
+            Iterator<String> idItr = idSet.iterator();
+            RemoteResource resource;
+            while (idItr.hasNext()) {
+                resource = resourceMap.get(idItr.next());
+                if (null != resource) {
+                    resourceList.add(resource);
+                }
+            }
+        }
+        // Sort the list
+        Collections.sort(resourceList, new Comparator<RemoteResource>() {
+            public int compare(RemoteResource res1, RemoteResource res2) {
+                String s1 = res1.getResourceURI();
+                String s2 = res2.getResourceURI();
+
+                String s1Part = s1.replaceAll("\\d", "");
+                String s2Part = s2.replaceAll("\\d", "");
+
+                if (s1Part.equalsIgnoreCase(s2Part)) {
+                    return extractInt(s1) - extractInt(s2);
+                }
+                return s1.compareTo(s2);
+            }
+
+            int extractInt(String s) {
+                String num = s.replaceAll("\\D", "");
+                // return 0 if no digits found
+                return num.isEmpty() ? 0 : Integer.parseInt(num);
+            }
+        });
+
+        return resourceList;
+    }
+
+    public List<RemoteResource> getFavResourceList() {
+        List<RemoteResource> resourceList;
+        synchronized (favoriteResources) {
+            resourceList = new ArrayList<RemoteResource>(favoriteResources);
+        }
+        return resourceList;
+    }
+
+    public String getAttributeValue(RemoteResource res, String attName) {
+        if (null == res || null == attName) {
+            return null;
+        }
+        return res.getAttributeValue(attName);
+    }
+
+    public void sendGetRequest(RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        try {
+            resourceN.get(null, getListener);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
+    }
+
+    public void sendPutRequest(RemoteResource resource,
+            List<PutPostAttributeModel> putPostModelList) {
+        System.out.println(putPostModelList);
+        System.out.println("ResourceManager: sendPutRequest");
+        if (null == resource) {
+            return;
+        }
+        System.out.println("ResourceManager: resource not null");
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        System.out.println("ResourceManager: Native resource not null");
+        Map<String, RemoteResourceAttribute> attMap = resource
+                .getResourceAttributesMap();
+        if (null == attMap || attMap.size() < 1) {
+            return;
+        }
+        System.out.println("ResourceManager: attrubutes obtained");
+        SimulatorResourceModel resourceModel = getUpdatedResourceModel(attMap,
+                putPostModelList);
+        System.out.println("ResourceModel exist?:" + (resourceModel != null));
+        try {
+            resourceN.put(resourceModel, null, putListener);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
+        System.out.println("ResourceManager: called native put");
+    }
+
+    public void sendPostRequest(RemoteResource resource,
+            List<PutPostAttributeModel> putPostModelList) {
+        System.out.println(putPostModelList);
+        if (null == resource) {
+            return;
+        }
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        Map<String, RemoteResourceAttribute> attMap = resource
+                .getResourceAttributesMap();
+        if (null == attMap || attMap.size() < 1) {
+            return;
+        }
+        // Filter out the attributes whose modification status is true.
+        Iterator<PutPostAttributeModel> itr = putPostModelList.iterator();
+        PutPostAttributeModel model;
+        while (itr.hasNext()) {
+            model = itr.next();
+            if (!model.isModified()) {
+                itr.remove();
+            }
+        }
+        SimulatorResourceModel resourceModel = getUpdatedResourceModel(attMap,
+                putPostModelList);
+        try {
+            resourceN.post(resourceModel, null, postListener);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
+    }
+
+    private SimulatorResourceModel getUpdatedResourceModel(
+            Map<String, RemoteResourceAttribute> attMap,
+            List<PutPostAttributeModel> putPostModelList) {
+        String attName;
+        SimulatorResourceModel resourceModel = new SimulatorResourceModel();
+        PutPostAttributeModel model;
+        RemoteResourceAttribute attribute;
+        Type attType;
+        Iterator<PutPostAttributeModel> itr = putPostModelList.iterator();
+        while (itr.hasNext()) {
+            model = itr.next();
+            attName = model.getAttName();
+            attribute = attMap.get(attName);
+            attType = attribute.getAttValBaseType();
+            if (attType == Type.INT) {
+                int attValue;
+                try {
+                    attValue = Integer.parseInt(model.getAttValue());
+                } catch (NumberFormatException e) {
+                    attValue = -1;
+                }
+                resourceModel.addAttribute(attName, attValue);
+            } else if (attType == Type.DOUBLE) {
+                double attValue;
+                try {
+                    attValue = Double.parseDouble(model.getAttValue());
+                } catch (NumberFormatException e) {
+                    attValue = -1.0;
+                }
+                resourceModel.addAttribute(attName, attValue);
+            } else if (attType == Type.BOOL) {
+                boolean attValue;
+                attValue = Boolean.parseBoolean(model.getAttValue());
+                resourceModel.addAttribute(attName, attValue);
+            } else if (attType == Type.STRING) {
+                String attValue;
+                attValue = model.getAttValue();
+                resourceModel.addAttribute(attName, attValue);
+            }
+        }
+        return resourceModel;
+    }
+
+    public void sendObserveRequest(RemoteResource resource) {
+        System.out.println("sendObserverRequest() entry");
+        if (null == resource) {
+            return;
+        }
+        System.out.println("Resource is null:" + (resource == null));
+        resource.setObserved(true);
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        try {
+            resourceN.observe(SimulatorObserveType.OBSERVE, null,
+                    observeListener);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
+        System.out.println("Observer called.");
+    }
+
+    public void sendCancelObserveRequest(RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        resource.setObserved(false);
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        try {
+            resourceN.cancelObserve();
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
+    }
+
+    public void startAutomationRequest(int reqType, RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        SimulatorVerificationType type = SimulatorVerificationType
+                .getVerificationType(reqType);
+        if (null == type) {
+            return;
+        }
+        System.out.println("Before calling startVerification: " + reqType);
+        int autoId;
+        try {
+            autoId = resourceN.startVerification(type, verifyListener);
+            System.out.println("After calling startVerification: " + autoId);
+            if (autoId != -1) {
+                if (reqType == Constants.GET_AUTOMATION_INDEX) {
+                    // resource.setGetAutomtnInProgress(true);
+                    resource.setGetAutomtnId(autoId);
+                } else if (reqType == Constants.PUT_AUTOMATION_INDEX) {
+                    // resource.setPutAutomtnInProgress(true);
+                    resource.setPutAutomtnId(autoId);
+                } else {// if(reqType == Constants.POST_AUTOMATION_INDEX) {
+                        // resource.setPostAutomtnInProgress(true);
+                    resource.setPostAutomtnId(autoId);
+                }
+            }
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
+    }
+
+    public void stopAutomationRequest(int reqType, RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        int autoId;
+        if (reqType == Constants.GET_AUTOMATION_INDEX) {
+            resource.setGetAutomtnInProgress(false);
+            autoId = resource.getGetAutomtnId();
+        } else if (reqType == Constants.PUT_AUTOMATION_INDEX) {
+            resource.setPutAutomtnInProgress(false);
+            autoId = resource.getPutAutomtnId();
+        } else {// if(reqType == Constants.POST_AUTOMATION_INDEX) {
+            resource.setPostAutomtnInProgress(false);
+            autoId = resource.getPostAutomtnId();
+        }
+        try {
+            resourceN.stopVerification(autoId);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
+    }
+
+    public void setConfigFilePath(RemoteResource resource, String configFilePath) {
+        if (null == resource) {
+            return;
+        }
+        SimulatorRemoteResource resourceN = resource.getResource();
+        if (null == resourceN) {
+            return;
+        }
+        try {
+            resourceN.configureRAMLPath(configFilePath);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+            return;
+        }
+        // Update the status
+        resource.setConfigUploaded(true);
+
+        // Notify the UI listeners
+        configUploadedNotification(resource);
+    }
+
+    public Image getImage(String resourceURI) {
+        if (null == resourceURI) {
+            return null;
+        }
+        URL url = Activator.getDefault().getBundle()
+                .getEntry(getImageURL(resourceURI));
+        if (null == url) {
+            return null;
+        }
+        return ImageDescriptor.createFromURL(url).createImage();
+    }
+
+    private String getImageURL(String resourceURI) {
+        // TODO: Hard-coding the image file name temporarily.
+        // It will be included in a separate class which manages all image
+        // resources
+        return "/icons/light_16x16.png";
+    }
+
+    public void shutdown() {
+        // TODO: To be implemented for clean-up activities.
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/perspective/PerspectiveFactory.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/perspective/PerspectiveFactory.java
new file mode 100644 (file)
index 0000000..527e460
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.perspective;
+
+import oic.simulator.clientcontroller.view.AttributeView;
+import oic.simulator.clientcontroller.view.LogView;
+import oic.simulator.clientcontroller.view.MetaPropertiesView;
+import oic.simulator.clientcontroller.view.MultiResourceOrchestrationView;
+import oic.simulator.clientcontroller.view.ResourceManagerView;
+
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/**
+ * This class creates a new eclipse perspective for client controller and
+ * positions the different views inside.
+ */
+public class PerspectiveFactory implements IPerspectiveFactory {
+
+    public static final String PERSPECTIVE_ID = "oic.simulator.clientcontroller.perspective";
+    private IPageLayout        factory;
+
+    @Override
+    public void createInitialLayout(IPageLayout factory) {
+        this.factory = factory;
+        factory.setEditorAreaVisible(false);
+        addViews();
+        factory.setFixed(false);
+    }
+
+    private void addViews() {
+        factory.addView(ResourceManagerView.VIEW_ID, IPageLayout.LEFT, 0.3f,
+                factory.getEditorArea());
+        factory.addView(MetaPropertiesView.VIEW_ID, IPageLayout.BOTTOM, 0.65f,
+                ResourceManagerView.VIEW_ID);
+        factory.addView(AttributeView.VIEW_ID, IPageLayout.LEFT, 0.7f,
+                factory.getEditorArea());
+        factory.addView(LogView.VIEW_ID, IPageLayout.BOTTOM, 0.65f,
+                AttributeView.VIEW_ID);
+        factory.addView(MultiResourceOrchestrationView.VIEW_ID,
+                IPageLayout.RIGHT, 0.6f, AttributeView.VIEW_ID);
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/MetaProperty.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/MetaProperty.java
new file mode 100644 (file)
index 0000000..b2fde06
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.remoteresource;
+
+/**
+ * This is a helper class for showing the meta properties of resources such as
+ * resource type, resource uri, etc.
+ */
+public class MetaProperty {
+    private String propName;
+    private String propValue;
+
+    public MetaProperty(String propName, String propValue) {
+        this.propName = propName;
+        this.propValue = propValue;
+    }
+
+    public String getPropValue() {
+        return propValue;
+    }
+
+    public void setPropValue(String propValue) {
+        this.propValue = propValue;
+    }
+
+    public String getPropName() {
+        return propName;
+    }
+
+    public void setPropName(String propName) {
+        this.propName = propName;
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/PutPostAttributeModel.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/PutPostAttributeModel.java
new file mode 100644 (file)
index 0000000..0b566a0
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.remoteresource;
+
+import java.util.List;
+
+/**
+ * This is a helper class for showing the resource attributes in PUT and POST
+ * dialogs.
+ */
+public class PutPostAttributeModel {
+
+    private String       attName;
+    private String       attValue;
+    private List<String> values;
+    boolean              modified;
+
+    public String getAttName() {
+        return attName;
+    }
+
+    public void setAttName(String attName) {
+        this.attName = attName;
+    }
+
+    public String getAttValue() {
+        return attValue;
+    }
+
+    public void setAttValue(String attValue) {
+        this.attValue = attValue;
+    }
+
+    public List<String> getValues() {
+        return values;
+    }
+
+    public void setValues(List<String> values) {
+        this.values = values;
+    }
+
+    public boolean isModified() {
+        return modified;
+    }
+
+    public void setModified(boolean modified) {
+        this.modified = modified;
+    }
+
+    public static PutPostAttributeModel getModel(
+            RemoteResourceAttribute attribute) {
+        PutPostAttributeModel putPostModel = null;
+        if (null != attribute) {
+            putPostModel = new PutPostAttributeModel();
+            putPostModel.setAttName(attribute.getAttributeName());
+            putPostModel.setAttValue(String.valueOf(attribute
+                    .getAttributeValue()));
+            putPostModel.setValues(attribute.getAllValues());
+            putPostModel.setModified(false);
+        }
+        return putPostModel;
+    }
+
+    @Override
+    public String toString() {
+        return attName + "," + attValue + "\n";
+    }
+
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/RemoteResource.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/RemoteResource.java
new file mode 100644 (file)
index 0000000..17a052e
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.remoteresource;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import oic.simulator.clientcontroller.utils.Constants;
+
+import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.clientcontroller.SimulatorConnectivityType;
+import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
+
+/**
+ * This class represents a remote resource. It maintains all the necessary
+ * information about the resource.
+ */
+public class RemoteResource {
+    private String                               uId;
+    private String                               resourceURI;
+    private String                               host;
+    private LinkedList<String>                   resourceTypes;
+    private LinkedList<String>                   resourceInterfaces;
+    private SimulatorConnectivityType            connectivityType;
+    private boolean                              isObservable;
+
+    private boolean                              observed;
+
+    // Native object references
+    private SimulatorRemoteResource              resourceN;
+    private SimulatorResourceModel               resourceModel;
+    private Map<String, RemoteResourceAttribute> resourceAttributesMap;
+
+    private boolean                              configUploaded;
+
+    private boolean                              getAutomtnInProgress;
+    private boolean                              putAutomtnInProgress;
+    private boolean                              postAutomtnInProgress;
+
+    private int                                  getAutomtnId;
+    private int                                  putAutomtnId;
+    private int                                  postAutomtnId;
+
+    private boolean                              isFavorite;
+
+    public SimulatorResourceModel getResourceModel() {
+        return resourceModel;
+    }
+
+    public void setResourceModel(SimulatorResourceModel resourceModel) {
+        this.resourceModel = resourceModel;
+    }
+
+    public Map<String, RemoteResourceAttribute> getResourceAttributesMap() {
+        return resourceAttributesMap;
+    }
+
+    public void setResourceAttributesMap(
+            Map<String, RemoteResourceAttribute> resourceAttributesMap) {
+        this.resourceAttributesMap = resourceAttributesMap;
+    }
+
+    public int getGetAutomtnId() {
+        return getAutomtnId;
+    }
+
+    public void setGetAutomtnId(int getAutomtnId) {
+        this.getAutomtnId = getAutomtnId;
+    }
+
+    public int getPutAutomtnId() {
+        return putAutomtnId;
+    }
+
+    public void setPutAutomtnId(int putAutomtnId) {
+        this.putAutomtnId = putAutomtnId;
+    }
+
+    public int getPostAutomtnId() {
+        return postAutomtnId;
+    }
+
+    public void setPostAutomtnId(int postAutomtnId) {
+        this.postAutomtnId = postAutomtnId;
+    }
+
+    public String getResourceURI() {
+        return resourceURI;
+    }
+
+    public void setResourceURI(String resourceURI) {
+        this.resourceURI = resourceURI;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public LinkedList<String> getResourceTypes() {
+        return resourceTypes;
+    }
+
+    public void setResourceTypes(LinkedList<String> resourceTypes) {
+        this.resourceTypes = resourceTypes;
+    }
+
+    public LinkedList<String> getResourceInterfaces() {
+        return resourceInterfaces;
+    }
+
+    public void setResourceInterfaces(LinkedList<String> resourceInterfaces) {
+        this.resourceInterfaces = resourceInterfaces;
+    }
+
+    public SimulatorConnectivityType getConnectivityType() {
+        return connectivityType;
+    }
+
+    public void setConnectivityType(SimulatorConnectivityType connectivityType) {
+        this.connectivityType = connectivityType;
+    }
+
+    public boolean isObservable() {
+        return isObservable;
+    }
+
+    public void setObservable(boolean isObservable) {
+        this.isObservable = isObservable;
+    }
+
+    public boolean isGetAutomtnInProgress() {
+        return getAutomtnInProgress;
+    }
+
+    public void setGetAutomtnInProgress(boolean getAutomtnInProgress) {
+        this.getAutomtnInProgress = getAutomtnInProgress;
+    }
+
+    public boolean isPutAutomtnInProgress() {
+        return putAutomtnInProgress;
+    }
+
+    public void setPutAutomtnInProgress(boolean putAutomtnInProgress) {
+        this.putAutomtnInProgress = putAutomtnInProgress;
+    }
+
+    public boolean isPostAutomtnInProgress() {
+        return postAutomtnInProgress;
+    }
+
+    public void setPostAutomtnInProgress(boolean postAutomtnInProgress) {
+        this.postAutomtnInProgress = postAutomtnInProgress;
+    }
+
+    public boolean isConfigUploaded() {
+        return configUploaded;
+    }
+
+    public void setConfigUploaded(boolean configUploaded) {
+        this.configUploaded = configUploaded;
+    }
+
+    public SimulatorRemoteResource getResource() {
+        return resourceN;
+    }
+
+    public void setResource(SimulatorRemoteResource resource) {
+        this.resourceN = resource;
+    }
+
+    public boolean isObserved() {
+        return observed;
+    }
+
+    public void setObserved(boolean observed) {
+        this.observed = observed;
+    }
+
+    public List<PutPostAttributeModel> getPutPostModel() {
+        Map<String, RemoteResourceAttribute> attMap = getResourceAttributesMap();
+        if (null == attMap || attMap.size() < 1) {
+            return null;
+        }
+        List<PutPostAttributeModel> putPostModelList = new ArrayList<PutPostAttributeModel>();
+        String attName;
+        RemoteResourceAttribute attribute;
+        PutPostAttributeModel putPostModel;
+        Iterator<String> attItr = attMap.keySet().iterator();
+        while (attItr.hasNext()) {
+            attName = attItr.next();
+            attribute = attMap.get(attName);
+            putPostModel = PutPostAttributeModel.getModel(attribute);
+            if (null != putPostModel) {
+                putPostModelList.add(putPostModel);
+            }
+        }
+        return putPostModelList;
+    }
+
+    public String getAttributeValue(String attName) {
+        RemoteResourceAttribute attribute = resourceAttributesMap.get(attName);
+        if (null == attribute) {
+            return null;
+        }
+        return String.valueOf(attribute.getAttributeValue());
+    }
+
+    public String getuId() {
+        return uId;
+    }
+
+    public void setuId(String uId) {
+        this.uId = uId;
+    }
+
+    public int getAutomationtype(int autoId) {
+        if (getAutomtnId == autoId) {
+            return Constants.GET_AUTOMATION_INDEX;
+        } else if (putAutomtnId == autoId) {
+            return Constants.PUT_AUTOMATION_INDEX;
+        } else {// if(postAutomtnId == autoId) {
+            return Constants.POST_AUTOMATION_INDEX;
+        }
+    }
+
+    public void updateAutomationStatus(int autoId, boolean status) {
+        if (getAutomtnId == autoId) {
+            getAutomtnInProgress = status;
+        } else if (putAutomtnId == autoId) {
+            putAutomtnInProgress = status;
+        } else {// if(postAutomtnId == autoId) {
+            postAutomtnInProgress = status;
+        }
+    }
+
+    public boolean isFavorite() {
+        return isFavorite;
+    }
+
+    public void setFavorite(boolean isFavorite) {
+        this.isFavorite = isFavorite;
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/RemoteResourceAttribute.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/RemoteResourceAttribute.java
new file mode 100644 (file)
index 0000000..27cbdc8
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.remoteresource;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.oic.simulator.ResourceAttribute;
+import org.oic.simulator.ResourceAttribute.Type;
+
+/**
+ * This class represents an attribute in the remote resource.
+ */
+public class RemoteResourceAttribute {
+
+    // Native object reference
+    private ResourceAttribute resourceAttribute;
+
+    private String            attributeName;
+    private Object            attributeValue;
+    private Type              attValType;
+    private Type              attValBaseType;
+    private List<Object>      allowedValues;
+
+    private Object            minValue;
+    private Object            maxValue;
+
+    public ResourceAttribute getResourceAttribute() {
+        return resourceAttribute;
+    }
+
+    public void setResourceAttribute(ResourceAttribute resourceAttribute) {
+        this.resourceAttribute = resourceAttribute;
+    }
+
+    public String getAttributeName() {
+        return attributeName;
+    }
+
+    public void setAttributeName(String attributeName) {
+        this.attributeName = attributeName;
+    }
+
+    public Object getAttributeValue() {
+        return attributeValue;
+    }
+
+    public void setAttributeValue(Object attributeValue) {
+        this.attributeValue = attributeValue;
+    }
+
+    public List<Object> getAllowedValues() {
+        return allowedValues;
+    }
+
+    public void setAllowedValues(List<Object> allowedValues) {
+        this.allowedValues = allowedValues;
+    }
+
+    public void setAllowedValues(String[] allowedValues) {
+        List<Object> allowedValueList = null;
+        if (null != allowedValues && allowedValues.length > 0) {
+            allowedValueList = new ArrayList<Object>();
+            for (String value : allowedValues) {
+                allowedValueList.add(value);
+            }
+        }
+        this.allowedValues = allowedValueList;
+    }
+
+    public Object getMinValue() {
+        return minValue;
+    }
+
+    public void setMinValue(Object minValue) {
+        this.minValue = minValue;
+    }
+
+    public Object getMaxValue() {
+        return maxValue;
+    }
+
+    public void setMaxValue(Object maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public static RemoteResourceAttribute clone(
+            RemoteResourceAttribute attribute) {
+        RemoteResourceAttribute clone = null;
+        if (null != attribute) {
+            clone = new RemoteResourceAttribute();
+            clone.setAttributeName(attribute.getAttributeName());
+            clone.setAttributeValue(attribute.getAttributeValue());
+            clone.setAllowedValues(attribute.getAllowedValues());
+            clone.setAttValBaseType(attribute.getAttValBaseType());
+            clone.setAttValType(attribute.getAttValType());
+            clone.setMinValue(attribute.getMinValue());
+            clone.setMaxValue(attribute.getMaxValue());
+            clone.setResourceAttribute(null);
+        }
+        return clone;
+    }
+
+    // This method gives all known possible values of the attribute in string
+    // format.
+    // It takes allowed values or range of values whichever is available
+    public List<String> getAllValues() {
+        List<String> valueList = new ArrayList<String>();
+        if (null != allowedValues) {
+            Iterator<Object> values = allowedValues.iterator();
+            Object value;
+            while (values.hasNext()) {
+                value = values.next();
+                if (null != value) {
+                    valueList.add(String.valueOf(value));
+                }
+            }
+        } else if (null != minValue && null != maxValue) {
+            if (attributeValue.getClass() == Integer.class) {
+                int min = (Integer) minValue;
+                int max = (Integer) maxValue;
+                for (int value = min; value <= max; value++) {
+                    valueList.add(String.valueOf(value));
+                }
+            } else if (attributeValue.getClass() == Double.class) {
+                double min = (Double) minValue;
+                double max = (Double) maxValue;
+                for (double value = min; value <= max; value++) {
+                    valueList.add(String.valueOf(value));
+                }
+            }
+        }
+        if (valueList.size() < 1 && null != attributeValue) {
+            valueList.add(String.valueOf(attributeValue));
+        }
+        return valueList;
+    }
+
+    public static void printAttributes(
+            Map<String, RemoteResourceAttribute> attributeMap) {
+        Iterator<String> itr = attributeMap.keySet().iterator();
+        String attName;
+        RemoteResourceAttribute att;
+        while (itr.hasNext()) {
+            attName = itr.next();
+            att = attributeMap.get(attName);
+            System.out.println("AttributeName:" + attName);
+            System.out.println("AttributeValue:"
+                    + att.getAttributeValue().toString());
+            System.out.println("Allowed Values:" + att.getAllValues());
+        }
+    }
+
+    public Type getAttValType() {
+        return attValType;
+    }
+
+    public void setAttValType(Type attValType) {
+        this.attValType = attValType;
+    }
+
+    public Type getAttValBaseType() {
+        return attValBaseType;
+    }
+
+    public void setAttValBaseType(Type attValBaseType) {
+        this.attValBaseType = attValBaseType;
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/Constants.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/Constants.java
new file mode 100644 (file)
index 0000000..3fe81ac
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.utils;
+
+import org.oic.simulator.serviceprovider.AutomationType;
+
+/**
+ * This class maintains all constants which are used throughout the client
+ * controller plug-in.
+ */
+public class Constants {
+    public static final String         FIND_PAGE_TITLE               = "Find Resources";
+
+    public static final String         FIND_PAGE_MESSAGE             = "Select the resource type of the resources to be discovered";
+
+    public static final int            FIND_RESOURCES_TIMEOUT        = 10;
+
+    public static final String         RESOURCE_URI                  = "Resource URI";
+    public static final String         CONNECTIVITY_TYPE             = "Connectivity Type";
+    public static final String         OBSERVABLE                    = "Observable";
+    public static final String         RESOURCE_TYPES                = "Resource Types";
+    public static final String         RESOURCE_INTERFACES           = "Resource Interfaces";
+
+    public static final String[]       META_PROPERTIES               = {
+            RESOURCE_URI, CONNECTIVITY_TYPE, OBSERVABLE, RESOURCE_TYPES,
+            RESOURCE_INTERFACES                                     };
+
+    public static final int            META_PROPERTY_COUNT           = META_PROPERTIES.length;
+
+    public static final AutomationType DEFAULT_AUTOMATION_TYPE       = AutomationType.NORMAL;
+
+    public static final int            DEFAULT_AUTOMATION_INTERVAL   = 500;
+
+    public static final String         YES                           = "Yes";
+    public static final String         NO                            = "No";
+
+    public static final String         GET                           = "Get";
+    public static final String         PUT                           = "Put";
+    public static final String         POST                          = "Post";
+
+    public static final String         ENABLE                        = "Enable";
+    public static final String         DISABLE                       = "Disable";
+    public static final String         ENABLED                       = "Enabled";
+    public static final String         DISABLED                      = "Disabled";
+
+    public static final String         NOT_AVAILABLE                 = "Not Available";
+
+    public static final int            PROPER_LOG_TIME_TOKEN_LENGTH  = 3;
+
+    public static final int            LOG_SIZE                      = 1000;
+
+    public static final String         INFO_LOG                      = "info_log";
+    public static final String         WARNING_LOG                   = "warning_log";
+    public static final String         ERROR_LOG                     = "error_log";
+    public static final String         DEBUG_LOG                     = "debug_log";
+    public static final String         UNKNOWN_LOG                   = "unknown_log";
+
+    public static final String         CHECKED                       = "Checked";
+    public static final String         UNCHECKED                     = "Unchecked";
+
+    public static final String         INFO                          = "Info";
+    public static final String         WARNING                       = "Warning";
+    public static final String         ERROR                         = "Error";
+    public static final String         DEBUG                         = "Debug";
+    public static final String         UNKNOWN                       = "Unknown";
+
+    public static final String[]       BROWSE_RAML_FILTER_EXTENSIONS = new String[] {
+            "*.raml", "*"                                           };
+    public static final String[]       SAVE_LOG_FILTER_EXTENSIONS    = new String[] {
+            "*.log", "*"                                            };
+
+    public static final int            GET_AUTOMATION_INDEX          = 0;
+    public static final int            PUT_AUTOMATION_INDEX          = 1;
+    public static final int            POST_AUTOMATION_INDEX         = 2;
+    public static final int            DELETE_AUTOMATION_INDEX       = 3;
+
+    public static final String         OIC_R_LIGHT                   = "oic.r.light";
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/Utility.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/Utility.java
new file mode 100644 (file)
index 0000000..8baed7c
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.utils;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * This class has common utility methods.
+ */
+public class Utility {
+    public static List<String> convertSetToList(Set<String> typeSet) {
+        if (null == typeSet) {
+            return null;
+        }
+        List<String> list = new ArrayList<String>();
+        Iterator<String> typeItr = typeSet.iterator();
+        while (typeItr.hasNext()) {
+            list.add(typeItr.next());
+        }
+        return list;
+    }
+
+    public static String getObservableInString(boolean observable) {
+        if (observable) {
+            return Constants.YES;
+        } else {
+            return Constants.NO;
+        }
+    }
+
+    public static String[] convertListToString(List<String> valueList) {
+        String[] strArr;
+        if (null != valueList && valueList.size() > 0) {
+            strArr = valueList.toArray(new String[1]);
+        } else {
+            strArr = new String[1];
+        }
+        return strArr;
+    }
+
+    /*
+     * public static List<Object> converArrayToList(int[] arr) { if(null == arr
+     * || arr.length < 1) { return null; } List<Object> valueList = new
+     * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
+     * valueList; }
+     * 
+     * public static List<Object> converArrayToList(double[] arr) { if(null ==
+     * arr || arr.length < 1) { return null; } List<Object> valueList = new
+     * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
+     * valueList; }
+     * 
+     * public static List<Object> converArrayToList(boolean[] arr) { if(null ==
+     * arr || arr.length < 1) { return null; } List<Object> valueList = new
+     * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
+     * valueList; }
+     * 
+     * public static List<Object> converArrayToList(String[] arr) { if(null ==
+     * arr || arr.length < 1) { return null; } List<Object> valueList = new
+     * ArrayList<Object>(); for(Object val:arr) { valueList.add(val); } return
+     * valueList; }
+     */
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/AttributeView.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/AttributeView.java
new file mode 100644 (file)
index 0000000..cd286db
--- /dev/null
@@ -0,0 +1,808 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view;
+
+import java.util.List;
+import java.util.Map;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.listener.IConfigurationUpload;
+import oic.simulator.clientcontroller.listener.IGetUIListener;
+import oic.simulator.clientcontroller.listener.IObserveUIListener;
+import oic.simulator.clientcontroller.listener.IPostUIListener;
+import oic.simulator.clientcontroller.listener.IPutUIListener;
+import oic.simulator.clientcontroller.listener.IResourceSelectionChangedUIListener;
+import oic.simulator.clientcontroller.listener.IVerificationUIListener;
+import oic.simulator.clientcontroller.manager.ResourceManager;
+import oic.simulator.clientcontroller.remoteresource.PutPostAttributeModel;
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+import oic.simulator.clientcontroller.remoteresource.RemoteResourceAttribute;
+import oic.simulator.clientcontroller.utils.Constants;
+import oic.simulator.clientcontroller.view.dialogs.VerificationDialog;
+import oic.simulator.clientcontroller.view.dialogs.PostRequestDialog;
+import oic.simulator.clientcontroller.view.dialogs.PutRequestDialog;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabFolder2Adapter;
+import org.eclipse.swt.custom.CTabFolderEvent;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * This class manages and shows the attribute view in the perspective.
+ */
+public class AttributeView extends ViewPart {
+
+    public static final String                  VIEW_ID        = "oic.simulator.clientcontroller.view.attribute";
+
+    private TableViewer                         attTblViewer;
+
+    private Button                              getButton;
+    private Button                              putButton;
+    private Button                              postButton;
+    private Button                              automateButton;
+    private Button                              observeResButton;
+
+    private CTabFolder                          payloadFolder;
+    private CTabItem                            requestPayloadTab;
+    private CTabItem                            responsePayloadTab;
+    private Text                                requestPayloadTxt;
+    private Text                                responsePayloadTxt;
+
+    private final String[]                      attTblHeaders  = {
+            "Attribute Name", "Attribute Value"               };
+    private final Integer[]                     attTblColWidth = { 200, 200 };
+
+    private ResourceManager                     resourceManager;
+
+    private IResourceSelectionChangedUIListener resourceSelectionChangedListener;
+    private IGetUIListener                      getUIListener;
+    private IPutUIListener                      putUIListener;
+    private IPostUIListener                     postUIListener;
+    private IObserveUIListener                  observeUIListener;
+    private IVerificationUIListener             verificationUIListener;
+    private IConfigurationUpload                configUploadUIListener;
+
+    private RemoteResource                      resourceInSelection;
+
+    public AttributeView() {
+        resourceManager = Activator.getDefault().getResourceManager();
+
+        resourceSelectionChangedListener = new IResourceSelectionChangedUIListener() {
+
+            @Override
+            public void onResourceSelectionChange(final RemoteResource resource) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        System.out
+                                .println("AttributeView: onResourceSelectionChange");
+                        resourceInSelection = resource;
+
+                        // Set visibility of manual and automation controls
+                        setVisibility((resource == null) ? false : true);
+
+                        // Update the attribute table
+                        if (null != attTblViewer
+                                && !attTblViewer.getControl().isDisposed()) {
+                            System.out.println("viewer is alive");
+                            updateViewer(getData(resource));
+                        }
+
+                        // Update the observe status
+                        updateObserve(resource);
+
+                        // Update the pay-load details if any
+                    }
+                });
+            }
+        };
+
+        getUIListener = new IGetUIListener() {
+
+            @Override
+            public void onGetCompleted(final RemoteResource resource) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+
+                        System.out.println("AttributeView: onGetCompleted");
+                        if (null == resource) {
+                            return;
+                        }
+                        // Update the attribute table
+                        if (resourceInSelection != resource) {
+                            System.out
+                                    .println("AttributeView: get response arrived for a different resource");
+                            return;
+                        }
+                        updateViewer(getData(resource));
+
+                        // Update the observe status
+                        updateObserve(resource);
+
+                        // Update the pay-load details if any
+                    }
+                });
+            }
+
+            @Override
+            public void onGetFailed(RemoteResource resource) {
+            }
+        };
+
+        putUIListener = new IPutUIListener() {
+
+            @Override
+            public void onPutCompleted(final RemoteResource resource) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+
+                        System.out.println("AttributeView: onPutCompleted");
+                        if (null == resource) {
+                            return;
+                        }
+                        // Update the attribute table
+                        if (resourceInSelection != resource) {
+                            System.out
+                                    .println("AttributeView: put response arrived for a different resource");
+                            return;
+                        }
+                        updateViewer(getData(resource));
+
+                        // Update the observe status
+                        updateObserve(resource);
+
+                        // Update the pay-load details if any
+                    }
+                });
+            }
+
+            @Override
+            public void onPutFailed(RemoteResource resource) {
+            }
+        };
+
+        postUIListener = new IPostUIListener() {
+
+            @Override
+            public void onPostCompleted(final RemoteResource resource) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+
+                        System.out.println("AttributeView: onPostCompleted");
+                        if (null == resource) {
+                            return;
+                        }
+                        // Update the attribute table
+                        if (resourceInSelection != resource) {
+                            System.out
+                                    .println("AttributeView: post response arrived for a different resource");
+                            return;
+                        }
+                        updateViewer(getData(resource));
+
+                        // Update the observe status
+                        updateObserve(resource);
+
+                        // Update the pay-load details if any
+                    }
+                });
+            }
+
+            @Override
+            public void onPostFailed(RemoteResource resource) {
+            }
+        };
+
+        observeUIListener = new IObserveUIListener() {
+
+            @Override
+            public void onObserveCompleted(final RemoteResource resource) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+
+                        System.out.println("AttributeView: onObserveCompleted");
+                        if (null == resource) {
+                            return;
+                        }
+                        // Update the attribute table
+                        if (resourceInSelection != resource) {
+                            System.out
+                                    .println("AttributeView: observe response arrived for a different resource");
+                            return;
+                        }
+                        updateViewer(getData(resource));
+
+                        // Update the observe status
+                        updateObserve(resource);
+
+                        // Update the pay-load details if any
+                    }
+                });
+            }
+
+            @Override
+            public void onObserveFailed(RemoteResource resource) {
+            }
+        };
+
+        verificationUIListener = new IVerificationUIListener() {
+
+            @Override
+            public void onVerificationStarted(final RemoteResource resource,
+                    final int autoType) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        changeReqBtnVisibility(autoType, false);
+                    }
+                });
+            }
+
+            @Override
+            public void onVerificationCompleted(final RemoteResource resource,
+                    final int autoType) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        changeReqBtnVisibility(autoType, true);
+                    }
+                });
+            }
+
+            @Override
+            public void onVerificationAborted(final RemoteResource resource,
+                    final int autoType) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        changeReqBtnVisibility(autoType, true);
+                    }
+                });
+            }
+        };
+
+        configUploadUIListener = new IConfigurationUpload() {
+
+            @Override
+            public void onConfigurationUploaded(final RemoteResource resource) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+
+                        System.out
+                                .println("AttributeView: onConfigurationUploaded");
+                        if (null == resource) {
+                            return;
+                        }
+                        if (resourceInSelection != resource) {
+                            System.out
+                                    .println("AttributeView: config upload response arrived for a different resource");
+                            return;
+                        }
+                        if (!automateButton.isDisposed()) {
+                            automateButton.setEnabled(true);
+                        }
+                    }
+                });
+            }
+        };
+    }
+
+    private void changeReqBtnVisibility(int reqType, boolean visibility) {
+        if (reqType == Constants.GET_AUTOMATION_INDEX) {
+            if (!getButton.isDisposed()) {
+                getButton.setEnabled(visibility);
+            }
+        } else if (reqType == Constants.PUT_AUTOMATION_INDEX) {
+            if (!putButton.isDisposed()) {
+                putButton.setEnabled(visibility);
+            }
+        } else {// if(reqType == Constants.POST_AUTOMATION_INDEX) {
+            if (!postButton.isDisposed()) {
+                postButton.setEnabled(visibility);
+            }
+        }
+    }
+
+    private Map<String, RemoteResourceAttribute> getData(RemoteResource resource) {
+        if (null == resource) {
+            return null;
+        }
+        Map<String, RemoteResourceAttribute> attMap = resource
+                .getResourceAttributesMap();
+        System.out.println("AttributeView: \n" + attMap);
+        return attMap;
+    }
+
+    private void updateViewer(Map<String, RemoteResourceAttribute> attMap) {
+        if (null != attTblViewer) {
+            Table tbl = attTblViewer.getTable();
+            if (null != attMap) {
+                attTblViewer.setInput(attMap.entrySet().toArray());
+                if (!tbl.isDisposed()) {
+                    tbl.setLinesVisible(true);
+                }
+            } else {
+                if (!tbl.isDisposed()) {
+                    tbl.removeAll();
+                    tbl.setLinesVisible(false);
+                }
+            }
+        }
+    }
+
+    private void updateObserve(RemoteResource resource) {
+        if (null == resource) {
+            return;
+        }
+        boolean observed = resource.isObserved();
+        if (!observeResButton.isDisposed()) {
+            observeResButton.setSelection(observed);
+        }
+    }
+
+    @Override
+    public void createPartControl(Composite parent) {
+        Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
+
+        parent.setLayout(new GridLayout(2, false));
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        parent.setLayoutData(gd);
+
+        Group attGroup = new Group(parent, SWT.NONE);
+        attGroup.setLayout(new GridLayout());
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        gd.horizontalSpan = 2;
+        gd.heightHint = 175;
+        attGroup.setLayoutData(gd);
+        attGroup.setText("Attributes");
+        attGroup.setBackground(color);
+
+        setupAttributeTable(attGroup);
+
+        setupMessageArea(parent);
+
+        setupResourceLevelOpsArea(parent);
+
+        setupTabArea(parent);
+
+        setUIListeners();
+
+        addManagerListeners();
+
+        setVisibility(false);
+
+        // Updating the data in the UI as per the resource in selection.
+        if (null != attTblViewer && !attTblViewer.getControl().isDisposed()) {
+            updateViewer(getData(resourceManager
+                    .getCurrentResourceInSelection()));
+        }
+    }
+
+    private void setupMessageArea(Composite parent) {
+        GridData gd;
+        Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
+        Group msgTypesGrp = new Group(parent, SWT.NONE);
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        msgTypesGrp.setLayoutData(gd);
+        GridLayout grid = new GridLayout(3, false);
+        msgTypesGrp.setLayout(grid);
+        msgTypesGrp.setText("Request Types");
+        msgTypesGrp.setBackground(color);
+
+        getButton = new Button(msgTypesGrp, SWT.PUSH);
+        getButton.setText("GET");
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        gd.widthHint = 50;
+        getButton.setLayoutData(gd);
+
+        putButton = new Button(msgTypesGrp, SWT.PUSH);
+        putButton.setText("PUT");
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        gd.widthHint = 50;
+        putButton.setLayoutData(gd);
+
+        postButton = new Button(msgTypesGrp, SWT.PUSH);
+        postButton.setText("POST");
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        gd.widthHint = 50;
+        postButton.setLayoutData(gd);
+    }
+
+    private void setupResourceLevelOpsArea(Composite parent) {
+        GridData gd;
+        Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
+        Group resOpsGrp = new Group(parent, SWT.NONE);
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        resOpsGrp.setLayoutData(gd);
+        GridLayout grid = new GridLayout(2, false);
+        resOpsGrp.setLayout(grid);
+        resOpsGrp.setText("Resource-Level Operations");
+        resOpsGrp.setBackground(color);
+
+        automateButton = new Button(resOpsGrp, SWT.PUSH);
+        automateButton.setText("Automation");
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        automateButton.setLayoutData(gd);
+
+        observeResButton = new Button(resOpsGrp, SWT.CHECK);
+        observeResButton.setText("Observe");
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        gd.horizontalAlignment = SWT.FILL;
+        observeResButton.setLayoutData(gd);
+    }
+
+    private void setupTabArea(final Composite parent) {
+        GridData gd;
+        payloadFolder = new CTabFolder(parent, SWT.BORDER);
+        gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        gd.horizontalSpan = 2;
+        payloadFolder.setLayoutData(gd);
+        payloadFolder.setSimple(false);
+        payloadFolder.setUnselectedCloseVisible(false);
+        payloadFolder.setUnselectedImageVisible(false);
+        // payloadFolder.setMaximizeVisible(true);
+        // payloadFolder.setMinimizeVisible(true);
+
+        requestPayloadTab = new CTabItem(payloadFolder, SWT.NULL);
+        requestPayloadTab.setText("Request Payload");
+
+        requestPayloadTxt = new Text(payloadFolder, SWT.MULTI | SWT.V_SCROLL
+                | SWT.H_SCROLL | SWT.READ_ONLY | SWT.WRAP);
+        requestPayloadTab.setControl(requestPayloadTxt);
+
+        responsePayloadTab = new CTabItem(payloadFolder, SWT.NULL);
+        responsePayloadTab.setText("Response Payload");
+
+        responsePayloadTxt = new Text(payloadFolder, SWT.MULTI | SWT.V_SCROLL
+                | SWT.H_SCROLL | SWT.READ_ONLY | SWT.WRAP);
+        responsePayloadTab.setControl(responsePayloadTxt);
+
+        // Add Listeners
+
+        payloadFolder.addCTabFolder2Listener(new CTabFolder2Adapter() {
+            @Override
+            public void minimize(CTabFolderEvent event) {
+                payloadFolder.setMinimized(true);
+                GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+                gd.horizontalSpan = 2;
+                payloadFolder.setLayoutData(gd);
+                parent.layout(true);
+            }
+
+            @Override
+            public void maximize(CTabFolderEvent event) {
+                payloadFolder.setMaximized(true);
+                GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+                gd.horizontalSpan = 2;
+                payloadFolder.setLayoutData(gd);
+                parent.layout(true);
+            }
+
+            @Override
+            public void restore(CTabFolderEvent event) {
+                payloadFolder.setMaximized(false);
+                payloadFolder.setMinimized(false);
+                GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+                gd.horizontalSpan = 2;
+                payloadFolder.setLayoutData(gd);
+                parent.layout(true);
+            }
+        });
+    }
+
+    private void setupAttributeTable(Group attGroup) {
+        attTblViewer = new TableViewer(attGroup, SWT.SINGLE | SWT.H_SCROLL
+                | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+        createAttributeColumns(attTblViewer);
+
+        // make lines and header visible
+        Table table = attTblViewer.getTable();
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        attTblViewer.setContentProvider(new AttributeContentProvider());
+    }
+
+    public void createAttributeColumns(TableViewer tableViewer) {
+
+        TableViewerColumn attName = new TableViewerColumn(tableViewer, SWT.NONE);
+        attName.getColumn().setWidth(attTblColWidth[0]);
+        attName.getColumn().setText(attTblHeaders[0]);
+        attName.setLabelProvider(new StyledCellLabelProvider() {
+            @Override
+            public void update(ViewerCell cell) {
+                Object element = cell.getElement();
+                if (element instanceof Map.Entry) {
+                    @SuppressWarnings("unchecked")
+                    Map.Entry<String, RemoteResourceAttribute> entry = (Map.Entry<String, RemoteResourceAttribute>) element;
+                    cell.setText(entry.getKey());
+                }
+            }
+        });
+
+        TableViewerColumn attValue = new TableViewerColumn(tableViewer,
+                SWT.NONE);
+        attValue.getColumn().setWidth(attTblColWidth[1]);
+        attValue.getColumn().setText(attTblHeaders[1]);
+        attValue.setLabelProvider(new StyledCellLabelProvider() {
+            @Override
+            public void update(ViewerCell cell) {
+                Object element = cell.getElement();
+                if (element instanceof Map.Entry) {
+                    @SuppressWarnings("unchecked")
+                    Map.Entry<String, RemoteResourceAttribute> entry = (Map.Entry<String, RemoteResourceAttribute>) element;
+                    Object value = entry.getValue().getAttributeValue();
+                    if (null == value) {
+                        cell.setText("");
+                    } else {
+                        cell.setText(String.valueOf(value));
+                    }
+                }
+            }
+        });
+    }
+
+    private void setUIListeners() {
+
+        getButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (resourceInSelection.isGetAutomtnInProgress()) {
+                    MessageDialog
+                            .openInformation(Display.getDefault()
+                                    .getActiveShell(), "GET Request",
+                                    "GET Automation is in progress. Please wait or stop the automation.");
+                } else {
+                    resourceManager.sendGetRequest(resourceInSelection);
+                }
+            }
+        });
+
+        putButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                PlatformUI.getWorkbench().getDisplay().syncExec(new Thread() {
+                    @Override
+                    public void run() {
+                        if (resourceInSelection.isPutAutomtnInProgress()) {
+                            MessageDialog
+                                    .openInformation(Display.getDefault()
+                                            .getActiveShell(), "PUT Request",
+                                            "PUT Automation is in progress. Please wait or stop the automation.");
+                            return;
+                        }
+                        List<PutPostAttributeModel> putPostModelList;
+                        putPostModelList = resourceInSelection
+                                .getPutPostModel();
+                        if (null == putPostModelList) {
+                            MessageDialog
+                                    .openInformation(Display.getDefault()
+                                            .getActiveShell(), "PUT Request",
+                                            "No attributes exist in the resource model.");
+                            return;
+                        }
+                        PutRequestDialog putDialog = new PutRequestDialog(
+                                Display.getDefault().getActiveShell(),
+                                putPostModelList);
+                        if (putDialog.open() == Window.OK) {
+                            // Call the native PUT method
+                            resourceManager.sendPutRequest(resourceInSelection,
+                                    putPostModelList);
+                        }
+                    }
+                });
+            }
+        });
+
+        postButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                PlatformUI.getWorkbench().getDisplay().syncExec(new Thread() {
+                    @Override
+                    public void run() {
+                        if (resourceInSelection.isPostAutomtnInProgress()) {
+                            MessageDialog
+                                    .openInformation(Display.getDefault()
+                                            .getActiveShell(), "POST Request",
+                                            "POST Automation is in progress. Please wait or stop the automation.");
+                            return;
+                        }
+                        List<PutPostAttributeModel> putPostModelList;
+                        putPostModelList = resourceInSelection
+                                .getPutPostModel();
+                        if (null == putPostModelList) {
+                            MessageDialog
+                                    .openInformation(Display.getDefault()
+                                            .getActiveShell(), "PUT Request",
+                                            "No attributes exist in the resource model.");
+                            return;
+                        }
+
+                        PostRequestDialog postDialog = new PostRequestDialog(
+                                Display.getDefault().getActiveShell(),
+                                putPostModelList);
+                        if (postDialog.open() == Window.OK) {
+                            // Call the native POST method
+                            resourceManager.sendPostRequest(
+                                    resourceInSelection, putPostModelList);
+                        }
+                    }
+                });
+            }
+        });
+
+        observeResButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                boolean checked = observeResButton.getSelection();
+                if (checked) {
+                    resourceManager.sendObserveRequest(resourceInSelection);
+                } else {
+                    resourceManager
+                            .sendCancelObserveRequest(resourceInSelection);
+                }
+            }
+        });
+
+        automateButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                PlatformUI.getWorkbench().getDisplay().syncExec(new Thread() {
+                    @Override
+                    public void run() {
+                        RemoteResource resource = resourceManager
+                                .getCurrentResourceInSelection();
+                        if (null == resource) {
+                            return;
+                        }
+                        Map<String, Boolean> autoStatus = resourceManager
+                                .getAutomationStatus(resource);
+                        if (null == autoStatus) {
+                            return;
+                        }
+                        VerificationDialog ad = new VerificationDialog(Display
+                                .getDefault().getActiveShell(), autoStatus);
+                        if (ad.open() == Window.OK) {
+
+                        }
+                    }
+                });
+            }
+        });
+    }
+
+    private void addManagerListeners() {
+        resourceManager
+                .addResourceSelectionChangedUIListener(resourceSelectionChangedListener);
+        resourceManager.addGetUIListener(getUIListener);
+        resourceManager.addPutUIListener(putUIListener);
+        resourceManager.addPostUIListener(postUIListener);
+        resourceManager.addObserveUIListener(observeUIListener);
+        resourceManager.addVerificationUIListener(verificationUIListener);
+        resourceManager.addConfigUploadUIListener(configUploadUIListener);
+    }
+
+    private void setVisibility(boolean visibility) {
+        if (!getButton.isDisposed())
+            getButton.setEnabled(visibility);
+        if (!putButton.isDisposed())
+            putButton.setEnabled(visibility);
+        if (!postButton.isDisposed())
+            postButton.setEnabled(visibility);
+        if (!automateButton.isDisposed()) {
+            if (visibility && null != resourceInSelection
+                    && resourceInSelection.isConfigUploaded()) {
+                automateButton.setEnabled(true);
+            } else {
+                automateButton.setEnabled(false);
+            }
+        }
+        if (!observeResButton.isDisposed())
+            observeResButton.setEnabled(visibility);
+    }
+
+    class AttributeContentProvider implements IStructuredContentProvider {
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public void inputChanged(Viewer viewer, Object arg1, Object arg2) {
+        }
+
+        @Override
+        public Object[] getElements(Object element) {
+            return (Object[]) element;
+        }
+
+    }
+
+    @Override
+    public void dispose() {
+        // Unregister the selection listener
+        if (null != resourceSelectionChangedListener) {
+            resourceManager
+                    .removeResourceSelectionChangedUIListener(resourceSelectionChangedListener);
+        }
+
+        // Unregister the GET listener
+        if (null != getUIListener) {
+            resourceManager.removeGetUIListener(getUIListener);
+        }
+
+        super.dispose();
+    }
+
+    @Override
+    public void setFocus() {
+    }
+
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/LogView.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/LogView.java
new file mode 100644 (file)
index 0000000..65a7e71
--- /dev/null
@@ -0,0 +1,722 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.List;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.listener.ILogUIListener;
+import oic.simulator.clientcontroller.manager.LogManager;
+import oic.simulator.clientcontroller.utils.Constants;
+import oic.simulator.clientcontroller.view.dialogs.FilterDialog;
+import oic.simulator.clientcontroller.view.dialogs.LogDetailsDialog;
+import oic.simulator.logger.LogContentProvider;
+import oic.simulator.logger.LogEntry;
+import oic.simulator.logger.LogLabelProvider;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+import org.eclipse.ui.part.ViewPart;
+import org.oic.simulator.ILogger.Level;
+
+/**
+ * This class manages and shows the log view in the perspective.
+ */
+public class LogView extends ViewPart {
+
+    public static final String        VIEW_ID              = "oic.simulator.clientcontroller.view.log";
+
+    private LogManager                logManager;
+    private ILogUIListener            logListener;
+
+    private LogContentProvider        treeContentProvider;
+
+    private FilteredTree              tree;
+    private TreeColumn                severityColumn;
+    private TreeColumn                dateColumn;
+    private TreeColumn                messageColumn;
+
+    private IAction                   exportLogAction;
+    private IAction                   clearLogAction;
+    private IAction                   deleteLogAction;
+    private IAction                   scrollLockAction;
+    private IAction                   logDetailsAction;
+    private IAction                   filterAction;
+    private IAction                   activateViewAction;
+    private IAction                   showTextFilter;
+    private IContributionItem         groupByAction;
+
+    private HashMap<Integer, Boolean> shownSeverities      = new HashMap<Integer, Boolean>();
+
+    private boolean                   activateOnChange     = false;
+
+    private boolean                   hideTextFilter       = false;
+
+    private boolean                   scrollLockDisabled;
+
+    public static final int           ORDER_BY_TIME        = 0;
+    public static final int           ORDER_BY_SEVERITY    = 1;
+    public static final int           ORDER_BY_MESSAGE     = 2;
+
+    int                               sortCandidate        = ORDER_BY_TIME;
+
+    SortAction                        sortByTimeAction     = new SortAction(
+                                                                   "Order by Time",
+                                                                   ORDER_BY_TIME);
+    SortAction                        sortBySeverityAction = new SortAction(
+                                                                   "Order by Severity",
+                                                                   ORDER_BY_SEVERITY);
+    SortAction                        sortByMessageAction  = new SortAction(
+                                                                   "Order by Message",
+                                                                   ORDER_BY_MESSAGE);
+
+    private ViewerComparator          dateComparator;
+    private ViewerComparator          severityComparator;
+    private ViewerComparator          messageComparator;
+
+    private TreeColumn                sortColumn           = null;
+    private static int                DOWN                 = 1;
+    private static int                UP                   = -1;
+    private int                       sortDirection        = DOWN;
+
+    public LogView() {
+
+        logListener = new ILogUIListener() {
+
+            @Override
+            public void logChanged(final List<LogEntry> entry) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        TreeViewer viewer = tree.getViewer();
+                        if (viewer.getControl().isDisposed()) {
+                            return;
+                        }
+                        viewer.setInput(entry);
+                        updateTree(false);
+                    }
+                });
+            }
+
+            @Override
+            public void logAdded(final LogEntry added) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        TreeViewer viewer = tree.getViewer();
+                        if (viewer.getControl().isDisposed()) {
+                            return;
+                        }
+                        LogContentProvider provider = (LogContentProvider) viewer
+                                .getContentProvider();
+                        provider.addLog(added);
+                        tree.getViewer().add(viewer.getInput(), added);
+                        @SuppressWarnings("unchecked")
+                        List<LogEntry> input = (List<LogEntry>) viewer
+                                .getInput();
+                        if (input.size() > Constants.LOG_SIZE) {
+                            viewer.remove(viewer.getInput(), 0);
+                        }
+                        updateTree(true);
+                    }
+                });
+            }
+
+            private void updateTree(boolean needscroll) {
+                if (activateOnChange) {
+                    IWorkbenchPage page = Activator.getDefault().getWorkbench()
+                            .getActiveWorkbenchWindow().getActivePage();
+                    if (page != null) {
+                        page.bringToTop(LogView.this);
+                    }
+                }
+                if (scrollLockDisabled && needscroll) {
+                    Tree tree2 = tree.getViewer().getTree();
+                    if (tree2.getItemCount() > 0) {
+                        TreeItem item = tree2.getItem(tree2.getItemCount() - 1);
+                        tree2.setTopItem(item);
+                        deleteLogAction.setEnabled(true);
+                    }
+                }
+            }
+        };
+
+        logManager = Activator.getDefault().getLogManager();
+
+        // Initially state of scroll lock
+        scrollLockDisabled = true;
+    }
+
+    @Override
+    public void createPartControl(Composite parent) {
+        PatternFilter filter = new PatternFilter() {
+
+            DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS");
+
+            @Override
+            protected boolean isLeafMatch(Viewer viewer, Object element) {
+                if (element instanceof LogEntry) {
+                    LogEntry logEntry = (LogEntry) element;
+                    String severity = LogManager.getSeverityName(logEntry
+                            .getSeverity());
+                    String date = dateFormat.format(logEntry.getDate());
+                    String message = logEntry.getMessage();
+                    return wordMatches(severity) || wordMatches(date)
+                            || wordMatches(message);
+                }
+                return false;
+            }
+        };
+        filter.setIncludeLeadingWildcard(true);
+        tree = new FilteredTree(parent, SWT.SINGLE | SWT.H_SCROLL
+                | SWT.V_SCROLL | SWT.FULL_SELECTION, filter, true);
+
+        setupFilteredTree();
+
+        createColumnComparators();
+
+        createActions();
+
+        setDefaultShownSeverities();
+
+        IActionBars actionBars = getViewSite().getActionBars();
+        IToolBarManager toolBarManager = actionBars.getToolBarManager();
+        toolBarManager.add(exportLogAction);
+        toolBarManager.add(clearLogAction);
+        toolBarManager.add(deleteLogAction);
+        toolBarManager.add(scrollLockAction);
+        toolBarManager
+                .add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+
+        IMenuManager mgr = actionBars.getMenuManager();
+        mgr.add(groupByAction);
+        mgr.add(new Separator());
+        mgr.add(filterAction);
+        mgr.add(new Separator());
+        mgr.add(activateViewAction);
+        mgr.add(showTextFilter);
+
+        addManagerListeners();
+
+        if (sortCandidate == ORDER_BY_TIME) {
+            sortByTimeAction.run();
+        } else if (sortCandidate == ORDER_BY_SEVERITY) {
+            sortBySeverityAction.run();
+        } else { // order_selected == ORDER_BY_NONE
+            sortByMessageAction.run();
+        }
+
+    }
+
+    private void setupFilteredTree() {
+        tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+        final Tree innerTree = tree.getViewer().getTree();
+        innerTree.setLinesVisible(true);
+
+        severityColumn = new TreeColumn(innerTree, SWT.LEFT);
+        severityColumn.setText("Severity");
+        severityColumn.setWidth(110);
+        severityColumn.addSelectionListener(new SelectionAdapter() {
+
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                sortBySeverityAction.run();
+            }
+        });
+        dateColumn = new TreeColumn(innerTree, SWT.LEFT);
+        dateColumn.setText("Time");
+        dateColumn.setWidth(110);
+        dateColumn.addSelectionListener(new SelectionAdapter() {
+
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                sortByTimeAction.run();
+            }
+        });
+        messageColumn = new TreeColumn(innerTree, SWT.LEFT);
+        messageColumn.setText("Message");
+        messageColumn.setWidth(180);
+        messageColumn.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                sortByMessageAction.run();
+            }
+        });
+
+        innerTree.setHeaderVisible(true);
+
+        treeContentProvider = new LogContentProvider();
+
+        tree.getViewer().setContentProvider(treeContentProvider);
+        tree.getViewer().setLabelProvider(new LogLabelProvider());
+
+        tree.getViewer().setInput(logManager.getLogEntries());
+
+        tree.getViewer().addSelectionChangedListener(
+                new ISelectionChangedListener() {
+
+                    @Override
+                    public void selectionChanged(SelectionChangedEvent event) {
+                        deleteLogAction.setEnabled(!tree.getViewer()
+                                .getSelection().isEmpty());
+                        logDetailsAction.setEnabled(!tree.getViewer()
+                                .getSelection().isEmpty());
+                    }
+                });
+
+        tree.getViewer().getTree().addKeyListener(new KeyListener() {
+
+            @Override
+            public void keyReleased(KeyEvent e) {
+            }
+
+            @Override
+            public void keyPressed(KeyEvent e) {
+                if (e.character == (char) 127) { // If delete key is pressed
+                    if (deleteLogAction.isEnabled()) {
+                        deleteLogAction.run();
+                    }
+                }
+            }
+        });
+
+        tree.getViewer().addDoubleClickListener(new IDoubleClickListener() {
+
+            @Override
+            public void doubleClick(DoubleClickEvent event) {
+                logDetailsAction.run();
+            }
+        });
+    }
+
+    private void createColumnComparators() {
+        dateComparator = new ViewerComparator() {
+
+            @Override
+            public int compare(Viewer viewer, Object e1, Object e2) {
+                LogEntry l1 = (LogEntry) e1;
+                LogEntry l2 = (LogEntry) e2;
+                return l1.getDate().compareTo(l2.getDate()) * sortDirection;
+            }
+        };
+
+        severityComparator = new ViewerComparator() {
+
+            @Override
+            public int compare(Viewer viewer, Object e1, Object e2) {
+                LogEntry l1 = (LogEntry) e1;
+                LogEntry l2 = (LogEntry) e2;
+                if (l1.getSeverity() < l2.getSeverity()) {
+                    return -1 * sortDirection;
+                }
+                if (l1.getSeverity() > l2.getSeverity()) {
+                    return 1 * sortDirection;
+                }
+                return 0;
+            }
+        };
+
+        messageComparator = new ViewerComparator() {
+
+            @Override
+            public int compare(Viewer viewer, Object e1, Object e2) {
+                LogEntry l1 = (LogEntry) e1;
+                LogEntry l2 = (LogEntry) e2;
+                return l1.getMessage().compareTo(l2.getMessage())
+                        * sortDirection;
+            }
+        };
+
+    }
+
+    private void setDefaultShownSeverities() {
+        shownSeverities.put(Level.INFO.ordinal(), true);
+        shownSeverities.put(Level.DEBUG.ordinal(), true);
+        shownSeverities.put(Level.WARNING.ordinal(), true);
+        shownSeverities.put(Level.ERROR.ordinal(), true);
+    }
+
+    private void addManagerListeners() {
+        logManager.addLogListener(logListener);
+        logManager.applyFilter(shownSeverities);
+    }
+
+    private void createActions() {
+        exportLogAction = createExportLogAction();
+        clearLogAction = createClearLogAction();
+        deleteLogAction = createDeleteLogAction();
+        scrollLockAction = createScrollLockAction();
+        logDetailsAction = createLogDetailsAction();
+
+        filterAction = createFilterAction();
+        activateViewAction = createActivateViewAction();
+        showTextFilter = createShowTextFilter();
+        groupByAction = createGroupByAction();
+    }
+
+    private IAction createExportLogAction() {
+        Action action = new Action("Export log") {
+            @Override
+            public void run() {
+                FileDialog fd = new FileDialog(Display.getDefault()
+                        .getActiveShell(), SWT.SAVE);
+                fd.setOverwrite(true);
+                fd.setFileName("OIC_Simulator_ServerLog.log");
+                fd.setFilterExtensions(Constants.SAVE_LOG_FILTER_EXTENSIONS);
+                String name = fd.open();
+                List<LogEntry> logEntries = logManager.getLogEntries();
+                StringBuilder sb = new StringBuilder();
+                for (LogEntry entry : logEntries) {
+                    sb.append(entry.toString());
+                }
+                String data = sb.toString();
+                BufferedWriter out = null;
+                try {
+                    out = new BufferedWriter(new FileWriter(name));
+                    out.write(data);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    MessageDialog.openError(
+                            Display.getDefault().getActiveShell(),
+                            "Export error",
+                            "Could not export log. IO exception: "
+                                    + e.getMessage());
+                } finally {
+                    try {
+                        out.close();
+                    } catch (IOException e) {
+                        // Error occurred during close. Ignoring
+                    }
+                }
+            }
+        };
+        action.setToolTipText("Export log");
+
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/export_log_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/export_log_d.gif"));
+        action.setEnabled(true);
+
+        return action;
+    }
+
+    private IAction createClearLogAction() {
+        Action action = new Action("Clear log") {
+
+            @Override
+            public void run() {
+                logManager.clearLog();
+            }
+        };
+        action.setToolTipText("Clear log");
+
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/clear_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/clear_d.gif"));
+        action.setEnabled(true);
+        return action;
+    }
+
+    private IAction createDeleteLogAction() {
+        Action action = new Action("Delete log entry") {
+
+            @Override
+            @SuppressWarnings("unchecked")
+            public void run() {
+                IStructuredSelection selection = (IStructuredSelection) tree
+                        .getViewer().getSelection();
+                List<LogEntry> entries = (List<LogEntry>) tree.getViewer()
+                        .getInput();
+                LogEntry selectedEntry = (LogEntry) selection.getFirstElement();
+                if (null != selectedEntry) {
+                    LogEntry toBeShownEntry = null;
+                    for (LogEntry entry : entries) {
+                        if (entry.equals(selectedEntry)) {
+                            int size = entries.size();
+                            int index = entries.indexOf(selectedEntry);
+                            if (index + 1 < size) {
+                                toBeShownEntry = entries.get(index + 1);
+                            } else if (index > 0) {
+                                toBeShownEntry = entries.get(index - 1);
+                            }
+                            break;
+                        }
+                    }
+                    logManager.removeEntry(selectedEntry);
+                    if (null != toBeShownEntry) {
+                        tree.getViewer().setSelection(
+                                new StructuredSelection(toBeShownEntry));
+                    }
+                }
+            }
+        };
+        action.setToolTipText("Delete log entry");
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/delete_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/delete_d.gif"));
+        action.setEnabled(false);
+        return action;
+    }
+
+    private IAction createScrollLockAction() {
+        Action action = new Action("Scroll lock") {
+
+            @Override
+            public void run() {
+                scrollLockDisabled = !this.isChecked();
+            };
+
+            @Override
+            public int getStyle() {
+                return IAction.AS_CHECK_BOX;
+            }
+        };
+        action.setToolTipText("Scroll lock");
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/lock_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/lock_d.gif"));
+        action.setEnabled(true);
+        return action;
+    }
+
+    private IAction createLogDetailsAction() {
+        Action action = new Action("Details...") {
+
+            @Override
+            public void run() {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        LogEntry x = (LogEntry) ((IStructuredSelection) tree
+                                .getViewer().getSelection()).getFirstElement();
+
+                        new LogDetailsDialog(Display.getDefault()
+                                .getActiveShell(), LogManager.getSeverityName(x
+                                .getSeverity()), LogManager.getSeverityIcon(x
+                                .getSeverity()), x.getDate(), x.getMessage())
+                                .open();
+                    }
+                });
+            }
+        };
+        action.setToolTipText("Details...");
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/log_details_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/log_details_e.gif"));
+        action.setEnabled(false);
+        return action;
+    }
+
+    private IAction createFilterAction() {
+        Action action = new Action("Filters ...") {
+
+            @Override
+            public void run() {
+                FilterDialog fd = new FilterDialog(Display.getDefault()
+                        .getActiveShell(), shownSeverities);
+                if (fd.open() == Window.OK) {
+                    logManager.applyFilter(shownSeverities);
+                }
+                tree.getViewer().refresh();
+            }
+        };
+        action.setToolTipText("Filters ...");
+
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/filter_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/filter_d.gif"));
+        action.setEnabled(true);
+        return action;
+    }
+
+    private IAction createActivateViewAction() {
+        Action action = new Action("Activate view on new events",
+                IAction.AS_CHECK_BOX) {
+
+            @Override
+            public void run() {
+                activateOnChange = this.isChecked();
+            }
+        };
+        action.setChecked(activateOnChange);
+        action.setToolTipText("Activate view on new events");
+
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/prop_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/prop_d.gif"));
+        action.setEnabled(true);
+        return action;
+    }
+
+    private IAction createShowTextFilter() {
+        Action action = new Action("Show text filter", IAction.AS_CHECK_BOX) {
+
+            @Override
+            public void run() {
+                Text filterControl = tree.getFilterControl();
+                Composite filterComposite = filterControl.getParent();
+                GridData gd = (GridData) filterComposite.getLayoutData();
+                boolean visible = isChecked();
+                gd.exclude = !visible;
+                filterComposite.setVisible(visible);
+                filterControl.setText("");
+                if (visible) {
+                    filterControl.selectAll();
+                    setFocus();
+                }
+                tree.layout(false);
+                hideTextFilter = !visible;
+            }
+        };
+        action.setToolTipText("Show text filter");
+
+        action.setImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/tree_mode_e.gif"));
+        action.setDisabledImageDescriptor(ImageDescriptor.createFromFile(
+                this.getClass(), "/icons/tree_mode_d.gif"));
+        action.setEnabled(true);
+        action.setChecked(!hideTextFilter);
+        if (hideTextFilter) {
+            action.run();
+        }
+        return action;
+    }
+
+    private IContributionItem createGroupByAction() {
+        IMenuManager manager = new MenuManager("Order by");
+        manager.add(sortByTimeAction);
+        manager.add(sortBySeverityAction);
+        manager.add(sortByMessageAction);
+        return manager;
+    }
+
+    class SortAction extends Action {
+
+        private final int sortBy;
+
+        public SortAction(String text, int sortBy) {
+            super(text, IAction.AS_RADIO_BUTTON);
+            this.sortBy = sortBy;
+
+            if (sortCandidate == sortBy) {
+                setChecked(true);
+            }
+        }
+
+        @Override
+        public void run() {
+            sortBySeverityAction.setChecked(false);
+            sortByTimeAction.setChecked(false);
+            sortCandidate = sortBy;
+            setChecked(true);
+
+            ViewerComparator comparator;
+            TreeColumn column;
+            if (sortBy == ORDER_BY_SEVERITY) {
+                comparator = severityComparator;
+                column = severityColumn;
+            } else if (sortBy == ORDER_BY_TIME) {
+                comparator = dateComparator;
+                column = dateColumn;
+            } else { // Order by message
+                comparator = messageComparator;
+                column = messageColumn;
+            }
+            TreeViewer viewer = tree.getViewer();
+            viewer.setComparator(comparator);
+            viewer.getTree().setSortColumn(column);
+            if (column.equals(sortColumn)) { // reverse sorting order
+                sortDirection = viewer.getTree().getSortDirection() == SWT.UP ? DOWN
+                        : UP;
+                viewer.getTree().setSortDirection(
+                        sortDirection == UP ? SWT.UP : SWT.DOWN);
+                viewer.refresh();
+            } else { // set this column as the one to sort by
+                sortDirection = DOWN;
+                viewer.getTree().setSortDirection(SWT.DOWN);
+            }
+            sortColumn = column;
+            refresh();
+        }
+    }
+
+    private void refresh() {
+        tree.getViewer().refresh();
+    }
+
+    @Override
+    public void setFocus() {
+        tree.setFocus();
+    }
+
+    @Override
+    public void dispose() {
+        logManager.removeLogListener(logListener);
+        super.dispose();
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/MetaPropertiesView.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/MetaPropertiesView.java
new file mode 100644 (file)
index 0000000..ae9fa40
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view;
+
+import java.util.List;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.listener.IResourceSelectionChangedUIListener;
+import oic.simulator.clientcontroller.manager.ResourceManager;
+import oic.simulator.clientcontroller.remoteresource.MetaProperty;
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * This class manages and shows the meta properties view in the perspective.
+ */
+public class MetaPropertiesView extends ViewPart {
+
+    public static final String                  VIEW_ID       = "oic.simulator.clientcontroller.view.metaproperties";
+
+    private TableViewer                         tableViewer;
+
+    private final String[]                      columnHeaders = { "Property",
+            "Value"                                          };
+
+    private final Integer[]                     columnWidth   = { 150, 150 };
+
+    private IResourceSelectionChangedUIListener resourceSelectionChangedListener;
+
+    private ResourceManager                     resourceManager;
+
+    public MetaPropertiesView() {
+
+        resourceManager = Activator.getDefault().getResourceManager();
+
+        resourceSelectionChangedListener = new IResourceSelectionChangedUIListener() {
+
+            @Override
+            public void onResourceSelectionChange(final RemoteResource resource) {
+                Display.getDefault().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        if (null != tableViewer) {
+                            updateViewer(getData(resource));
+                        }
+                    }
+                });
+            }
+        };
+    }
+
+    @Override
+    public void createPartControl(Composite parent) {
+        parent.setLayout(new GridLayout(1, false));
+
+        tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
+                | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+        createColumns(tableViewer);
+
+        // make lines and header visible
+        final Table table = tableViewer.getTable();
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        tableViewer.setContentProvider(new PropertycontentProvider());
+
+        addManagerListeners();
+
+        // Check whether there is any resource selected already
+        List<MetaProperty> propertyList = getData(null);
+        if (null != propertyList) {
+            updateViewer(propertyList);
+        }
+
+    }
+
+    private List<MetaProperty> getData(RemoteResource resource) {
+        if (null == resource) {
+            resource = Activator.getDefault().getResourceManager()
+                    .getCurrentResourceInSelection();
+        }
+        List<MetaProperty> metaPropertyList = resourceManager
+                .getMetaProperties(resource);
+        return metaPropertyList;
+    }
+
+    private void updateViewer(List<MetaProperty> metaPropertyList) {
+        if (null != tableViewer) {
+            Table tbl = tableViewer.getTable();
+            if (null != metaPropertyList) {
+                tableViewer.setInput(metaPropertyList.toArray());
+                if (!tbl.isDisposed()) {
+                    tbl.setLinesVisible(true);
+                }
+            } else {
+                if (!tbl.isDisposed()) {
+                    tbl.removeAll();
+                    tbl.setLinesVisible(false);
+                }
+            }
+        }
+    }
+
+    public void createColumns(TableViewer tableViewer) {
+        TableViewerColumn propName = new TableViewerColumn(tableViewer,
+                SWT.NONE);
+        propName.getColumn().setWidth(columnWidth[0]);
+        propName.getColumn().setText(columnHeaders[0]);
+        propName.setLabelProvider(new ColumnLabelProvider() {
+            @Override
+            public String getText(Object element) {
+                MetaProperty prop = (MetaProperty) element;
+                if (null != prop) {
+                    return prop.getPropName();
+                } else {
+                    return "";
+                }
+            }
+        });
+
+        TableViewerColumn propValue = new TableViewerColumn(tableViewer,
+                SWT.NONE);
+        propValue.getColumn().setWidth(columnWidth[1]);
+        propValue.getColumn().setText(columnHeaders[1]);
+        propValue.setLabelProvider(new ColumnLabelProvider() {
+            @Override
+            public String getText(Object element) {
+                MetaProperty prop = (MetaProperty) element;
+                if (null != prop) {
+                    return prop.getPropValue();
+                } else {
+                    return "";
+                }
+            }
+        });
+    }
+
+    private void addManagerListeners() {
+        resourceManager
+                .addResourceSelectionChangedUIListener(resourceSelectionChangedListener);
+    }
+
+    class PropertycontentProvider implements IStructuredContentProvider {
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+        }
+
+        @Override
+        public Object[] getElements(Object element) {
+            return (Object[]) element;
+        }
+
+    }
+
+    @Override
+    public void dispose() {
+        // Unregister the listener
+        if (null != resourceSelectionChangedListener) {
+            resourceManager
+                    .removeResourceSelectionChangedUIListener(resourceSelectionChangedListener);
+        }
+        super.dispose();
+    }
+
+    @Override
+    public void setFocus() {
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/MultiResourceOrchestrationView.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/MultiResourceOrchestrationView.java
new file mode 100644 (file)
index 0000000..67ae7ce
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * This class manages and shows the multi-resource automation view in the
+ * perspective.
+ */
+public class MultiResourceOrchestrationView extends ViewPart {
+
+    public static final String VIEW_ID = "oic.simulator.clientcontroller.view.orchestration";
+
+    @Override
+    public void createPartControl(Composite arg0) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setFocus() {
+        // TODO Auto-generated method stub
+
+    }
+
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/ResourceManagerView.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/ResourceManagerView.java
new file mode 100644 (file)
index 0000000..eecc4a7
--- /dev/null
@@ -0,0 +1,762 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view;
+
+import java.util.List;
+import java.util.Set;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.listener.IFindResourceUIListener;
+import oic.simulator.clientcontroller.manager.ResourceManager;
+import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+import oic.simulator.clientcontroller.utils.Constants;
+import oic.simulator.clientcontroller.view.dialogs.FindResourceWizard;
+import oic.simulator.clientcontroller.view.dialogs.LoadRAMLDialog;
+import oic.simulator.clientcontroller.view.dialogs.ResourceWizardDialog;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * This class manages and shows the resource manager view in the perspective.
+ */
+public class ResourceManagerView extends ViewPart {
+
+    public static final String      VIEW_ID = "oic.simulator.clientcontroller.view.resourcemanager";
+
+    private Button                  findResButton;
+    private Button                  refreshButton;
+
+    private TreeViewer              treeViewer;
+    private TreeViewer              favTreeViewer;
+
+    private CTabFolder              folder;
+    private CTabItem                foundResTab;
+    private CTabItem                favResTab;
+
+    private ResourceManager         resourceManager;
+
+    private IFindResourceUIListener findListener;
+
+    private Boolean                 foundResource;
+
+    private MessageDialog           findDialog;
+
+    private MessageDialog           refreshDialog;
+
+    private Thread                  sleepThreadHandle;
+
+    public ResourceManagerView() {
+        resourceManager = Activator.getDefault().getResourceManager();
+
+        findListener = new IFindResourceUIListener() {
+
+            @Override
+            public void onNewResourceFound(final RemoteResource resource) {
+                System.out.println("View: onNewResourceFound");
+                if (null == resource) {
+                    return;
+                }
+                // Changing the status of the find operation.
+                setFoundResource(true);
+
+                // Interrupt the sleep thread.
+                if (null != sleepThreadHandle && sleepThreadHandle.isAlive()) {
+                    sleepThreadHandle.interrupt();
+                }
+
+                // Update the tree viewer
+                Display.getDefault().asyncExec(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (!treeViewer.getControl().isDisposed()) {
+                            treeViewer.refresh();
+                        }
+
+                        if (!favTreeViewer.getControl().isDisposed()) {
+                            favTreeViewer.refresh();
+                        }
+
+                        // Close the find dialog
+                        if (null != findDialog) {
+                            boolean status = findDialog.close();
+                            System.out
+                                    .println("dialog close status: " + status);
+                        }
+
+                        // Close the refresh dialog
+                        if (null != refreshDialog) {
+                            boolean status = refreshDialog.close();
+                            System.out
+                                    .println("dialog close status: " + status);
+                        }
+                    }
+                });
+            }
+        };
+    }
+
+    @Override
+    public void createPartControl(Composite parent) {
+        Composite compContent = new Composite(parent, SWT.NONE);
+        compContent.setLayout(new GridLayout());
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        compContent.setLayoutData(gd);
+
+        Composite buttonComp = new Composite(compContent, SWT.NONE);
+        buttonComp.setLayout(new GridLayout(2, false));
+
+        gd = new GridData();
+        gd.horizontalAlignment = SWT.FILL;
+        gd.grabExcessHorizontalSpace = true;
+
+        buttonComp.setLayoutData(gd);
+
+        findResButton = new Button(buttonComp, SWT.PUSH);
+        findResButton.setText("Find Resources");
+        findResButton.setToolTipText("Find OIC resources");
+
+        gd = new GridData();
+        gd.widthHint = 130;
+        findResButton.setLayoutData(gd);
+
+        refreshButton = new Button(buttonComp, SWT.PUSH);
+        refreshButton.setText("Refresh");
+        refreshButton.setToolTipText("Restart the search once again");
+
+        gd = new GridData();
+        gd.widthHint = 90;
+        refreshButton.setLayoutData(gd);
+
+        // Create a Tab Folder.
+        folder = new CTabFolder(compContent, SWT.BORDER);
+        gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        folder.setLayoutData(gd);
+        folder.setSimple(false);
+        folder.setUnselectedCloseVisible(false);
+        folder.setUnselectedImageVisible(false);
+        folder.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                /*
+                 * CTabItem selectedTab = folder.getSelection(); if(selectedTab
+                 * == foundResTab) { System.out.println("Found resources tab");
+                 * } else { System.out.println("Favorite resources tab"); }
+                 */
+                // Tab is switched.
+                treeViewer.setSelection(null);
+                favTreeViewer.setSelection(null);
+                resourceManager.resourceSelectionChanged(null);
+            }
+        });
+
+        createFoundResourcesArea();
+
+        createFavoriteResourcesArea();
+
+        folder.setSelection(foundResTab);
+
+        findDialog = new MessageDialog(Display.getDefault().getActiveShell(),
+                "Finding Servers", null,
+                "Finding the requested servers\nPlease wait...",
+                MessageDialog.INFORMATION, new String[] { "Cancel" }, 0);
+        // findDialog.setBlockOnOpen(false);
+
+        refreshDialog = new MessageDialog(
+                Display.getDefault().getActiveShell(),
+                "Finding Servers",
+                null,
+                "Refreshing the search and finding the requested servers once again\nPlease wait...",
+                MessageDialog.INFORMATION, new String[] { "Cancel" }, 0);
+        // refreshDialog.setBlockOnOpen(false);
+
+        addUIListeners();
+
+        addManagerListeners();
+
+        // Setting the initial visibility of refresh based on the last known
+        // search operation.
+        Set<String> prevSearchTypes = resourceManager.getLastKnownSearchTypes();
+        if (null == prevSearchTypes || prevSearchTypes.size() < 1) {
+            refreshButton.setEnabled(false);
+        } else {
+            refreshButton.setEnabled(true);
+        }
+    }
+
+    private void createFoundResourcesArea() {
+        foundResTab = new CTabItem(folder, SWT.NULL);
+        foundResTab.setText("Found Resources");
+
+        // Create a group to show all the discovered resources.
+        // Adding the group to the folder.
+        Group resourceGroup = new Group(folder, SWT.NONE);
+        // resourceGroup.setText("Discovered Resources");
+
+        Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
+        resourceGroup.setBackground(color);
+
+        resourceGroup.setLayout(new GridLayout(1, false));
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        resourceGroup.setLayoutData(gd);
+
+        PatternFilter filter = new PatternFilter();
+        FilteredTree filteredTree = new FilteredTree(resourceGroup,
+                SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE, filter, true);
+        treeViewer = filteredTree.getViewer();
+        treeViewer.getTree().setLayoutData(
+                new GridData(SWT.FILL, SWT.FILL, true, true));
+        treeViewer.setContentProvider(new TreeContentProvider());
+        treeViewer.setLabelProvider(new TreeLabelProvider());
+        treeViewer.setInput(new Object());
+
+        addMenuToFoundResources();
+
+        foundResTab.setControl(resourceGroup);
+    }
+
+    private void addMenuToFoundResources() {
+
+        if (null != treeViewer) {
+            final Tree resourceTreeHead = treeViewer.getTree();
+            if (null != resourceTreeHead) {
+                // Below code creates menu entries and shows them on right
+                // clicking a resource
+                final Menu menu = new Menu(resourceTreeHead);
+                resourceTreeHead.setMenu(menu);
+                menu.addMenuListener(new MenuAdapter() {
+                    @Override
+                    public void menuShown(MenuEvent e) {
+                        // Clear existing menu items
+                        MenuItem[] items = menu.getItems();
+                        for (int index = 0; index < items.length; index++) {
+                            items[index].dispose();
+                        }
+                        MenuItem uploadRAMLItem = new MenuItem(menu, SWT.NONE);
+                        uploadRAMLItem.setText("Upload RAML Configuration");
+                        uploadRAMLItem
+                                .addSelectionListener(new SelectionAdapter() {
+                                    @Override
+                                    public void widgetSelected(SelectionEvent e) {
+                                        // Open the RAML configuration dialog if
+                                        // RAML file is not yet uploaded for the
+                                        // currently selected resource
+                                        RemoteResource resource = resourceManager
+                                                .getCurrentResourceInSelection();
+                                        if (null == resource) {
+                                            return;
+                                        }
+                                        if (!resource.isConfigUploaded()) {
+                                            // Open the dialog in a separate
+                                            // UI thread.
+                                            PlatformUI.getWorkbench()
+                                                    .getDisplay()
+                                                    .syncExec(new Thread() {
+                                                        @Override
+                                                        public void run() {
+                                                            LoadRAMLDialog ramlDialog = new LoadRAMLDialog(
+                                                                    Display.getDefault()
+                                                                            .getActiveShell());
+                                                            if (ramlDialog
+                                                                    .open() != Window.OK) {
+                                                                return;
+                                                            }
+                                                            String configFilePath = ramlDialog
+                                                                    .getConfigFilePath();
+                                                            if (null == configFilePath
+                                                                    || configFilePath
+                                                                            .length() < 1) {
+                                                                MessageDialog
+                                                                        .openInformation(
+                                                                                Display.getDefault()
+                                                                                        .getActiveShell(),
+                                                                                "Invalid RAML Config path",
+                                                                                "Configuration file path is invalid.");
+                                                                return;
+                                                            }
+                                                            resourceManager
+                                                                    .setConfigFilePath(
+                                                                            resourceManager
+                                                                                    .getCurrentResourceInSelection(),
+                                                                            configFilePath);
+                                                        }
+                                                    });
+                                        } else {
+                                            MessageDialog
+                                                    .openInformation(Display
+                                                            .getDefault()
+                                                            .getActiveShell(),
+                                                            "Already Uploaded",
+                                                            "Configuration file for the selected resource is already uploaded");
+                                        }
+                                    }
+                                });
+
+                        RemoteResource resource = resourceManager
+                                .getCurrentResourceInSelection();
+                        if (null == resource) {
+                            return;
+                        }
+                        String menuText = !resource.isFavorite() ? "Add to favorites"
+                                : "Remove from favorites";
+                        MenuItem addToFavMenuItem = new MenuItem(menu, SWT.NONE);
+                        addToFavMenuItem.setText(menuText);
+                        addToFavMenuItem
+                                .addSelectionListener(new SelectionAdapter() {
+                                    @Override
+                                    public void widgetSelected(SelectionEvent e) {
+                                        RemoteResource resource = (RemoteResource) ((IStructuredSelection) treeViewer
+                                                .getSelection())
+                                                .getFirstElement();
+                                        if (null == resource) {
+                                            return;
+                                        }
+                                        System.out.println("Selected resource:"
+                                                + resource.getResourceURI());
+                                        if (!resource.isFavorite()) {
+                                            resourceManager
+                                                    .addResourcetoFavorites(resource);
+                                        } else {
+                                            resourceManager
+                                                    .removeResourceFromFavorites(resource);
+                                            resourceManager
+                                                    .removeResourceURIFromFavorites(resource);
+                                        }
+                                        favTreeViewer.refresh();
+                                    }
+                                });
+                    }
+                });
+            }
+        }
+    }
+
+    private void createFavoriteResourcesArea() {
+        favResTab = new CTabItem(folder, SWT.NULL);
+        favResTab.setText("Favorite Resources");
+
+        // Create a group to show all the discovered resources.
+        // Adding the group to the folder.
+        Group resourceGroup = new Group(folder, SWT.NONE);
+        // resourceGroup.setText("Discovered Resources");
+
+        Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
+        resourceGroup.setBackground(color);
+
+        resourceGroup.setLayout(new GridLayout(1, false));
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        resourceGroup.setLayoutData(gd);
+
+        PatternFilter filter = new PatternFilter();
+        FilteredTree filteredTree = new FilteredTree(resourceGroup,
+                SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE, filter, true);
+        favTreeViewer = filteredTree.getViewer();
+        favTreeViewer.getTree().setLayoutData(
+                new GridData(SWT.FILL, SWT.FILL, true, true));
+        favTreeViewer.setContentProvider(new FavTreeContentProvider());
+        favTreeViewer.setLabelProvider(new TreeLabelProvider());
+        favTreeViewer.setInput(new Object());
+
+        favResTab.setControl(resourceGroup);
+
+        addMenuToFavResources();
+    }
+
+    private void addMenuToFavResources() {
+        if (null != favTreeViewer) {
+            final Tree resourceTreeHead = favTreeViewer.getTree();
+            if (null != resourceTreeHead) {
+                // Below code creates menu entries and shows them on right
+                // clicking a resource
+                final Menu menu = new Menu(resourceTreeHead);
+                resourceTreeHead.setMenu(menu);
+                menu.addMenuListener(new MenuAdapter() {
+                    @Override
+                    public void menuShown(MenuEvent e) {
+                        // Clear existing menu items
+                        MenuItem[] items = menu.getItems();
+                        for (int index = 0; index < items.length; index++) {
+                            items[index].dispose();
+                        }
+                        MenuItem addToFavMenuItem = new MenuItem(menu, SWT.NONE);
+                        addToFavMenuItem.setText("Remove from favorites");
+                        addToFavMenuItem
+                                .addSelectionListener(new SelectionAdapter() {
+                                    @Override
+                                    public void widgetSelected(SelectionEvent e) {
+                                        RemoteResource resource = (RemoteResource) ((IStructuredSelection) favTreeViewer
+                                                .getSelection())
+                                                .getFirstElement();
+                                        if (null == resource) {
+                                            return;
+                                        }
+                                        resourceManager
+                                                .removeResourceFromFavorites(resource);
+                                        resourceManager
+                                                .removeResourceURIFromFavorites(resource);
+                                        favTreeViewer.refresh();
+                                    }
+                                });
+                    }
+                });
+            }
+        }
+    }
+
+    private void addUIListeners() {
+        findResButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        FindResourceWizard findWizard = new FindResourceWizard();
+                        ResourceWizardDialog wizardDialog = new ResourceWizardDialog(
+                                PlatformUI.getWorkbench().getDisplay()
+                                        .getActiveShell(), findWizard);
+                        int open = wizardDialog.open();
+                        if (open == WizardDialog.OK) {
+                            // Setting initial value on starting the find
+                            // operation.
+                            setFoundResource(false);
+
+                            Set<String> searchTypes = findWizard
+                                    .getSearchTypes();
+                            System.out.println(searchTypes);
+                            // Call native method to clear existing resources of
+                            // the given search types.
+                            resourceManager.deleteResources(searchTypes);
+
+                            // Update the tree
+                            treeViewer.refresh();
+                            favTreeViewer.refresh();
+
+                            // Call native method to find Resources
+                            boolean result = resourceManager
+                                    .findResourceRequest(searchTypes);
+                            if (result) {
+                                searchUIOperation(false);
+                            } else {
+                                MessageDialog
+                                        .openError(Display.getDefault()
+                                                .getActiveShell(),
+                                                "Find Resource status",
+                                                "Operation failed due to some problems in core layer.");
+                            }
+
+                            // Store this information for refresh functionality
+                            resourceManager
+                                    .setLastKnownSearchTypes(searchTypes);
+
+                            // Change the refresh visibility
+                            refreshButton.setEnabled(true);
+                        }
+                    }
+                });
+            }
+        });
+
+        refreshButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                Set<String> searchTypes = resourceManager
+                        .getLastKnownSearchTypes();
+                if (null == searchTypes) {
+                    return;
+                }
+                setFoundResource(false);
+
+                // Call native method to clear existing resources of the given
+                // search types.
+                resourceManager.deleteResources(searchTypes);
+
+                // Update the tree
+                treeViewer.refresh();
+                favTreeViewer.refresh();
+
+                // Call native method to find Resources
+                boolean result = resourceManager
+                        .findResourceRequest(searchTypes);
+                if (result) {
+                    searchUIOperation(true);
+                } else {
+                    MessageDialog
+                            .openError(Display.getDefault().getActiveShell(),
+                                    "Find Resource status",
+                                    "Operation failed due to some problems in core layer.");
+                }
+            }
+        });
+
+        // Below code adds a listener to the tree for selection changes
+        // and notifies the resource manager
+        ISelectionChangedListener treeSelectionListener = new ISelectionChangedListener() {
+
+            @Override
+            public void selectionChanged(SelectionChangedEvent e) {
+                if (e.getSelection().isEmpty()) {
+                    return;
+                }
+                if (e.getSelection() instanceof IStructuredSelection) {
+                    IStructuredSelection selection = (IStructuredSelection) e
+                            .getSelection();
+                    RemoteResource resource = (RemoteResource) selection
+                            .getFirstElement();
+                    if (null == resource) {
+                        return;
+                    }
+                    System.out.println("Selected resource: "
+                            + resource.getResourceURI());
+                    resourceManager.resourceSelectionChanged(resource);
+                }
+            }
+        };
+
+        treeViewer.addSelectionChangedListener(treeSelectionListener);
+        favTreeViewer.addSelectionChangedListener(treeSelectionListener);
+    }
+
+    // If refresh is true, then Refresh Dialog else Find Dialog will be shown.
+    private void searchUIOperation(boolean refresh) {
+        final MessageDialog targetDialog;
+        if (refresh) {
+            targetDialog = refreshDialog;
+        } else {
+            targetDialog = findDialog;
+        }
+        // Open the dialog in a new thread.
+        PlatformUI.getWorkbench().getDisplay().syncExec(new Thread() {
+
+            @Override
+            public void run() {
+                if (isFoundResource()) {
+                    setFoundResource(false);
+                    return;
+                }
+
+                PlatformUI.getWorkbench().getDisplay().asyncExec(new Thread() {
+                    @Override
+                    public void run() {
+                        targetDialog.open(); // This method returns once the
+                        // cancel button is pressed.
+
+                        // Interrupt the sleep thread.
+                        if (null != sleepThreadHandle
+                                && sleepThreadHandle.isAlive()) {
+                            sleepThreadHandle.interrupt();
+                        }
+
+                        // Set the status of find.
+                        setFoundResource(false);
+                    }
+                });
+
+                // Thread for find time-out.
+                sleepThreadHandle = new Thread() {
+                    Thread child;
+
+                    public void run() {
+                        try {
+                            Thread.sleep(Constants.FIND_RESOURCES_TIMEOUT * 1000);
+                        } catch (InterruptedException e) {
+                            System.out.println("Interrupted during sleep.");
+                            return;
+                        }
+
+                        child = new Thread() {
+                            @Override
+                            public void run() {
+                                if (null != targetDialog) {
+                                    targetDialog.close();
+
+                                    // Check if any new resources are
+                                    // discovered.
+                                    // Is no new resources, then display a
+                                    // message box.
+                                    if (!isFoundResource()) {
+                                        MessageDialog
+                                                .openInformation(
+                                                        Display.getDefault()
+                                                                .getActiveShell(),
+                                                        "No servers found",
+                                                        "No servers are available as of now.\n"
+                                                                + "Please check the servers' status and press"
+                                                                + "'Refresh' button to restart the search.");
+                                    } else {
+                                        // Resetting the status to false for
+                                        // ensuring safety.
+                                        setFoundResource(false);
+                                    }
+                                }
+                            }
+                        };
+
+                        PlatformUI.getWorkbench().getDisplay().syncExec(child);
+                    }
+                };
+                sleepThreadHandle.start();
+            }
+        });
+    }
+
+    private void addManagerListeners() {
+        resourceManager.addFindresourceUIListener(findListener);
+    }
+
+    @Override
+    public void dispose() {
+        // Unregister the listener
+        if (null != findListener) {
+            resourceManager.removeFindresourceUIListener(findListener);
+            resourceManager.resourceSelectionChanged(null);
+        }
+        super.dispose();
+    }
+
+    @Override
+    public void setFocus() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public synchronized void setFoundResource(boolean value) {
+        foundResource = value;
+    }
+
+    public synchronized boolean isFoundResource() {
+        return foundResource;
+    }
+}
+
+class TreeContentProvider implements ITreeContentProvider {
+
+    @Override
+    public void dispose() {
+    }
+
+    @Override
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+    }
+
+    @Override
+    public Object[] getChildren(Object parent) {
+        return null;
+    }
+
+    @Override
+    public Object[] getElements(Object parent) {
+        System.out.println("Inside getElements()");
+        List<RemoteResource> resourceList = Activator.getDefault()
+                .getResourceManager().getResourceList();
+        return resourceList.toArray();
+    }
+
+    @Override
+    public Object getParent(Object child) {
+        return null;
+    }
+
+    @Override
+    public boolean hasChildren(Object parent) {
+        return false;
+    }
+
+}
+
+class FavTreeContentProvider implements ITreeContentProvider {
+
+    @Override
+    public void dispose() {
+    }
+
+    @Override
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+    }
+
+    @Override
+    public Object[] getChildren(Object parent) {
+        return null;
+    }
+
+    @Override
+    public Object[] getElements(Object parent) {
+        System.out.println("Inside getElements()");
+        List<RemoteResource> resourceList = Activator.getDefault()
+                .getResourceManager().getFavResourceList();
+        return resourceList.toArray();
+    }
+
+    @Override
+    public Object getParent(Object child) {
+        return null;
+    }
+
+    @Override
+    public boolean hasChildren(Object parent) {
+        return false;
+    }
+
+}
+
+class TreeLabelProvider extends LabelProvider {
+    @Override
+    public String getText(Object element) {
+        RemoteResource resource = (RemoteResource) element;
+        return resource.getResourceURI();
+    }
+
+    @Override
+    public Image getImage(Object element) {
+        RemoteResource resource = (RemoteResource) element;
+        ResourceManager resourceManager = Activator.getDefault()
+                .getResourceManager();
+        return resourceManager.getImage(resource.getResourceURI());
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FilterDialog.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FilterDialog.java
new file mode 100644 (file)
index 0000000..c9626e2
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Map;
+
+import oic.simulator.clientcontroller.manager.LogManager;
+
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This class shows a dialog for filtering logs based on severity levels.
+ */
+public class FilterDialog extends TrayDialog {
+    private Map<Integer, Boolean> severities;
+
+    public FilterDialog(Shell shell, Map<Integer, Boolean> severities) {
+        super(shell);
+        this.severities = severities;
+    }
+
+    @Override
+    protected void configureShell(Shell shell) {
+        super.configureShell(shell);
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite composite = (Composite) super.createDialogArea(parent);
+        createSeverityGroup(composite);
+        getShell().setText("Filter details");
+        return composite;
+    }
+
+    /**
+     * Dynamically creates a check-box list for severity levels for user to
+     * choose from
+     */
+    private void createSeverityGroup(Composite parent) {
+        Group group = new Group(parent, SWT.NONE);
+        group.setLayout(new GridLayout());
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.widthHint = 275;
+        group.setLayoutData(gd);
+        group.setText("Severity Levels");
+
+        ArrayList<Integer> arrayList = new ArrayList<Integer>(
+                severities.keySet());
+        Collections.sort(arrayList);
+        for (final Integer i : arrayList) {
+            final Button checkbox = new Button(group, SWT.CHECK);
+            checkbox.setText(LogManager.getSeverityName(i));
+            checkbox.setSelection(severities.get(i));
+            checkbox.addSelectionListener(new SelectionAdapter() {
+
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    severities.put(i, checkbox.getSelection());
+                }
+            });
+        }
+    }
+
+    @Override
+    public boolean isHelpAvailable() {
+        return false;
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FindResourcePage.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FindResourcePage.java
new file mode 100644 (file)
index 0000000..cba84d9
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import oic.simulator.clientcontroller.utils.Constants;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This class shows UI for finding resources.
+ */
+public class FindResourcePage extends WizardPage {
+
+    private Button      stdResTypeRbtn;
+    private CCombo      resourceTypeCmb;
+    private Button      cusResTypeRbtn;
+    private Text        resTypeTxt;
+    private Label       stdRTypeLbl;
+    private Label       cusRTypeLbl;
+
+    private Set<String> typesToSearch;
+
+    private String      dummyRType;
+
+    protected FindResourcePage() {
+        super("Find Resource");
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        setPageComplete(false);
+        setTitle(Constants.FIND_PAGE_TITLE);
+        setMessage(Constants.FIND_PAGE_MESSAGE);
+
+        Composite compContent = new Composite(parent, SWT.NONE);
+        GridLayout gridLayout = new GridLayout();
+        compContent.setLayout(gridLayout);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        compContent.setLayoutData(gd);
+
+        Group configGroup = new Group(compContent, SWT.NONE);
+        gridLayout = new GridLayout(1, false);
+        gridLayout.verticalSpacing = 10;
+        gridLayout.marginTop = 5;
+        configGroup.setLayout(gridLayout);
+        gd = new GridData();
+        gd.horizontalAlignment = SWT.FILL;
+        gd.grabExcessHorizontalSpace = true;
+        configGroup.setLayoutData(gd);
+        configGroup.setText("Resource Type");
+
+        stdResTypeRbtn = new Button(configGroup, SWT.RADIO);
+        stdResTypeRbtn.setText("Standard OIC Resources");
+
+        Composite stdConfigComp = new Composite(configGroup, SWT.NONE);
+        stdConfigComp.setLayout(new GridLayout(2, false));
+        gd = new GridData();
+        gd.horizontalAlignment = SWT.FILL;
+        gd.grabExcessHorizontalSpace = true;
+        stdConfigComp.setLayoutData(gd);
+
+        stdRTypeLbl = new Label(stdConfigComp, SWT.NONE);
+        stdRTypeLbl.setText("ResourceType:");
+        stdRTypeLbl.setEnabled(false);
+
+        resourceTypeCmb = new CCombo(stdConfigComp, SWT.READ_ONLY | SWT.BORDER);
+        gd = new GridData();
+        gd.widthHint = 150;
+        resourceTypeCmb.setLayoutData(gd);
+        resourceTypeCmb.setEnabled(false);
+
+        cusResTypeRbtn = new Button(configGroup, SWT.RADIO);
+        cusResTypeRbtn.setText("Custom Resources");
+
+        Composite cusConfigComp = new Composite(configGroup, SWT.NONE);
+        cusConfigComp.setLayout(new GridLayout(2, false));
+        gd = new GridData();
+        gd.horizontalAlignment = SWT.FILL;
+        gd.grabExcessHorizontalSpace = true;
+        cusConfigComp.setLayoutData(gd);
+
+        cusRTypeLbl = new Label(cusConfigComp, SWT.NONE);
+        cusRTypeLbl.setText("Enter ResourceType:");
+        cusRTypeLbl.setEnabled(false);
+
+        resTypeTxt = new Text(cusConfigComp, SWT.BORDER);
+        gd = new GridData();
+        gd.minimumWidth = 200;
+        gd.horizontalAlignment = SWT.FILL;
+        gd.grabExcessHorizontalSpace = true;
+        resTypeTxt.setLayoutData(gd);
+        resTypeTxt.setEnabled(false);
+
+        populateDataInUI();
+
+        addUIListeners();
+
+        setControl(compContent);
+    }
+
+    private void populateDataInUI() {
+        // Populate Standard resource-types in Combo
+        populateResourceTypeCombo();
+    }
+
+    private void populateResourceTypeCombo() {
+        /*
+         * List<String> configList; configList =
+         * Activator.getDefault().getManager().getResourceConfigurationList();
+         * if(null != configList) { Iterator<String> itr =
+         * configList.iterator(); while(itr.hasNext()) {
+         * resourceTypeCmb.add(itr.next()); } }
+         */
+
+        // TODO: Temporarily adding a resourceType for testing
+        resourceTypeCmb.add("oic.r.light");
+
+        // By default, selecting the first item in the resourceType combo
+        if (resourceTypeCmb.getItemCount() > 0) {
+            resourceTypeCmb.select(0);
+            // TODO: Get the RAML configuration file path of the selected
+            // resource
+            // configFilePath =
+            // Activator.getManager().getConfigFilePath(resourceTypeCmb.getItem(0));
+        }
+    }
+
+    private void addUIListeners() {
+        stdResTypeRbtn.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                // Clear the existing items from the search list
+                if (null != typesToSearch)
+                    typesToSearch.clear();
+
+                // Set the configFilePath to the first item in the combo
+                if (resourceTypeCmb.getItemCount() > 0) {
+                    resourceTypeCmb.select(0);
+                    addSearchType(resourceTypeCmb.getText());
+                }
+
+                setPageComplete(isSelectionDone());
+
+                // Change the visibility of widgets
+                changeVisibility(true);
+            }
+        });
+
+        cusResTypeRbtn.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                // Clear the existing items from the search list
+                if (null != typesToSearch)
+                    typesToSearch.clear();
+
+                addSearchType(resTypeTxt.getText());
+
+                setPageComplete(isSelectionDone());
+
+                // Change the visibility of widgets
+                changeVisibility(false);
+
+                resTypeTxt.setFocus();
+            }
+        });
+
+        resourceTypeCmb.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                int index = resourceTypeCmb.getSelectionIndex();
+                if (index < 0) {
+                    return;
+                }
+                String resourceType = resourceTypeCmb.getItem(index);
+                addSearchType(resourceType);
+                setPageComplete(isSelectionDone());
+            }
+        });
+
+        resTypeTxt.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                String resourceType = resTypeTxt.getText();
+                if (null != dummyRType) {
+                    removeSearchType(dummyRType);
+                }
+                dummyRType = resourceType;
+                addSearchType(resourceType);
+                setPageComplete(isSelectionDone());
+            }
+        });
+    }
+
+    private void changeVisibility(boolean standard) {
+        stdRTypeLbl.setEnabled(standard);
+        resourceTypeCmb.setEnabled(standard);
+        cusRTypeLbl.setEnabled(!standard);
+        resTypeTxt.setEnabled(!standard);
+    }
+
+    private boolean isSelectionDone() {
+        if (null == typesToSearch || typesToSearch.size() < 1) {
+            return false;
+        }
+        return true;
+    }
+
+    private void addSearchType(String resourceType) {
+        if (null == resourceType)
+            return;
+        resourceType = resourceType.trim();
+        if (resourceType.length() < 1) {
+            return;
+        }
+        if (null == typesToSearch) {
+            typesToSearch = new HashSet<String>();
+        }
+        typesToSearch.add(resourceType);
+    }
+
+    private void removeSearchType(String resourceType) {
+        if (null == resourceType || null == typesToSearch)
+            return;
+        resourceType = resourceType.trim();
+        if (resourceType.length() < 1) {
+            return;
+        }
+        typesToSearch.remove(resourceType);
+    }
+
+    public Set<String> getSearchTypes() {
+        return typesToSearch;
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FindResourceWizard.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/FindResourceWizard.java
new file mode 100644 (file)
index 0000000..1463b17
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import java.net.URL;
+import java.util.Set;
+
+import oic.simulator.clientcontroller.Activator;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * This class creates a UI wizard for find resource operation.
+ */
+public class FindResourceWizard extends Wizard {
+    private FindResourcePage page;
+
+    public FindResourceWizard() {
+        setWindowTitle("Find resources");
+        IPath path = new Path("/icons/oic_logo_64x64.png");
+        URL find = FileLocator.find(Activator.getDefault().getBundle(), path,
+                null);
+        setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(find));
+    }
+
+    public Set<String> getSearchTypes() {
+        return page.getSearchTypes();
+    }
+
+    @Override
+    public void addPages() {
+        page = new FindResourcePage();
+        addPage(page);
+    }
+
+    @Override
+    public boolean performFinish() {
+        return true;
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/LoadRAMLDialog.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/LoadRAMLDialog.java
new file mode 100644 (file)
index 0000000..d19e1d4
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import oic.simulator.clientcontroller.utils.Constants;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This dialog is used for loading the RAML file.
+ */
+public class LoadRAMLDialog extends TitleAreaDialog {
+
+    private Text   locationTxt;
+    private Button btnBrowse;
+    private String configFilePath;
+
+    public LoadRAMLDialog(Shell parentShell) {
+        super(parentShell);
+    }
+
+    @Override
+    public void create() {
+        super.create();
+        setTitle("Load Remote Resource Configuration");
+        setMessage("Select the RAML Configuration file of the resource to enable Automation.");
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite compLayout = (Composite) super.createDialogArea(parent);
+        Composite container = new Composite(compLayout, SWT.NONE);
+        container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        GridLayout layout = new GridLayout(3, false);
+        layout.verticalSpacing = 10;
+        layout.marginTop = 10;
+        container.setLayout(layout);
+
+        Label loadRamlLbl = new Label(container, SWT.NONE);
+        loadRamlLbl.setText("Load RAML File");
+        GridData gd;
+        gd = new GridData();
+        gd.horizontalSpan = 3;
+        loadRamlLbl.setLayoutData(gd);
+
+        Label locationLbl = new Label(container, SWT.NONE);
+        locationLbl.setText("Location:");
+
+        locationTxt = new Text(container, SWT.BORDER);
+        gd = new GridData();
+        gd.minimumWidth = 300;
+        gd.horizontalAlignment = SWT.FILL;
+        gd.grabExcessHorizontalSpace = true;
+        locationTxt.setLayoutData(gd);
+
+        btnBrowse = new Button(container, SWT.NONE);
+        btnBrowse.setText("Browse");
+        gd = new GridData();
+        gd.widthHint = 80;
+        gd.horizontalAlignment = SWT.FILL;
+        btnBrowse.setLayoutData(gd);
+
+        addUIListeners();
+
+        return compLayout;
+    }
+
+    private void addUIListeners() {
+        btnBrowse.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                FileDialog fileDialog = new FileDialog(PlatformUI
+                        .getWorkbench().getDisplay().getActiveShell(), SWT.NONE);
+                fileDialog
+                        .setFilterExtensions(Constants.BROWSE_RAML_FILTER_EXTENSIONS);
+                configFilePath = fileDialog.open();
+                if (null == configFilePath) {
+                    System.out.println("Config file path is null");
+                    configFilePath = "";
+                }
+                locationTxt.setText(configFilePath);
+            }
+        });
+    }
+
+    public String getConfigFilePath() {
+        return configFilePath;
+    }
+
+    @Override
+    public boolean isHelpAvailable() {
+        return false;
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/LogDetailsDialog.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/LogDetailsDialog.java
new file mode 100644 (file)
index 0000000..12d0c59
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This class shows detailed information about a log. The dialog will be opened
+ * on double-clicking a log entry in the log view.
+ */
+public class LogDetailsDialog extends Dialog {
+    private final String severity;
+    private final Date   date;
+    private final String message;
+    private final Image  severityIcon;
+
+    public LogDetailsDialog(Shell parentShell, String severity,
+            Image severityIcon, Date date, String message) {
+        super(parentShell);
+        this.severity = severity;
+        this.severityIcon = severityIcon;
+        this.message = message;
+        this.date = date;
+    }
+
+    @Override
+    protected boolean isResizable() {
+        return true;
+    }
+
+    @Override
+    protected void configureShell(Shell shell) {
+        super.configureShell(shell);
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        getShell().setText("Logged event details");
+
+        Composite container = (Composite) super.createDialogArea(parent);
+
+        GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+        container.setLayoutData(layoutData);
+        container.setLayout(new GridLayout(2, false));
+
+        GridData gd;
+
+        Label l1 = new Label(container, SWT.NONE);
+        l1.setText("Severity:");
+        gd = new GridData();
+        gd.widthHint = 100;
+        l1.setLayoutData(gd);
+
+        Composite y = new Composite(container, SWT.NONE);
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        y.setLayoutData(gd);
+        y.setLayout(new RowLayout(SWT.HORIZONTAL));
+
+        Label l2 = new Label(y, SWT.NONE);
+        l2.setImage(severityIcon);
+        l2.setLayoutData(new RowData());
+        Label l3 = new Label(y, SWT.NONE);
+        l3.setText(severity);
+        l3.setLayoutData(new RowData());
+
+        Label l4 = new Label(container, SWT.NONE);
+        l4.setText("Date:");
+        gd = new GridData();
+        gd.widthHint = 100;
+        l4.setLayoutData(gd);
+
+        Label l5 = new Label(container, SWT.NONE);
+        DateFormat dateFormat = DateFormat.getDateTimeInstance(
+                DateFormat.SHORT, DateFormat.SHORT);
+        l5.setText(dateFormat.format(date));
+        gd = new GridData();
+        gd.grabExcessHorizontalSpace = true;
+        l5.setLayoutData(gd);
+
+        new Label(container, SWT.NONE); // separator
+
+        Label l6 = new Label(container, SWT.NONE);
+        l6.setText("Message details");
+        gd = new GridData();
+        gd.horizontalSpan = 2;
+        l6.setLayoutData(gd);
+
+        Text text = new Text(container, SWT.MULTI | SWT.READ_ONLY
+                | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+        if (message != null) {
+            text.setText(message);
+        } else {
+            text.setText("No description available");
+        }
+        gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+        gd.horizontalSpan = 2;
+        gd.heightHint = 350;
+        gd.widthHint = 500;
+        text.setLayoutData(gd);
+
+        return container;
+    }
+
+    @Override
+    protected Button createButton(Composite parent, int id, String label,
+            boolean defaultButton) {
+        if (id == IDialogConstants.CANCEL_ID) {
+            return null;
+        }
+        return super.createButton(parent, id, label, defaultButton);
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PostRequestDialog.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PostRequestDialog.java
new file mode 100644 (file)
index 0000000..3b01cff
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import java.util.List;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.manager.ResourceManager;
+import oic.simulator.clientcontroller.remoteresource.PutPostAttributeModel;
+import oic.simulator.clientcontroller.utils.Constants;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+
+/**
+ * This dialog is used for generating a POST request.
+ */
+public class PostRequestDialog extends TitleAreaDialog {
+
+    private TableViewer                 attTblViewer;
+
+    private final String[]              attTblHeaders  = { "Name", "Value",
+            "Select"                                  };
+    private final Integer[]             attTblColWidth = { 200, 200, 50 };
+
+    private ResourceManager             resourceManager;
+
+    private List<PutPostAttributeModel> modelList      = null;
+
+    public PostRequestDialog(Shell parentShell,
+            List<PutPostAttributeModel> modelList) {
+        super(parentShell);
+        this.modelList = modelList;
+        resourceManager = Activator.getDefault().getResourceManager();
+    }
+
+    @Override
+    public void create() {
+        super.create();
+        setTitle("Generate POST Request");
+        setMessage("Dialog which takes input and generates a post request.");
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite compLayout = (Composite) super.createDialogArea(parent);
+        Composite container = new Composite(compLayout, SWT.NONE);
+        container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        GridLayout layout = new GridLayout(1, false);
+        layout.verticalSpacing = 10;
+        layout.marginTop = 10;
+        container.setLayout(layout);
+
+        createTableViewer(container);
+
+        attTblViewer.setInput(modelList.toArray());
+
+        return compLayout;
+    }
+
+    private void createTableViewer(Composite parent) {
+        attTblViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
+                | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+        createAttributeColumns(attTblViewer);
+
+        // make lines and header visible
+        Table table = attTblViewer.getTable();
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        attTblViewer.setContentProvider(new AttributeContentProvider());
+    }
+
+    public void createAttributeColumns(TableViewer tableViewer) {
+
+        // attributeEditor = new AttributeEditingSupport();
+
+        TableViewerColumn attName = new TableViewerColumn(tableViewer, SWT.NONE);
+        attName.getColumn().setWidth(attTblColWidth[0]);
+        attName.getColumn().setText(attTblHeaders[0]);
+        attName.setLabelProvider(new StyledCellLabelProvider() {
+            @Override
+            public void update(ViewerCell cell) {
+                Object element = cell.getElement();
+                if (element instanceof PutPostAttributeModel) {
+                    PutPostAttributeModel entry = (PutPostAttributeModel) element;
+                    cell.setText(entry.getAttName());
+                }
+            }
+        });
+
+        TableViewerColumn attValue = new TableViewerColumn(tableViewer,
+                SWT.NONE);
+        attValue.getColumn().setWidth(attTblColWidth[1]);
+        attValue.getColumn().setText(attTblHeaders[1]);
+        attValue.setLabelProvider(new StyledCellLabelProvider() {
+            @Override
+            public void update(ViewerCell cell) {
+                Object element = cell.getElement();
+                if (element instanceof PutPostAttributeModel) {
+                    PutPostAttributeModel entry = (PutPostAttributeModel) element;
+                    cell.setText(entry.getAttValue());
+                }
+            }
+        });
+        attValue.setEditingSupport(new AttributeValueEditor(attTblViewer));
+
+        TableViewerColumn updateColumn = new TableViewerColumn(tableViewer,
+                SWT.NONE);
+        updateColumn.getColumn().setWidth(attTblColWidth[2]);
+        updateColumn.getColumn().setText(attTblHeaders[2]);
+        updateColumn.setLabelProvider(new ColumnLabelProvider() {
+            @Override
+            public String getText(Object element) {
+                return "";
+            }
+
+            @Override
+            public Image getImage(Object element) {
+                PutPostAttributeModel model = (PutPostAttributeModel) element;
+                if (model.isModified()) {
+                    return Activator.getDefault().getImageRegistry()
+                            .get(Constants.CHECKED);
+                }
+                return Activator.getDefault().getImageRegistry()
+                        .get(Constants.UNCHECKED);
+            }
+        });
+        updateColumn.setEditingSupport(new UpdateEditor(attTblViewer));
+    }
+
+    @Override
+    protected boolean isResizable() {
+        return true;
+    }
+
+    @Override
+    public boolean isHelpAvailable() {
+        return false;
+    }
+
+    @Override
+    protected Button createButton(Composite parent, int id, String label,
+            boolean defaultButton) {
+        if (id == IDialogConstants.OK_ID) {
+            label = "POST";
+        }
+        return super.createButton(parent, id, label, defaultButton);
+    }
+
+    class AttributeContentProvider implements IStructuredContentProvider {
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+        }
+
+        @Override
+        public Object[] getElements(Object element) {
+            return (Object[]) element;
+        }
+
+    }
+
+    class AttributeValueEditor extends EditingSupport {
+        private final TableViewer viewer;
+        private final CellEditor  editor;
+
+        public AttributeValueEditor(TableViewer viewer) {
+            super(viewer);
+            this.viewer = viewer;
+            editor = new TextCellEditor(viewer.getTable());
+        }
+
+        @Override
+        protected boolean canEdit(Object arg0) {
+            return true;
+        }
+
+        @Override
+        protected CellEditor getCellEditor(Object element) {
+            return editor;
+        }
+
+        @Override
+        protected Object getValue(Object element) {
+            PutPostAttributeModel model = (PutPostAttributeModel) element;
+            return model.getAttValue();
+        }
+
+        @Override
+        protected void setValue(Object element, Object value) {
+            PutPostAttributeModel model = (PutPostAttributeModel) element;
+            // Compare the actual value and the new value
+            // If there is a change, then its corresponding check box should be
+            // checked.
+            String newValue = String.valueOf(value);
+            String actualValue = resourceManager.getAttributeValue(
+                    resourceManager.getCurrentResourceInSelection(),
+                    model.getAttName());
+            if (newValue.equals(actualValue)) {
+                model.setModified(false);
+            } else {
+                model.setModified(true);
+            }
+            model.setAttValue(newValue);
+            viewer.update(element, null);
+        }
+    }
+
+    class UpdateEditor extends EditingSupport {
+
+        private final TableViewer viewer;
+
+        public UpdateEditor(TableViewer viewer) {
+            super(viewer);
+            this.viewer = viewer;
+        }
+
+        @Override
+        protected boolean canEdit(Object arg0) {
+            return true;
+        }
+
+        @Override
+        protected CellEditor getCellEditor(Object element) {
+            return new CheckboxCellEditor(null, SWT.CHECK | SWT.READ_ONLY);
+        }
+
+        @Override
+        protected Object getValue(Object element) {
+            PutPostAttributeModel model = (PutPostAttributeModel) element;
+            return model.isModified();
+        }
+
+        @Override
+        protected void setValue(Object element, Object value) {
+            PutPostAttributeModel model = (PutPostAttributeModel) element;
+            boolean status = (boolean) value;
+            model.setModified(status);
+            viewer.update(element, null);
+        }
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PutRequestDialog.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PutRequestDialog.java
new file mode 100644 (file)
index 0000000..3ba0c87
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import java.util.List;
+
+import oic.simulator.clientcontroller.remoteresource.PutPostAttributeModel;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+
+/**
+ * This dialog is used for generating a PUT request.
+ */
+public class PutRequestDialog extends TitleAreaDialog {
+
+    private TableViewer                 attTblViewer;
+
+    private final String[]              attTblHeaders  = { "Name", "Value" };
+    private final Integer[]             attTblColWidth = { 200, 200 };
+
+    private List<PutPostAttributeModel> modelList      = null;
+
+    public PutRequestDialog(Shell parentShell,
+            List<PutPostAttributeModel> modelList) {
+        super(parentShell);
+        this.modelList = modelList;
+    }
+
+    @Override
+    public void create() {
+        super.create();
+        setTitle("Generate PUT Request");
+        setMessage("Dialog which takes input and generates a put request.");
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite compLayout = (Composite) super.createDialogArea(parent);
+        Composite container = new Composite(compLayout, SWT.NONE);
+        container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        GridLayout layout = new GridLayout(1, false);
+        layout.verticalSpacing = 10;
+        layout.marginTop = 10;
+        container.setLayout(layout);
+
+        createTableViewer(container);
+
+        attTblViewer.setInput(modelList.toArray());
+
+        return compLayout;
+    }
+
+    private void createTableViewer(Composite parent) {
+        attTblViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
+                | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+        createAttributeColumns(attTblViewer);
+
+        // make lines and header visible
+        Table table = attTblViewer.getTable();
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        attTblViewer.setContentProvider(new AttributeContentProvider());
+    }
+
+    public void createAttributeColumns(TableViewer tableViewer) {
+
+        TableViewerColumn attName = new TableViewerColumn(tableViewer, SWT.NONE);
+        attName.getColumn().setWidth(attTblColWidth[0]);
+        attName.getColumn().setText(attTblHeaders[0]);
+        attName.setLabelProvider(new StyledCellLabelProvider() {
+            @Override
+            public void update(ViewerCell cell) {
+                Object element = cell.getElement();
+                if (element instanceof PutPostAttributeModel) {
+                    PutPostAttributeModel entry = (PutPostAttributeModel) element;
+                    cell.setText(entry.getAttName());
+                }
+            }
+        });
+
+        TableViewerColumn attValue = new TableViewerColumn(tableViewer,
+                SWT.NONE);
+        attValue.getColumn().setWidth(attTblColWidth[1]);
+        attValue.getColumn().setText(attTblHeaders[1]);
+        attValue.setLabelProvider(new StyledCellLabelProvider() {
+            @Override
+            public void update(ViewerCell cell) {
+                Object element = cell.getElement();
+                if (element instanceof PutPostAttributeModel) {
+                    PutPostAttributeModel entry = (PutPostAttributeModel) element;
+                    cell.setText(entry.getAttValue());
+                }
+            }
+        });
+        attValue.setEditingSupport(new AttributeValueEditor(attTblViewer));
+    }
+
+    class AttributeContentProvider implements IStructuredContentProvider {
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+        }
+
+        @Override
+        public Object[] getElements(Object element) {
+            return (Object[]) element;
+        }
+    }
+
+    class AttributeValueEditor extends EditingSupport {
+        private final TableViewer viewer;
+        private final CellEditor  editor;
+
+        public AttributeValueEditor(TableViewer viewer) {
+            super(viewer);
+            this.viewer = viewer;
+            editor = new TextCellEditor(viewer.getTable());
+        }
+
+        @Override
+        protected boolean canEdit(Object arg0) {
+            return true;
+        }
+
+        @Override
+        protected CellEditor getCellEditor(Object element) {
+            return editor;
+        }
+
+        @Override
+        protected Object getValue(Object element) {
+            PutPostAttributeModel model = (PutPostAttributeModel) element;
+            return model.getAttValue();
+        }
+
+        @Override
+        protected void setValue(Object element, Object value) {
+            PutPostAttributeModel model = (PutPostAttributeModel) element;
+            model.setAttValue(String.valueOf(value));
+            viewer.update(element, null);
+        }
+    }
+
+    public List<PutPostAttributeModel> getUpdatedModel() {
+        return modelList;
+    }
+
+    @Override
+    protected boolean isResizable() {
+        return true;
+    }
+
+    @Override
+    public boolean isHelpAvailable() {
+        return false;
+    }
+
+    @Override
+    protected Button createButton(Composite parent, int id, String label,
+            boolean defaultButton) {
+        if (id == IDialogConstants.OK_ID) {
+            label = "PUT";
+        }
+        return super.createButton(parent, id, label, defaultButton);
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/ResourceWizardDialog.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/ResourceWizardDialog.java
new file mode 100644 (file)
index 0000000..1b8658c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog for handling wizards.
+ */
+public class ResourceWizardDialog extends WizardDialog {
+
+    public ResourceWizardDialog(Shell parentShell, IWizard newWizard) {
+        super(parentShell, newWizard);
+    }
+
+    @Override
+    public boolean isHelpAvailable() {
+        return false;
+    }
+
+    @Override
+    public void finishPressed() {
+        super.finishPressed();
+    }
+
+    @Override
+    protected void createButtonsForButtonBar(Composite parent) {
+        super.createButtonsForButtonBar(parent);
+        Button finishButton = getButton(IDialogConstants.FINISH_ID);
+        if (finishButton != null) {
+            finishButton.setText(IDialogConstants.OK_LABEL);
+        }
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/VerificationDialog.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/VerificationDialog.java
new file mode 100644 (file)
index 0000000..a221760
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.clientcontroller.view.dialogs;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Set;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.manager.ResourceManager;
+import oic.simulator.clientcontroller.utils.Constants;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog for starting and stopping the automatic verifications.
+ */
+public class VerificationDialog extends TrayDialog {
+    private Map<String, Boolean> automationStatus;
+
+    public VerificationDialog(Shell shell, Map<String, Boolean> automationStatus) {
+        super(shell);
+        this.automationStatus = automationStatus;
+    }
+
+    @Override
+    protected void configureShell(Shell shell) {
+        super.configureShell(shell);
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite composite = (Composite) super.createDialogArea(parent);
+        createAutomationGroup(composite);
+        getShell().setText("Automation Settings");
+        return composite;
+    }
+
+    /**
+     * Dynamically creates a check-box list for enabling/disabling different
+     * types of automation
+     */
+    private void createAutomationGroup(Composite parent) {
+        Group group = new Group(parent, SWT.NONE);
+        group.setLayout(new GridLayout());
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.widthHint = 275;
+        group.setLayoutData(gd);
+        group.setText("Automation Levels");
+
+        Set<String> keySet = automationStatus.keySet();
+        if (null == keySet) {
+            return;
+        }
+        ArrayList<String> list = new ArrayList<String>(
+                automationStatus.keySet());
+        for (final String str : list) {
+            final Button checkbox = new Button(group, SWT.CHECK);
+            checkbox.setText(str);
+            checkbox.setSelection(automationStatus.get(str));
+            checkbox.addSelectionListener(new SelectionAdapter() {
+
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    boolean checked = checkbox.getSelection();
+                    boolean answer = MessageDialog.openQuestion(Display
+                            .getDefault().getActiveShell(), "Verification",
+                            "Do you want to "
+                                    + (checked ? "enable" : "disable")
+                                    + " the verification?");
+                    if (!answer) {
+                        checkbox.setSelection(!checked);
+                        checked = !checked;
+                    } else {
+                        ResourceManager resourceManager = Activator
+                                .getDefault().getResourceManager();
+                        String reqTypeTxt = checkbox.getText();
+                        int reqType;
+                        if (reqTypeTxt.equals("Get")) {
+                            reqType = Constants.GET_AUTOMATION_INDEX;
+                        } else if (reqTypeTxt.equals("Put")) {
+                            reqType = Constants.PUT_AUTOMATION_INDEX;
+                        } else {// if(reqTypeTxt.equals("Post")) {
+                            reqType = Constants.POST_AUTOMATION_INDEX;
+                        }
+                        if (checked) {
+                            resourceManager.startAutomationRequest(reqType,
+                                    resourceManager
+                                            .getCurrentResourceInSelection());
+                        } else {
+                            resourceManager.stopAutomationRequest(reqType,
+                                    resourceManager
+                                            .getCurrentResourceInSelection());
+                        }
+                    }
+                    automationStatus.put(str, checked);
+                }
+            });
+        }
+    }
+
+    @Override
+    protected Button createButton(Composite parent, int id, String label,
+            boolean defaultButton) {
+        if (id == IDialogConstants.CANCEL_ID) {
+            return null;
+        }
+        return super.createButton(parent, id, label, defaultButton);
+    }
+
+    @Override
+    public boolean isHelpAvailable() {
+        return false;
+    }
+}
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogContentProvider.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogContentProvider.java
new file mode 100644 (file)
index 0000000..c782557
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Maintains simulator log entries and provides content to the log view.
+ */
+public class LogContentProvider implements ITreeContentProvider {
+
+    List<LogEntry> logEntryList = new ArrayList<LogEntry>();
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        logEntryList = (List<LogEntry>) newInput;
+    }
+
+    @Override
+    public Object[] getChildren(Object element) {
+        return new Object[0];
+    }
+
+    @Override
+    public Object[] getElements(Object input) {
+        return logEntryList.toArray();
+    }
+
+    @Override
+    public Object getParent(Object element) {
+        return null;
+    }
+
+    @Override
+    public boolean hasChildren(Object element) {
+        return false;
+    }
+
+    @Override
+    public void dispose() {
+    }
+
+    public synchronized void addLog(LogEntry newElement) {
+        logEntryList.add(newElement);
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogEntry.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogEntry.java
new file mode 100644 (file)
index 0000000..f042dfc
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
+
+import java.util.Date;
+
+import oic.simulator.clientcontroller.manager.LogManager;
+
+/**
+ * Class for log entry.
+ */
+public class LogEntry {
+    private final int    severity;
+    private final Date   date;
+    private final String message;
+
+    public LogEntry(int severity, Date date, String message) {
+        this.severity = severity;
+        this.date = date;
+        this.message = message;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public int getSeverity() {
+        return severity;
+    }
+
+    @Override
+    public String toString() {
+        String newline = System.getProperty("line.separator");
+        String out = date.toString() + newline;
+        out += "Severity: " + LogManager.getSeverityName(severity) + newline;
+        out += "Message: " + message + newline;
+        out += "===============================" + newline + newline;
+        return out;
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogLabelProvider.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LogLabelProvider.java
new file mode 100644 (file)
index 0000000..ca80ad1
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import oic.simulator.clientcontroller.manager.LogManager;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Label provider which determines what data has to be shown in the log view.
+ */
+public class LogLabelProvider extends LabelProvider implements
+        ITableLabelProvider {
+
+    DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS");
+
+    @Override
+    public Image getColumnImage(Object element, int columnIndex) {
+        if (columnIndex == 0) {
+            LogEntry entry = (LogEntry) element;
+            return LogManager.getSeverityIcon(entry.getSeverity());
+        }
+        return null;
+    }
+
+    @Override
+    public String getColumnText(Object element, int columnIndex) {
+        LogEntry entry = (LogEntry) element;
+        if (columnIndex == 0) {
+            return LogManager.getSeverityName(entry.getSeverity());
+        } else if (columnIndex == 1) {
+            return dateFormat.format(entry.getDate());
+        } else {
+            return entry.getMessage();
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LoggerCallback.java b/service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/logger/LoggerCallback.java
new file mode 100644 (file)
index 0000000..81110b0
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.utils.Constants;
+
+import org.oic.simulator.ILogger;
+
+/**
+ * Class which provides a callback method to receive log from native layer.
+ */
+public class LoggerCallback implements ILogger {
+
+    @Override
+    public void write(String time, int level, String message) {
+        if (null == time || level < 0 || null == message) {
+            return;
+        }
+        // Parse the time
+        Date date = parseTime(time);
+        if (null == date) {
+            return;
+        }
+        Activator activator = Activator.getDefault();
+        if (null == activator) {
+            return;
+        }
+        activator.getLogManager().log(level, date, message);
+    }
+
+    private Date parseTime(String time) {
+        Date date;
+        String[] token = time.split("\\.");
+        int h, m, s;
+        try {
+            if (token.length == Constants.PROPER_LOG_TIME_TOKEN_LENGTH) {
+                h = Integer.parseInt(token[0]);
+                m = Integer.parseInt(token[1]);
+                s = Integer.parseInt(token[2]);
+
+                Calendar calendar;
+                calendar = Calendar.getInstance();
+                calendar.set(Calendar.HOUR, h);
+                calendar.set(Calendar.MINUTE, m);
+                calendar.set(Calendar.SECOND, s);
+
+                date = calendar.getTime();
+            } else {
+                date = null;
+            }
+        } catch (NumberFormatException nfe) {
+            date = null;
+        }
+        return date;
+    }
+}
\ No newline at end of file
index b522aba..3db1138 100644 (file)
@@ -4,5 +4,6 @@ bin.includes = META-INF/,\
                .,\
                icons/,\
                plugin.xml,\
-               libs/
+               libs/,\
+               resource/
 
diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light-error.json b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light-error.json
new file mode 100644 (file)
index 0000000..3a31e6f
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "id": "http://openinterconnect.org/schemas/oic.r.light#",
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "title": "OIC Light",
+  "$ref": "#/definitions/oic.r.light",
+  "definitions": {
+    "oic.r.light": {
+      "type": "object",
+      "properties": {
+               "rt": {
+          "type": "string",
+          "description": "Description about resource type",
+          "default": "oic.r.light"
+        },
+               "if": {
+          "type": "string",
+          "description": "Interface supported",
+          "default": "oic.if.baseline"
+        },
+        "intensity":  {
+          "type": "integer",
+          "description": "ReadOnly, Comma separated min,max values for intensity on this device",
+          "default": "10,20"
+        }
+      }
+    }
+  },
+   "required": ["rt","if"]
+}
diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light.json b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light.json
new file mode 100644 (file)
index 0000000..0bd007d
--- /dev/null
@@ -0,0 +1,39 @@
+{
+  "id": "http://openinterconnect.org/schemas/oic.r.light#",
+  "$schema": "http://json-schema.org/schema#",
+  "title": "OIC Light",
+  "$ref": "#/definitions/oic.r.light",
+  "definitions": {
+    "oic.r.light": {
+      "type": "object",
+      "properties": {
+               "rt": {
+          "type": "string",
+          "description": "Description about resource type",
+          "default": "oic.r.light"
+        },
+               "if": {
+          "type": "string",
+          "description": "Interface supported",
+          "default": "oic.if.baseline"
+        },
+               "power": {
+                 "type": "string",
+                 "description": "Light status",
+                 "default": "on",
+                 "enum": ["on","off"],
+                 "update_frequency": 1000
+                 },
+               "intensity": {
+                 "type": "integer",
+                 "description": "brightness of the light",
+                 "default": 1,
+                 "minimum": 1,
+          "maximum": 9,                  
+                 "update_frequency": 1001
+                 }
+                }
+               }
+       },      
+  "required": [ "rt","if","power" ]
+}
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light.raml b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/Light/oic.r.light.raml
new file mode 100644 (file)
index 0000000..810e061
--- /dev/null
@@ -0,0 +1,63 @@
+#%RAML 0.8
+title: OICLight
+version: v1.0-20150910
+schemas:
+  - OICLight: !include oic.r.light.json
+    OICLightError: !include oic.r.light-error.json
+
+traits:
+  - interface:
+      queryParameters:
+        if:
+          enum: ["oic.if.a"]
+
+/oic/r/light:
+  description: |
+    Resource to be exposed by any OIC Device that can act as Light.
+  displayName: OIC Light
+  is: [ interface ] # valid for all methods
+
+  get:
+    responses:
+      200:
+        body:
+          application/json:
+            schema: OICLight
+            example: |
+              {
+                "rt":     "oic.r.light",
+                "id":     "light_id",
+                "power":  "off"
+              }
+  post:
+    body:
+      application/json:
+        schema: OICLight
+        example: |
+          {
+            "id":    "light_id",
+            "power":  "off"
+          }
+    responses:
+      200:
+        body:
+          application/json:
+            schema: OICLight
+            example: |
+              {
+                "id":    "light_id",
+                "power":  "off"
+              }
+      403:
+        description: |
+          This response is generated by the OIC Server when the client sends:
+            An update with an out of range property value for intensity.
+          The server responds with the range property illustrating the error.
+        body:
+          application/json:
+            schema: OICLightError
+            example: |
+              {
+                "id":     "light_id",
+                "range":  "10,20"
+              }
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/light.raml b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/light.raml
deleted file mode 100644 (file)
index 937c518..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#%RAML 0.8
-#RAML for Light Resource
-title: Resource Light
-version: 1.0
-mediaType : application/json
-schemas:
-- lightPublish: !include oic.light.json
-resourceTypes:
-  - typeDelete:
-      description: mdescription
-      delete:
-        description: mDeletedescription
-
-/oic/light:
-  displayName: Resource Light
-  description: |
-    Resource to be exposed by any OIC Device that can act as Light
-  type: typeDelete
-  get:
-    description: |
-      Get the attributes of light
-    responses:
-      200:
-        description: |
-          Respond with the selector criteria
-        body:
-          application/json:
-            schema: lightPublish
-            example: |
-              {
-              
-              }                          
-  put:
-    description: Publish the resource information.
-    body:
-      application/json:
-        schema: lightPublish
-    responses:
-      200:
-        description: This value is used by to update the attributes.
-        body:
-          application/json:
-            schema: lightPublish
-            example: |
-              {
-              
-              }
-      400:
-        description: not found.
-        body:
-          application/json:
-            schema: lightPublish
-            example: |
-              {
-              
-              }
-  post:
-    description: Publish the resource information.
-    body:
-      application/json:
-        schema: lightPublish
-    responses:
-      200:
-        description: This value is used by to update the attributes.
-        body:
-          application/json:
-            schema: lightPublish
-            example: |
-              {
-              
-              }
-      400:
-        description: not found.
-        body:
-          application/json:
-            schema: lightPublish
-            example: |
-              {
-              
-              }
\ No newline at end of file
diff --git a/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/oic.light.json b/service/simulator/java/eclipse-plugin/ServiceProviderPlugin/resource/oic.light.json
deleted file mode 100644 (file)
index 7474deb..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-{
-  "title": "light",
-  "rt": "oic.light",
-  "if": "oic.if.baseline",
-  "properties": {
-    "power": {
-      "type": "string",
-      "description": "Light status",
-      "values": ["on","off"],
-      "default": "on",
-      "update_frequency": 1000
-    },
-    "intensity": {
-      "type": "integer",
-      "description": "brightness of the light",
-      "range": [1,9],
-      "default": 1,
-      "update_frequency": 1001
-    }
-  }
-}
\ No newline at end of file
index 5d70e68..c782557 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
 
 import java.util.ArrayList;
@@ -6,6 +22,9 @@ import java.util.List;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 
+/**
+ * Maintains simulator log entries and provides content to the log view.
+ */
 public class LogContentProvider implements ITreeContentProvider {
 
     List<LogEntry> logEntryList = new ArrayList<LogEntry>();
index 989a273..883cc0d 100644 (file)
@@ -1,9 +1,28 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
 
 import java.util.Date;
 
 import oic.simulator.serviceprovider.manager.LogManager;
 
+/**
+ * Class for log entry.
+ */
 public class LogEntry {
     private final int    severity;
     private final Date   date;
index 7ec2759..f392bc8 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
 
 import java.text.DateFormat;
@@ -9,6 +25,9 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
 
+/**
+ * Label provider which determines what data has to be shown in the log view.
+ */
 public class LogLabelProvider extends LabelProvider implements
         ITableLabelProvider {
 
index 94168e0..83d02fa 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.logger;
 
 import java.util.Calendar;
@@ -8,6 +24,9 @@ import oic.simulator.serviceprovider.utils.Constants;
 
 import org.oic.simulator.ILogger;
 
+/**
+ * Class which provides a callback method to receive log from native layer.
+ */
 public class LoggerCallback implements ILogger {
 
     @Override
@@ -39,7 +58,7 @@ public class LoggerCallback implements ILogger {
 
                 Calendar calendar;
                 calendar = Calendar.getInstance();
-                calendar.set(Calendar.HOUR, h);
+                calendar.set(Calendar.HOUR_OF_DAY, h);
                 calendar.set(Calendar.MINUTE, m);
                 calendar.set(Calendar.SECOND, s);
 
index 093fb78..f9816d3 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider;
 
 import oic.simulator.serviceprovider.manager.ImageManager;
@@ -8,12 +24,12 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
 /**
- * The activator class controls the plug-in life cycle
+ * The activator class controls the plug-in life cycle.
  */
 public class Activator extends AbstractUIPlugin {
 
     // The plug-in ID
-    public static final String     PLUGIN_ID = "ServiceProviderPlugin"; //$NON-NLS-1$
+    public static final String     PLUGIN_ID = "ServiceProviderPlugin";
 
     // The shared instance
     private static Activator       plugin;
@@ -24,14 +40,18 @@ public class Activator extends AbstractUIPlugin {
 
     private static ImageManager    imageManager;
 
+    static {
+        System.loadLibrary("SimulatorManager");
+    }
+
     public Activator() {
     }
 
     public void start(BundleContext context) throws Exception {
         super.start(context);
         plugin = this;
-        setResourceManager(new ResourceManager());
         setLogManager(new LogManager());
+        setResourceManager(new ResourceManager());
         imageManager = ImageManager.getInstance();
     }
 
index ecc2ee7..215fb5f 100644 (file)
@@ -1,5 +1,25 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.listener;
 
+/**
+ * Interface through which the automation events are notified to the UI
+ * listeners.
+ */
 public interface IAutomationUIListener {
     public void onResourceAutomationStart(String resourceURI);
 
index dc539cd..e77823b 100644 (file)
@@ -1,9 +1,28 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.listener;
 
 import java.util.List;
 
 import oic.simulator.logger.LogEntry;
 
+/**
+ * 
+ */
 public interface ILogUIListener {
     public void logAdded(LogEntry added);
 
index 702ba11..3beb52a 100644 (file)
@@ -1,5 +1,25 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.listener;
 
+/**
+ * Interface through which the resource observer events are sent to the UI
+ * listeners.
+ */
 public interface IObserverListChangedUIListener {
     public void onObserverListChanged(String resourceURI);
 }
index 17ed87f..b5eb331 100644 (file)
@@ -1,5 +1,25 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.listener;
 
+/**
+ * Interface through which the resource creation/deletion events are sent to the
+ * UI listeners.
+ */
 public interface IResourceListChangedUIListener {
     public void onResourceCreation();
 
index 3340e9a..b778e0e 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.listener;
 
 import java.util.Set;
@@ -5,6 +21,10 @@ import java.util.Set;
 import oic.simulator.serviceprovider.resource.ModelChangeNotificationType;
 import oic.simulator.serviceprovider.resource.LocalResourceAttribute;
 
+/**
+ * Interface through which the resource model change events are sent to the UI
+ * listeners.
+ */
 public interface IResourceModelChangedUIListener {
     public void onResourceModelChange(
             ModelChangeNotificationType notificationType, String resourceURI,
index 4c844d6..dc891da 100644 (file)
@@ -1,5 +1,25 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.listener;
 
+/**
+ * Interface through which the resource selection UI event is sent to the other
+ * UI listeners.
+ */
 public interface IResourceSelectionChangedUIListener {
     public void onResourceSelectionChange();
 }
\ No newline at end of file
index 4852717..2f20853 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.manager;
 
 import java.net.URL;
@@ -10,6 +26,10 @@ import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.swt.graphics.Image;
 import org.osgi.framework.Bundle;
 
+/**
+ * Class which loads the icons/images into the image registry, and has methods
+ * to handle the image related requests from other UI modules.
+ */
 public class ImageManager {
 
     private static ImageManager imageManager;
@@ -36,7 +56,7 @@ public class ImageManager {
                 .createFromURL(bundle.getEntry("icons/button_pressed.PNG")));
 
         // Resource icons based on the resource type
-        r.put(Constants.OIC_LIGHT, ImageDescriptor.createFromURL(bundle
+        r.put(Constants.OIC_R_LIGHT, ImageDescriptor.createFromURL(bundle
                 .getEntry("/icons/light_16x16.png")));
 
         // Log View related icons
index 53ff8f3..e7ca9a9 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.manager;
 
 import java.util.ArrayList;
@@ -17,6 +33,10 @@ import org.oic.simulator.ILogger;
 import org.oic.simulator.ILogger.Level;
 import org.oic.simulator.SimulatorManager;
 
+/**
+ * Class which handles the native logs, maintains log entries and updates the
+ * UI.
+ */
 public class LogManager {
     private LinkedList<LogEntry>         entries           = new LinkedList<LogEntry>();
     private ArrayList<ILogUIListener>    listeners         = new ArrayList<ILogUIListener>();
index 702fb9c..32e70ba 100644 (file)
@@ -1,7 +1,24 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.manager;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -25,18 +42,27 @@ import oic.simulator.serviceprovider.utils.Constants;
 import oic.simulator.serviceprovider.utils.Utility;
 
 import org.eclipse.swt.graphics.Image;
-import org.oic.simulator.AutomationType;
 import org.oic.simulator.IAutomation;
+import org.oic.simulator.ILogger.Level;
 import org.oic.simulator.ResourceAttribute;
 import org.oic.simulator.ResourceAttribute.Range;
 import org.oic.simulator.ResourceAttribute.Type;
+import org.oic.simulator.SimulatorException;
 import org.oic.simulator.SimulatorManager;
 import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.serviceprovider.AutomationType;
 import org.oic.simulator.serviceprovider.IObserver;
 import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
 import org.oic.simulator.serviceprovider.ObserverInfo;
 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
 
+/**
+ * This class acts as an interface between the simulator java SDK and the
+ * various UI modules. It maintains all the details of resources and provides
+ * other UI modules with the information required. It also handles model change,
+ * automation, and observer related events from native layer and propagates
+ * those events to the registered UI listeners.
+ */
 public class ResourceManager {
 
     private Map<String, Map<String, SimulatorResource>> resourceMap;
@@ -67,10 +93,6 @@ public class ResourceManager {
 
     private Thread                                      threadHandle;
 
-    static {
-        System.loadLibrary("SimulatorManager");
-    }
-
     public ResourceManager() {
         resourceMap = new HashMap<String, Map<String, SimulatorResource>>();
         orderedResourceUriMap = new HashMap<String, ArrayList<String>>();
@@ -449,8 +471,20 @@ public class ResourceManager {
             @Override
             public void run() {
                 SimulatorResourceServer resourceServerN;
-                resourceServerN = SimulatorManager.createResource(
-                        configFilePath, resourceModelChangeListener);
+                try {
+                    resourceServerN = SimulatorManager.createResource(
+                            configFilePath, resourceModelChangeListener);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "[" + e.getClass().getSimpleName() + "]"
+                                            + e.code().toString() + "-"
+                                            + e.message());
+                    return;
+                }
                 SimulatorResource simulatorResource;
                 simulatorResource = fetchResourceData(resourceServerN);
                 if (null != simulatorResource) {
@@ -461,7 +495,18 @@ public class ResourceManager {
                     resourceCreatedUINotification();
 
                     // Set the observer for the created resource
-                    resourceServerN.setObserverCallback(observer);
+                    try {
+                        resourceServerN.setObserverCallback(observer);
+                    } catch (SimulatorException e) {
+                        Activator
+                                .getDefault()
+                                .getLogManager()
+                                .log(Level.ERROR.ordinal(),
+                                        new Date(),
+                                        "[" + e.getClass().getSimpleName()
+                                                + "]" + e.code().toString()
+                                                + "-" + e.message());
+                    }
 
                     // Print the resource data
                     simulatorResource.printResourceInfo();
@@ -477,9 +522,21 @@ public class ResourceManager {
             public void run() {
                 Map<String, SimulatorResource> resourceTypeMap;
                 SimulatorResourceServer[] simulatorResourceServers = null;
-                simulatorResourceServers = SimulatorManager.createResource(
-                        configFilePath, noOfInstances,
-                        resourceModelChangeListener);
+                try {
+                    simulatorResourceServers = SimulatorManager.createResource(
+                            configFilePath, noOfInstances,
+                            resourceModelChangeListener);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "[" + e.getClass().getSimpleName() + "]"
+                                            + e.code().toString() + "-"
+                                            + e.message());
+                    return;
+                }
                 if (null == simulatorResourceServers) {
                     return;
                 }
@@ -495,7 +552,18 @@ public class ResourceManager {
                                 uri);
                     }
                     // Set the observer for the created resource
-                    resourceServerN.setObserverCallback(observer);
+                    try {
+                        resourceServerN.setObserverCallback(observer);
+                    } catch (SimulatorException e) {
+                        Activator
+                                .getDefault()
+                                .getLogManager()
+                                .log(Level.ERROR.ordinal(),
+                                        new Date(),
+                                        "[" + e.getClass().getSimpleName()
+                                                + "]" + e.code().toString()
+                                                + "-" + e.message());
+                    }
                 }
 
                 // Find the resourceType and add it to the local data
@@ -532,7 +600,20 @@ public class ResourceManager {
             simulatorResource.setResourceInterface(resourceServerN
                     .getInterfaceType());
 
-            SimulatorResourceModel resourceModelN = resourceServerN.getModel();
+            SimulatorResourceModel resourceModelN;
+            try {
+                resourceModelN = resourceServerN.getModel();
+            } catch (SimulatorException e) {
+                Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(),
+                                new Date(),
+                                "[" + e.getClass().getSimpleName() + "]"
+                                        + e.code().toString() + "-"
+                                        + e.message());
+                return null;
+            }
             if (null != resourceModelN) {
                 simulatorResource.setResourceModel(resourceModelN);
 
@@ -702,7 +783,18 @@ public class ResourceManager {
             SimulatorResourceServer resourceServerN = resource
                     .getResourceServer();
             if (null != resourceServerN) {
-                SimulatorManager.deleteResource(resourceServerN);
+                try {
+                    SimulatorManager.deleteResource(resourceServerN);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "[" + e.getClass().getSimpleName() + "]"
+                                            + e.code().toString() + "-"
+                                            + e.message());
+                }
             }
         }
     }
@@ -739,7 +831,18 @@ public class ResourceManager {
 
     private void deleteResource(String resourceType) {
         if (null != resourceType) {
-            SimulatorManager.deleteResources(resourceType);
+            try {
+                SimulatorManager.deleteResources(resourceType);
+            } catch (SimulatorException e) {
+                Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(),
+                                new Date(),
+                                "[" + e.getClass().getSimpleName() + "]"
+                                        + e.code().toString() + "-"
+                                        + e.message());
+            }
         }
     }
 
@@ -767,7 +870,17 @@ public class ResourceManager {
     }
 
     private void deleteResource() {
-        SimulatorManager.deleteResources(null);
+        try {
+            SimulatorManager.deleteResources(null);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
     }
 
     private void deleteLocalResourceDetails(String resourceType,
@@ -1042,28 +1155,39 @@ public class ResourceManager {
                     return;
                 }
                 Type baseType = att.getAttValBaseType();
-                if (baseType == Type.STRING) {
-                    server.updateAttributeStringN(attributeName, value);
-                } else if (baseType == Type.INT) {
-                    int val;
-                    try {
-                        val = Integer.parseInt(value);
-                    } catch (NumberFormatException nfe) {
-                        return;
-                    }
-                    server.updateAttributeInteger(attributeName, val);
-                } else if (baseType == Type.DOUBLE) {
-                    double val;
-                    try {
-                        val = Double.parseDouble(value);
-                    } catch (NumberFormatException nfe) {
-                        return;
+                try {
+                    if (baseType == Type.STRING) {
+                        server.updateAttributeString(attributeName, value);
+                    } else if (baseType == Type.INT) {
+                        int val;
+                        try {
+                            val = Integer.parseInt(value);
+                        } catch (NumberFormatException nfe) {
+                            return;
+                        }
+                        server.updateAttributeInteger(attributeName, val);
+                    } else if (baseType == Type.DOUBLE) {
+                        double val;
+                        try {
+                            val = Double.parseDouble(value);
+                        } catch (NumberFormatException nfe) {
+                            return;
+                        }
+                        server.updateAttributeDouble(attributeName, val);
+                    } else if (baseType == Type.BOOL) {
+                        boolean val;
+                        val = Boolean.parseBoolean(value);
+                        server.updateAttributeBoolean(attributeName, val);
                     }
-                    server.updateAttributeDouble(attributeName, val);
-                } else if (baseType == Type.BOOL) {
-                    boolean val;
-                    val = Boolean.parseBoolean(value);
-                    server.updateAttributeBoolean(attributeName, val);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "[" + e.getClass().getSimpleName() + "]"
+                                            + e.code().toString() + "-"
+                                            + e.message());
                 }
             }
         }
@@ -1145,8 +1269,20 @@ public class ResourceManager {
                     .getResourceServer();
             if (null != resourceServerN) {
                 String attrName = attribute.getAttributeName();
-                autoId = resourceServerN.startAttributeAutomation(attrName,
-                        autoType.ordinal(), automationListener);
+                try {
+                    autoId = resourceServerN.startAttributeAutomation(attrName,
+                            autoType, automationListener);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "[" + e.getClass().getSimpleName() + "]"
+                                            + e.code().toString() + "-"
+                                            + e.message());
+                    return -1;
+                }
                 if (-1 != autoId) {
                     attribute.setAutomationId(autoId);
                     attribute.setAutomationType(autoType);
@@ -1167,7 +1303,19 @@ public class ResourceManager {
             SimulatorResourceServer resourceServerN = resource
                     .getResourceServer();
             if (null != resourceServerN) {
-                resourceServerN.stopAutomation(autoId);
+                try {
+                    resourceServerN.stopAutomation(autoId);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "[" + e.getClass().getSimpleName() + "]"
+                                            + e.code().toString() + "-"
+                                            + e.message());
+                    return;
+                }
                 // Change the automation status
                 att.setAutomationInProgress(false);
                 resource.setAttributeAutomationInProgress(isAnyAttributeInAutomation(resource));
@@ -1241,8 +1389,21 @@ public class ResourceManager {
             if (null != resourceServer) {
                 // TODO: Temporarily handling the normal one-time automation for
                 // resources
-                int autoId = resourceServer.startResourceAutomation(
-                        AutomationType.NORMAL.ordinal(), automationListener);
+                int autoId = -1;
+                try {
+                    autoId = resourceServer.startResourceAutomation(
+                            AutomationType.NORMAL, automationListener);
+                } catch (SimulatorException e) {
+                    Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(),
+                                    new Date(),
+                                    "[" + e.getClass().getSimpleName() + "]"
+                                            + e.code().toString() + "-"
+                                            + e.message());
+                    autoId = -1;
+                }
                 if (-1 == autoId) {
                     // Automation request failed and hence status is being
                     // rolled back
@@ -1281,7 +1442,18 @@ public class ResourceManager {
             return false;
         }
         // Call native method
-        resourceServer.stopAutomation(autoId);
+        try {
+            resourceServer.stopAutomation(autoId);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+            return false;
+        }
 
         // Notify the UI Listeners. Invoke the automation complete callback.
         Thread stopThread = new Thread() {
@@ -1365,7 +1537,17 @@ public class ResourceManager {
         if (null == server) {
             return;
         }
-        server.notifyObserver(observerId);
+        try {
+            server.notifyObserver(observerId);
+        } catch (SimulatorException e) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(),
+                            new Date(),
+                            "[" + e.getClass().getSimpleName() + "]"
+                                    + e.code().toString() + "-" + e.message());
+        }
     }
 
     public Image getImage(String resourceURI) {
index ef9033a..079f645 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.perspective;
 
 import oic.simulator.serviceprovider.view.AttributeView;
@@ -11,6 +27,10 @@ import org.eclipse.ui.IFolderLayout;
 import org.eclipse.ui.IPageLayout;
 import org.eclipse.ui.IPerspectiveFactory;
 
+/**
+ * This class creates a new eclipse perspective for service provider and
+ * positions the different views inside.
+ */
 public class PerspectiveFactory implements IPerspectiveFactory {
 
     public static final String PERSPECTIVE_ID = "oic.simulator.serviceprovider.perspective";
index 3784f5f..0136296 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
 import java.util.ArrayList;
@@ -6,8 +22,12 @@ import java.util.List;
 
 import oic.simulator.serviceprovider.utils.Constants;
 
-import org.oic.simulator.AutomationType;
+import org.oic.simulator.serviceprovider.AutomationType;
 
+/**
+ * This is a helper class for providing the automation settings information to
+ * UI.
+ */
 public class AutomationSettingHelper {
     private String       settingID;
     private String       settingValue;
index 5825062..336d82d 100644 (file)
@@ -1,5 +1,24 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
+/**
+ * Enumerates different types of supported delete operations.
+ */
 public enum DeleteCategory {
     ALL, BY_TYPE, BY_URI, NONE
 }
\ No newline at end of file
index 1aea3e8..c04b07e 100644 (file)
@@ -1,12 +1,31 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
 import java.util.List;
 
-import org.oic.simulator.AutomationType;
 import org.oic.simulator.ResourceAttribute;
 import org.oic.simulator.ResourceAttribute.Range;
 import org.oic.simulator.ResourceAttribute.Type;
+import org.oic.simulator.serviceprovider.AutomationType;
 
+/**
+ * This class represents an attribute in the simulated resource.
+ */
 public class LocalResourceAttribute {
 
     // Native object reference
index bff71e7..61881b1 100644 (file)
@@ -1,5 +1,25 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
+/**
+ * This is a helper class for showing the meta properties of resources such as
+ * resource type, resource uri, etc.
+ */
 public class MetaProperty {
     private String propName;
     private String propValue;
index 3dc1c60..0a1b17a 100644 (file)
@@ -1,5 +1,24 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
+/**
+ * Enumerates the different types of operations for model change notifications.
+ */
 public enum ModelChangeNotificationType {
     ATTRIBUTE_ADDED, ATTRIBUTE_REMOVED, ATTRIBUTE_VALUE_CHANGED, NONE, NO_ATTRIBUTES_IN_MODEL
 }
\ No newline at end of file
index 512ee3d..b581a6e 100644 (file)
@@ -1,7 +1,26 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
 import org.oic.simulator.serviceprovider.ObserverInfo;
 
+/**
+ * This class holds observer details of resources.
+ */
 public class ObserverDetail {
 
     private ObserverInfo observerInfo;
index 84f0605..38d9730 100644 (file)
@@ -1,14 +1,34 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-import org.oic.simulator.AutomationType;
 import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.serviceprovider.AutomationType;
 import org.oic.simulator.serviceprovider.ObserverInfo;
 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
 
+/**
+ * This class represents a simulated resource. It maintains all the necessary
+ * information about the resource.
+ */
 public class SimulatorResource {
     private String                              resourceURI;
     private String                              resourceName;
index dc46487..4a3035c 100644 (file)
@@ -1,19 +1,40 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.resource;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.Date;
+import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import oic.simulator.serviceprovider.Activator;
 import oic.simulator.serviceprovider.utils.Constants;
 
 import org.eclipse.core.runtime.FileLocator;
-import org.osgi.framework.Bundle;
+import org.oic.simulator.ILogger.Level;
 
+/**
+ * Class which loads and maintains the standard RAML configuration file list.
+ */
 public class StandardConfiguration {
 
     // A map of filename of standard resources as the key and the complete
@@ -22,39 +43,45 @@ public class StandardConfiguration {
 
     public StandardConfiguration() {
         stdConfigFiles = new HashMap<String, String>();
-        addFiles();
         populateStandardConfigurationList();
     }
 
-    private void addFiles() {
-        stdConfigFiles.put(Constants.RAML_FILE_PREFIX + "light.raml", null);
-    }
-
     private void populateStandardConfigurationList() {
-        if (stdConfigFiles.isEmpty()) {
+        Enumeration<URL> fileList = Activator.getDefault().getBundle()
+                .findEntries(Constants.CONFIG_DIRECTORY_PATH, "*", true);
+        if (null == fileList) {
+            Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(), new Date(),
+                            "No configuration files exist.");
             return;
         }
-        Iterator<String> fileItr = stdConfigFiles.keySet().iterator();
-        String fileName;
         URL url;
+        URL resolvedURL;
+        URI resolvedURI;
         File file;
-        String filePath;
-        Bundle bundle = Activator.getDefault().getBundle();
-        while (fileItr.hasNext()) {
-            fileName = fileItr.next();
-            url = bundle.getEntry(Constants.CONFIG_DIRECTORY_PATH + "/"
-                    + fileName);
-            if (null == url) {
-                return;
-            }
+        String relPath;
+        String absPath;
+        while (fileList.hasMoreElements()) {
+            url = (URL) fileList.nextElement();
+            relPath = url.getPath();
+            System.out.println(url.getPath());
             try {
-                file = new File(FileLocator.resolve(url).toURI());
+                resolvedURL = FileLocator.toFileURL(url);
+                if (relPath.toLowerCase().endsWith(
+                        Constants.RAML_FILE_EXTENSION)) {
+                    resolvedURI = new URI(resolvedURL.getProtocol(),
+                            resolvedURL.getPath(), null);
+                    file = new File(resolvedURI);
+                    absPath = file.getAbsolutePath();
+                    stdConfigFiles.put(relPath, absPath);
+                    System.out.println("File path:" + absPath);
+                }
             } catch (URISyntaxException | IOException e) {
-                System.out.println(e.getMessage());
-                return;
+                Activator.getDefault().getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
             }
-            filePath = file.getAbsolutePath();
-            stdConfigFiles.put(fileName, filePath);
         }
     }
 
index d71dea7..890c076 100644 (file)
@@ -1,7 +1,27 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.utils;
 
-import org.oic.simulator.AutomationType;
+import org.oic.simulator.serviceprovider.AutomationType;
 
+/**
+ * This class maintains all constants which are used throughout the service
+ * provider plug-in.
+ */
 public class Constants {
 
     public static final String         CONFIG_DIRECTORY_PATH            = "/resource";
@@ -9,7 +29,7 @@ public class Constants {
     public static final String         UNDERSCORE                       = "_";
     public static final String         FORWARD_SLASH                    = "/";
 
-    public static final String         OIC                              = "oic";
+    public static final String         OIC_PREFIX                       = "/oic/r";
     public static final String         SIMULATOR                        = "simulator";
 
     public static final String         RESOURCE_URI                     = "Resource URI";
@@ -39,7 +59,7 @@ public class Constants {
     public static final String         START_RESOURCE_AUTOMATION        = "Start Automation";
     public static final String         STOP_RESOURCE_AUTOMATION         = "Stop Automation";
 
-    public static final int            PROPER_RESOURCE_URI_TOKEN_COUNT  = 5;
+    public static final int            PROPER_RESOURCE_URI_TOKEN_COUNT  = 6;
     public static final int            DISPLAY_RESOURCE_URI_TOKEN_COUNT = 2;
 
     public static final AutomationType DEFAULT_AUTOMATION_TYPE          = AutomationType.NORMAL;
@@ -77,11 +97,12 @@ public class Constants {
     public static final String         DELETE_PAGE_TITLE                = "Delete Resource";
     public static final String         DELETE_PAGE_MESSAGE              = "Select the resource(s) to be deleted";
 
-    public static final String         RAML_FILE_PREFIX                 = "";
+    public static final String         RAML_FILE_PREFIX                 = "/resource/";
 
     public static final String         RAML_FILE_EXTENSION              = ".raml";
+    public static final String         JSON_FILE_EXTENSION              = ".json";
 
     public static final String         SPLIT_BY_DOT_PATTERN             = "\\.";
 
-    public static final String         OIC_LIGHT                        = "oic.light";
+    public static final String         OIC_R_LIGHT                      = "oic.r.light";
 }
\ No newline at end of file
index 160da63..3de0cb5 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.utils;
 
 import java.util.ArrayList;
@@ -5,6 +21,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
+/**
+ * This class has common utility methods.
+ */
 public class Utility {
 
     public static String uriToDisplayName(String uri) {
@@ -13,7 +32,7 @@ public class Utility {
             String tokens[] = uri.split(Constants.FORWARD_SLASH);
             if (Constants.PROPER_RESOURCE_URI_TOKEN_COUNT == tokens.length) {
                 // Proper URI
-                result = tokens[2] + Constants.UNDERSCORE + tokens[4];
+                result = tokens[3] + Constants.UNDERSCORE + tokens[5];
             }
         }
         return result;
@@ -25,10 +44,10 @@ public class Utility {
             String tokens[] = displayName.split(Constants.UNDERSCORE);
             if (Constants.DISPLAY_RESOURCE_URI_TOKEN_COUNT == tokens.length) {
                 // Proper Display Name
-                result = Constants.FORWARD_SLASH + Constants.OIC
-                        + Constants.FORWARD_SLASH + tokens[0]
-                        + Constants.FORWARD_SLASH + Constants.SIMULATOR
-                        + Constants.FORWARD_SLASH + tokens[1];
+                result = Constants.OIC_PREFIX + Constants.FORWARD_SLASH
+                        + tokens[0] + Constants.FORWARD_SLASH
+                        + Constants.SIMULATOR + Constants.FORWARD_SLASH
+                        + tokens[1];
             }
         }
         return result;
@@ -47,13 +66,9 @@ public class Utility {
         }
 
         // Removing the file extension
-        String[] token = fileName.split(Constants.SPLIT_BY_DOT_PATTERN);
-        int tokLen = token.length;
-        String result = null;
-        if (tokLen - 2 >= 0) {
-            result = token[tokLen - 2];
-        }
-        return result;
+        int index = fileName.lastIndexOf('.');
+        fileName = fileName.substring(0, index);
+        return fileName;
     }
 
     public static String displayToFileName(String displayName) {
index faf2542..5b8e299 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view;
 
 import java.util.List;
@@ -23,8 +39,12 @@ import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.MessageBox;
-import org.oic.simulator.AutomationType;
+import org.oic.simulator.serviceprovider.AutomationType;
 
+/**
+ * This class provides editing support to the resources attributes table in the
+ * attributes view.
+ */
 public class AttributeEditingSupport {
 
     private AttributeValueEditor attValueEditor;
index b986900..d4443b4 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view;
 
 import java.util.List;
@@ -31,6 +47,9 @@ import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.part.ViewPart;
 
+/**
+ * This class manages and shows the attribute view in the perspective.
+ */
 public class AttributeView extends ViewPart {
 
     public static final String                  VIEW_ID        = "oic.simulator.serviceprovider.view.attribute";
index deb8005..ba5f839 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view;
 
 import java.io.BufferedWriter;
@@ -58,6 +74,9 @@ import org.eclipse.ui.dialogs.PatternFilter;
 import org.eclipse.ui.part.ViewPart;
 import org.oic.simulator.ILogger.Level;
 
+/**
+ * This class manages and shows the log view in the perspective.
+ */
 public class LogView extends ViewPart {
 
     public static final String        VIEW_ID              = "oic.simulator.serviceprovider.view.log";
index 8785d07..8f8ff18 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view;
 
 import java.util.List;
@@ -21,6 +37,9 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.part.ViewPart;
 
+/**
+ * This class manages and shows the meta properties view in the perspective.
+ */
 public class MetaPropertiesView extends ViewPart {
 
     public static final String                  VIEW_ID       = "oic.simulator.serviceprovider.view.metaproperties";
index 99659a4..ac26bb0 100644 (file)
@@ -1,8 +1,28 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view;
 
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.part.ViewPart;
 
+/**
+ * This class manages and shows the multi-resource automation view in the
+ * perspective.
+ */
 public class MultiResourceOrchestrationView extends ViewPart {
 
     public static final String VIEW_ID = "oic.simulator.serviceprovider.view.orchestration";
index b15c3e3..99a609a 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view;
 
 import java.util.ArrayList;
@@ -41,6 +57,9 @@ import org.eclipse.ui.dialogs.FilteredTree;
 import org.eclipse.ui.dialogs.PatternFilter;
 import org.eclipse.ui.part.ViewPart;
 
+/**
+ * This class manages and shows the resource manager view in the perspective.
+ */
 public class ResourceManagerView extends ViewPart {
 
     public static final String             VIEW_ID = "oic.simulator.serviceprovider.view.resourcemanager";
index 1a785c4..5e9361f 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view;
 
 import java.util.Iterator;
@@ -31,6 +47,9 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.part.ViewPart;
 
+/**
+ * This class manages and shows the resource observer view in the perspective.
+ */
 public class ResourceObserverView extends ViewPart {
     public static final String                  VIEW_ID       = "oic.simulator.serviceprovider.view.observer";
 
index 996cdc1..e2bb48f 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import java.util.Iterator;
@@ -18,6 +34,10 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 
+/**
+ * This class manages and shows the automation settings dialog from the
+ * attribute view.
+ */
 public class AutomationSettingDialog extends TitleAreaDialog {
 
     private CCombo                        autoTypeCmb;
index 11a305d..dc44ad6 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import java.util.Iterator;
@@ -28,6 +44,9 @@ import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.PlatformUI;
 
+/**
+ * This class shows UI for creating resources.
+ */
 public class CreateResourcePage extends WizardPage {
 
     private Button stdResourceRbtn;
index 5beab41..47452cf 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import java.net.URL;
@@ -10,6 +26,9 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.wizard.Wizard;
 
+/**
+ * This class creates a UI wizard for create resource operation.
+ */
 public class CreateResourceWizard extends Wizard {
 
     private CreateResourcePage page;
index e40d570..a62f0ae 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import java.util.Iterator;
@@ -21,6 +37,9 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Text;
 
+/**
+ * This class shows UI for deleting resources.
+ */
 public class DeleteResourcePage extends WizardPage {
 
     private Button         allRbtn;
index 6b368dc..16c3c9c 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import java.net.URL;
@@ -15,6 +31,9 @@ import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.PlatformUI;
 
+/**
+ * This class creates a UI wizard for delete resource operation.
+ */
 public class DeleteResourceWizard extends Wizard {
 
     private DeleteResourcePage page;
index e0f4397..b43d4cc 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import java.util.ArrayList;
@@ -18,6 +34,9 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Shell;
 
+/**
+ * This class shows a dialog for filtering logs based on severity levels.
+ */
 public class FilterDialog extends TrayDialog {
     private Map<Integer, Boolean> severities;
 
index 489dff4..81c1f6a 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import java.text.DateFormat;
@@ -18,6 +34,10 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 
+/**
+ * This class shows detailed information about a log. The dialog will be opened
+ * on double-clicking a log entry in the log view.
+ */
 public class LogDetailsDialog extends Dialog {
     private final String severity;
     private final Date   date;
index 59dd8e0..09f95fe 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
 
 import org.eclipse.jface.dialogs.IDialogConstants;
@@ -7,6 +23,9 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Shell;
 
+/**
+ * Dialog for handling wizards.
+ */
 public class ResourceWizardDialog extends WizardDialog {
 
     public ResourceWizardDialog(Shell parentShell, IWizard newWizard) {
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/DeviceInfo.java b/service/simulator/java/sdk/src/org/oic/simulator/DeviceInfo.java
new file mode 100644 (file)
index 0000000..090d4b9
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * This class contains remote device information and provides APIs to access it.
+ */
+public class DeviceInfo {
+    private String mName;
+    private String mID;
+    private String mSpecVersion;
+    private String mDMVVersion;
+
+    /**
+     * This method is for getting the device name.
+     * 
+     * @return Device name.
+     */
+    public String getName() {
+        return mName;
+    }
+
+    /**
+     * This method is for getting the device id.
+     * 
+     * @return Device id.
+     */
+    public String getID() {
+        return mID;
+    }
+
+    /**
+     * This method is for getting device specification version.
+     * 
+     * @return Specification version.
+     */
+    public String getSpecVersion() {
+        return mSpecVersion;
+    }
+
+    /**
+     * This method is for getting device data model version.
+     * 
+     * @return Device data model version.
+     */
+    public String getDataModelVersion() {
+        return mDMVVersion;
+    }
+}
index 4dbe18e..e74fbd1 100644 (file)
@@ -14,9 +14,6 @@
  * limitations under the License.
  */
 
-/**
- * This file provides an interface for receiving notification when an automation completes.
- */
 package org.oic.simulator;
 
 /**
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/IDeviceInfo.java b/service/simulator/java/sdk/src/org/oic/simulator/IDeviceInfo.java
new file mode 100644 (file)
index 0000000..0d4c8a3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * Interface for getting device information.
+ */
+public interface IDeviceInfo {
+    /**
+     * Callback method which provides remote device information.
+     * 
+     * @param devInfo
+     *            {@link DeviceInfo} object holding the device information.
+     */
+    public void onDeviceFound(DeviceInfo devInfo);
+}
index 629899f..082e59e 100644 (file)
@@ -14,9 +14,6 @@
  * limitations under the License.
  */
 
-/**
- * This file provides an interface for handling the log messages.
- */
 package org.oic.simulator;
 
 /**
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/IPlatformInfo.java b/service/simulator/java/sdk/src/org/oic/simulator/IPlatformInfo.java
new file mode 100644 (file)
index 0000000..9d948ce
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * Interface for getting platform information.
+ */
+public interface IPlatformInfo {
+    /**
+     * Callback method which provides remote device platform information.
+     * 
+     * @param platformInfo
+     *            {@link PlatformInfo} object holding the platform information.
+     */
+    public void onPlatformFound(PlatformInfo platformInfo);
+}
  * limitations under the License.
  */
 
-/**
- * This file provides a enum which contains the automation types.
- */
 package org.oic.simulator;
 
 /**
- * This Enum contains the different types of automation which are supported by
- * the simulator.
+ * Class for representing invalid arguments exception.
  */
-public enum AutomationType {
-    NORMAL, RECURRENT
+@SuppressWarnings("serial")
+public class InvalidArgsException extends SimulatorException {
+    private InvalidArgsException(int errorCode, String errMessage) {
+        super(errorCode, errMessage);
+    }
 }
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/NoSupportException.java b/service/simulator/java/sdk/src/org/oic/simulator/NoSupportException.java
new file mode 100644 (file)
index 0000000..3329fd2
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * Class for representing unsupported operations exception.
+ */
+@SuppressWarnings("serial")
+public class NoSupportException extends SimulatorException {
+    private NoSupportException(int errorCode, String errMessage) {
+        super(errorCode, errMessage);
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/OCSimulatorResult.java b/service/simulator/java/sdk/src/org/oic/simulator/OCSimulatorResult.java
deleted file mode 100644 (file)
index 296cd06..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- * 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.
- */
-
-/**
- * This file provides a Enum which contains Status codes for Success and Errors.
- */
-package org.oic.simulator;
-
-/**
- * This Enum contains Status codes for Success and Errors.
- */
-public enum OCSimulatorResult {
-    OC_STACK_OK,
-    OC_STACK_RESOURCE_CREATED,
-    OC_STACK_RESOURCE_DELETED,
-    OC_STACK_CONTINUE,
-    OC_STACK_INVALID_URI,
-    OC_STACK_INVALID_QUERY,
-    OC_STACK_INVALID_IP,
-    OC_STACK_INVALID_PORT,
-    OC_STACK_INVALID_CALLBACK,
-    OC_STACK_INVALID_METHOD,
-    OC_STACK_INVALID_PARAM,
-    OC_STACK_INVALID_OBSERVE_PARAM,
-    OC_STACK_NO_MEMORY,
-    OC_STACK_COMM_ERROR,
-    OC_STACK_NOTIMPL,
-    OC_STACK_NO_RESOURCE,
-    OC_STACK_RESOURCE_ERROR,
-    OC_STACK_SLOW_RESOURCE,
-    OC_STACK_REPEATED_REQUEST,
-    OC_STACK_NO_OBSERVERS,
-    OC_STACK_OBSERVER_NOT_FOUND,
-    OC_STACK_VIRTUAL_DO_NOT_HANDLE,
-    OC_STACK_INVALID_OPTION,
-    OC_STACK_MALFORMED_RESPONSE,
-    OC_STACK_PERSISTENT_BUFFER_REQUIRED,
-    OC_STACK_INVALID_REQUEST_HANDLE,
-    OC_STACK_INVALID_DEVICE_INFO,
-    OC_STACK_INVALID_JSON,
-    OC_STACK_PRESENCE_STOPPED,
-    OC_STACK_PRESENCE_TIMEOUT,
-    OC_STACK_PRESENCE_DO_NOT_HANDLE,
-    OC_STACK_ERROR,
-    OC_STACK_LISTENER_NOT_SET;
-
-    public static OCSimulatorResult conversion(int ordinal) {
-
-        OCSimulatorResult result = OCSimulatorResult.values()[31];
-
-        if (ordinal == 0)
-            result = OCSimulatorResult.values()[0];
-        else if (ordinal == 1)
-            result = OCSimulatorResult.values()[1];
-        else if (ordinal == 2)
-            result = OCSimulatorResult.values()[2];
-        else if (ordinal == 3)
-            result = OCSimulatorResult.values()[3];
-
-        else if (ordinal == 20)
-            result = OCSimulatorResult.values()[4];
-        else if (ordinal == 21)
-            result = OCSimulatorResult.values()[5];
-        else if (ordinal == 22)
-            result = OCSimulatorResult.values()[6];
-        else if (ordinal == 23)
-            result = OCSimulatorResult.values()[7];
-        else if (ordinal == 24)
-            result = OCSimulatorResult.values()[8];
-        else if (ordinal == 25)
-            result = OCSimulatorResult.values()[9];
-        else if (ordinal == 26)
-            result = OCSimulatorResult.values()[10];
-        else if (ordinal == 27)
-            result = OCSimulatorResult.values()[11];
-        else if (ordinal == 28)
-            result = OCSimulatorResult.values()[12];
-        else if (ordinal == 29)
-            result = OCSimulatorResult.values()[13];
-        else if (ordinal == 30)
-            result = OCSimulatorResult.values()[14];
-        else if (ordinal == 31)
-            result = OCSimulatorResult.values()[15];
-        else if (ordinal == 32)
-            result = OCSimulatorResult.values()[16];
-        else if (ordinal == 33)
-            result = OCSimulatorResult.values()[17];
-        else if (ordinal == 34)
-            result = OCSimulatorResult.values()[18];
-        else if (ordinal == 35)
-            result = OCSimulatorResult.values()[19];
-        else if (ordinal == 36)
-            result = OCSimulatorResult.values()[20];
-        else if (ordinal == 37)
-            result = OCSimulatorResult.values()[21];
-        else if (ordinal == 38)
-            result = OCSimulatorResult.values()[22];
-        else if (ordinal == 39)
-            result = OCSimulatorResult.values()[23];
-        else if (ordinal == 40)
-            result = OCSimulatorResult.values()[24];
-        else if (ordinal == 41)
-            result = OCSimulatorResult.values()[25];
-        else if (ordinal == 42)
-            result = OCSimulatorResult.values()[26];
-        else if (ordinal == 43)
-            result = OCSimulatorResult.values()[27];
-
-        else if (ordinal == 128)
-            result = OCSimulatorResult.values()[28];
-        else if (ordinal == 129)
-            result = OCSimulatorResult.values()[29];
-        else if (ordinal == 130)
-            result = OCSimulatorResult.values()[30];
-
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/OperationInProgressException.java b/service/simulator/java/sdk/src/org/oic/simulator/OperationInProgressException.java
new file mode 100644 (file)
index 0000000..0a95097
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * Class for representing an exception that will be thrown to indicate requested
+ * operation is not allowed as other operation is in progress state.
+ */
+@SuppressWarnings("serial")
+public class OperationInProgressException extends SimulatorException {
+    private OperationInProgressException(int errorCode, String errMessage) {
+        super(errorCode, errMessage);
+    }
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/PlatformInfo.java b/service/simulator/java/sdk/src/org/oic/simulator/PlatformInfo.java
new file mode 100644 (file)
index 0000000..2b97e13
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * This class contains remote device platform information and provide APIs
+ * access it.
+ */
+public class PlatformInfo {
+    private String mPlatformId;
+    private String m_manufacturerName;
+    private String m_manufacturerUrl;
+    private String m_modelNumber;
+    private String m_dateOfManufacture;
+    private String m_platformVersion;
+    private String m_operationSystemVersion;
+    private String m_hardwareVersion;
+    private String m_firmwareVersion;
+    private String m_supportUrl;
+    private String m_systemTime;
+
+    /**
+     * This method is for getting platform id.
+     * 
+     * @return Platform id.
+     */
+    public String getPlatformID() {
+        return mPlatformId;
+    }
+
+    /**
+     * This method is for setting platform id.
+     * 
+     * @param mPlatformId
+     *            Platform identifier.
+     */
+    public void setPlatformID(String mPlatformId) {
+        this.mPlatformId = mPlatformId;
+    }
+
+    /**
+     * This method is for getting manufacturer name.
+     * 
+     * @return Manufacturer name.
+     */
+    public String getManufacturerName() {
+        return m_manufacturerName;
+    }
+
+    /**
+     * This method is for setting manufacturer name.
+     * 
+     * @param m_manufacturerName
+     *            Manufacturer name.
+     */
+    public void setManufacturerName(String m_manufacturerName) {
+        this.m_manufacturerName = m_manufacturerName;
+    }
+
+    /**
+     * This method is for getting manufacturer URL.
+     * 
+     * @return Manufacturer URL.
+     */
+    public String getManufacturerUrl() {
+        return m_manufacturerUrl;
+    }
+
+    /**
+     * This method is for setting manufacturer URL.
+     * 
+     * @param m_manufacturerUrl
+     *            Manufacturer URL.
+     */
+    public void setManufacturerUrl(String m_manufacturerUrl) {
+        this.m_manufacturerUrl = m_manufacturerUrl;
+    }
+
+    /**
+     * This method is for getting model number.
+     * 
+     * @return Model number.
+     */
+    public String getModelNumber() {
+        return m_modelNumber;
+    }
+
+    /**
+     * This method is for setting model number.
+     * 
+     * @param m_modelNumber
+     *            Model number.
+     */
+    public void setModelNumber(String m_modelNumber) {
+        this.m_modelNumber = m_modelNumber;
+    }
+
+    /**
+     * This method is for getting date of manufacture.
+     * 
+     * @return Date of manufacture.
+     */
+    public String getDateOfManufacture() {
+        return m_dateOfManufacture;
+    }
+
+    /**
+     * This method is for setting date of manufacture.
+     * 
+     * @param m_dateOfManufacture
+     *            Date of manufacture.
+     */
+    public void setDateOfManufacture(String m_dateOfManufacture) {
+        this.m_dateOfManufacture = m_dateOfManufacture;
+    }
+
+    /**
+     * This method is for getting platform version.
+     * 
+     * @return Platform version.
+     */
+    public String getPlatformVersion() {
+        return m_platformVersion;
+    }
+
+    /**
+     * This method is for setting platform version.
+     * 
+     * @param m_platformVersion
+     *            Platform version.
+     */
+    public void setPlatformVersion(String m_platformVersion) {
+        this.m_platformVersion = m_platformVersion;
+    }
+
+    /**
+     * This method is for getting operating system version.
+     * 
+     * @return Operation system version.
+     */
+    public String getOperationSystemVersion() {
+        return m_operationSystemVersion;
+    }
+
+    /**
+     * This method is for setting operating system version.
+     * 
+     * @param m_operationSystemVersion
+     *            Operation system version.
+     */
+    public void setOperationSystemVersion(String m_operationSystemVersion) {
+        this.m_operationSystemVersion = m_operationSystemVersion;
+    }
+
+    /**
+     * This method is for getting hardware version.
+     * 
+     * @return Hardware version.
+     */
+    public String getHardwareVersion() {
+        return m_hardwareVersion;
+    }
+
+    /**
+     * This method is for setting hardware version.
+     * 
+     * @param m_hardwareVersion
+     *            Hardware version.
+     */
+    public void setHardwareVersion(String m_hardwareVersion) {
+        this.m_hardwareVersion = m_hardwareVersion;
+    }
+
+    /**
+     * This method is for getting firmware version.
+     * 
+     * @return Firmware version.
+     */
+    public String getFirmwareVersion() {
+        return m_firmwareVersion;
+    }
+
+    /**
+     * This method is for setting firmware version.
+     * 
+     * @param m_firmwareVersion
+     *            Firmware version.
+     */
+    public void setFirmwareVersion(String m_firmwareVersion) {
+        this.m_firmwareVersion = m_firmwareVersion;
+    }
+
+    /**
+     * This method is for getting support link URL.
+     * 
+     * @return URL of support link.
+     */
+    public String getSupportUrl() {
+        return m_supportUrl;
+    }
+
+    /**
+     * This method is for setting support link URL.
+     * 
+     * @param m_supportUrl
+     *            URL of support link.
+     */
+    public void setSupportUrl(String m_supportUrl) {
+        this.m_supportUrl = m_supportUrl;
+    }
+
+    /**
+     * This method is for getting system time.
+     * 
+     * @return System time.
+     */
+    public String getSystemTime() {
+        return m_systemTime;
+    }
+
+    /**
+     * This method is for setting system time.
+     * 
+     * @param m_systemTime
+     *            System time.
+     */
+    public void setSystemTime(String m_systemTime) {
+        this.m_systemTime = m_systemTime;
+    }
+}
index ffda865..9f39fc5 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file contains a class which has a set of native methods for
- * getting the information associated with a particular attribute.
- */
 package org.oic.simulator;
 
 /**
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/SimulatorException.java b/service/simulator/java/sdk/src/org/oic/simulator/SimulatorException.java
new file mode 100644 (file)
index 0000000..7b4c5c8
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * Base class for simulator exceptions that will be thrown to indicate general
+ * exceptions.
+ */
+@SuppressWarnings("serial")
+public class SimulatorException extends Exception {
+
+    private SimulatorResult errorCode;
+    private String          errorMessage;
+
+    public SimulatorException(int errorCode, String errMessage) {
+        this.errorCode = SimulatorResult.get(errorCode);
+        this.errorMessage = errMessage;
+    }
+
+    public SimulatorResult code() {
+        return errorCode;
+    }
+
+    public String message() {
+        return errorMessage;
+    }
+}
\ No newline at end of file
index ee4691f..ca14557 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file contains a class which has the methods
- * for creation and deletion of resources.
- */
 package org.oic.simulator;
 
-import java.util.ArrayList;
-import java.util.Vector;
-
 import org.oic.simulator.clientcontroller.IFindResourceListener;
-import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
 import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
 
 /**
- * This class provides a set of methods for creation and deletion of resources.
+ * This class provides a set of methods for creation, discovery and deletion of
+ * resources.
  */
 public class SimulatorManager {
 
     /**
-     * Set listener for receiving log messages.
-     *
-     * @param logger
-     *            {@link ILogger} to receive the log messages.
-     */
-    public static void setLogger(ILogger logger) {
-        SimulatorManagerNativeInterface.setLogger(logger);
-    }
-
-    /**
      * API for creating a resource from a RAML configuration file whose path is
      * given as a parameter.
      *
@@ -55,9 +38,15 @@ public class SimulatorManager {
      * 
      * @return {@link SimulatorResourceServer} - Created resource on success,
      *         otherwise null.
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the input parameters are empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
     public static SimulatorResourceServer createResource(String configPath,
-            IResourceModelChangedListener listener) {
+            IResourceModelChangedListener listener)
+            throws InvalidArgsException, SimulatorException {
         SimulatorResourceServer simulatorResourceServerObj;
         simulatorResourceServerObj = SimulatorManagerNativeInterface
                 .createResource(configPath, listener);
@@ -78,9 +67,15 @@ public class SimulatorManager {
      * 
      * @return Returns an array of {@link SimulatorResourceServer} objects one
      *         for each created resource on success, otherwise null.
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the input parameters are empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
     public static SimulatorResourceServer[] createResource(String configPath,
-            int count, IResourceModelChangedListener listener) {
+            int count, IResourceModelChangedListener listener)
+            throws InvalidArgsException, SimulatorException {
         SimulatorResourceServer[] simulatorResourceServers;
         simulatorResourceServers = SimulatorManagerNativeInterface
                 .createResources(configPath, count, listener);
@@ -88,26 +83,19 @@ public class SimulatorManager {
     }
 
     /**
-     * API for getting all locally created resources.
-     *
-     * @return Returns a list of {@link SimulatorResourceServer} objects on
-     *         success, otherwise null.
-     */
-    public static Vector<SimulatorResourceServer> getLocalResources() {
-        Vector<SimulatorResourceServer> simulatorResourceServerVector = null;
-        simulatorResourceServerVector = SimulatorManagerNativeInterface
-                .getResources();
-        return simulatorResourceServerVector;
-    }
-
-    /**
      * API for deleting a specific resource.
      *
      * @param resource
      *            {@link SimulatorResourceServer} object of the resource to be
      *            deleted.
+     *
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static void deleteResource(SimulatorResourceServer resource) {
+    public static void deleteResource(SimulatorResourceServer resource)
+            throws InvalidArgsException, SimulatorException {
         SimulatorManagerNativeInterface.deleteResource(resource);
     }
 
@@ -119,47 +107,101 @@ public class SimulatorManager {
      *
      * @param resourceType
      *            Type of resource to be deleted.
+     *
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static void deleteResources(String resourceType) {
+    public static void deleteResources(String resourceType)
+            throws InvalidArgsException, SimulatorException {
         SimulatorManagerNativeInterface.deleteResources(resourceType);
     }
 
     /**
-     * API for discovering resources in the network. Callback is called whenever
-     * a resource is discovered in the network.
+     * API for discovering all types of resources in the network. Callback is
+     * called when a resource is discovered in the network.
      *
-     * @param resourceType
-     *            Required resource type
      * @param listener
      *            Interface to receive the discovered remote resources.
      * 
-     * @return OCSimulatorResult - return value of this API. It returns
-     *         OC_STACK_OK if success.
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static OCSimulatorResult findResource(String resourceType,
-            IFindResourceListener listener) {
-        OCSimulatorResult result;
-        int ordinal = SimulatorManagerNativeInterface.findResource(
-                resourceType, listener);
-        result = OCSimulatorResult.conversion(ordinal);
-        return result;
+    public static void findResource(IFindResourceListener listener)
+            throws InvalidArgsException, SimulatorException {
+        SimulatorManagerNativeInterface.findResource(listener);
     }
 
     /**
-     * API for getting the list of previously discovered resources in the
-     * network.
+     * API for discovering specific type of resources in the network. Callback
+     * is called when a resource is discovered in the network.
      *
      * @param resourceType
      *            Required resource type
+     * @param listener
+     *            Interface to receive the discovered remote resources.
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
+     */
+    public static void findResources(String resourceType,
+            IFindResourceListener listener) throws InvalidArgsException,
+            SimulatorException {
+        SimulatorManagerNativeInterface.findResources(resourceType, listener);
+    }
+
+    /**
+     * API to set the listener for receiving log messages.
      *
-     * @return A list of {@link SimulatorRemoteResource} - returns list of
-     *         SimulatorRemoteResource
-     *
+     * @param logger
+     *            {@link ILogger} to receive the log messages.
+     */
+    public static void setLogger(ILogger logger) {
+        SimulatorManagerNativeInterface.setLogger(logger);
+    }
+
+    /**
+     * API to set the device information.
+     * 
+     * @param deviceInfo
+     *            Device information.
+     */
+    public static void setDeviceInfo(String deviceInfo) {
+        SimulatorManagerNativeInterface.setDeviceInfo(deviceInfo);
+    }
+
+    /**
+     * API to get the device information asynchronously via the listener.
+     * 
+     * @param listener
+     *            Interface for receiving the device information.
+     */
+    public static void getDeviceInfo(IDeviceInfo listener) {
+        SimulatorManagerNativeInterface.getDeviceInfo(listener);
+    }
+
+    /**
+     * API to set the platform information.
+     * 
+     * @param platformInfo
+     *            {@link PlatformInfo} - Platform information.
+     */
+    public static void setPlatformInfo(PlatformInfo platformInfo) {
+        SimulatorManagerNativeInterface.setPlatformInfo(platformInfo);
+    }
+
+    /**
+     * API to get the platform information asynchronously via the listener.
+     * 
+     * @param listener
+     *            Interface for receiving the platform information.
      */
-    public static ArrayList<SimulatorRemoteResource> getFoundResources(
-            String resourceType) {
-        ArrayList<SimulatorRemoteResource> resourceList = SimulatorManagerNativeInterface
-                .getFoundResources(resourceType);
-        return resourceList;
+    public static void getPlatformInfo(IPlatformInfo listener) {
+        SimulatorManagerNativeInterface.getPlatformInfo(listener);
     }
 }
\ No newline at end of file
index dc33156..62410cc 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file contains a class which provides a set of native methods
- * for creation and deletion of resources.
- */
 package org.oic.simulator;
 
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Vector;
-
 import org.oic.simulator.clientcontroller.IFindResourceListener;
-import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
-import org.oic.simulator.ILogger;
 import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
 
 /**
- * This class provides a set of native functions for creation and deletion of
- * resources.
+ * This class provides a set of native functions for creation, discovery and
+ * deletion of resources.
  */
 class SimulatorManagerNativeInterface {
 
@@ -47,9 +37,15 @@ class SimulatorManagerNativeInterface {
      *
      * @return {@link SimulatorResourceServer} object on success, otherwise
      *         null.
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the input parameters are empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
     public static native SimulatorResourceServer createResource(
-            String configPath, IResourceModelChangedListener listener);
+            String configPath, IResourceModelChangedListener listener)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function for creating several resources.
@@ -64,98 +60,116 @@ class SimulatorManagerNativeInterface {
      *
      * @return An array of {@link SimulatorResourceServer} objects on success,
      *         otherwise null.
-     */
-    public static native SimulatorResourceServer[] createResources(
-            String configPath, int count, IResourceModelChangedListener listener);
-
-    /**
-     * Native function to get the list of locally created resources.
      *
-     * @return A list of {@link SimulatorResourceServer} objects on success,
-     *         otherwise null.
+     * @throws InvalidArgsException
+     *             Thrown if the input parameters are empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static native Vector<SimulatorResourceServer> getResources();
+    public static native SimulatorResourceServer[] createResources(
+            String configPath, int count, IResourceModelChangedListener listener)
+            throws InvalidArgsException, SimulatorException;
 
     /**
-     * Native function to delete a specific resource
+     * Native function to delete a specific resource.
      *
      * @param resource
      *            {@link SimulatorResourceServer} object of the resource to be
      *            deleted.
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static native void deleteResource(SimulatorResourceServer resource);
+    public static native void deleteResource(SimulatorResourceServer resource)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to delete all resources or resources of a specific type.
      *
      * @param resourceType
      *            Type of the resource.
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static native void deleteResources(String resourceType);
+    public static native void deleteResources(String resourceType)
+            throws InvalidArgsException, SimulatorException;
 
     /**
-     * Native function to set the logger listener for receiving the log messages
-     * from native layer.
+     * Native function for discovering all types of resources.
+     *
+     * @param listener
+     *            Interface to receive the discovered remote resources.
      * 
-     * @param logger
-     *            Interface to receive log.
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static native void setLogger(ILogger logger);
+    public static native void findResource(IFindResourceListener listener)
+            throws InvalidArgsException, SimulatorException;
 
     /**
-     * Native function for discovering resources.
+     * Native function for discovering specific type of resources.
      *
      * @param resourceType
      *            required resource type
      * @param listener
      *            Interface to receive the discovered remote resources.
-     *
-     * @return OCSimulatorResult - return value of this API. It returns
-     *         OC_STACK_OK if success.
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the input parameter is empty.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public static native int findResource(String resourceType,
-            IFindResourceListener listener);
+    public static native void findResources(String resourceType,
+            IFindResourceListener listener) throws InvalidArgsException,
+            SimulatorException;
 
     /**
-     * Native function for getting the list of previously discovered resources
-     * in the network.
-     *
-     * @param resourceType
-     *            required resource type
-     *
-     * @return ArrayList<SimulatorRemoteResource> - returns list of
-     *         SimulatorRemoteResource
-     *
+     * Native function to set the logger listener for receiving the log messages
+     * from native layer.
+     * 
+     * @param logger
+     *            Interface to receive log.
      */
-    public static native ArrayList<SimulatorRemoteResource> getFoundResources(
-            String resourceType);
+    public static native void setLogger(ILogger logger);
 
     /**
-     * Method to get the URI for this resource
-     *
-     * @return Resource URI
+     * Native function to set the device information.
+     * 
+     * @param deviceInfo
+     *            Device information.
      */
-    public static native String getUri();
+    public static native void setDeviceInfo(String deviceInfo);
 
     /**
-     * Method to get the list of resource types
-     *
-     * @return List of resource types
+     * Native function to get the device information asynchronously via the
+     * listener.
+     * 
+     * @param listener
+     *            Interface for receiving the device information.
      */
-    public static native List<String> getResourceTypes();
+    public static native void getDeviceInfo(IDeviceInfo listener);
 
     /**
-     * Method to get the list of resource interfaces
-     *
-     * @return List of resource interfaces
+     * Native function to set the platform information.
+     * 
+     * @param platformInfo
+     *            Platform information.
      */
-    public static native List<String> getResourceInterfaces();
+    public static native void setPlatformInfo(PlatformInfo platformInfo);
 
     /**
-     * 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
+     * Native function to get the platform information asynchronously via the
+     * listener.
+     * 
+     * @param listener
+     *            Interface for receiving the platform information.
      */
-    public static native String getServerId();
+    public static native void getPlatformInfo(IPlatformInfo listener);
 }
\ No newline at end of file
index 199f819..49bc4c0 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file contains a class which has a set of native methods for accessing
- * the resource model.
- */
 package org.oic.simulator;
 
 import org.oic.simulator.ResourceAttribute;
@@ -30,7 +26,9 @@ import java.util.Map;
 public class SimulatorResourceModel {
 
     /**
-     * Constructor.
+     * Constructor for creating a native resource model object. Client requests
+     * such as PUT and POST uses this method for passing the new new/updated
+     * resource model.
      */
     public SimulatorResourceModel() {
         create();
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/SimulatorResult.java b/service/simulator/java/sdk/src/org/oic/simulator/SimulatorResult.java
new file mode 100644 (file)
index 0000000..62d1c4c
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator;
+
+/**
+ * This Enum contains Status codes for Success and Errors.
+ */
+public enum SimulatorResult {
+    /** STACK error codes - START */
+    SIMULATOR_OK,
+    SIMULATOR_RESOURCE_CREATED,
+    SIMULATOR_RESOURCE_DELETED,
+    SIMULATOR_CONTINUE,
+    SIMULATOR_INVALID_URI,
+    SIMULATOR_INVALID_QUERY,
+    SIMULATOR_INVALID_IP,
+    SIMULATOR_INVALID_PORT,
+    SIMULATOR_INVALID_CALLBACK,
+    SIMULATOR_INVALID_METHOD,
+    SIMULATOR_INVALID_PARAM,
+    SIMULATOR_INVALID_OBSERVE_PARAM,
+    SIMULATOR_NO_MEMORY,
+    SIMULATOR_COMM_ERROR,
+    SIMULATOR_TIMEOUT,
+    SIMULATOR_ADAPTER_NOT_ENABLED,
+    SIMULATOR_NOTIMPL,
+    SIMULATOR_NO_RESOURCE,
+    SIMULATOR_RESOURCE_ERROR,
+    SIMULATOR_SLOW_RESOURCE,
+    SIMULATOR_DUPLICATE_REQUEST,
+    SIMULATOR_NO_OBSERVERS,
+    SIMULATOR_OBSERVER_NOT_FOUND,
+    SIMULATOR_VIRTUAL_DO_NOT_HANDLE,
+    SIMULATOR_INVALID_OPTION,
+    SIMULATOR_MALFORMED_RESPONSE,
+    SIMULATOR_PERSISTENT_BUFFER_REQUIRED,
+    SIMULATOR_INVALID_REQUEST_HANDLE,
+    SIMULATOR_INVALID_DEVICE_INFO,
+    SIMULATOR_INVALID_JSON,
+    SIMULATOR_UNAUTHORIZED_REQ,
+
+    SIMULATOR_PRESENCE_STOPPED,
+    SIMULATOR_PRESENCE_TIMEOUT,
+    SIMULATOR_PRESENCE_DO_NOT_HANDLE,
+    /** STACK error codes - END */
+
+    /** Simulator specific error codes - START */
+    SIMULATOR_INVALID_TYPE,
+    SIMULATOR_NOT_SUPPORTED,
+    SIMULATOR_OPERATION_NOT_ALLOWED,
+    SIMULATOR_OPERATION_IN_PROGRESS,
+
+    SIMULATOR_INVALID_RESPONSE_CODE,
+    SIMULATOR_UKNOWN_PROPERTY,
+    SIMULATOR_TYPE_MISMATCH,
+    SIMULATOR_BAD_VALUE,
+    /** Simulator specific error codes - END */
+
+    SIMULATOR_ERROR;
+
+    public static SimulatorResult get(int ordinal) {
+
+        SimulatorResult result;
+
+        if (ordinal == 0)
+            result = SimulatorResult.values()[0];
+        else if (ordinal == 1)
+            result = SimulatorResult.values()[1];
+        else if (ordinal == 2)
+            result = SimulatorResult.values()[2];
+        else if (ordinal == 3)
+            result = SimulatorResult.values()[3];
+
+        else if (ordinal == 20)
+            result = SimulatorResult.values()[4];
+        else if (ordinal == 21)
+            result = SimulatorResult.values()[5];
+        else if (ordinal == 22)
+            result = SimulatorResult.values()[6];
+        else if (ordinal == 23)
+            result = SimulatorResult.values()[7];
+        else if (ordinal == 24)
+            result = SimulatorResult.values()[8];
+        else if (ordinal == 25)
+            result = SimulatorResult.values()[9];
+        else if (ordinal == 26)
+            result = SimulatorResult.values()[10];
+        else if (ordinal == 27)
+            result = SimulatorResult.values()[11];
+        else if (ordinal == 28)
+            result = SimulatorResult.values()[12];
+        else if (ordinal == 29)
+            result = SimulatorResult.values()[13];
+        else if (ordinal == 30)
+            result = SimulatorResult.values()[14];
+        else if (ordinal == 31)
+            result = SimulatorResult.values()[15];
+        else if (ordinal == 32)
+            result = SimulatorResult.values()[16];
+        else if (ordinal == 33)
+            result = SimulatorResult.values()[17];
+        else if (ordinal == 34)
+            result = SimulatorResult.values()[18];
+        else if (ordinal == 35)
+            result = SimulatorResult.values()[19];
+        else if (ordinal == 36)
+            result = SimulatorResult.values()[20];
+        else if (ordinal == 37)
+            result = SimulatorResult.values()[21];
+        else if (ordinal == 38)
+            result = SimulatorResult.values()[22];
+        else if (ordinal == 39)
+            result = SimulatorResult.values()[23];
+        else if (ordinal == 40)
+            result = SimulatorResult.values()[24];
+        else if (ordinal == 41)
+            result = SimulatorResult.values()[25];
+        else if (ordinal == 42)
+            result = SimulatorResult.values()[26];
+        else if (ordinal == 43)
+            result = SimulatorResult.values()[27];
+        else if (ordinal == 44)
+            result = SimulatorResult.values()[28];
+        else if (ordinal == 45)
+            result = SimulatorResult.values()[29];
+        else if (ordinal == 46)
+            result = SimulatorResult.values()[30];
+                
+        else if (ordinal == 128)
+            result = SimulatorResult.values()[31];
+        else if (ordinal == 129)
+            result = SimulatorResult.values()[32];
+        else if (ordinal == 130)
+            result = SimulatorResult.values()[33];
+
+        else if (ordinal == 131 || ordinal == 47)
+            result = SimulatorResult.values()[34];
+        else if (ordinal == 132 || ordinal == 48)
+            result = SimulatorResult.values()[35];
+        else if (ordinal == 133 || ordinal == 49)
+            result = SimulatorResult.values()[36];
+        else if (ordinal == 134 || ordinal == 50)
+            result = SimulatorResult.values()[37];
+        
+        else if (ordinal == 135 || ordinal == 51)
+            result = SimulatorResult.values()[38];
+        else if (ordinal == 136 || ordinal == 52)
+            result = SimulatorResult.values()[39];
+        else if (ordinal == 137 || ordinal == 53)
+            result = SimulatorResult.values()[40];
+        else if (ordinal == 138 || ordinal == 54)
+            result = SimulatorResult.values()[41];
+        
+        else
+            result = SimulatorResult.values()[42];
+        return result;
+    }
+}
\ No newline at end of file
index dc63e95..dcd9557 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides interface for getting notification when resources are
- * discovered in network.
- */
 package org.oic.simulator.clientcontroller;
 
 import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
@@ -28,11 +24,12 @@ import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
  */
 public interface IFindResourceListener {
     /**
-     * This callback method will be called whenever resource is discovered in
-     * the network.
+     * This callback method will be called when resource is discovered in the
+     * network.
      *
      * @param resource
-     *            resource discovered in the network
+     *            {@link SimulatorRemoteResource} object representing the
+     *            resource discovered in the network.
      */
     public void onResourceCallback(SimulatorRemoteResource resource);
 }
index 24f89a4..3436a3d 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides interface for get callback information.
- */
 package org.oic.simulator.clientcontroller;
 
 import org.oic.simulator.SimulatorResourceModel;
 
 /**
- * An OnGetListener can be registered via the resource get call. Event listeners
- * are notified asynchronously
+ * Interface for receiving response for GET request. An IGetListener can be
+ * registered via the resource get call. Event listeners are notified
+ * asynchronously.
  */
 public interface IGetListener {
+    /**
+     * This method will be called when response from the remote resource for GET
+     * request arrives.
+     * 
+     * @param uId
+     *            Unique Id of the resource.
+     * @param representation
+     *            {@link SimulatorResourceModel}.
+     */
     public void onGetCompleted(String uId, SimulatorResourceModel representation);
 
+    /**
+     * Called when there is an error in GET request.
+     * 
+     * @param ex
+     *            Error information.
+     */
     public void onGetFailed(Throwable ex);
 }
index cdf297c..f09feaf 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides interface for getting notification on resource model change.
- */
 package org.oic.simulator.clientcontroller;
 
 import org.oic.simulator.SimulatorResourceModel;
 
 /**
  * Provides interface for getting notification when resource model of an
- * observed resource gets changed. An OnObserveListener can be registered via
- * the SimulatorRemoteResource observe call. Event listeners are notified
+ * observed resource gets changed. An IObserveListener can be registered via the
+ * SimulatorRemoteResource observe call. Event listeners are notified
  * asynchronously.
  */
 public interface IObserveListener {
+    /**
+     * This method will be called when there is a change in the resource model
+     * of the remote resource.
+     * 
+     * @param uId
+     *            Unique Id of the resource.
+     * @param representation
+     *            {@link SimulatorResourceModel}.
+     * @param sequenceNumber
+     *            Sequential number for ordering the model change notifications.
+     */
     public void onObserveCompleted(String uId,
             SimulatorResourceModel representation, int sequenceNumber);
 
+    /**
+     * Called when there is an error in observe request.
+     * 
+     * @param ex
+     *            Error information.
+     */
     public void onObserveFailed(Throwable ex);
 }
index 1b4ddcb..5f4cbe0 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides interface for post callback information.
- */
 package org.oic.simulator.clientcontroller;
 
 import org.oic.simulator.SimulatorResourceModel;
 
 /**
- * An OnPostListener can be registered via the resource post call. Event
- * listeners are notified asynchronously
+ * Interface for receiving response for POST request. An IPostListener can be
+ * registered via the resource post call. Event listeners are notified
+ * asynchronously.
  */
 public interface IPostListener {
+    /**
+     * This method will be called when response from the remote resource for
+     * POST request arrives.
+     * 
+     * @param uId
+     *            Unique Id of the resource.
+     * @param representation
+     *            {@link SimulatorResourceModel}.
+     */
     public void onPostCompleted(String uId,
             SimulatorResourceModel representation);
 
+    /**
+     * Called when there is an error in POST request.
+     * 
+     * @param ex
+     *            Error information.
+     */
     public void onPostFailed(Throwable ex);
 }
index dced792..c44b917 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides interface for put callback information.
- */
 package org.oic.simulator.clientcontroller;
 
 import org.oic.simulator.SimulatorResourceModel;
 
 /**
- * An OnPutListener can be registered via the resource put call. Event listeners
- * are notified asynchronously
+ * Interface for receiving response for PUT request. An IPutListener can be
+ * registered via the resource put call. Event listeners are notified
+ * asynchronously.
  */
 public interface IPutListener {
+    /**
+     * This method will be called when response from the remote resource for PUT
+     * request arrives.
+     * 
+     * @param uId
+     *            Unique Id of the resource.
+     * @param representation
+     *            {@link SimulatorResourceModel}.
+     */
     public void onPutCompleted(String uId, SimulatorResourceModel representation);
 
+    /**
+     * Called when there is an error in PUT request.
+     * 
+     * @param ex
+     *            Error information.
+     */
     public void onPutFailed(Throwable ex);
 }
index 3b582c6..1114f6b 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides interface for verification callback information.
- */
 package org.oic.simulator.clientcontroller;
 
 /**
- * An OnVerificationListener can be registered via the resource
- * startVerification call. Event listeners are notified asynchronously.
+ * Interface for receiving the verification status via callback. An
+ * IVerificationListener can be registered via the resource startVerification
+ * call. Event listeners are notified asynchronously.
  */
 public interface IVerificationListener {
+    /**
+     * Called when the verification request is accepted and started.
+     * 
+     * @param uId
+     *            Unique Id of the resource.
+     * @param id
+     *            Verification Id.
+     */
     public void onVerificationStarted(String uId, int id);
 
+    /**
+     * Called when the verification is stopped before its completion.
+     * 
+     * @param uId
+     *            Unique Id of the resource.
+     * @param id
+     *            Verification Id.
+     */
     public void onVerificationAborted(String uId, int id);
 
+    /**
+     * Called when the verification is done.
+     * 
+     * @param uId
+     *            Unique Id of the resource.
+     * @param id
+     *            Verification Id.
+     */
     public void onVerificationCompleted(String uId, int id);
-}
+}
\ No newline at end of file
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorConnectivityType.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorConnectivityType.java
new file mode 100644 (file)
index 0000000..94eb195
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator.clientcontroller;
+
+/**
+ * Supported connectivity types.
+ */
+public enum SimulatorConnectivityType {
+    SIMULATOR_CT_DEFAULT(0),
+
+    /** IPv4 and IPv6, including 6LoWPAN. */
+    SIMULATOR_CT_ADAPTER_IP(1 << 16),
+
+    /** GATT over Bluetooth LE. */
+    SIMULATOR_CT_ADAPTER_GATT_BTLE(1 << 17),
+
+    /** RFCOMM over Bluetooth EDR. */
+    SIMULATOR_CT_ADAPTER_RFCOMM_BTEDR(1 << 18),
+
+    /** Remote Access over XMPP. */
+    SIMULATOR_CT_ADAPTER_REMOTE_ACCESS(1 << 19),
+
+    /** Insecure transport is the default (subject to change). */
+
+    /** secure the transport path. */
+    SIMULATOR_CT_FLAG_SECURE(1 << 4),
+
+    /** IPv4 & IPv6 autoselection is the default. */
+
+    /** IP adapter only. */
+    SIMULATOR_CT_IP_USE_V6(1 << 5),
+
+    /** IP adapter only. */
+    SIMULATOR_CT_IP_USE_V4(1 << 6),
+
+    /**
+     * Link-Local multicast is the default multicast scope for IPv6. These are
+     * placed here to correspond to the IPv6 address bits.
+     */
+
+    /** IPv6 Interface-Local scope(loopback). */
+    SIMULATOR_CT_SCOPE_INTERFACE(0x1),
+
+    /** IPv6 Link-Local scope (default). */
+    SIMULATOR_CT_SCOPE_LINK(0x2),
+
+    /** IPv6 Realm-Local scope. */
+    SIMULATOR_CT_SCOPE_REALM(0x3),
+
+    /** IPv6 Admin-Local scope. */
+    SIMULATOR_CT_SCOPE_ADMIN(0x4),
+
+    /** IPv6 Site-Local scope. */
+    SIMULATOR_CT_SCOPE_SITE(0x5),
+
+    /** IPv6 Organization-Local scope. */
+    SIMULATOR_CT_SCOPE_ORG(0x8),
+
+    /** IPv6 Global scope. */
+    SIMULATOR_CT_SCOPE_GLOBAL(0xE);
+
+    private int value;
+
+    private SimulatorConnectivityType(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+
+    /**
+     * Method to get the {@link SimulatorConnectivityType} from an integer
+     * value.
+     * 
+     * @param value
+     *            Integral value of {@link SimulatorConnectivityType}.
+     * @return {@link SimulatorConnectivityType} corresponding to the given
+     *         value.
+     */
+    public static SimulatorConnectivityType getConnectivityType(int value) {
+        SimulatorConnectivityType result = null;
+        SimulatorConnectivityType[] types = SimulatorConnectivityType.values();
+        for (SimulatorConnectivityType type : types) {
+            if (type.getValue() == value) {
+                result = type;
+                break;
+            }
+        }
+        return result;
+    }
+}
\ No newline at end of file
index ef38085..9f32d1c 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides a enum which contains the observable types.
- */
 package org.oic.simulator.clientcontroller;
 
+/**
+ * Enum for observe types.
+ */
 public enum SimulatorObserveType {
-    OBSERVE(0), OBSERVE_ALL(1);
+    OBSERVE(0), OBSERVE_ALL(1);
 
     private int value;
 
index 078e999..cfa9d78 100644 (file)
  * limitations under the License.
  */
 
-/**
- * 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.LinkedList;
 import java.util.Map;
 
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.NoSupportException;
+import org.oic.simulator.OperationInProgressException;
+import org.oic.simulator.SimulatorException;
 import org.oic.simulator.SimulatorResourceModel;
 
 /**
@@ -37,102 +37,125 @@ public class SimulatorRemoteResource {
     }
 
     /**
-     * Method to get the URI for this resource
+     * Method to get the URI for this resource.
      * 
-     * @return resource URI
+     * @return Resource URI
      */
     public String getUri() {
         return mUri;
     }
 
     /**
-     * Method to get the observe capability of this resource
+     * Method to get the observe capability of this resource.
      * 
-     * @return true if the resource is observable, otherwise false.
+     * @return True if the resource is observable, otherwise false.
      */
     public boolean getIsObservable() {
         return mIsObservable;
     }
 
     /**
-     * Method to get the connectivity type for this resource
+     * Method to get the connectivity type for this resource.
      * 
      * @return Connectivity type.
      */
-    public String getConnectivityType() {
-        return mConnType;
+    public SimulatorConnectivityType getConnectivityType() {
+        return SimulatorConnectivityType.getConnectivityType(mConnType);
     }
 
     /**
-     * Method to get the list of resource types
+     * Method to get the list of resource types.
      * 
-     * @return List of resource types
+     * @return List of resource types.
      */
     public LinkedList<String> getResourceTypes() {
         return mResTypes;
     }
 
     /**
-     * Method to get the list of resource interfaces
+     * Method to get the list of resource interfaces.
      * 
-     * @return List of resource interface
+     * @return List of resource interfaces.
      */
     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.
+     * Method to get a string representation of the host address of the remote
+     * resource.
      * 
-     * @return server ID
+     * @return Host address.
      */
-    public String getServerId() {
-        return mSid;
+    public String getHost() {
+        return mHost;
     }
 
     /**
-     * Method to get a unique Id of the resource.
+     * Method to get a unique Id for the resource.
      * 
      * @return Unique ID.
      */
-    public String getUid() {
-        return mUid;
+    public String getId() {
+        return mId;
     }
 
     /**
-     * Method to set observation on the resource
+     * Method to set observation on the remote resource.
      * 
      * @param observeType
-     *            allows the client to specify how it wants to observe
+     *            Allows the client to specify how it wants to observe.
      * @param queryParamsMap
-     *            map which can have the query parameter name and value
+     *            Map which can have the query parameter names and values.
      * @param onObserveListener
-     *            event handler The handler method will be invoked with a map of
-     *            attribute name and values.
+     *            The handler method which will be invoked with a map of
+     *            attribute names and values whenever there is a change in
+     *            resource model of the remote resource.
      * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
     public native void observe(SimulatorObserveType observeType,
             Map<String, String> queryParamsMap,
-            IObserveListener onObserveListener);
+            IObserveListener onObserveListener) throws InvalidArgsException,
+            SimulatorException;
 
     /**
-     * Method to cancel the observation on the resource
+     * Method to cancel the observation on the resource.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if the native remote resource
+     *             object is unavailable.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void cancelObserve();
+    public native void cancelObserve() throws InvalidArgsException,
+            SimulatorException;
 
     /**
      * Method to get the attributes of a resource.
      * 
      * @param queryParamsMap
-     *            map which can have the query parameter name and value
+     *            Map which can have the query parameter name and value.
      * @param onGetListener
-     *            The event handler will be invoked with a map of attribute name
-     *            and values. The event handler will also have the result from
-     *            this Get operation This will have error codes
+     *            Event handler which will be invoked with the response for GET
+     *            request with a map of attribute name and values.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws NoSupportException
+     *             This exception will be thrown if we cannot send GET request
+     *             to the remote resource.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
     public void get(Map<String, String> queryParamsMap,
-            IGetListener onGetListener) {
+            IGetListener onGetListener) throws InvalidArgsException,
+            NoSupportException, SimulatorException {
         this.get(null, queryParamsMap, onGetListener);
     }
 
@@ -140,106 +163,184 @@ public class SimulatorRemoteResource {
      * Method to get the attributes of a resource.
      * 
      * @param resourceInterface
-     *            interface type of the resource to operate on
+     *            Interface type of the resource to operate on.
      * @param queryParamsMap
-     *            map which can have the query parameter name and value
+     *            Map which can have the query parameter name and value.
      * @param onGetListener
-     *            The event handler will be invoked with a map of attribute name
-     *            and values. The event handler will also have the result from
-     *            this Get operation This will have error codes
+     *            Event handler which will be invoked with the response for GET
+     *            request with a map of attribute name and values.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws NoSupportException
+     *             This exception will be thrown if we cannot send GET request
+     *             to the remote resource.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
     public native void get(String resourceInterface,
-            Map<String, String> queryParamsMap, IGetListener onGetListener);
+            Map<String, String> queryParamsMap, IGetListener onGetListener)
+            throws InvalidArgsException, NoSupportException, SimulatorException;
 
     /**
      * Method to set the representation of a resource (via PUT)
      * 
      * @param representation
-     *            representation of the resource
+     *            {@link SimulatorResourceModel} holding the representation of
+     *            the resource.
      * @param queryParamsMap
-     *            Map which can have the query parameter name and value
+     *            Map which can have the query parameter name and value.
      * @param onPutListener
-     *            event handler The event handler will be invoked with a map of
-     *            attribute name and values.
+     *            Event handler which will be invoked with the response for PUT
+     *            request with a map of attribute name and values.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             value.
+     * @throws NoSupportException
+     *             This exception will be thrown if we cannot send PUT request
+     *             to the remote resource.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
     public void put(SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPutListener onPutListener) {
+            Map<String, String> queryParamsMap, IPutListener onPutListener)
+            throws InvalidArgsException, NoSupportException, SimulatorException {
         this.put(null, representation, queryParamsMap, onPutListener);
     }
 
     /**
-     * Method to set the representation of a resource (via PUT)
+     * Method to set the representation of a resource (via PUT).
      * 
      * @param resourceInterface
-     *            interface type of the resource to operate on
+     *            Interface type of the resource to operate on.
      * @param representation
-     *            representation of the resource
+     *            {@link SimulatorResourceModel} holding the representation of
+     *            the resource.
      * @param queryParamsMap
-     *            Map which can have the query parameter name and value
+     *            Map which can have the query parameter name and value.
      * @param onPutListener
-     *            event handler The event handler will be invoked with a map of
-     *            attribute name and values.
+     *            Event handler which will be invoked with the response for PUT
+     *            request with a map of attribute name and values.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             value.
+     * @throws NoSupportException
+     *             This exception will be thrown if we cannot send PUT request
+     *             to the remote resource.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    private native int put(String resourceInterface,
+    private native void put(String resourceInterface,
             SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPutListener onPutListener);
+            Map<String, String> queryParamsMap, IPutListener onPutListener)
+            throws InvalidArgsException, NoSupportException, SimulatorException;
 
     /**
-     * Method to POST on a resource
+     * Method to POST on a resource.
      * 
      * @param representation
-     *            representation of the resource
+     *            {@link SimulatorResourceModel} holding the representation of
+     *            the resource
      * @param queryParamsMap
      *            Map which can have the query parameter name and value
      * @param onPostListener
-     *            event handler The event handler will be invoked with a map of
-     *            attribute name and values.
+     *            Event handler which will be invoked with the response for POST
+     *            request with a map of attribute name and values.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             value.
+     * @throws NoSupportException
+     *             This exception will be thrown if we cannot send POST request
+     *             on the remote resource.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
     public void post(SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPostListener onPostListener) {
+            Map<String, String> queryParamsMap, IPostListener onPostListener)
+            throws InvalidArgsException, NoSupportException, SimulatorException {
         this.post(null, representation, queryParamsMap, onPostListener);
     }
 
     /**
-     * Method to POST on a resource
+     * Method to POST on a resource.
      * 
      * @param resourceInterface
-     *            interface type of the resource to operate on
+     *            Interface type of the resource to operate on.
      * @param representation
-     *            representation of the resource
+     *            {@link SimulatorResourceModel} holding the representation of
+     *            the resource.
      * @param queryParamsMap
-     *            Map which can have the query parameter name and value
+     *            Map which can have the query parameter name and value.
      * @param onPostListener
-     *            event handler The event handler will be invoked with a map of
-     *            attribute name and values.
+     *            Event handler which will be invoked with the response for POST
+     *            request with a map of attribute name and values.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             value.
+     * @throws NoSupportException
+     *             This exception will be thrown if we cannot send POST request
+     *             on the remote resource.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    private native int post(String resourceInterface,
+    public native void post(String resourceInterface,
             SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPostListener onPostListener);
+            Map<String, String> queryParamsMap, IPostListener onPostListener)
+            throws InvalidArgsException, NoSupportException, SimulatorException;
 
     /**
      * Method to set the RAML file path from application
      * 
      * @param ramlPath
      *            RAML configuration file path
+     * 
+     * @throws InvalidArgsException
+     *             Thrown if the RAML configuration file path is invalid.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public native void configureRAMLPath(String ramlPath);
+    public native void configureRAMLPath(String ramlPath)
+            throws InvalidArgsException, SimulatorException;
 
     /**
-     * Method to start verification of a resource using automation
+     * Method to start verification of a resource using automation.
      * 
      * @param requestType
-     *            request type to verify
-     * 
+     *            Request type to verify.
      * @param onVerifyListener
-     *            event handler The event handler will be invoked with the
-     *            automation ID.
+     *            This event handler will be invoked with the current status of
+     *            the automation.
      * 
      * @return Automation ID.
      * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             value.
+     * @throws NoSupportException
+     *             Thrown either if the resource does not support the request
+     *             type or the resource is not configured with RAML.
+     * @throws OperationInProgressException
+     *             Thrown if another request generation session is already in
+     *             progress.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native int startVerification(int requestType,
-            IVerificationListener onVerifyListener);
+    public int startVerification(SimulatorVerificationType requestType,
+            IVerificationListener onVerifyListener)
+            throws InvalidArgsException, NoSupportException,
+            OperationInProgressException, SimulatorException {
+        return startVerification(requestType.ordinal(), onVerifyListener);
+    }
+
+    private native int startVerification(int requestType,
+            IVerificationListener onVerifyListener)
+            throws InvalidArgsException, NoSupportException,
+            OperationInProgressException, SimulatorException;
 
     /**
      * Method to stop verification of a resource previously started.
@@ -247,8 +348,15 @@ public class SimulatorRemoteResource {
      * @param id
      *            Automation ID.
      * 
+     * @throws InvalidArgsException
+     *             Thrown if the automation ID is invalid.
+     * @throws NoSupportException
+     *             Thrown if the resource is not configured with RAML.
+     * @throws SimulatorException
+     *             Thrown for other errors.
      */
-    public native void stopVerification(int id);
+    public native void stopVerification(int id) throws InvalidArgsException,
+            NoSupportException, SimulatorException;
 
     @Override
     protected void finalize() throws Throwable {
@@ -261,10 +369,10 @@ public class SimulatorRemoteResource {
 
     private long               nativeHandle;
     private String             mUri;
-    private String             mConnType;
-    private String             mSid;
-    private String             mUid;
-    private boolean            mIsObservable;
+    private int                mConnType;
+    private String             mHost;
+    private String             mId;
     private LinkedList<String> mResTypes;
     private LinkedList<String> mResInterfaces;
+    private boolean            mIsObservable;
 }
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorVerificationType.java b/service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorVerificationType.java
new file mode 100644 (file)
index 0000000..7c5e2b1
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator.clientcontroller;
+
+/**
+ * Types of automatic verification.
+ */
+public enum SimulatorVerificationType {
+    RQ_TYPE_GET(0), RQ_TYPE_PUT(1), RQ_TYPE_POST(2), RQ_TYPE_DELETE(3);
+
+    private int value;
+
+    private SimulatorVerificationType(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+
+    /**
+     * Method to get the {@link SimulatorVerificationType} from an integer
+     * value.
+     * 
+     * @param value
+     *            Integral value of {@link SimulatorVerificationType}.
+     * @return {@link SimulatorVerificationType} corresponding to the given
+     *         value.
+     */
+    public static SimulatorVerificationType getVerificationType(int value) {
+        SimulatorVerificationType result = null;
+        SimulatorVerificationType[] types = SimulatorVerificationType.values();
+        for (SimulatorVerificationType type : types) {
+            if (type.getValue() == value) {
+                result = type;
+                break;
+            }
+        }
+        return result;
+    }
+}
diff --git a/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/AutomationType.java b/service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/AutomationType.java
new file mode 100644 (file)
index 0000000..06409ff
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * 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.oic.simulator.serviceprovider;
+
+/**
+ * This enum contains the different levels of server side automation which are
+ * supported by the simulator.
+ */
+public enum AutomationType {
+    NORMAL(0), RECURRENT(1);
+
+    private int value;
+
+    private AutomationType(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 7e48fe5..11750ce 100644 (file)
@@ -14,9 +14,6 @@
  * limitations under the License.
  */
 
-/**
- * This file provides an interface for receiving the notifications on observers.
- */
 package org.oic.simulator.serviceprovider;
 
 /**
index bb5c3ac..744116b 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file provides an interface for handling the resource model
- * related notifications.
- */
 package org.oic.simulator.serviceprovider;
 
 import org.oic.simulator.SimulatorResourceModel;
@@ -34,7 +30,7 @@ public interface IResourceModelChangedListener {
      * @param resourceURI
      *            URI of resource.
      * @param resourceModel
-     *            Resource model of the resource.
+     *            {@link SimulatorResourceModel} of the resource.
      */
     public void onResourceModelChanged(String resourceURI,
             SimulatorResourceModel resourceModel);
index 7f9b166..e082f80 100644 (file)
@@ -14,9 +14,6 @@
  * limitations under the License.
  */
 
-/**
- * This file contains a class for storing observer related information.
- */
 package org.oic.simulator.serviceprovider;
 
 /**
index 8112a0b..eacfc4c 100644 (file)
  * limitations under the License.
  */
 
-/**
- * This file contains a class which has a set of native methods for manipulating
- * the simulated resource by adding and removing attributes to its model,
- * automating the attribute value updates, and changing the range of
- * acceptable values of the attributes.
- */
 package org.oic.simulator.serviceprovider;
 
 import java.util.Vector;
 
 import org.oic.simulator.IAutomation;
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorException;
 import org.oic.simulator.SimulatorResourceModel;
 
 /**
  * This class represents a resource in the simulator. It provides a set of
- * native methods for manipulating the attributes.
+ * native methods for manipulating the simulated resource by adding and removing
+ * attributes to its model, automating the attribute value updates, and changing
+ * the range of acceptable values of the attributes.
  */
 public class SimulatorResourceServer {
 
@@ -45,47 +43,6 @@ public class SimulatorResourceServer {
     }
 
     /**
-     * API to set the name of the resource. Example: Light, Fan, etc.
-     *
-     * @param resourceName
-     *            Name of the resource.
-     */
-    public void setName(String resourceName) {
-        this.resourceName = resourceName;
-    }
-
-    /**
-     * API to set the URI of the resource. Example: /oic/light, /oic/fan, etc.
-     *
-     * @param resourceURI
-     *            URI of the resource.
-     */
-    private void setURI(String resourceURI) {
-        this.resourceURI = resourceURI;
-    }
-
-    /**
-     * API to set the type of the resource. Example: oic.light, oic.fan, etc.
-     *
-     * @param resourceType
-     *            Type of the resource.
-     */
-    private void setResourceType(String resourceType) {
-        this.resourceType = resourceType;
-    }
-
-    /**
-     * API to set the interface type of the resource. Example: oic.if.baseline,
-     * oic.if.b, etc.
-     *
-     * @param interfaceType
-     *            Interface type of the resource.
-     */
-    private void setInterfaceType(String interfaceType) {
-        this.interfaceType = interfaceType;
-    }
-
-    /**
      * API to get the resource name. Example: Light, Fan, etc.
      *
      * @return Resource name.
@@ -132,154 +89,250 @@ public class SimulatorResourceServer {
      * corresponding resource.
      *
      * @return {@link SimulatorResourceModel} object on success, otherwise null.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if the native resource object
+     *             is invalid. values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native SimulatorResourceModel getModel();
-
-    /**
-     * Native function to automatically update the value of an attribute from
-     * its allowed values.
-     *
-     * @param attrName
-     *            Name of the attribute
-     *
-     * @param index
-     *            Index of the value in the allowed values.
-     */
-    public native void updateAttributeFromAllowedValues(String attrName,
-            int index);
-
-    /**
-     * Native function to set the range of allowed values. This function is
-     * intended to be used for integral type attributes.
-     *
-     * @param attrName
-     *            Name of the attribute
-     * @param min
-     *            Minimum value in the range.
-     * @param max
-     *            Maximum value in the range.
-     */
-    public native void setRange(String attrName, int min, int max);
+    public native SimulatorResourceModel getModel()
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to add an attribute whose value is of type int.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            Initial value of the attribute
+     *            Initial value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void addAttributeInteger(String key, int value);
+    public native void addAttributeInteger(String key, int value)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to add an attribute whose value is of type double.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            Initial value of the attribute
+     *            Initial value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void addAttributeDouble(String key, double value);
+    public native void addAttributeDouble(String key, double value)
+            throws InvalidArgsException, SimulatorException;
 
     /**
-     * Native function to add an attribute whose value is of type Boolean.
+     * Native function to add an attribute whose value is of type boolean.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            Initial value of the attribute
+     *            Initial value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void addAttributeBoolean(String key, Boolean value);
+    public native void addAttributeBoolean(String key, boolean value)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to add an attribute whose value is of type String.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            Initial value of the attribute
+     *            Initial value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void addAttributeStringN(String key, String value);
+    public native void addAttributeString(String key, String value)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to update the value of an attribute whose value is of
      * type int.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            New value of the attribute
+     *            New value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void updateAttributeInteger(String key, int value);
+    public native void updateAttributeInteger(String key, int value)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to update the value of an attribute whose value is of
      * type double.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            New value of the attribute
+     *            New value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void updateAttributeDouble(String key, double value);
+    public native void updateAttributeDouble(String key, double value)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to update the value of an attribute whose value is of
      * type boolean.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            New value of the attribute
+     *            New value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void updateAttributeBoolean(String key, Boolean value);
+    public native void updateAttributeBoolean(String key, boolean value)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to update the value of an attribute whose value is of
      * type String.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param value
-     *            New value of the attribute
+     *            New value of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
+     */
+    public native void updateAttributeString(String key, String value)
+            throws InvalidArgsException, SimulatorException;
+
+    /**
+     * Native function to automatically update the value of an attribute from
+     * its allowed values.
+     *
+     * @param attrName
+     *            Name of the attribute.
+     * @param index
+     *            Index of the value in the allowed values.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
+     */
+    public native void updateAttributeFromAllowedValues(String attrName,
+            int index) throws InvalidArgsException, SimulatorException;
+
+    /**
+     * Native function to set the range of allowed values. This function is
+     * intended to be used for integral type attributes.
+     *
+     * @param attrName
+     *            Name of the attribute.
+     * @param min
+     *            Minimum value in the range.
+     * @param max
+     *            Maximum value in the range.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void updateAttributeStringN(String key, String value);
+    public native void setRange(String attrName, int min, int max)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to set the allowed values of attribute whose value is of
      * type int.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param allowedValues
-     *            Allowed values of the attribute
+     *            Allowed values of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
     public native void setAllowedValuesInteger(String key,
-            Vector<Integer> allowedValues);
+            Vector<Integer> allowedValues) throws InvalidArgsException,
+            SimulatorException;
 
     /**
      * Native function to set the allowed values of attribute whose value is of
      * type double.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param allowedValues
-     *            Allowed values of the attribute
+     *            Allowed values of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
     public native void setAllowedValuesDouble(String key,
-            Vector<Double> allowedValues);
+            Vector<Double> allowedValues) throws InvalidArgsException,
+            SimulatorException;
 
     /**
      * Native function to set the allowed values of attribute whose value is of
      * type String.
      *
      * @param key
-     *            Name of the attribute
+     *            Name of the attribute.
      * @param allowedValues
-     *            Allowed values of the attribute
+     *            Allowed values of the attribute.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void setAllowedValuesStringN(String key,
-            Vector<String> allowedValues);
+    public native void setAllowedValuesString(String key,
+            Vector<String> allowedValues) throws InvalidArgsException,
+            SimulatorException;
 
     /**
      * Native function to start the resource level automation. This automation
@@ -287,14 +340,28 @@ public class SimulatorResourceServer {
      * attributes sequentially.
      *
      * @param typeOfAutomation
-     *            Indicates whether the automation is one-time or recursive.
+     *            {@link AutomationType} indicating whether the automation is
+     *            one-time or recursive.
      * @param listener
      *            Listener to be notified when automation ends.
      *
      * @return Automation ID using which the automation can be stopped.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native int startResourceAutomation(int typeOfAutomation,
-            IAutomation listener);
+    public int startResourceAutomation(AutomationType typeOfAutomation,
+            IAutomation listener) throws InvalidArgsException,
+            SimulatorException {
+        return startResourceAutomation(typeOfAutomation.getValue(), listener);
+    }
+
+    private native int startResourceAutomation(int typeOfAutomation,
+            IAutomation listener) throws InvalidArgsException,
+            SimulatorException;
 
     /**
      * Native function to start the attribute level automation. This automation
@@ -304,58 +371,115 @@ public class SimulatorResourceServer {
      * @param attrName
      *            Name of the attribute to be automated.
      * @param typeOfAutomation
-     *            Indicates whether the automation is one-time or recursive.
+     *            {@link AutomationType} indicating whether the automation is
+     *            one-time or recursive.
      * @param listener
      *            Listener to be notified when automation ends.
      *
      * @return Automation ID using which the automation can be stopped.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if any parameter has invalid
+     *             values.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native int startAttributeAutomation(String attrName,
-            int typeOfAutomation, IAutomation listener);
+    public int startAttributeAutomation(String attrName,
+            AutomationType typeOfAutomation, IAutomation listener)
+            throws InvalidArgsException, SimulatorException {
+        return startAttributeAutomation(attrName, typeOfAutomation.getValue(),
+                listener);
+    }
+
+    private native int startAttributeAutomation(String attrName,
+            int typeOfAutomation, IAutomation listener)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to stop the automation.
      *
      * @param automationId
      *            Using which a specific automation can be stopped.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if the native resource object
+     *             does not exist.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void stopAutomation(int automationId);
+    public native void stopAutomation(int automationId)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function to remove an attribute from the resource model.
      *
      * @param key
-     *            Name of the attribute to be deleted
+     *            Name of the attribute to be deleted.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown either if the parameter has
+     *             invalid value or the native resource object does not exist.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void removeAttribute(String key);
+    public native void removeAttribute(String key) throws InvalidArgsException,
+            SimulatorException;
 
     /**
-     * Native function to set the observation callback.
+     * Native function to get the details of a list of observers.
      * 
-     * @param observer
-     *            Listener to be notified when clients start/stop observing.
+     * @return An array of {@link ObserverInfo} objects.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if the native resource object
+     *             does not exist.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void setObserverCallback(IObserver observer);
+    public native ObserverInfo[] getObserversList()
+            throws InvalidArgsException, SimulatorException;
 
     /**
-     * Native function to get the details of a list of observers.
+     * Native function to set the observation callback.
      * 
-     * @return An array of {@link ObserverInfo} objects.
+     * @param observer
+     *            Listener to be notified when clients start/stop observing.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown either if the parameter has
+     *             invalid value or the native resource object does not exist.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native ObserverInfo[] getObserversList();
+    public native void setObserverCallback(IObserver observer)
+            throws InvalidArgsException, SimulatorException;
 
     /**
      * Native function which sends notification to a specific observer.
      * 
      * @param id
      *            Observer's Id.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if the native resource object
+     *             does not exist.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void notifyObserver(int id);
+    public native void notifyObserver(int id) throws InvalidArgsException,
+            SimulatorException;
 
     /**
      * Native function which sends notification to all observers.
+     * 
+     * @throws InvalidArgsException
+     *             This exception will be thrown if the native resource object
+     *             does not exist.
+     * @throws SimulatorException
+     *             This exception will be thrown for other errors.
      */
-    public native void notifyAllObservers();
+    public native void notifyAllObservers() throws InvalidArgsException,
+            SimulatorException;
 
     /**
      * Native function to release the memory allocated to the native object for