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.EnumSet;
24 import java.util.HashMap;
25 import java.util.List;
27 import java.util.Vector;
29 import org.iotivity.base.OcException;
30 import org.iotivity.base.OcHeaderOption;
31 import org.iotivity.base.OcPlatform;
32 import org.iotivity.base.OcRepresentation;
33 import org.iotivity.base.OcResource;
34 import org.iotivity.base.OcResourceHandle;
35 import org.iotivity.base.ResourceProperty;
36 import org.iotivity.service.tm.OCStackResult;
37 import org.iotivity.service.tm.GroupManager;
38 import org.iotivity.service.tm.ThingsMaintenance;
39 import org.iotivity.service.tm.GroupManager.*;
40 import org.iotivity.service.tm.ThingsConfiguration;
41 import org.iotivity.service.tm.ThingsConfiguration.*;
42 import org.iotivity.service.tm.ThingsMaintenance.*;
44 import android.app.Activity;
45 import android.app.Dialog;
46 import android.content.Context;
47 import android.os.Bundle;
48 import android.os.Handler;
49 import android.os.Message;
50 import android.util.Log;
51 import android.view.View;
52 import android.view.View.OnClickListener;
53 import android.widget.AdapterView;
54 import android.widget.AdapterView.OnItemClickListener;
55 import android.widget.ArrayAdapter;
56 import android.widget.Button;
57 import android.widget.EditText;
58 import android.widget.ListView;
59 import android.widget.Toast;
62 * Activity for Handling all Configuration Apis as per user's selection on the UI.
65 public class ConfigurationApiActivity extends Activity {
67 private class ResourceInformation {
68 OcResource resource = null;
69 OcResourceHandle resourceHandle = null;
72 private final String LOG_TAG = "[TMSample] "
76 private final String CONFIGURATION_COLLECTION_RESOURCE_URI = "/core/configuration/resourceset";
77 private final String CONFIGURATION_COLLECTION_RESOURCE_TYPE = "core.configuration.resourceset";
78 private final String MAINTENANCE_COLLECTION_RESOURCE_URI = "/core/maintenance/resourceset";
79 private final String MAINTENANCE_COLLECTION_RESOURCE_TYPE = "core.maintenance.resourceset";
80 private final String FACTORYSET_COLLECTION_RESOURCE_URI = "/core/factoryset/resourceset";
81 private final String FACTORYSET_COLLECTION_RESOURCE_TYPE = "core.factoryset.resourceset";
83 private final String CONFIGURATION_RESOURCE_URI = "/oic/con";
84 private final String MAINTENANCE_RESOURCE_URI = "/oic/mnt";
85 private final String FACTORYSET_RESOURCE_URI = "/factorySet";
87 private ListView list;
88 private ArrayAdapter<String> configurationApis;
89 private ArrayList<String> configurationApisList;
91 private static int messageCount = 0;
92 private static EditText logs;
93 private static String logMessage = "";
94 private static Handler mHandler;
95 private static Message msg;
97 private GroupManager groupManager = 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 thingsConfiguration = ThingsConfiguration.getInstance();
119 thingsMaintenance = ThingsMaintenance.getInstance();
122 setResourceListener();
123 setConfigurationListener();
124 setDiagnosticsListener();
126 // Create API menu list
127 configurationApisList = new ArrayList<String>();
129 logs = (EditText) findViewById(R.id.EditText);
131 list = (ListView) findViewById(R.id.configApisList);
132 configurationApisList.add("Find All Groups");
133 configurationApisList.add("Find All Resources");
134 configurationApisList.add("Get a Configuration Resource");
135 configurationApisList.add("Update Attribute (Region)");
136 configurationApisList.add("Factory Reset");
137 configurationApisList.add("Reboot");
138 configurationApisList.add("Get Supported Configuration Units");
139 configurationApis = new ArrayAdapter<String>(this,
140 android.R.layout.simple_list_item_1, configurationApisList);
141 list.setAdapter(configurationApis);
143 // setting the Listener for calling the APIs as per User selection
144 list.setOnItemClickListener(new OnItemClickListener() {
147 public void onItemClick(AdapterView<?> parent, View view,
148 int position, long id) {
152 Vector<String> resourceTypes = new Vector<String>();
153 resourceTypes.add("core.configuration.resourceset");
154 findCandidateResources(resourceTypes);
160 resourceTypes.clear();
161 resourceTypes.add("core.diagnostics.resourceset");
162 findCandidateResources(resourceTypes);
166 resourceTypes.clear();
167 resourceTypes.add("core.factoryset.resourceset");
168 findCandidateResources(resourceTypes);
172 } else if (position == 1) { // Find All Resources
173 if (false == findGroupPressedFlag) {
174 displayToastMessage("Configuration collection resource does not exist!");
176 Vector<String> resourceTypes = new Vector<String>();
177 resourceTypes.add("oic.wk.con");
178 findCandidateResources(resourceTypes);
184 resourceTypes.clear();
185 resourceTypes.add("oic.wk.mnt");
186 findCandidateResources(resourceTypes);
190 resourceTypes.clear();
191 resourceTypes.add("factorySet");
192 findCandidateResources(resourceTypes);
196 } else if (position == 2) { // Get Configuration
198 } else if (position == 3) { // Update Attribute (Region)
200 } else if (position == 4) { // Factory Reset
202 } else if (position == 5) { // Reboot
204 } else if (position == 6) { // Get Supported Configuration Units
205 String configurationUnits;
206 configurationUnits = getListOfSupportedConfigurationUnits();
207 Log.i(LOG_TAG, "Configuration Units:" + configurationUnits);
208 logMessage = configurationUnits;
210 logs.setText(logMessage);
216 resourceList = new HashMap<String, ResourceInformation>();
217 collectionList = new HashMap<String, ResourceInformation>();
220 createResourceCollection(CONFIGURATION_COLLECTION_RESOURCE_URI,
221 CONFIGURATION_COLLECTION_RESOURCE_TYPE);
222 createResourceCollection(MAINTENANCE_COLLECTION_RESOURCE_URI,
223 MAINTENANCE_COLLECTION_RESOURCE_TYPE);
224 createResourceCollection(FACTORYSET_COLLECTION_RESOURCE_URI,
225 FACTORYSET_COLLECTION_RESOURCE_TYPE);
226 } catch (OcException e) {
227 Log.e(LOG_TAG, "OcException occured! " + e.toString());
230 // handler for updating the UI i.e. LogMessage TextBox
231 mHandler = new Handler() {
233 public void handleMessage(Message msg) {
237 logs.setText(logMessage);
238 Log.i(LOG_TAG, logMessage);
245 private void userInputDialog() {
247 ResourceInformation configurationCollection = collectionList
248 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
249 if (null == configurationCollection
250 || null == configurationCollection.resource) {
251 displayToastMessage("Configuration collection resource does not exist!");
253 if (false == configurationResourceFlag) {
254 displayToastMessage("Configuration resource does not exist!");
256 final Dialog dialog = new Dialog(mcontext);
257 dialog.setContentView(R.layout.userinputforregionvalue);
258 dialog.setTitle("Enter the Region Value");
260 dialog.setCancelable(false);
262 Button ok = (Button) dialog.findViewById(R.id.ok);
263 Button cancel = (Button) dialog.findViewById(R.id.cancel);
265 ok.setOnClickListener(new OnClickListener() {
267 public void onClick(View v) {
269 EditText regionValue = (EditText) dialog
270 .findViewById(R.id.region);
271 region = regionValue.getText().toString();
272 if (region.equalsIgnoreCase("")) {
273 String toastmessage = "Please enter the Region Value";
274 displayToastMessage(toastmessage);
277 updateConfiguration(region);
281 cancel.setOnClickListener(new OnClickListener() {
283 public void onClick(View v) {
291 public void onBackPressed() {
292 super.onBackPressed();
294 // unregistering resource from the platform
296 resourceList.clear();
298 collectionList.clear();
299 collectionList = null;
302 private void setResourceListener() {
304 .setFindCandidateResourceListener(new IFindCandidateResourceListener() {
307 public void onResourceFoundCallback(
308 Vector<OcResource> resources) {
309 // TODO Auto-generated method stub
310 Log.i(LOG_TAG, "onResourceCallback: enter");
311 for (int i = 0; i < resources.size(); i++) {
312 OcResource resource = resources.get(i);
313 String uri = resource.getUri();
314 String host = resource.getHost();
316 // Display resource information
317 Log.i(LOG_TAG, "Resource URI:" + uri);
318 Log.i(LOG_TAG, "Resource HOST: " + host);
319 Log.i(LOG_TAG, "Resource types: ");
320 logMessage += "Resource URI : " + uri + "\n";
321 logMessage += "Resource Host : " + host + "\n";
323 List<String> resourcetypes = resource
325 for (int j = 0; j < resourcetypes.size(); j++) {
326 Log.i(LOG_TAG, resourcetypes.get(j));
327 logMessage += "ResourceType " + (j + 1) + " : "
328 + resourcetypes.get(j) + "\n";
331 Log.i(LOG_TAG, "Interface types: ");
332 List<String> interfacetypes = resource
333 .getResourceInterfaces();
334 for (int j = 0; j < interfacetypes.size(); j++) {
335 Log.i(LOG_TAG, interfacetypes.get(j));
336 logMessage += "interfacetype " + (j + 1)
337 + " : " + interfacetypes.get(j) + "\n";
341 if (true == uri.contains("/resourceset")) {
342 collectionFound(resource);
344 resourceFound(resource);
346 } catch (OcException e) {
348 "OcExcepion occured! " + e.toString());
351 if (messageCount == 3) {
352 msg = Message.obtain();
354 mHandler.sendMessage(msg);
360 private void setConfigurationListener() {
362 .setConfigurationListener(new IConfigurationListener() {
364 public void onBootStrapCallback(
365 Vector<OcHeaderOption> headerOptions,
366 OcRepresentation rep, int errorValue) {
367 Log.i(LOG_TAG, "onBootStrapCallback: enter");
371 public void onUpdateConfigurationsCallback(
372 Vector<OcHeaderOption> headerOptions,
373 OcRepresentation rep, int errorValue) {
374 Log.i(LOG_TAG, "onUpdateConfigurationsCallback: enter");
375 Log.i(LOG_TAG, "Resource URI: " + rep.getUri());
376 if (rep.hasAttribute("n")) {
377 logMessage += "Device Name : "
378 + rep.getValueString("n") + "\n";
380 if (rep.hasAttribute("loc")) {
381 logMessage += "Location : "
382 + rep.getValueString("loc") + "\n";
384 if (rep.hasAttribute("locn")) {
385 logMessage += "Location Name : "
386 + rep.getValueString("locn") + "\n";
388 if (rep.hasAttribute("r")) {
389 logMessage += "Region : " + rep.getValueString("r")
392 if (rep.hasAttribute("c")) {
393 logMessage += "Currency : "
394 + rep.getValueString("c") + "\n";
399 public void onGetConfigurationsCallback(
400 Vector<OcHeaderOption> headerOptions,
401 OcRepresentation rep, int errorValue) {
402 Log.i(LOG_TAG, "onGetConfigurationsCallback: enter");
403 Log.i(LOG_TAG, "Resource URI: " + rep.getUri());
404 logMessage += "Resource URI : " + rep.getUri() + "\n";
406 if (rep.hasAttribute("n")) {
407 logMessage += "Device Name : "
408 + rep.getValueString("n") + "\n";
410 if (rep.hasAttribute("loc")) {
411 logMessage += "Location : "
412 + rep.getValueString("loc") + "\n";
414 if (rep.hasAttribute("locn")) {
415 logMessage += "Location Name : "
416 + rep.getValueString("locn") + "\n";
418 if (rep.hasAttribute("r")) {
419 logMessage += "Region : " + rep.getValueString("r")
422 if (rep.hasAttribute("c")) {
423 logMessage += "Currency : "
424 + rep.getValueString("c") + "\n";
427 msg = Message.obtain();
429 mHandler.sendMessage(msg);
434 private void setDiagnosticsListener() {
436 .setThingsMaintenanceListener(new IThingsMaintenanceListener() {
439 public void onRebootCallback(
440 Vector<OcHeaderOption> headerOptions,
441 OcRepresentation rep, int errorValue) {
442 // TODO Auto-generated method stu
446 public void onFactoryResetCallback(
447 Vector<OcHeaderOption> headerOptions,
448 OcRepresentation rep, int errorValue) {
449 // TODO Auto-generated method stub
456 * This method find the resources available in network.
458 private void findCandidateResources(Vector<String> resourceTypes) {
459 OCStackResult result = groupManager.findCandidateResources(
461 if (OCStackResult.OC_STACK_OK != result) {
462 Log.e(LOG_TAG, "Error while calling findCandidateResources");
463 String toastmessage = "findCandidateResources API returned error! ["
465 displayToastMessage(toastmessage);
467 if (messageCount == 1)
468 logMessage += "API RESULT : " + result.toString() + "\n";
472 * This method gets the configuration data from con-server.
474 private void getConfiguration() {
475 Log.i(LOG_TAG, "There are " + resourceList.size()
476 + " servers present in network");
477 ResourceInformation configurationCollection = collectionList
478 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
479 if (null == configurationCollection
480 || null == configurationCollection.resource) {
481 displayToastMessage("Configuration collection resource does not exist!");
484 if (false == configurationResourceFlag) {
486 displayToastMessage("Configuration resource does not exist!");
491 Vector<String> configs = new Vector<String>();
494 OCStackResult result = OCStackResult.OC_STACK_ERROR;
496 result = thingsConfiguration.getConfigurations(
497 configurationCollection.resource, configs);
498 } catch (OcException e) {
502 if (OCStackResult.OC_STACK_OK != result) {
503 Log.e(LOG_TAG, "getConfigurations failed!");
504 String toastmessage = "getConfigurations API returned error! ["
506 displayToastMessage(toastmessage);
508 logMessage = "API RESULT : " + result.toString() + "\n";
509 msg = Message.obtain();
511 mHandler.sendMessage(msg);
515 * This method update the configuration resource region attribute to given
520 private void updateConfiguration(String region) {
521 ResourceInformation configurationCollection = collectionList
522 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
524 Map<String, String> configurations = new HashMap<String, String>();
527 configurations.put(name, region);
528 } catch (Exception e) {
529 Log.e(LOG_TAG, "Exception occured! " + e.toString());
532 OCStackResult result = OCStackResult.OC_STACK_ERROR;
534 result = thingsConfiguration.updateConfigurations(
535 configurationCollection.resource, configurations);
536 } catch (OcException e) {
539 if (OCStackResult.OC_STACK_OK != result) {
540 Log.e(LOG_TAG, "updateConfigurations failed!");
541 String toastmessage = "updateConfigurations API returned error! ["
543 displayToastMessage(toastmessage);
545 logMessage = "API RESULT : " + result.toString() + "\n";
546 logMessage += "Updating region to " + region;
547 msg = Message.obtain();
549 mHandler.sendMessage(msg);
553 * This method send request to reset all the configuration attribute values
556 private void factoryReset() {
557 ResourceInformation diagnosticsCollection = collectionList
558 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
559 if (null == diagnosticsCollection
560 || null == diagnosticsCollection.resource) {
561 displayToastMessage("Diagnostic collection does not exist!");
565 if (false == maintenanceResourceFlag) {
566 displayToastMessage("Diagnostic resource does not exist!");
570 OCStackResult result = OCStackResult.values()[30];
573 result = thingsMaintenance
574 .factoryReset(diagnosticsCollection.resource);
575 } catch (OcException e) {
579 if (OCStackResult.OC_STACK_OK != result) {
580 Log.e(LOG_TAG, "factoryReset failed!");
581 String toastmessage = "factoryReset API returned error! [" + result
583 displayToastMessage(toastmessage);
586 logMessage = "API RESULT : " + result.toString() + "\n";
587 msg = Message.obtain();
589 mHandler.sendMessage(msg);
593 * This method send request to reboot server.
595 private void reboot() {
596 ResourceInformation diagnosticsCollection = collectionList
597 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
598 if (null == diagnosticsCollection
599 || null == diagnosticsCollection.resource) {
600 displayToastMessage("Diagnostic collection does not exist!");
603 if (false == maintenanceResourceFlag) {
604 displayToastMessage("Diagnostic resource does not exist!");
608 OCStackResult result = OCStackResult.OC_STACK_ERROR;
610 result = thingsMaintenance.reboot(diagnosticsCollection.resource);
611 } catch (OcException e) {
615 if (OCStackResult.OC_STACK_OK != result) {
616 Log.e(LOG_TAG, "reboot failed!");
617 String toastmessage = "reboot API returned error! [" + result + "]";
618 displayToastMessage(toastmessage);
620 logMessage = "API RESULT : " + result.toString() + "\n";
621 msg = Message.obtain();
623 mHandler.sendMessage(msg);
627 * This method is for getting list of all supported configuration values.
628 * Response will be in JSON format (key-value pair).
630 private String getListOfSupportedConfigurationUnits() {
631 return thingsConfiguration.getListOfSupportedConfigurationUnits();
634 private void displayToastMessage(String message) {
635 Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
637 Log.i(LOG_TAG, message);
640 private void collectionFound(OcResource resource) {
641 String uri = resource.getUri();
642 ResourceInformation resourceInfo = collectionList.get(uri);
643 if (null == resourceInfo) {
644 Log.e(LOG_TAG, "Collection is not created!");
648 if (null != resourceInfo.resource) {
649 Log.e(LOG_TAG, "Collection resource already updated!");
653 resourceInfo.resource = resource;
654 if (3 == messageCount) {
655 findGroupPressedFlag = true;
660 * This callback will be invoked when the interested resource discovered in
663 private void resourceFound(OcResource resource) throws OcException {
664 String uri = resource.getUri();
665 String host = resource.getHost();
667 // Check if the resource already exist in the map table
668 ResourceInformation resourceInfo = resourceList.get(uri + host);
669 if (null != resourceInfo) {
670 Log.e(LOG_TAG, "Resource already exists!");
675 resourceInfo = new ResourceInformation();
676 resourceInfo.resource = resource;
677 if (uri.equalsIgnoreCase("/oic/con")) {
678 ResourceInformation collectionResource = collectionList
679 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
680 if (null == collectionResource
681 || null == collectionResource.resourceHandle) {
682 Log.e(LOG_TAG, "Invalid Configuration collection!");
686 ResourceInformation resourceInfoCollection;
687 resourceInfoCollection = collectionList
688 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
689 OcResourceHandle handle;
690 handle = resourceInfoCollection.resourceHandle;
691 resourceInfo.resourceHandle = handle;
692 resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
695 resourceList.put(uri + host, resourceInfo);
696 configurationResourceFlag = true;
697 } else if (uri.equalsIgnoreCase("/oic/mnt")) {
698 ResourceInformation diagnosticResource = collectionList
699 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
700 if (null == diagnosticResource
701 || null == diagnosticResource.resourceHandle) {
702 Log.e(LOG_TAG, "Invalid Configuration collection!");
706 ResourceInformation resourceInfoCollection;
707 resourceInfoCollection = collectionList
708 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
709 OcResourceHandle handle;
710 handle = resourceInfoCollection.resourceHandle;
711 resourceInfo.resourceHandle = handle;
712 resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
715 resourceList.put(uri + host, resourceInfo);
716 maintenanceResourceFlag = true;
717 } else if (uri.equalsIgnoreCase("/factorySet")) {
718 ResourceInformation factorysetResource = collectionList
719 .get(FACTORYSET_COLLECTION_RESOURCE_URI);
720 if (null == factorysetResource
721 || null == factorysetResource.resourceHandle) {
722 Log.e(LOG_TAG, "Invalid Configuration collection!");
726 ResourceInformation resourceInfoCollection;
727 resourceInfoCollection = collectionList
728 .get(FACTORYSET_COLLECTION_RESOURCE_URI);
729 OcResourceHandle handle;
730 handle = resourceInfoCollection.resourceHandle;
731 resourceInfo.resourceHandle = handle;
732 resourceInfo.resourceHandle = groupManager.bindResourceToGroup(
735 resourceList.put(uri + host, resourceInfo);
736 factorySetResourceFlag = true;
738 Log.e(LOG_TAG, "Resource is of different type: " + uri);
743 private void createResourceCollection(String uri, String typename)
746 Map<String, OcResourceHandle> groupList = new HashMap<String, OcResourceHandle>();
748 Log.i(LOG_TAG, "createGroup: " + typename);
749 // Check if the resource collection is already created
750 if (null != collectionList.get(uri)) {
751 Log.e(LOG_TAG, "Collection is already exist!");
755 OcResourceHandle resourceHandle = null;
758 resourceHandle = OcPlatform.registerResource(
761 OcPlatform.BATCH_INTERFACE, null, EnumSet.of(
762 ResourceProperty.DISCOVERABLE));
763 } catch (OcException e) {
764 Log.e(LOG_TAG, "go exception");
765 Log.e(LOG_TAG, "RegisterResource error. " + e.getMessage());
768 OcPlatform.bindInterfaceToResource(resourceHandle, OcPlatform.GROUP_INTERFACE);
769 } catch (OcException e) {
770 // TODO Auto-generated catch block
774 OcPlatform.bindInterfaceToResource(resourceHandle, OcPlatform.DEFAULT_INTERFACE);
775 } catch (OcException e) {
776 // TODO Auto-generated catch block
780 if (null == resourceHandle) {
781 Log.e(LOG_TAG, " createResourceCollection : resourceHandle is NULL");
784 // Add the collection resource to map table
785 ResourceInformation resourceInfo = new ResourceInformation();
786 resourceInfo.resourceHandle = resourceHandle;
787 collectionList.put(uri, resourceInfo);
788 Log.i(LOG_TAG, "size of collectionList : " + collectionList.size());
791 private void deleteResources() {
792 Log.i(LOG_TAG, "deleteResources: enter");
794 // unregister all resources
795 for (ResourceInformation resource : resourceList.values()) {
796 if (null != resource.resourceHandle) {
797 if (resource.resource.getUri().equalsIgnoreCase(
798 CONFIGURATION_RESOURCE_URI)) {
799 ResourceInformation collectionResource = collectionList
800 .get(CONFIGURATION_COLLECTION_RESOURCE_URI);
801 if (null != collectionResource
802 && null != collectionResource.resourceHandle) {
804 .unregisterResource(resource.resourceHandle);
805 Log.i(LOG_TAG, "unregistered resource"
806 + CONFIGURATION_COLLECTION_RESOURCE_URI);
809 } else if (resource.resource.getUri().equalsIgnoreCase(
810 MAINTENANCE_RESOURCE_URI)) {
811 ResourceInformation diagnosticResource = collectionList
812 .get(MAINTENANCE_COLLECTION_RESOURCE_URI);
813 if (null != diagnosticResource
814 && null != diagnosticResource.resourceHandle) {
816 .unregisterResource(resource.resourceHandle);
817 Log.i(LOG_TAG, "unregistered resource"
818 + CONFIGURATION_COLLECTION_RESOURCE_URI);
820 } else if (resource.resource.getUri().equalsIgnoreCase(
821 FACTORYSET_RESOURCE_URI)) {
822 ResourceInformation factorysetResource = collectionList
823 .get(FACTORYSET_COLLECTION_RESOURCE_URI);
824 if (null != factorysetResource
825 && null != factorysetResource.resourceHandle) {
827 .unregisterResource(resource.resourceHandle);
828 Log.i(LOG_TAG, "unregistered resource"
829 + CONFIGURATION_COLLECTION_RESOURCE_URI);
835 } catch (OcException e) {
836 Log.e(LOG_TAG, "OcException occured! " + e.toString());