From: Markus Jung Date: Thu, 12 Nov 2015 00:14:23 +0000 (+0900) Subject: Extended RcsReousrceAttributes to support update of multiple attributes at once X-Git-Tag: 1.2.0+RC1~634^2^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c43b60e6657c8a995e2acdd35a1eb6daa82c13e;p=platform%2Fupstream%2Fiotivity.git Extended RcsReousrceAttributes to support update of multiple attributes at once Change-Id: Ibfe08f0d0228a126754e03c091681fcdd3be6d59 Signed-off-by: Markus Jung Reviewed-on: https://gerrit.iotivity.org/gerrit/4159 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/AndroidBundleResource.java b/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/AndroidBundleResource.java index 4320004..3494fc7 100644 --- a/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/AndroidBundleResource.java +++ b/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/AndroidBundleResource.java @@ -23,7 +23,7 @@ package org.iotivity.service.resourcecontainer; import java.util.HashMap; import java.util.Set; import android.content.Context; - +import android.util.Log; /** * Basic BundleResource that should be used as a base class by a bundle @@ -32,154 +32,171 @@ import android.content.Context; * specific messages. */ public abstract class AndroidBundleResource { - protected String m_name, m_uri, m_resourceType, m_address; - - protected RcsResourceAttributes m_attributes = new RcsResourceAttributes(); - - protected Context m_context; - - public AndroidBundleResource(){ - initAttributes(); - } - - public AndroidBundleResource(Context context){ - this(); - this.m_context = context; - } - - /** - * Initialize the internal attribute structure. - */ - protected abstract void initAttributes(); - - /** - * Set the attribute (map to a send command for the according protocol) - * - * @param key - * name of the attribute to be set - * @param value - * new value of the attribute - */ - protected final void setAttribute(String key, RcsValue value) { - m_attributes.put(key, value); - } - - /** - * Set the attribute (map to a send command for the according protocol) - * - * @param key - * name of the attribute to be set - * @param value - * new value of the attribute - */ - public abstract void handleSetAttributesRequest(RcsResourceAttributes value); - - /** - * Retrieve the attribute (only data) - * - * @param key - * name of the attribute to be read - * @return Value of the attribute - */ - protected final RcsValue getAttribute(String key) { - return m_attributes.get(key); - } - - /** - * Retrieve the attribute (map to read command) - * - * @param key - * name of the attribute to be set - * @param value - * new value of the attribute - */ - public abstract RcsResourceAttributes handleGetAttributesRequest(); - - /** - * Attribute keys provided through by the bundle resource. - * - * @return Name of attribute keys as string array - */ - public String[] getAttributeKeys() { - Set keys = m_attributes.keySet(); - return keys.toArray(new String[keys.size()]); - } - - /** - * Setter for the uri property - * - * @param uri - * URI of the resource - */ - public void setURI(String uri) { - this.m_uri = uri; - } - - /** - * Returns the URI of the resource - * - * @return Resource URI - */ - public String getURI() { - return m_uri; + protected String m_name, m_uri, m_resourceType, m_address; + + protected RcsResourceAttributes m_attributes = new RcsResourceAttributes(); + + protected Context m_context; + + public AndroidBundleResource() { + initAttributes(); + } + + public AndroidBundleResource(Context context) { + this(); + this.m_context = context; + } + + /** + * Initialize the internal attribute structure. + */ + protected abstract void initAttributes(); + + /** + * Set the attribute (map to a send command for the according protocol) + * + * @param key + * name of the attribute to be set + * @param value + * new value of the attribute + */ + protected final void setAttribute(String key, RcsValue value) { + m_attributes.put(key, value); + } + + /** + * Set the attribute (map to a send command for the according protocol) + * + * @param key + * name of the attribute to be set + * @param value + * new value of the attribute + */ + protected final void setAttributes(RcsResourceAttributes value) { + m_attributes.put(value); + } + + /** + * Set the attribute (map to a send command for the according protocol) + * + * @param key + * name of the attribute to be set + * @param value + * new value of the attribute + */ + public abstract void handleSetAttributesRequest(RcsResourceAttributes value); + + /** + * Retrieve the attribute (only data) + * + * @param key + * name of the attribute to be read + * @return Value of the attribute + */ + protected final RcsValue getAttribute(String key) { + return m_attributes.get(key); + } + + protected final RcsResourceAttributes getAttributes() { + RcsResourceAttributes ret = new RcsResourceAttributes(this.m_attributes); + return ret; + } + + /** + * Retrieve the attribute (map to read command) + * + * @param key + * name of the attribute to be set + * @param value + * new value of the attribute + */ + public abstract RcsResourceAttributes handleGetAttributesRequest(); + + /** + * Attribute keys provided through by the bundle resource. + * + * @return Name of attribute keys as string array + */ + public String[] getAttributeKeys() { + Set keys = m_attributes.keySet(); + return keys.toArray(new String[keys.size()]); } - /** - * Sets the resource type property - * - * @param resourceType - * OIC resource type - */ - public void setResourceType(String resourceType) { - this.m_resourceType = resourceType; - } - - /** - * Getter for the resource type - * - * @return OIC resource type - */ - public String getResourceType() { - return m_resourceType; - } - - /** - * Sets the technology specific address information (e.g., ZigBee short or - * long identifier) - * - * @param address - * Resource address - */ - public void setAddress(String address) { - this.m_address = address; - } - - /** - * Returns the technology specific address information - * - * @return Resource address - */ - public String getAddress() { - return m_address; - } - - /** - * Sets the name property of the resource - * - * @param name - * Resource name - */ - public void setName(String name) { - this.m_name = name; - } - - /** - * Returns the name property of the resource - * - * @return Resource name - */ - public String getName() { - return m_name; - } + /** + * Setter for the uri property + * + * @param uri + * URI of the resource + */ + public void setURI(String uri) { + this.m_uri = uri; + } + + /** + * Returns the URI of the resource + * + * @return Resource URI + */ + public String getURI() { + return m_uri; + } + + /** + * Sets the resource type property + * + * @param resourceType + * OIC resource type + */ + public void setResourceType(String resourceType) { + this.m_resourceType = resourceType; + } + + /** + * Getter for the resource type + * + * @return OIC resource type + */ + public String getResourceType() { + return m_resourceType; + } + + /** + * Sets the technology specific address information (e.g., ZigBee short or + * long identifier) + * + * @param address + * Resource address + */ + public void setAddress(String address) { + this.m_address = address; + } + + /** + * Returns the technology specific address information + * + * @return Resource address + */ + public String getAddress() { + return m_address; + } + + /** + * Sets the name property of the resource + * + * @param name + * Resource name + */ + public void setName(String name) { + this.m_name = name; + } + + /** + * Returns the name property of the resource + * + * @return Resource name + */ + public String getName() { + return m_name; + } } diff --git a/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsBundleInfo.java b/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsBundleInfo.java index f782a5b..952239f 100644 --- a/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsBundleInfo.java +++ b/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsBundleInfo.java @@ -34,7 +34,7 @@ public class RcsBundleInfo { private final String mLibraryPath; private final String mVersion; - private RcsBundleInfo(String id, String path, String activatorName, + private RcsBundleInfo(String id, String path, String activatorName, String libraryPath, String version) { mId = id; mPath = path; @@ -45,9 +45,9 @@ public class RcsBundleInfo { /** * API for getting the Id of the bundle - * + * * @return string - Id of the bundle - * + * */ public String getID() { return mId; @@ -55,9 +55,9 @@ public class RcsBundleInfo { /** * API for getting the path of the bundle - * + * * @return path - path of the bundle - * + * */ public String getPath() { return mPath; @@ -65,9 +65,9 @@ public class RcsBundleInfo { /** * API for setting the Activator name for the bundle - * + * * @return string - Name of the activator - * + * */ public String getActivatorName() { return mActivatorName; @@ -75,9 +75,9 @@ public class RcsBundleInfo { /** * API for getting the library path for the bundle - * + * * @return string - Library path in string form - * + * */ public String getLibraryPath() { return mLibraryPath; @@ -85,9 +85,9 @@ public class RcsBundleInfo { /** * API for getting the version of the bundle - * + * * @return string - version of the bundle - * + * */ public String getVersion() { return mVersion; diff --git a/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsResourceAttributes.java b/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsResourceAttributes.java index f3611b1..219a9a6 100644 --- a/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsResourceAttributes.java +++ b/service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsResourceAttributes.java @@ -63,6 +63,12 @@ public final class RcsResourceAttributes extends RcsObject { mCache.put(key, lockedAttrs.get(key)); } } + + public RcsResourceAttributes(RcsResourceAttributes attrs){ + for (final String key : attrs.keySet()) { + mCache.put(key, attrs.get(key)); + } + } /** * Returns a unmodifiable Set view of the keys contained in this attributes. @@ -232,5 +238,14 @@ public final class RcsResourceAttributes extends RcsObject { esnureAllExtracted(); return mCache.hashCode(); } + + /** + * Updates all properties provided as parameter. + */ + public void put(RcsResourceAttributes attrs){ + for (final String key : attrs.keySet()) { + mCache.put(key, attrs.get(key)); + } + } } diff --git a/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp b/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp index 49425a5..b74de4b 100644 --- a/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp +++ b/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp @@ -480,7 +480,6 @@ namespace OIC assert(request != nullptr); auto attrs = getAttributesFromOCRequest(request); - OC_LOG(INFO, "RESOURCE_OBJECT", ("handleRequestGet " + request->getResourceUri()).c_str()); return sendResponse(*this, request, invokeHandler(attrs, request, m_getRequestHandler)); }