4f510ab6fc92ed1e95544ff34fb3684824bf57e5
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ClientControllerPlugin / src / oic / simulator / clientcontroller / manager / ResourceManager.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package oic.simulator.clientcontroller.manager;
18
19 import java.text.NumberFormat;
20 import java.util.ArrayList;
21 import java.util.Collections;
22 import java.util.Comparator;
23 import java.util.Date;
24 import java.util.HashMap;
25 import java.util.Iterator;
26 import java.util.LinkedList;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.Set;
30 import java.util.Vector;
31
32 import org.oic.simulator.ArrayProperty;
33 import org.oic.simulator.AttributeProperty;
34 import org.oic.simulator.AttributeProperty.Type;
35 import org.oic.simulator.AttributeValue;
36 import org.oic.simulator.AttributeValue.TypeInfo;
37 import org.oic.simulator.AttributeValue.ValueType;
38 import org.oic.simulator.BooleanProperty;
39 import org.oic.simulator.DeviceInfo;
40 import org.oic.simulator.DeviceListener;
41 import org.oic.simulator.DoubleProperty;
42 import org.oic.simulator.ILogger.Level;
43 import org.oic.simulator.IntegerProperty;
44 import org.oic.simulator.PlatformInfo;
45 import org.oic.simulator.PlatformListener;
46 import org.oic.simulator.SimulatorException;
47 import org.oic.simulator.SimulatorManager;
48 import org.oic.simulator.SimulatorResourceAttribute;
49 import org.oic.simulator.SimulatorResourceModel;
50 import org.oic.simulator.SimulatorResult;
51 import org.oic.simulator.StringProperty;
52 import org.oic.simulator.client.FindResourceListener;
53 import org.oic.simulator.client.SimulatorRemoteResource;
54 import org.oic.simulator.client.SimulatorRemoteResource.GetResponseListener;
55 import org.oic.simulator.client.SimulatorRemoteResource.ObserveNotificationListener;
56 import org.oic.simulator.client.SimulatorRemoteResource.PostResponseListener;
57 import org.oic.simulator.client.SimulatorRemoteResource.PutResponseListener;
58 import org.oic.simulator.client.SimulatorRemoteResource.RequestType;
59 import org.oic.simulator.client.SimulatorRemoteResource.VerificationListener;
60 import org.oic.simulator.client.SimulatorRequestModel;
61
62 import oic.simulator.clientcontroller.Activator;
63 import oic.simulator.clientcontroller.remoteresource.DeviceAndPlatformInfo;
64 import oic.simulator.clientcontroller.remoteresource.MetaProperty;
65 import oic.simulator.clientcontroller.remoteresource.RemoteResource;
66 import oic.simulator.clientcontroller.utils.AttributeValueStringConverter;
67 import oic.simulator.clientcontroller.utils.Constants;
68 import oic.simulator.clientcontroller.utils.Utility;
69
70 /**
71  * This class acts as an interface between the simulator java SDK and the
72  * various UI modules. It maintains all the details of resources and provides
73  * other UI modules with the information required. It also handles responses for
74  * find, GET, PUT, POST, Observe and automatic verification operations from
75  * native layer and propagates those events to the registered UI listeners.
76  */
77 public class ResourceManager {
78
79     private Set<String>                        lastKnownSearchTypes;
80
81     private RemoteResource                     currentResourceInSelection;
82
83     private FindResourceListener               findResourceListener;
84     private GetResponseListener                getListener;
85     private PutResponseListener                putListener;
86     private PostResponseListener               postListener;
87     private ObserveNotificationListener        observeListener;
88     private VerificationListener               verifyListener;
89     private DeviceListener                     deviceListener;
90     private PlatformListener                   platformListener;
91
92     private ResponseSynchronizerThread         synchronizerThread;
93
94     private Thread                             threadHandle;
95
96     // Map with Server ID as key and the complete object as the value
97     private Map<String, RemoteResource>        resourceMap;
98     private List<RemoteResource>               favoriteResources;
99     // Maintaining a list of resource URIs for favorite resources feature.
100     private List<String>                       favoriteURIList;
101
102     // Maintaining a list of observed resource URIs.
103     private List<String>                       observedResourceURIList;
104
105     private Map<String, DeviceAndPlatformInfo> hostDeviceAndPlatformMap;
106
107     public ResourceManager() {
108         resourceMap = new HashMap<String, RemoteResource>();
109         favoriteResources = new ArrayList<RemoteResource>();
110         favoriteURIList = new ArrayList<String>();
111         observedResourceURIList = new ArrayList<String>();
112         hostDeviceAndPlatformMap = new HashMap<String, DeviceAndPlatformInfo>();
113
114         findResourceListener = new FindResourceListener() {
115
116             @Override
117             public void onResourceFound(final SimulatorRemoteResource resourceN) {
118                 synchronizerThread.addToQueue(new Runnable() {
119                     @Override
120                     public void run() {
121                         if (null == resourceN) {
122                             return;
123                         }
124
125                         // Ignore the response if the resource is a device or
126                         // platform.
127                         Vector<String> resTypes = resourceN.getResourceTypes();
128                         if (null != resTypes && resTypes.contains("oic.wk.d")
129                                 || resTypes.contains("oic.wk.p")) {
130                             return;
131                         }
132
133                         // If id is not available, then it cannot be added to
134                         // the local map as null value should not be allowed as
135                         // key.
136                         String uid = resourceN.getId();
137                         if (null == uid) {
138                             return;
139                         }
140
141                         // If resource already exist, then ignore it.
142                         boolean exist = isUidExist(uid);
143                         if (exist) {
144                             return;
145                         }
146
147                         RemoteResource resource = new RemoteResource();
148                         resource.setRemoteResourceRef(resourceN);
149
150                         String uri = resourceN.getURI();
151                         if (null != uri && uri.trim().length() > 0) {
152                             // Add resource to favorite list if it was in
153                             // favorites list during find/refresh operation.
154                             if (favoriteURIList.contains(uri)) {
155                                 addResourcetoFavorites(resource);
156                             }
157                             // Add resource to observed resources list if it was
158                             // in observe list during find/refresh operation.
159                             if (observedResourceURIList.contains(uri)) {
160                                 sendObserveRequest(resource);
161                             }
162                         } else {
163                             Activator
164                                     .getDefault()
165                                     .getLogManager()
166                                     .log(Level.INFO.ordinal(), new Date(),
167                                             "Found a resource without URI. Ignoring it.");
168                             return;
169                         }
170
171                         // Add the resource in local data structure
172                         addResourceDetails(resource);
173
174                         // Notify the UI listener
175                         UiListenerHandler.getInstance()
176                                 .newResourceFoundNotification(resource);
177
178                         Activator
179                                 .getDefault()
180                                 .getLogManager()
181                                 .log(Level.INFO.ordinal(),
182                                         new Date(),
183                                         "Resource Found [" + resourceN.getURI()
184                                                 + "].");
185
186                         // Send an initial GET request to get the resource
187                         // attributes on an interface supported by the resource.
188                         try {
189                             String ifType = null;
190                             Vector<String> resInterfaces = resourceN
191                                     .getResourceInterfaces();
192                             if (null != resInterfaces) {
193                                 ifType = resInterfaces.get(0);
194                             }
195                             resourceN.get(formQueryParameters(ifType, null),
196                                     getListener);
197                         } catch (SimulatorException e) {
198                             Activator
199                                     .getDefault()
200                                     .getLogManager()
201                                     .log(Level.ERROR.ordinal(),
202                                             new Date(),
203                                             Utility.getSimulatorErrorString(e,
204                                                     null));
205                         }
206
207                         // Get the device information
208                         if (!isDeviceInfoExist(resourceN.getHost())) {
209                             try {
210                                 SimulatorManager.findDevices(resource
211                                         .getRemoteResourceRef().getHost(),
212                                         deviceListener);
213                             } catch (SimulatorException e) {
214                                 Activator
215                                         .getDefault()
216                                         .getLogManager()
217                                         .log(Level.ERROR.ordinal(),
218                                                 new Date(),
219                                                 Utility.getSimulatorErrorString(
220                                                         e, null));
221                             }
222                         }
223
224                         // Get the platform information
225                         if (!isPlatformInfoExist(resourceN.getHost())) {
226                             try {
227                                 SimulatorManager.getPlatformInformation(
228                                         resource.getRemoteResourceRef()
229                                                 .getHost(), platformListener);
230                             } catch (SimulatorException e) {
231                                 Activator
232                                         .getDefault()
233                                         .getLogManager()
234                                         .log(Level.ERROR.ordinal(),
235                                                 new Date(),
236                                                 Utility.getSimulatorErrorString(
237                                                         e, null));
238                             }
239                         }
240                     }
241                 });
242             }
243         };
244
245         // Listeners for device and platform information.
246         deviceListener = new DeviceListener() {
247
248             @Override
249             public void onDeviceFound(final String host,
250                     final DeviceInfo deviceInfo) {
251                 if (null == deviceInfo || null == host) {
252                     return;
253                 }
254                 synchronizerThread.addToQueue(new Runnable() {
255                     @Override
256                     public void run() {
257                         synchronized (hostDeviceAndPlatformMap) {
258                             DeviceAndPlatformInfo info = hostDeviceAndPlatformMap
259                                     .get(host);
260                             if (null == info) {
261                                 info = new DeviceAndPlatformInfo();
262                                 info.setHost(host);
263                                 hostDeviceAndPlatformMap.put(host, info);
264                             }
265                             info.setDeviceInfo(deviceInfo);
266                         }
267
268                         // Notify UI listeners
269                         UiListenerHandler.getInstance()
270                                 .deviceInfoReceivedNotification();
271                     }
272                 });
273             }
274         };
275
276         platformListener = new PlatformListener() {
277
278             @Override
279             public void onPlatformFound(final String host,
280                     final PlatformInfo platformInfo) {
281                 if (null == platformInfo || null == host) {
282                     return;
283                 }
284                 synchronizerThread.addToQueue(new Runnable() {
285                     @Override
286                     public void run() {
287                         synchronized (hostDeviceAndPlatformMap) {
288                             DeviceAndPlatformInfo info = hostDeviceAndPlatformMap
289                                     .get(host);
290                             if (null == info) {
291                                 info = new DeviceAndPlatformInfo();
292                                 info.setHost(host);
293                                 hostDeviceAndPlatformMap.put(host, info);
294                             }
295                             info.setPlatformInfo(platformInfo);
296                         }
297
298                         // Notify UI listeners
299                         UiListenerHandler.getInstance()
300                                 .platformInfoReceivedNotification();
301                     }
302                 });
303             }
304         };
305
306         getListener = new GetResponseListener() {
307             @Override
308             public void onGetResponse(final String uid,
309                     final SimulatorResult result,
310                     final SimulatorResourceModel resourceModelN) {
311                 if (result != SimulatorResult.SIMULATOR_OK) {
312                     Activator
313                             .getDefault()
314                             .getLogManager()
315                             .log(Level.ERROR.ordinal(),
316                                     new Date(),
317                                     "["
318                                             + result.toString()
319                                             + "] Received error response for GET request.");
320                     return;
321                 }
322                 synchronizerThread.addToQueue(new Runnable() {
323                     @Override
324                     public void run() {
325                         // Handling the response which includes retrieving the
326                         // attributes and updating the local model.
327                         RemoteResource resource = handleResponse(uid,
328                                 resourceModelN);
329                         if (null != resource) {
330                             // Notify the UI listeners
331                             UiListenerHandler.getInstance()
332                                     .getCompleteNotification(resource);
333                         }
334                     }
335                 });
336             }
337         };
338
339         putListener = new PutResponseListener() {
340
341             @Override
342             public void onPutResponse(final String uid,
343                     final SimulatorResult result,
344                     final SimulatorResourceModel resourceModelN) {
345                 if (result != SimulatorResult.SIMULATOR_OK) {
346                     Activator
347                             .getDefault()
348                             .getLogManager()
349                             .log(Level.ERROR.ordinal(),
350                                     new Date(),
351                                     "["
352                                             + result.toString()
353                                             + "] Received error response for PUT request.");
354                     return;
355                 }
356                 synchronizerThread.addToQueue(new Thread() {
357                     @Override
358                     public void run() {
359                         // Handling the response which includes retrieving the
360                         // attributes and updating the local model.
361                         RemoteResource resource = handleResponse(uid,
362                                 resourceModelN);
363                         if (null != resource) {
364                             // Notify the UI listeners
365                             UiListenerHandler.getInstance()
366                                     .putCompleteNotification(resource);
367                         }
368                     }
369                 });
370             }
371         };
372
373         postListener = new PostResponseListener() {
374             @Override
375             public void onPostResponse(final String uid,
376                     final SimulatorResult result,
377                     final SimulatorResourceModel resourceModelN) {
378                 if (result != SimulatorResult.SIMULATOR_OK) {
379                     Activator
380                             .getDefault()
381                             .getLogManager()
382                             .log(Level.ERROR.ordinal(),
383                                     new Date(),
384                                     "["
385                                             + result.toString()
386                                             + "] Received error response for POST request.");
387                     return;
388                 }
389                 synchronizerThread.addToQueue(new Runnable() {
390                     @Override
391                     public void run() {
392                         // Handling the response which includes retrieving the
393                         // attributes and updating the local model.
394                         RemoteResource resource = handleResponse(uid,
395                                 resourceModelN);
396                         if (null != resource) {
397                             // Notify the UI listeners
398                             UiListenerHandler.getInstance()
399                                     .postCompleteNotification(resource);
400                         }
401                     }
402                 });
403             }
404         };
405
406         observeListener = new ObserveNotificationListener() {
407
408             @Override
409             public void onObserveNotification(final String uid,
410                     final SimulatorResourceModel resourceModelN, final int seq) {
411                 synchronizerThread.addToQueue(new Runnable() {
412                     @Override
413                     public void run() {
414                         // Handling the response which includes retrieving the
415                         // attributes and updating the local model.
416                         RemoteResource resource = handleResponse(uid,
417                                 resourceModelN);
418                         if (null != resource) {
419                             // Notify the UI listeners
420                             UiListenerHandler.getInstance()
421                                     .observeCompleteNotification(resource);
422                         }
423                     }
424                 });
425             }
426         };
427
428         verifyListener = new VerificationListener() {
429
430             @Override
431             public void onVerificationStarted(final String uid, final int autoId) {
432                 synchronizerThread.addToQueue(new Runnable() {
433                     @Override
434                     public void run() {
435                         RemoteResource resource = getResource(uid);
436                         if (null == resource) {
437                             return;
438                         }
439                         // Update the automation status.
440                         resource.updateAutomationStatus(autoId, true);
441
442                         RequestType reqType = resource
443                                 .getAutomationtype(autoId);
444
445                         // Notify the listeners.
446                         UiListenerHandler.getInstance()
447                                 .verificationStartedNotification(resource,
448                                         reqType);
449                     }
450                 });
451             }
452
453             @Override
454             public void onVerificationCompleted(final String uid,
455                     final int autoId) {
456                 synchronizerThread.addToQueue(new Runnable() {
457                     @Override
458                     public void run() {
459                         RemoteResource resource = getResource(uid);
460                         if (null == resource) {
461                             return;
462                         }
463                         // Update the automation status.
464                         resource.updateAutomationStatus(autoId, false);
465
466                         RequestType reqType = resource
467                                 .getAutomationtype(autoId);
468
469                         // Notify the listeners.
470                         UiListenerHandler.getInstance()
471                                 .verificationCompletedNotification(resource,
472                                         reqType);
473                     }
474                 });
475             }
476
477             @Override
478             public void onVerificationAborted(final String uid, final int autoId) {
479                 synchronizerThread.addToQueue(new Runnable() {
480                     @Override
481                     public void run() {
482                         RemoteResource resource = getResource(uid);
483                         if (null == resource) {
484                             return;
485                         }
486                         // Update the automation status.
487                         resource.updateAutomationStatus(autoId, false);
488
489                         RequestType reqType = resource
490                                 .getAutomationtype(autoId);
491
492                         // Notify the listeners.
493                         UiListenerHandler.getInstance()
494                                 .verificationAbortedNotification(resource,
495                                         reqType);
496                     }
497                 });
498             }
499         };
500
501         synchronizerThread = new ResponseSynchronizerThread();
502         threadHandle = new Thread(synchronizerThread);
503         threadHandle.setName("Simulator Client Controller Event Queue");
504         threadHandle.start();
505     }
506
507     private RemoteResource handleResponse(String uid,
508             SimulatorResourceModel resourceModelN) {
509         if (null == uid || null == resourceModelN) {
510             return null;
511         }
512
513         // Update the local model
514         RemoteResource resource;
515         resource = getResource(uid);
516         if (null == resource) {
517             return null;
518         }
519
520         resource.setResourceModelRef(resourceModelN);
521         resource.setResourceRepresentation(resourceModelN);
522
523         return resource;
524     }
525
526     public synchronized boolean isDeviceInfoExist(String host) {
527         DeviceAndPlatformInfo info = hostDeviceAndPlatformMap.get(host);
528         if (null == info) {
529             return false;
530         }
531         if (null == info.getDeviceInfo()) {
532             return false;
533         }
534         return true;
535     }
536
537     public synchronized boolean isPlatformInfoExist(String host) {
538         DeviceAndPlatformInfo info = hostDeviceAndPlatformMap.get(host);
539         if (null == info) {
540             return false;
541         }
542         if (null == info.getPlatformInfo()) {
543             return false;
544         }
545         return true;
546     }
547
548     private static class ResponseSynchronizerThread implements Runnable {
549
550         LinkedList<Runnable> responseQueue = new LinkedList<Runnable>();
551
552         @Override
553         public void run() {
554             while (!Thread.interrupted()) {
555                 synchronized (this) {
556                     try {
557                         while (responseQueue.isEmpty()) {
558                             this.wait();
559                             break;
560                         }
561                     } catch (InterruptedException e) {
562                         return;
563                     }
564                 }
565
566                 Runnable thread;
567                 synchronized (this) {
568                     thread = responseQueue.pop();
569                 }
570                 try {
571                     thread.run();
572                 } catch (Exception e) {
573                     if (e instanceof InterruptedException) {
574                         return;
575                     }
576                     e.printStackTrace();
577                 }
578             }
579         }
580
581         public void addToQueue(Runnable event) {
582             synchronized (this) {
583                 responseQueue.add(event);
584                 this.notify();
585             }
586         }
587     }
588
589     public void addResourcetoFavorites(RemoteResource resource) {
590         if (null == resource) {
591             return;
592         }
593         resource.setFavorite(true);
594         synchronized (favoriteResources) {
595             favoriteResources.add(resource);
596         }
597     }
598
599     public void removeResourceFromFavorites(RemoteResource resource) {
600         if (null == resource) {
601             return;
602         }
603         resource.setFavorite(false);
604         synchronized (favoriteResources) {
605             favoriteResources.remove(resource);
606         }
607     }
608
609     public void addResourceURItoFavorites(RemoteResource resource) {
610         if (null == resource) {
611             return;
612         }
613         synchronized (favoriteURIList) {
614             favoriteURIList.add(resource.getRemoteResourceRef().getURI());
615         }
616     }
617
618     public void removeResourceURIFromFavorites(RemoteResource resource) {
619         if (null == resource) {
620             return;
621         }
622         synchronized (favoriteURIList) {
623             favoriteURIList.remove(resource.getRemoteResourceRef().getURI());
624         }
625     }
626
627     public void addObservedResourceURI(String resourceURI) {
628         synchronized (observedResourceURIList) {
629             if (!observedResourceURIList.contains(resourceURI))
630                 observedResourceURIList.add(resourceURI);
631         }
632     }
633
634     public void removeObservedResourceURI(String resourceURI) {
635         synchronized (observedResourceURIList) {
636             observedResourceURIList.remove(resourceURI);
637         }
638     }
639
640     public boolean isResourceObserved(String resourceURI) {
641         boolean observed = false;
642         synchronized (observedResourceURIList) {
643             observed = observedResourceURIList.contains(resourceURI);
644         }
645         return observed;
646     }
647
648     public synchronized RemoteResource getCurrentResourceInSelection() {
649         return currentResourceInSelection;
650     }
651
652     public synchronized void setCurrentResourceInSelection(
653             RemoteResource resource) {
654         this.currentResourceInSelection = resource;
655     }
656
657     private void addResourceDetails(RemoteResource remoteResource) {
658         if (null != remoteResource) {
659             synchronized (resourceMap) {
660                 resourceMap.put(remoteResource.getRemoteResourceRef().getId(),
661                         remoteResource);
662             }
663         }
664     }
665
666     private boolean isUidExist(String uid) {
667         boolean exist;
668         synchronized (resourceMap) {
669             exist = resourceMap.containsKey(uid);
670         }
671         return exist;
672     }
673
674     private RemoteResource getResource(String uid) {
675         if (null == uid) {
676             return null;
677         }
678         RemoteResource resource;
679         synchronized (resourceMap) {
680             resource = resourceMap.get(uid);
681         }
682         return resource;
683     }
684
685     public synchronized Set<String> getLastKnownSearchTypes() {
686         return lastKnownSearchTypes;
687     }
688
689     public synchronized void setLastKnownSearchTypes(
690             Set<String> lastKnownSearchTypes) {
691         this.lastKnownSearchTypes = lastKnownSearchTypes;
692     }
693
694     public boolean findResourceRequest(Set<String> searchTypes) {
695         boolean result = false;
696         if (null == searchTypes || searchTypes.size() < 1) {
697             try {
698                 SimulatorManager.findResource(findResourceListener);
699                 result = true;
700             } catch (SimulatorException e) {
701                 Activator
702                         .getDefault()
703                         .getLogManager()
704                         .log(Level.ERROR.ordinal(), new Date(),
705                                 Utility.getSimulatorErrorString(e, null));
706             }
707         } else {
708             Iterator<String> searchItr = searchTypes.iterator();
709             String rType;
710             while (searchItr.hasNext()) {
711                 rType = searchItr.next();
712                 try {
713                     SimulatorManager.findResource(rType, findResourceListener);
714                     result = true;
715                 } catch (SimulatorException e) {
716                     Activator
717                             .getDefault()
718                             .getLogManager()
719                             .log(Level.ERROR.ordinal(), new Date(),
720                                     Utility.getSimulatorErrorString(e, null));
721                 }
722             }
723         }
724         return result;
725     }
726
727     public void deleteResources(final Set<String> searchTypes) {
728         synchronized (resourceMap) {
729             if (null == resourceMap && resourceMap.isEmpty()) {
730                 return;
731             }
732         }
733         new Thread() {
734             public void run() {
735                 if (null == searchTypes || searchTypes.size() < 1) {
736                     synchronized (resourceMap) {
737                         // Stop observing all the resources
738                         Iterator<String> itr = resourceMap.keySet().iterator();
739                         while (itr.hasNext()) {
740                             sendCancelObserveRequest(
741                                     resourceMap.get(itr.next()), false);
742                         }
743                         // Delete all cached details of resources
744                         resourceMap.clear();
745                         favoriteResources.clear();
746
747                         // Clearing the device and platform information
748                         hostDeviceAndPlatformMap.clear();
749                     }
750                     // Change the current resource in selection
751                     setCurrentResourceInSelection(null);
752                     UiListenerHandler.getInstance()
753                             .resourceSelectionChangedUINotification(null);
754                 } else {
755                     Iterator<String> typeItr = searchTypes.iterator();
756                     String resType;
757                     while (typeItr.hasNext()) {
758                         resType = typeItr.next();
759                         deleteResourcesByType(resType);
760
761                         // Change the current resource in selection
762                         updateCurrentResourceInSelection(searchTypes);
763                     }
764                 }
765             }
766         }.start();
767     }
768
769     private void updateCurrentResourceInSelection(Set<String> searchTypes) {
770         if (null == searchTypes || searchTypes.size() < 1) {
771             return;
772         }
773         RemoteResource resourceInSelection = getCurrentResourceInSelection();
774         if (null == resourceInSelection) {
775             return;
776         }
777         List<String> typesOfSelection = resourceInSelection
778                 .getRemoteResourceRef().getResourceTypes();
779         if (null == typesOfSelection || typesOfSelection.size() < 1) {
780             return;
781         }
782         Iterator<String> itr = typesOfSelection.iterator();
783         String type;
784         while (itr.hasNext()) {
785             type = itr.next();
786             if (searchTypes.contains(type)) {
787                 setCurrentResourceInSelection(null);
788                 UiListenerHandler.getInstance()
789                         .resourceSelectionChangedUINotification(null);
790                 break;
791             }
792         }
793     }
794
795     private void deleteResourcesByType(String resourceType) {
796         if (null == resourceType) {
797             return;
798         }
799         synchronized (resourceMap) {
800             Set<String> keySet = resourceMap.keySet();
801             if (null == keySet) {
802                 return;
803             }
804             Iterator<String> keyItr = keySet.iterator();
805             String uId;
806             RemoteResource resource;
807             boolean exist;
808             List<String> types;
809             while (keyItr.hasNext()) {
810                 uId = keyItr.next();
811                 resource = resourceMap.get(uId);
812                 if (null == resource) {
813                     continue;
814                 }
815                 types = resource.getRemoteResourceRef().getResourceTypes();
816                 if (null != types) {
817                     exist = types.contains(resourceType);
818                     if (exist) {
819                         // Cancel observing the resource.
820                         sendCancelObserveRequest(resource, false);
821                         // Remove the resource from favorites list.
822                         removeResourceFromFavorites(resource);
823                         // Remove the resource
824                         keyItr.remove();
825                         // Remove the device and platform information
826                         synchronized (hostDeviceAndPlatformMap) {
827                             hostDeviceAndPlatformMap.remove(resource
828                                     .getRemoteResourceRef().getHost());
829                         }
830                     }
831                 }
832             }
833         }
834     }
835
836     public void resourceSelectionChanged(final RemoteResource resource) {
837         new Thread() {
838             @Override
839             public void run() {
840                 setCurrentResourceInSelection(resource);
841                 // Notify all observers for resource selection change event
842                 UiListenerHandler.getInstance()
843                         .resourceSelectionChangedUINotification(resource);
844             }
845         }.start();
846     }
847
848     public List<MetaProperty> getDefaultProperties(RemoteResource resource) {
849         if (null != resource) {
850             String propName;
851             String propValue;
852
853             List<MetaProperty> metaPropertyList = new ArrayList<MetaProperty>();
854
855             for (int index = 0; index < Constants.META_PROPERTY_COUNT; index++) {
856                 propName = Constants.META_PROPERTIES[index];
857                 if (propName.equals(Constants.RESOURCE_URI)) {
858                     propValue = resource.getRemoteResourceRef().getURI();
859                 } else if (propName.equals(Constants.CONNECTIVITY_TYPE)) {
860                     propValue = resource.getRemoteResourceRef()
861                             .getConnectivityType().toString();
862                 } else if (propName.equals(Constants.ADDRESS)) {
863                     propValue = resource.getRemoteResourceRef().getHost();
864                 } else if (propName.equals(Constants.OBSERVABLE)) {
865                     propValue = Utility.getObservableInString(resource
866                             .getRemoteResourceRef().isObservable());
867                 } else if (propName.equals(Constants.RESOURCE_TYPES)) {
868                     Vector<String> resTypes = resource.getRemoteResourceRef()
869                             .getResourceTypes();
870                     if (null != resTypes && !resTypes.isEmpty()) {
871                         propValue = "";
872                         Iterator<String> itr = resTypes.iterator();
873                         while (itr.hasNext()) {
874                             propValue += itr.next();
875                             if (itr.hasNext()) {
876                                 propValue += ", ";
877                             }
878                         }
879                     } else {
880                         propValue = Constants.NOT_AVAILABLE;
881                     }
882                 } else if (propName.equals(Constants.RESOURCE_INTERFACES)) {
883                     Vector<String> interfaces = resource.getRemoteResourceRef()
884                             .getResourceInterfaces();
885                     if (null != interfaces && !interfaces.isEmpty()) {
886                         propValue = "";
887                         Iterator<String> itr = interfaces.iterator();
888                         while (itr.hasNext()) {
889                             propValue += itr.next();
890                             if (itr.hasNext()) {
891                                 propValue += ", ";
892                             }
893                         }
894                     } else {
895                         propValue = Constants.NOT_AVAILABLE;
896                     }
897                 } else {
898                     propValue = null;
899                 }
900                 if (null != propValue) {
901                     metaPropertyList.add(new MetaProperty(propName, propValue));
902                 }
903             }
904
905             return metaPropertyList;
906         }
907         return null;
908     }
909
910     public List<MetaProperty> getDeviceProperties() {
911         if (null == currentResourceInSelection) {
912             return null;
913         }
914
915         SimulatorRemoteResource remoteResource = currentResourceInSelection
916                 .getRemoteResourceRef();
917         if (null == remoteResource) {
918             return null;
919         }
920
921         String host = remoteResource.getHost();
922         if (null == host) {
923             return null;
924         }
925
926         if (!isDeviceInfoExist(host)) {
927             // Device Information
928             try {
929                 SimulatorManager.findDevices(host, deviceListener);
930             } catch (SimulatorException e) {
931                 Activator
932                         .getDefault()
933                         .getLogManager()
934                         .log(Level.ERROR.ordinal(), new Date(),
935                                 Utility.getSimulatorErrorString(e, null));
936             }
937             return null;
938         }
939
940         List<MetaProperty> metaProperties = new ArrayList<MetaProperty>();
941         synchronized (hostDeviceAndPlatformMap) {
942             DeviceInfo devInfo = hostDeviceAndPlatformMap.get(host)
943                     .getDeviceInfo();
944             metaProperties.add(new MetaProperty(Constants.DEVICE_ID, devInfo
945                     .getID()));
946             metaProperties.add(new MetaProperty(Constants.DEVICE_NAME, devInfo
947                     .getName()));
948             metaProperties.add(new MetaProperty(Constants.DEVICE_SPEC_VERSION,
949                     devInfo.getSpecVersion()));
950             metaProperties.add(new MetaProperty(Constants.DEVICE_DMV_VERSION,
951                     devInfo.getDataModelVersion()));
952         }
953
954         return metaProperties;
955     }
956
957     public List<MetaProperty> getPlatformProperties() {
958         if (null == currentResourceInSelection) {
959             return null;
960         }
961
962         SimulatorRemoteResource remoteResource = currentResourceInSelection
963                 .getRemoteResourceRef();
964         if (null == remoteResource) {
965             return null;
966         }
967
968         String host = remoteResource.getHost();
969         if (null == host) {
970             return null;
971         }
972
973         if (!isPlatformInfoExist(host)) {
974             // Platform Information
975             try {
976                 SimulatorManager.getPlatformInformation(host, platformListener);
977             } catch (SimulatorException e) {
978                 Activator
979                         .getDefault()
980                         .getLogManager()
981                         .log(Level.ERROR.ordinal(), new Date(),
982                                 Utility.getSimulatorErrorString(e, null));
983             }
984             return null;
985         }
986
987         List<MetaProperty> metaProperties = new ArrayList<MetaProperty>();
988         synchronized (hostDeviceAndPlatformMap) {
989             PlatformInfo platInfo = hostDeviceAndPlatformMap.get(host)
990                     .getPlatformInfo();
991             metaProperties.add(new MetaProperty(Constants.PLATFORM_ID, platInfo
992                     .getPlatformID()));
993             metaProperties.add(new MetaProperty(
994                     Constants.PLATFORM_MANUFAC_NAME, platInfo
995                             .getManufacturerName()));
996             metaProperties.add(new MetaProperty(Constants.PLATFORM_MANUFAC_URL,
997                     platInfo.getManufacturerUrl()));
998             metaProperties.add(new MetaProperty(Constants.PLATFORM_MODEL_NO,
999                     platInfo.getModelNumber()));
1000             metaProperties.add(new MetaProperty(
1001                     Constants.PLATFORM_DATE_OF_MANUFAC, platInfo
1002                             .getDateOfManufacture()));
1003             metaProperties.add(new MetaProperty(Constants.PLATFORM_VERSION,
1004                     platInfo.getPlatformVersion()));
1005             metaProperties.add(new MetaProperty(Constants.PLATFORM_OS_VERSION,
1006                     platInfo.getOperationSystemVersion()));
1007             metaProperties.add(new MetaProperty(
1008                     Constants.PLATFORM_HARDWARE_VERSION, platInfo
1009                             .getHardwareVersion()));
1010             metaProperties.add(new MetaProperty(
1011                     Constants.PLATFORM_FIRMWARE_VERSION, platInfo
1012                             .getFirmwareVersion()));
1013             metaProperties.add(new MetaProperty(Constants.PLATFORM_SUPPORT_URL,
1014                     platInfo.getSupportUrl()));
1015             metaProperties.add(new MetaProperty(Constants.PLATFORM_SYSTEM_TIME,
1016                     platInfo.getSystemTime()));
1017         }
1018         return metaProperties;
1019     }
1020
1021     public Map<String, Boolean> getAutomationStatus(RemoteResource resource) {
1022         if (null == resource) {
1023             return null;
1024         }
1025         Map<String, Boolean> autoStatus = new HashMap<String, Boolean>();
1026         autoStatus.put(Constants.GET, resource.isGetAutomtnInProgress());
1027         autoStatus.put(Constants.PUT, resource.isPutAutomtnInProgress());
1028         autoStatus.put(Constants.POST, resource.isPostAutomtnInProgress());
1029         return autoStatus;
1030     }
1031
1032     public List<RemoteResource> getResourceList() {
1033         List<RemoteResource> resourceList = new ArrayList<RemoteResource>();
1034         synchronized (resourceMap) {
1035             Set<String> idSet = resourceMap.keySet();
1036             Iterator<String> idItr = idSet.iterator();
1037             RemoteResource resource;
1038             while (idItr.hasNext()) {
1039                 resource = resourceMap.get(idItr.next());
1040                 if (null != resource) {
1041                     resourceList.add(resource);
1042                 }
1043             }
1044         }
1045         // Sort the list
1046         Collections.sort(resourceList, new Comparator<RemoteResource>() {
1047             public int compare(RemoteResource res1, RemoteResource res2) {
1048                 String s1 = res1.getRemoteResourceRef().getURI();
1049                 String s2 = res2.getRemoteResourceRef().getURI();
1050
1051                 String s1Part = s1.replaceAll("\\d", "");
1052                 String s2Part = s2.replaceAll("\\d", "");
1053
1054                 if (s1Part.equalsIgnoreCase(s2Part)) {
1055                     return extractInt(s1) - extractInt(s2);
1056                 }
1057                 return s1.compareTo(s2);
1058             }
1059
1060             int extractInt(String s) {
1061                 String num = s.replaceAll("\\D", "");
1062                 // return 0 if no digits found
1063                 return num.isEmpty() ? 0 : Integer.parseInt(num);
1064             }
1065         });
1066
1067         return resourceList;
1068     }
1069
1070     public List<RemoteResource> getFavResourceList() {
1071         List<RemoteResource> resourceList;
1072         synchronized (favoriteResources) {
1073             resourceList = new ArrayList<RemoteResource>(favoriteResources);
1074         }
1075         return resourceList;
1076     }
1077
1078     public List<String> getAllValuesOfAttribute(SimulatorResourceAttribute att) {
1079         if (null == att) {
1080             return null;
1081         }
1082
1083         AttributeValue val = att.value();
1084         if (null == val || null == val.get()) {
1085             return null;
1086         }
1087
1088         TypeInfo type = val.typeInfo();
1089
1090         if (type.mBaseType == ValueType.RESOURCEMODEL) {
1091             return null;
1092         }
1093
1094         List<String> values = new ArrayList<String>();
1095
1096         AttributeProperty prop = att.property();
1097         if (null == prop) {
1098             values.add(new AttributeValueStringConverter(val).toString());
1099             return values;
1100         }
1101
1102         if (type.mType == ValueType.ARRAY) {
1103             if (type.mDepth == 1) {
1104                 ArrayProperty arrayProperty = prop.asArray();
1105                 if (null != arrayProperty) {
1106                     AttributeProperty childProp = arrayProperty
1107                             .getElementProperty();
1108                     switch (childProp.getType()) {
1109                         case INTEGER:
1110                             IntegerProperty intProperty = childProp.asInteger();
1111                             if (null != intProperty) {
1112                                 values.addAll(getAllValues(att, intProperty,
1113                                         Type.INTEGER));
1114                             }
1115                             break;
1116                         case DOUBLE:
1117                             DoubleProperty dblProperty = childProp.asDouble();
1118                             if (null != dblProperty) {
1119                                 values.addAll(getAllValues(att, dblProperty,
1120                                         Type.DOUBLE));
1121                             }
1122                             break;
1123                         case BOOLEAN:
1124                             BooleanProperty boolProperty = childProp
1125                                     .asBoolean();
1126                             if (null != boolProperty) {
1127                                 values.addAll(getAllValues(att, boolProperty,
1128                                         Type.BOOLEAN));
1129                             }
1130                             break;
1131                         case STRING:
1132                             StringProperty stringProperty = childProp
1133                                     .asString();
1134                             if (null != stringProperty) {
1135                                 values.addAll(getAllValues(att, stringProperty,
1136                                         Type.STRING));
1137                             }
1138                             break;
1139                         default:
1140                             break;
1141                     }
1142                 }
1143             }
1144         } else {
1145             switch (prop.getType()) {
1146                 case INTEGER:
1147                     IntegerProperty intProperty = prop.asInteger();
1148                     if (null != intProperty) {
1149                         values.addAll(getAllValues(att, intProperty,
1150                                 Type.INTEGER));
1151                     }
1152                     break;
1153                 case DOUBLE:
1154                     DoubleProperty dblProperty = prop.asDouble();
1155                     if (null != dblProperty) {
1156                         values.addAll(getAllValues(att, dblProperty,
1157                                 Type.DOUBLE));
1158                     }
1159                     break;
1160                 case BOOLEAN:
1161                     BooleanProperty boolProperty = prop.asBoolean();
1162                     if (null != boolProperty) {
1163                         values.addAll(getAllValues(att, boolProperty,
1164                                 Type.BOOLEAN));
1165                     }
1166                     break;
1167                 case STRING:
1168                     StringProperty stringProperty = prop.asString();
1169                     if (null != stringProperty) {
1170                         values.addAll(getAllValues(att, stringProperty,
1171                                 Type.STRING));
1172                     }
1173                     break;
1174                 default:
1175                     break;
1176             }
1177         }
1178
1179         return values;
1180     }
1181
1182     public List<String> getAllValues(SimulatorResourceAttribute attribute,
1183             IntegerProperty intProperty, AttributeProperty.Type type) {
1184         List<String> values = new ArrayList<String>();
1185
1186         if (intProperty.hasRange()) {
1187             int min = (int) intProperty.min();
1188             int max = (int) intProperty.max();
1189             for (int iVal = min; iVal <= max; iVal++) {
1190                 values.add(String.valueOf(iVal));
1191             }
1192         } else if (intProperty.hasValues()) {
1193             for (Integer val : intProperty.getValues()) {
1194                 values.add(String.valueOf(val));
1195             }
1196         } else {
1197             AttributeValue value = attribute.value();
1198             if (null != value && null != value.get()) {
1199                 // Adding the current value of the attribute.
1200                 values.add(String.valueOf(value.get()));
1201             }
1202         }
1203         return values;
1204     }
1205
1206     public List<String> getAllValues(SimulatorResourceAttribute attribute,
1207             DoubleProperty dblProperty, AttributeProperty.Type type) {
1208         NumberFormat formatter = NumberFormat.getInstance();
1209         List<String> values = new ArrayList<String>();
1210
1211         if (dblProperty.hasRange()) {
1212             double min = (double) dblProperty.min();
1213             double max = (double) dblProperty.max();
1214             for (double val = min; val <= max; val += 0.1) {
1215                 formatter.setMaximumFractionDigits(1);
1216                 formatter.setMinimumFractionDigits(1);
1217                 values.add(formatter.format(val));
1218             }
1219         } else if (dblProperty.hasValues()) {
1220             for (Double val : dblProperty.getValues()) {
1221                 values.add(String.valueOf(val));
1222             }
1223         } else {
1224             AttributeValue value = attribute.value();
1225             if (null != value && null != value.get()) {
1226                 // Adding the current value of the attribute.
1227                 values.add(String.valueOf(value.get()));
1228             }
1229         }
1230         return values;
1231     }
1232
1233     public List<String> getAllValues(SimulatorResourceAttribute attribute,
1234             BooleanProperty boolProperty, AttributeProperty.Type type) {
1235         List<String> values = new ArrayList<String>();
1236         values.add("true");
1237         values.add("false");
1238         return values;
1239     }
1240
1241     public List<String> getAllValues(SimulatorResourceAttribute attribute,
1242             StringProperty stringProperty, AttributeProperty.Type type) {
1243         List<String> values = new ArrayList<String>();
1244
1245         if (stringProperty.hasValues()) {
1246             for (String val : stringProperty.getValues()) {
1247                 values.add(String.valueOf(val));
1248             }
1249         } else {
1250             AttributeValue value = attribute.value();
1251             if (null != value && null != value.get()) {
1252                 // Adding the current value of the attribute.
1253                 values.add(String.valueOf(value.get()));
1254             }
1255         }
1256         return values;
1257     }
1258
1259     public void sendGetRequest(String ifType, String query,
1260             RemoteResource resource) {
1261         if (null == resource) {
1262             return;
1263         }
1264         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1265         if (null == resourceN) {
1266             return;
1267         }
1268
1269         Map<String, String> queryParams = formQueryParameters(ifType, query);
1270         try {
1271             resourceN.get(queryParams, getListener);
1272         } catch (SimulatorException e) {
1273             Activator
1274                     .getDefault()
1275                     .getLogManager()
1276                     .log(Level.ERROR.ordinal(), new Date(),
1277                             Utility.getSimulatorErrorString(e, null));
1278         }
1279     }
1280
1281     public void sendPutRequest(String ifType, RemoteResource resource,
1282             SimulatorResourceModel model) {
1283         if (null == resource || null == model) {
1284             return;
1285         }
1286         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1287         if (null == resourceN) {
1288             return;
1289         }
1290         Map<String, String> queryParams = formQueryParameters(ifType, null);
1291         try {
1292             resourceN.put(queryParams, model, putListener);
1293         } catch (Exception e) {
1294             String addlInfo;
1295             addlInfo = "Invalid Attribute Value. Cannot send PUT request.";
1296             Activator
1297                     .getDefault()
1298                     .getLogManager()
1299                     .log(Level.ERROR.ordinal(), new Date(),
1300                             Utility.getSimulatorErrorString(e, addlInfo));
1301         }
1302     }
1303
1304     public void sendPostRequest(String ifType, RemoteResource resource,
1305             SimulatorResourceModel model) {
1306         if (null == resource || null == model) {
1307             return;
1308         }
1309         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1310         if (null == resourceN) {
1311             return;
1312         }
1313         Map<String, String> queryParams = formQueryParameters(ifType, null);
1314         try {
1315             resourceN.post(queryParams, model, postListener);
1316         } catch (Exception e) {
1317             String addlInfo;
1318             addlInfo = "Invalid Attribute Value. Cannot send POST request.";
1319             Activator
1320                     .getDefault()
1321                     .getLogManager()
1322                     .log(Level.ERROR.ordinal(), new Date(),
1323                             Utility.getSimulatorErrorString(e, addlInfo));
1324         }
1325     }
1326
1327     public boolean sendObserveRequest(RemoteResource resource) {
1328         if (null == resource) {
1329             return false;
1330         }
1331         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1332         if (null == resourceN) {
1333             return false;
1334         }
1335         try {
1336             resourceN.observe(observeListener);
1337             resource.setObserved(true);
1338             // Add observed resource URI to show the proper status after every
1339             // find/refresh operations.
1340             addObservedResourceURI(resource.getRemoteResourceRef().getURI());
1341         } catch (SimulatorException e) {
1342             Activator
1343                     .getDefault()
1344                     .getLogManager()
1345                     .log(Level.ERROR.ordinal(), new Date(),
1346                             Utility.getSimulatorErrorString(e, null));
1347             return false;
1348         }
1349         return true;
1350     }
1351
1352     private Map<String, String> formQueryParameters(String ifType, String query) {
1353         Map<String, String> queryParams = new HashMap<String, String>();
1354
1355         // Including the interface type, if given,
1356         if (null != ifType) {
1357             ifType = ifType.trim();
1358             if (ifType.length() > 0)
1359                 queryParams.put("if", ifType);
1360         }
1361
1362         // Including other queries, if given.
1363         if (null != query) {
1364             query = query.trim();
1365             if (query.length() > 0) {
1366                 // Parse the query parameters and fill the map.
1367                 String queries[] = query.split(";");
1368                 if (queries.length > 0) {
1369                     for (String pair : queries) {
1370                         String tok[] = pair.split("=");
1371                         if (null != tok && tok.length == 2) {
1372                             queryParams.put(tok[0].trim(), tok[1].trim());
1373                         }
1374                     }
1375                 }
1376             }
1377         }
1378         return queryParams;
1379     }
1380
1381     public boolean sendCancelObserveRequest(RemoteResource resource,
1382             boolean removeEntry) {
1383         if (null == resource || !resource.isObserved()) {
1384             return false;
1385         }
1386         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1387         if (null == resourceN) {
1388             return false;
1389         }
1390         try {
1391             resourceN.stopObserve();
1392             resource.setObserved(false);
1393             // Remove observed resource URI to show the proper status after
1394             // every find/refresh operations.
1395             if (removeEntry)
1396                 removeObservedResourceURI(resource.getRemoteResourceRef()
1397                         .getURI());
1398         } catch (SimulatorException e) {
1399             Activator
1400                     .getDefault()
1401                     .getLogManager()
1402                     .log(Level.ERROR.ordinal(), new Date(),
1403                             Utility.getSimulatorErrorString(e, null));
1404             return false;
1405         }
1406         return true;
1407     }
1408
1409     public void startAutomationRequest(RequestType reqType,
1410             RemoteResource resource) {
1411         if (null == resource) {
1412             return;
1413         }
1414         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1415         if (null == resourceN) {
1416             return;
1417         }
1418         if (null == reqType) {
1419             return;
1420         }
1421         int autoId;
1422         try {
1423             autoId = resourceN.startVerification(reqType, verifyListener);
1424             if (autoId != -1) {
1425                 if (reqType == RequestType.GET) {
1426                     resource.setGetAutomtnId(autoId);
1427                 } else if (reqType == RequestType.PUT) {
1428                     resource.setPutAutomtnId(autoId);
1429                 } else {
1430                     resource.setPostAutomtnId(autoId);
1431                 }
1432             }
1433             Activator
1434                     .getDefault()
1435                     .getLogManager()
1436                     .log(Level.INFO.ordinal(),
1437                             new Date(),
1438                             "[" + reqType.toString()
1439                                     + "] Verification Started for \""
1440                                     + resourceN.getURI() + "\".");
1441         } catch (SimulatorException e) {
1442             Activator
1443                     .getDefault()
1444                     .getLogManager()
1445                     .log(Level.ERROR.ordinal(), new Date(),
1446                             Utility.getSimulatorErrorString(e, null));
1447         }
1448     }
1449
1450     public void stopAutomationRequest(RequestType reqType,
1451             RemoteResource resource) {
1452         if (null == resource) {
1453             return;
1454         }
1455         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1456         if (null == resourceN) {
1457             return;
1458         }
1459         int autoId;
1460         if (reqType == RequestType.GET) {
1461             resource.setGetAutomtnInProgress(false);
1462             autoId = resource.getGetAutomtnId();
1463         } else if (reqType == RequestType.PUT) {
1464             resource.setPutAutomtnInProgress(false);
1465             autoId = resource.getPutAutomtnId();
1466         } else {
1467             resource.setPostAutomtnInProgress(false);
1468             autoId = resource.getPostAutomtnId();
1469         }
1470         try {
1471             resourceN.stopVerification(autoId);
1472         } catch (SimulatorException e) {
1473             Activator
1474                     .getDefault()
1475                     .getLogManager()
1476                     .log(Level.ERROR.ordinal(), new Date(),
1477                             Utility.getSimulatorErrorString(e, null));
1478         }
1479     }
1480
1481     public boolean setConfigFilePath(RemoteResource resource,
1482             String configFilePath) throws SimulatorException {
1483
1484         if (null == resource) {
1485             return false;
1486         }
1487         SimulatorRemoteResource resourceN = resource.getRemoteResourceRef();
1488         if (null == resourceN) {
1489             return false;
1490         }
1491         try {
1492             Map<RequestType, SimulatorRequestModel> requestModels;
1493             requestModels = resourceN.setConfigInfo(configFilePath);
1494             if (null == requestModels) {
1495                 return false;
1496             }
1497
1498             // Store the resource model in the local cache
1499             resource.setRequestModels(requestModels);
1500         } catch (SimulatorException e) {
1501             Activator
1502                     .getDefault()
1503                     .getLogManager()
1504                     .log(Level.ERROR.ordinal(), new Date(),
1505                             Utility.getSimulatorErrorString(e, null));
1506             throw e;
1507         } catch (Exception e) {
1508             Activator
1509                     .getDefault()
1510                     .getLogManager()
1511                     .log(Level.ERROR.ordinal(),
1512                             new Date(),
1513                             Utility.getSimulatorErrorString(e,
1514                                     "Error while configuring the attribute properties"));
1515         }
1516         // Update the status
1517         resource.setConfigUploaded(true);
1518
1519         // Notify the UI listeners
1520         UiListenerHandler.getInstance().configUploadedNotification(resource);
1521
1522         return true;
1523     }
1524
1525     public void shutdown() {
1526     }
1527 }