API change: allow passing query parameters to attribute GET/SET handlers.
Change-Id: Ib3d294a4901f066409a837f03db16a94791fd8f8
Signed-off-by: Inga Stotland <inga.stotland@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8121
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
}
-void JniBundleResource::handleSetAttributesRequest(const RCSResourceAttributes &attrs){
+void JniBundleResource::handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams)
+{
LOGD("handleSetAttributesRequest called %d", attrs.size());
//m_env->CallObjectMethod(m_bundleResource, m_attributeSetRequestHandler, attrName, val);
}
}
-RCSResourceAttributes JniBundleResource::handleGetAttributesRequest()
+RCSResourceAttributes JniBundleResource::handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams)
{
LOGD("handleGetAttributesRequest");
RCSResourceAttributes::Value handleGetAttributeRequest(const std::string& key);
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs);
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams);
- virtual RCSResourceAttributes handleGetAttributesRequest();
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams);
/**
* SoftSensor logic. Has to be provided by the soft sensor developer.
#include "NotificationReceiver.h"
#include "RCSResourceAttributes.h"
+#include "RCSRequest.h"
namespace OIC
{
* The implementor of the function can decide weather to notify OIC clients
* about the changed state or not.
*
+ * @param queryParams Request parameters
+ *
* @return All attributes
*/
- virtual RCSResourceAttributes handleGetAttributesRequest() = 0;
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams) = 0;
/**
* This function should be implemented by the according bundle resource
* about the changed state or not.
*
* @param attrs Attributes to set
+ * @param queryParams Request parameters
*
* @return void
*/
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs) = 0;
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams) = 0;
private:
void sendNotification(NotificationReceiver *notficiationRecevier, std::string uri);
* The implementor of the function can decide weather to notify OIC clients
* about the changed state or not.
*
+ * @param queryParams Request parameters
+ *
* @return Value of all attributes
*/
- virtual RCSResourceAttributes handleGetAttributesRequest() = 0;
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams) = 0;
/**
* This function should be implemented by the according bundle resource
* about the changed state or not.
*
* @param attrs Attributes to set
+ * @param queryParams Request parameters
*
* @return void
*/
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs) = 0;
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams) = 0;
};
}
}
* The implementor of the function can decide weather to notify OIC clients
* about the changed state or not.
*
+ * @param queryParams Request parameters
+ *
* @return Value of all attributes
*/
- virtual RCSResourceAttributes handleGetAttributesRequest() = 0;
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams) = 0;
/**
* This function should be implemented by the according bundle resource
* about the changed state or not.
*
* @param attrs Attributes to set
+ * @param queryParams Request parameters
*
* @return void
*/
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs) = 0;
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams) = 0;
/**
* SoftSensor logic. Has to be provided by the soft sensor developer.
BMISensorResource& operator=( const BMISensorResource& rhs )=delete;
~BMISensorResource();
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs);
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams);
- virtual RCSResourceAttributes handleGetAttributesRequest();
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams);
virtual void executeLogic();
}
void BMISensorResource::handleSetAttributesRequest(
- const RCSResourceAttributes &value)
+ const RCSResourceAttributes &value,
+ const std::map< std::string, std::string > &queryParams)
{
BundleResource::setAttributes(value);
}
-RCSResourceAttributes BMISensorResource::handleGetAttributesRequest()
+RCSResourceAttributes BMISensorResource::handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams)
{
return BundleResource::getAttributes();
}
DiscomfortIndexSensorResource(const DiscomfortIndexSensorResource &other)=delete;
DiscomfortIndexSensorResource& operator=( const DiscomfortIndexSensorResource& rhs )=delete;
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs);
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams);
- virtual RCSResourceAttributes handleGetAttributesRequest();
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams);
virtual void executeLogic();
}
void DiscomfortIndexSensorResource::handleSetAttributesRequest(
- const RCSResourceAttributes &value)
+ const RCSResourceAttributes &value,
+ const std::map< std::string, std::string > &queryParams)
{
BundleResource::setAttributes(value);
}
-RCSResourceAttributes DiscomfortIndexSensorResource::handleGetAttributesRequest()
+RCSResourceAttributes DiscomfortIndexSensorResource::handleGetAttributesRequest(
+ const std::map< std::string, std::string > &queryParams)
{
return BundleResource::getAttributes();
}
virtual void initAttributes();
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs);
-
- virtual RCSResourceAttributes handleGetAttributesRequest();
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs,
+ const std::map< std::string, std::string > &queryParams);
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams);
private:
std::string m_address;
BundleResource::setAttribute("color", 0, false);
}
-RCSResourceAttributes HueLight::handleGetAttributesRequest()
+RCSResourceAttributes HueLight::handleGetAttributesRequest(
+ const std::map< std::string, std::string > &queryParams)
{
cout << "HueLight::handleGetAttributesRequest" << endl;
// TODO read from HueLight and update attribute data
return BundleResource::getAttributes();
}
-void HueLight::handleSetAttributesRequest(const RCSResourceAttributes &value)
+void HueLight::handleSetAttributesRequest(const RCSResourceAttributes &value,
+ const std::map< std::string, std::string > &queryParams)
{
cout << "HueLight::handleSetAttributesRequest" << std::endl;
{
RCSResourceAttributes attr;
std::string strResourceUri = request.getResourceUri();
+ const std::map< std::string, std::string > &queryParams = request.getQueryParams();
+
OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s",strResourceUri.c_str());
if (m_mapServers.find(strResourceUri) != m_mapServers.end()
{
if (m_mapResources[strResourceUri])
{
- auto getFunction = [this, &attr, &strResourceUri]()
+ auto getFunction = [this, &attr, &strResourceUri, queryParams]()
{
- attr = m_mapResources[strResourceUri]->handleGetAttributesRequest();
+ attr = m_mapResources[strResourceUri]->handleGetAttributesRequest(queryParams);
};
boost::thread getThread(getFunction);
getThread.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
RCSResourceAttributes attr;
std::list<std::string> lstAttributes;
std::string strResourceUri = request.getResourceUri();
+ const std::map< std::string, std::string > &queryParams = request.getQueryParams();
OIC_LOG_V(INFO, CONTAINER_TAG, "Container set request for %s, %zu attributes",strResourceUri.c_str(), attributes.size());
{
if (m_mapResources[strResourceUri])
{
- auto setFunction = [this, &lstAttributes, &strResourceUri, &attributes, &attr]()
+ auto setFunction = [this, &lstAttributes, &strResourceUri, &attributes, &attr, queryParams]()
{
lstAttributes = m_mapResources[strResourceUri]->getAttributeNames();
}
OIC_LOG_V(INFO, CONTAINER_TAG, "Calling handleSetAttributeRequest");
- m_mapResources[strResourceUri]->handleSetAttributesRequest(attr);
+ m_mapResources[strResourceUri]->handleSetAttributesRequest(attr, queryParams);
};
boost::thread setThread(setFunction);
setThread.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
public:
virtual void initAttributes() { }
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attr)
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attr,
+ const std::map< std::string, std::string > &queryParams)
{
BundleResource::setAttributes(attr);
}
- virtual RCSResourceAttributes handleGetAttributesRequest()
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams)
{
return BundleResource::getAttributes();
}
setAttribute("attrib3", RCSResourceAttributes::Value(true));
}
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attr)
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attr,
+ const std::map< std::string, std::string > &queryParams)
{
BundleResource::setAttributes(attr);
}
- virtual RCSResourceAttributes handleGetAttributesRequest()
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams)
{
return BundleResource::getAttributes();
}
SoftSensorResource::initAttributes();
}
- virtual void handleSetAttributesRequest(const RCSResourceAttributes &attr)
+ virtual void handleSetAttributesRequest(const RCSResourceAttributes &attr,
+ const std::map< std::string, std::string > &queryParams)
{
BundleResource::setAttributes(attr);
}
- virtual RCSResourceAttributes handleGetAttributesRequest()
+ virtual RCSResourceAttributes handleGetAttributesRequest(const
+ std::map< std::string, std::string > &queryParams)
{
return BundleResource::getAttributes();
}
testResource.getAttributeNames();
RCSResourceAttributes fullAttributes;
+ const std::map< std::string, std::string > queryParams = {};
fullAttributes["attrib1"] = "test";
fullAttributes["attrib2"] = 1;
fullAttributes["attrib2"] = 2;
fullAttributes["attrib3"] = false;
- testResource.handleSetAttributesRequest(fullAttributes);
+ testResource.handleSetAttributesRequest(fullAttributes, queryParams);
EXPECT_EQ((unsigned int) 3, testResource.getAttributeNames().size());
- EXPECT_EQ((unsigned int) 3, testResource.handleGetAttributesRequest().size());
+ EXPECT_EQ((unsigned int) 3, testResource.handleGetAttributesRequest(queryParams).size());
std::string testString = "test";
testResource.setAttribute("attrib1", RCSResourceAttributes::Value(testString), false);
public:
void initAttributes() { };
- RCSResourceAttributes handleGetAttributesRequest()
+ RCSResourceAttributes handleGetAttributesRequest(
+ const std::map< std::string, std::string > &queryParams)
{
return BundleResource::getAttributes();
}
void handleSetAttributesRequest(
- const RCSResourceAttributes &value)
+ const RCSResourceAttributes &value,
+ const std::map< std::string, std::string > &queryParams)
{
BundleResource::setAttributes(value);
}