1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
20 package com.tm.sample;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
26 import java.util.Vector;
28 import org.iotivity.base.OcException;
29 import org.iotivity.base.OcHeaderOption;
30 import org.iotivity.base.OcPlatform;
31 import org.iotivity.base.OcRepresentation;
32 import org.iotivity.base.OcResource;
33 import org.iotivity.base.OcResourceHandle;
34 import org.iotivity.service.tm.GroupSynchronization;
35 import org.iotivity.service.tm.OCStackResult;
36 import org.iotivity.service.tm.GroupManager;
37 import org.iotivity.service.tm.ThingsMaintenance;
38 import org.iotivity.service.tm.GroupManager.*;
39 import org.iotivity.service.tm.ThingsConfiguration;
40 import org.iotivity.service.tm.ThingsConfiguration.*;
41 import org.iotivity.service.tm.ThingsMaintenance.*;
43 import android.app.Activity;
44 import android.app.Dialog;
45 import android.content.Context;
46 import android.os.Bundle;
47 import android.os.Handler;
48 import android.os.Message;
49 import android.util.Log;
50 import android.view.View;
51 import android.view.View.OnClickListener;
52 import android.widget.AdapterView;
53 import android.widget.AdapterView.OnItemClickListener;
54 import android.widget.ArrayAdapter;
55 import android.widget.Button;
56 import android.widget.EditText;
57 import android.widget.ListView;
58 import android.widget.Toast;
61 * Activity for Handling all Configuration Apis as per user's selection on the UI.
64 public class ConfigurationApiActivity extends Activity {
66 private class ResourceInformation {
67 OcResource resource = null;
68 OcResourceHandle resourceHandle = null;
71 private final String LOG_TAG = "[TMSample] "
75 private final String CONFIGURATION_COLLECTION_RESOURCE_URI = "/core/configuration/resourceset";
76 private final String CONFIGURATION_COLLECTION_RESOURCE_TYPE = "core.configuration.resourceset";
77 private final String MAINTENANCE_COLLECTION_RESOURCE_URI = "/core/maintenance/resourceset";
78 private final String MAINTENANCE_COLLECTION_RESOURCE_TYPE = "core.maintenance.resourceset";
79 private final String FACTORYSET_COLLECTION_RESOURCE_URI = "/core/factoryset/resourceset";
80 private final String FACTORYSET_COLLECTION_RESOURCE_TYPE = "core.factoryset.resourceset";
82 private final String CONFIGURATION_RESOURCE_URI = "/oic/con";
83 private final String MAINTENANCE_RESOURCE_URI = "/oic/mnt";
84 private final String FACTORYSET_RESOURCE_URI = "/factorySet";
86 private ListView list;
87 private ArrayAdapter<String> configurationApis;
88 private ArrayList<String> configurationApisList;
90 private static int messageCount = 0;
91 private static EditText logs;
92 private static String logMessage = "";
93 private static Handler mHandler;
94 private static Message msg;
96 private GroupManager groupManager = null;
97 private GroupSynchronization groupSyn = null;
98 private ThingsConfiguration thingsConfiguration = null;
99 private ThingsMaintenance thingsMaintenance = null;
100 private Map<String, ResourceInformation> resourceList = null;
101 private Map<String, ResourceInformation> collectionList = null;
103 public boolean configurationResourceFlag = false;
104 public boolean factorySetResourceFlag = false;
105 public boolean maintenanceResourceFlag = false;
107 public static Context mcontext;
108 public String region = "";
109 public boolean findGroupPressedFlag = false;
112 protected void onCreate(Bundle savedInstanceState) {
113 super.onCreate(savedInstanceState);
114 setContentView(R.layout.configapis);
117 groupManager = new GroupManager();
118 groupSyn = new GroupSynchronization();
119 thingsConfiguration = ThingsConfiguration.getInstance();
120 thingsMaintenance = ThingsMaintenance.getInstance();
123 setResourceListener();
124 setConfigurationListener();
125 setDiagnosticsListener();
127 // Create API menu list
128 configurationApisList = new ArrayList<String>();
130 logs = (EditText) findViewById(R.id.EditText);
132 list = (ListView) findViewById(R.id.configApisList);
133 configurationApisList.add("Find All Groups");
134 configurationApisList.add("Find All Resources");
135 configurationApisList.add("Get a Configuration Resource");
136 configurationApisList.add("Update Attribute (Region)");
137 configurationApisList.add("Factory Reset");
138 configurationApisList.add("Reboot");
139 configurationApisList.add("Get Supported Configuration Units");
140 configurationApis = new ArrayAdapter<String>(this,
141 android.R.layout.simple_list_item_1, configurationApisList);
142 list.setAdapter(configurationApis);
144 // setting the Listener for calling the APIs as per User selection
145 list.setOnItemClickListener(new OnItemClickListener() {
148 public void onItemClick(AdapterView<?> parent, View view,
149 int position, long id) {
153 Vector<String> resourceTypes = new Vector<String>();
154 resourceTypes.add("core.configuration.resourceset");
155 findCandidateResources(resourceTypes);
161 resourceTypes.clear();
162 resourceTypes.add("core.diagnostics.resourceset");
163 findCandidateResources(resourceTypes);
167 resourceTypes.clear();
168 resourceTypes.add("core.factoryset.resourceset");
169 findCandidateResources(resourceTypes);
173 } else if (position == 1) { // Find All Resources
174 if (false == findGroupPressedFlag) {
175 displayToastMessage("Configuration collection resource does not exist!");
177 Vector<String> resourceTypes = new Vector<String>();
178 resourceTypes.add("oic.wk.con");
179 findCandidateResources(resourceTypes);
185 resourceTypes.clear();
186 resourceTypes.add("oic.wk.mnt");
187 findCandidateResources(resourceTypes);
191 resourceTypes.clear();
192 resourceTypes.add("factorySet");
193 findCandidateResources(resourceTypes);
197 } else if (position == 2) { // Get Configuration
199 } else if (position == 3) { // Update Attribute (Region)
201 } else if (position == 4) { // Factory Reset
203 } else if (position == 5) { // Reboot
205 } else if (position == 6) { // Get Supported Configuration Units
206 String configurationUnits;
207 configurationUnits = getListOfSupportedConfigurationUnits();
208 Log.i(LOG_TAG, "Configuration Units:" + configurationUnits);
209 logMessage = configurationUnits;
211 logs.setText(logMessage);
217 resourceList = new HashMap<String, ResourceInformation>();
218 collectionList = new HashMap<String, ResourceInformation>();
221 createResourceCollection(CONFIGURATION_COLLECTION_RESOURCE_URI,
222 CONFIGURATION_COLLECTION_RESOURCE_TYPE);
223 createResourceCollection(MAINTENANCE_COLLECTION_RESOURCE_URI,
224 MAINTENANCE_COLLECTION_RESOURCE_TYPE);
225 createResourceCollection(FACTORYSET_COLLECTION_RESOURCE_URI,
226 FACTORYSET_COLLECTION_RESOURCE_TYPE);
227 } catch (OcException e) {
228 Log.e(LOG_TAG, "OcException occured! " + e.toString());
231 // handler for updating the UI i.e. LogMessage TextBox
232 mHandler = new Handler() {
234 public void handleMessage(Message msg) {
238 logs.setText(logMessage);
239 Log.i(LOG_TAG, logMessage);
246 private void userInputDialog() {
248 ResourceInformation configurationCollection = collectionList
249 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
250 if (null == configurationCollection
251 || null == configurationCollection.resource) {
252 displayToastMessage("Configuration collection resource does not exist!");
254 if (false == configurationResourceFlag) {
255 displayToastMessage("Configuration resource does not exist!");
257 final Dialog dialog = new Dialog(mcontext);
258 dialog.setContentView(R.layout.userinputforregionvalue);
259 dialog.setTitle("Enter the Region Value");
261 dialog.setCancelable(false);
263 Button ok = (Button) dialog.findViewById(R.id.ok);
264 Button cancel = (Button) dialog.findViewById(R.id.cancel);
266 ok.setOnClickListener(new OnClickListener() {
268 public void onClick(View v) {
270 EditText regionValue = (EditText) dialog
271 .findViewById(R.id.region);
272 region = regionValue.getText().toString();
273 if (region.equalsIgnoreCase("")) {
274 String toastmessage = "Please enter the Region Value";
275 displayToastMessage(toastmessage);
278 updateConfiguration(region);
282 cancel.setOnClickListener(new OnClickListener() {
284 public void onClick(View v) {
292 public void onBackPressed() {
293 super.onBackPressed();
295 // unregistering resource from the platform
297 resourceList.clear();
299 collectionList.clear();
300 collectionList = null;
303 private void setResourceListener() {
305 .setFindCandidateResourceListener(new IFindCandidateResourceListener() {
308 public void onResourceFoundCallback(
309 Vector<OcResource> resources) {
310 // TODO Auto-generated method stub
311 Log.i(LOG_TAG, "onResourceCallback: enter");
312 for (int i = 0; i < resources.size(); i++) {
313 OcResource resource = resources.get(i);
314 String uri = resource.getUri();
315 String host = resource.getHost();
317 // Display resource information
318 Log.i(LOG_TAG, "Resource URI:" + uri);
319 Log.i(LOG_TAG, "Resource HOST: " + host);
320 Log.i(LOG_TAG, "Resource types: ");
321 logMessage += "Resource URI : " + uri + "\n";
322 logMessage += "Resource Host : " + host + "\n";
324 List<String> resourcetypes = resource
326 for (int j = 0; j < resourcetypes.size(); j++) {
327 Log.i(LOG_TAG, resourcetypes.get(j));
328 logMessage += "ResourceType " + (j + 1) + " : "
329 + resourcetypes.get(j) + "\n";
332 Log.i(LOG_TAG, "Interface types: ");
333 List<String> interfacetypes = resource
334 .getResourceInterfaces();
335 for (int j = 0; j < interfacetypes.size(); j++) {
336 Log.i(LOG_TAG, interfacetypes.get(j));
337 logMessage += "interfacetype " + (j + 1)
338 + " : " + interfacetypes.get(j) + "\n";
342 if (true == uri.contains("/resourceset")) {
343 collectionFound(resource);
345 resourceFound(resource);
347 } catch (OcException e) {
349 "OcExcepion occured! " + e.toString());
352 if (messageCount == 3) {
353 msg = Message.obtain();
355 mHandler.sendMessage(msg);
361 private void setConfigurationListener() {
363 .setConfigurationListener(new IConfigurationListener() {
365 public void onBootStrapCallback(
366 Vector<OcHeaderOption> headerOptions,
367 OcRepresentation rep, int errorValue) {
368 Log.i(LOG_TAG, "onBootStrapCallback: enter");
372 public void onUpdateConfigurationsCallback(
373 Vector<OcHeaderOption> headerOptions,
374 OcRepresentation rep, int errorValue) {
375 Log.i(LOG_TAG, "onUpdateConfigurationsCallback: enter");
376 Log.i(LOG_TAG, "Resource URI: " + rep.getUri());
377 if (rep.hasAttribute("n")) {
378 logMessage += "Device Name : "
379 + rep.getValueString("n") + "\n";
381 if (rep.hasAttribute("loc")) {
382 logMessage += "Location : "
383 + rep.getValueString("loc") + "\n";
385 if (rep.hasAttribute("locn")) {
386 logMessage += "Location Name : "
387 + rep.getValueString("locn") + "\n";
389 if (rep.hasAttribute("r")) {
390 logMessage += "Region : " + rep.getValueString("r")
393 if (rep.hasAttribute("c")) {
394 logMessage += "Currency : "
395 + rep.getValueString("c") + "\n";
400 public void onGetConfigurationsCallback(
401 Vector<OcHeaderOption> headerOptions,
402 OcRepresentation rep, int errorValue) {
403 Log.i(LOG_TAG, "onGetConfigurationsCallback: enter");
404 Log.i(LOG_TAG, "Resource URI: " + rep.getUri());
405 logMessage += "Resource URI : " + rep.getUri() + "\n";
407 if (rep.hasAttribute("n")) {
408 logMessage += "Device Name : "
409 + rep.getValueString("n") + "\n";
411 if (rep.hasAttribute("loc")) {
412 logMessage += "Location : "
413 + rep.getValueString("loc") + "\n";
415 if (rep.hasAttribute("locn")) {
416 logMessage += "Location Name : "
417 + rep.getValueString("locn") + "\n";
419 if (rep.hasAttribute("r")) {
420 logMessage += "Region : " + rep.getValueString("r")
423 if (rep.hasAttribute("c")) {
424 logMessage += "Currency : "
425 + rep.getValueString("c") + "\n";
428 msg = Message.obtain();
430 mHandler.sendMessage(msg);
435 private void setDiagnosticsListener() {
437 .setThingsMaintenanceListener(new IThingsMaintenanceListener() {
440 public void onRebootCallback(
441 Vector<OcHeaderOption> headerOptions,
442 OcRepresentation rep, int errorValue) {
443 // TODO Auto-generated method stu
447 public void onFactoryResetCallback(
448 Vector<OcHeaderOption> headerOptions,
449 OcRepresentation rep, int errorValue) {
450 // TODO Auto-generated method stub
457 * This method find the resources available in network.
459 private void findCandidateResources(Vector<String> resourceTypes) {
460 OCStackResult result = groupManager.findCandidateResources(
462 if (OCStackResult.OC_STACK_OK != result) {
463 Log.e(LOG_TAG, "Error while calling findCandidateResources");
464 String toastmessage = "findCandidateResources API returned error! ["
466 displayToastMessage(toastmessage);
468 if (messageCount == 1)
469 logMessage += "API RESULT : " + result.toString() + "\n";
473 * This method gets the configuration data from con-server.
475 private void getConfiguration() {
476 Log.i(LOG_TAG, "There are " + resourceList.size()
477 + " servers present in network");
478 ResourceInformation configurationCollection = collectionList
479 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
480 if (null == configurationCollection
481 || null == configurationCollection.resource) {
482 displayToastMessage("Configuration collection resource does not exist!");
485 if (false == configurationResourceFlag) {
487 displayToastMessage("Configuration resource does not exist!");
492 Vector<String> configs = new Vector<String>();
495 OCStackResult result = OCStackResult.OC_STACK_ERROR;
497 result = thingsConfiguration.getConfigurations(
498 configurationCollection.resource, configs);
499 } catch (OcException e) {
503 if (OCStackResult.OC_STACK_OK != result) {
504 Log.e(LOG_TAG, "getConfigurations failed!");
505 String toastmessage = "getConfigurations API returned error! ["
507 displayToastMessage(toastmessage);
509 logMessage = "API RESULT : " + result.toString() + "\n";
510 msg = Message.obtain();
512 mHandler.sendMessage(msg);
516 * This method update the configuration resource region attribute to given
521 private void updateConfiguration(String region) {
522 ResourceInformation configurationCollection = collectionList
523 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
525 Map<String, String> configurations = new HashMap<String, String>();
528 configurations.put(name, region);
529 } catch (Exception e) {
530 Log.e(LOG_TAG, "Exception occured! " + e.toString());
533 OCStackResult result = OCStackResult.OC_STACK_ERROR;
535 result = thingsConfiguration.updateConfigurations(
536 configurationCollection.resource, configurations);
537 } catch (OcException e) {
540 if (OCStackResult.OC_STACK_OK != result) {
541 Log.e(LOG_TAG, "updateConfigurations failed!");
542 String toastmessage = "updateConfigurations API returned error! ["
544 displayToastMessage(toastmessage);
546 logMessage = "API RESULT : " + result.toString() + "\n";
547 logMessage += "Updating region to " + region;
548 msg = Message.obtain();
550 mHandler.sendMessage(msg);
554 * This method send request to reset all the configuration attribute values
557 private void factoryReset() {
558 ResourceInformation diagnosticsCollection = collectionList
559 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
560 if (null == diagnosticsCollection
561 || null == diagnosticsCollection.resource) {
562 displayToastMessage("Diagnostic collection does not exist!");
566 if (false == maintenanceResourceFlag) {
567 displayToastMessage("Diagnostic resource does not exist!");
571 OCStackResult result = OCStackResult.values()[30];
574 result = thingsMaintenance
575 .factoryReset(diagnosticsCollection.resource);
576 } catch (OcException e) {
580 if (OCStackResult.OC_STACK_OK != result) {
581 Log.e(LOG_TAG, "factoryReset failed!");
582 String toastmessage = "factoryReset API returned error! [" + result
584 displayToastMessage(toastmessage);
587 logMessage = "API RESULT : " + result.toString() + "\n";
588 msg = Message.obtain();
590 mHandler.sendMessage(msg);
594 * This method send request to reboot server.
596 private void reboot() {
597 ResourceInformation diagnosticsCollection = collectionList
598 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
599 if (null == diagnosticsCollection
600 || null == diagnosticsCollection.resource) {
601 displayToastMessage("Diagnostic collection does not exist!");
604 if (false == maintenanceResourceFlag) {
605 displayToastMessage("Diagnostic resource does not exist!");
609 OCStackResult result = OCStackResult.OC_STACK_ERROR;
611 result = thingsMaintenance.reboot(diagnosticsCollection.resource);
612 } catch (OcException e) {
616 if (OCStackResult.OC_STACK_OK != result) {
617 Log.e(LOG_TAG, "reboot failed!");
618 String toastmessage = "reboot API returned error! [" + result + "]";
619 displayToastMessage(toastmessage);
621 logMessage = "API RESULT : " + result.toString() + "\n";
622 msg = Message.obtain();
624 mHandler.sendMessage(msg);
628 * This method is for getting list of all supported configuration values.
629 * Response will be in JSON format (key-value pair).
631 private String getListOfSupportedConfigurationUnits() {
632 return thingsConfiguration.getListOfSupportedConfigurationUnits();
635 private void displayToastMessage(String message) {
636 Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
638 Log.i(LOG_TAG, message);
641 private void collectionFound(OcResource resource) {
642 String uri = resource.getUri();
643 ResourceInformation resourceInfo = collectionList.get(uri);
644 if (null == resourceInfo) {
645 Log.e(LOG_TAG, "Collection is not created!");
649 if (null != resourceInfo.resource) {
650 Log.e(LOG_TAG, "Collection resource already updated!");
654 resourceInfo.resource = resource;
655 if (3 == messageCount) {
656 findGroupPressedFlag = true;
661 * This callback will be invoked when the interested resource discovered in
664 private void resourceFound(OcResource resource) throws OcException {
665 String uri = resource.getUri();
666 String host = resource.getHost();
668 // Check if the resource already exist in the map table
669 ResourceInformation resourceInfo = resourceList.get(uri + host);
670 if (null != resourceInfo) {
671 Log.e(LOG_TAG, "Resource already exists!");
676 resourceInfo = new ResourceInformation();
677 resourceInfo.resource = resource;
678 if (uri.equalsIgnoreCase("/oic/con")) {
679 ResourceInformation collectionResource = collectionList
680 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
681 if (null == collectionResource
682 || null == collectionResource.resourceHandle) {
683 Log.e(LOG_TAG, "Invalid Configuration collection!");
687 ResourceInformation resourceInfoCollection;
688 resourceInfoCollection = collectionList
689 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
690 OcResourceHandle handle;
691 handle = resourceInfoCollection.resourceHandle;
692 resourceInfo.resourceHandle = handle;
693 resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
696 resourceList.put(uri + host, resourceInfo);
697 configurationResourceFlag = true;
698 } else if (uri.equalsIgnoreCase("/oic/mnt")) {
699 ResourceInformation diagnosticResource = collectionList
700 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
701 if (null == diagnosticResource
702 || null == diagnosticResource.resourceHandle) {
703 Log.e(LOG_TAG, "Invalid Configuration collection!");
707 ResourceInformation resourceInfoCollection;
708 resourceInfoCollection = collectionList
709 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
710 OcResourceHandle handle;
711 handle = resourceInfoCollection.resourceHandle;
712 resourceInfo.resourceHandle = handle;
713 resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
716 resourceList.put(uri + host, resourceInfo);
717 maintenanceResourceFlag = true;
718 } else if (uri.equalsIgnoreCase("/factorySet")) {
719 ResourceInformation factorysetResource = collectionList
720 .get(FACTORYSET_COLLECTION_RESOURCE_URI);
721 if (null == factorysetResource
722 || null == factorysetResource.resourceHandle) {
723 Log.e(LOG_TAG, "Invalid Configuration collection!");
727 ResourceInformation resourceInfoCollection;
728 resourceInfoCollection = collectionList
729 .get(FACTORYSET_COLLECTION_RESOURCE_URI);
730 OcResourceHandle handle;
731 handle = resourceInfoCollection.resourceHandle;
732 resourceInfo.resourceHandle = handle;
733 resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
736 resourceList.put(uri + host, resourceInfo);
737 factorySetResourceFlag = true;
739 Log.e(LOG_TAG, "Resource is of different type: " + uri);
744 private void createResourceCollection(String uri, String typename)
747 Map<String, OcResourceHandle> groupList = new HashMap<String, OcResourceHandle>();
749 Log.i(LOG_TAG, "createGroup: " + typename);
750 // Check if the resource collection is already created
751 if (null != collectionList.get(uri)) {
752 Log.e(LOG_TAG, "Collection is already exist!");
756 OcResourceHandle resourceHandle = null;
759 OCStackResult result = groupSyn.createGroup(typename);
760 if ((OCStackResult.OC_STACK_OK != result)) {
761 Log.e(LOG_TAG, "createGroup returned error: " + result.name());
764 Log.e(LOG_TAG, "createGroup returned: " + result.name());
766 groupList = groupSyn.getGroupList();
767 if (groupList.containsKey(typename)) {
768 resourceHandle = groupList.get(typename);
770 Log.e(LOG_TAG, "group does not contain groupResourceType: "
774 if (null == resourceHandle) {
775 Log.e(LOG_TAG, " createResourceCollection : resourceHandle is NULL");
778 // Add the collection resource to map table
779 ResourceInformation resourceInfo = new ResourceInformation();
780 resourceInfo.resourceHandle = resourceHandle;
781 collectionList.put(uri, resourceInfo);
782 Log.i(LOG_TAG, "size of collectionList : " + collectionList.size());
785 private void deleteResources() {
786 Log.i(LOG_TAG, "deleteResources: enter");
788 // unregister all resources
789 for (ResourceInformation resource : resourceList.values()) {
790 if (null != resource.resourceHandle) {
791 if (resource.resource.getUri().equalsIgnoreCase(
792 CONFIGURATION_RESOURCE_URI)) {
793 ResourceInformation collectionResource = collectionList
794 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
795 if (null != collectionResource
796 && null != collectionResource.resourceHandle) {
798 .unregisterResource(resource.resourceHandle);
799 Log.i(LOG_TAG, "unregistered resource"
800 + CONFIGURATION_COLLECTION_RESOURCE_URI);
803 } else if (resource.resource.getUri().equalsIgnoreCase(
804 MAINTENANCE_RESOURCE_URI)) {
805 ResourceInformation diagnosticResource = collectionList
806 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
807 if (null != diagnosticResource
808 && null != diagnosticResource.resourceHandle) {
810 .unregisterResource(resource.resourceHandle);
811 Log.i(LOG_TAG, "unregistered resource"
812 + CONFIGURATION_COLLECTION_RESOURCE_URI);
814 } else if (resource.resource.getUri().equalsIgnoreCase(
815 FACTORYSET_RESOURCE_URI)) {
816 ResourceInformation factorysetResource = collectionList
817 .get(FACTORYSET_COLLECTION_RESOURCE_URI);
818 if (null != factorysetResource
819 && null != factorysetResource.resourceHandle) {
821 .unregisterResource(resource.resourceHandle);
822 Log.i(LOG_TAG, "unregistered resource"
823 + CONFIGURATION_COLLECTION_RESOURCE_URI);
829 // delete all the groups
830 groupSyn.deleteGroup(CONFIGURATION_COLLECTION_RESOURCE_TYPE);
831 groupSyn.deleteGroup(MAINTENANCE_COLLECTION_RESOURCE_TYPE);
832 groupSyn.deleteGroup(FACTORYSET_COLLECTION_RESOURCE_TYPE);
833 } catch (OcException e) {
834 Log.e(LOG_TAG, "OcException occured! " + e.toString());