Resource was creating with oic.if.def which is not defined in OIC spec.
Modified the code such that all simulated resource will be having at least
oic.if.baseline interface at any point of time as per 1.0.0 core spec.
Change-Id: I07c6e4513546d1d4be9c0584408801552c5f4ce4
Signed-off-by: Harish Kumara Marappa <h.marappa@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7877
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit
3cd3700407657c96d02534f6e6be6c2398b97c68)
Reviewed-on: https://gerrit.iotivity.org/gerrit/8047
}
// Set the resource interfaces.
- jSimulatorSingleResource
- .setInterface(Utility.convertSetToVectorString(resource
- .getResourceInterfaces()));
+ Set<String> interfaces = resource.getResourceInterfaces();
+ if (null != interfaces && !interfaces.isEmpty()) {
+ jSimulatorSingleResource.setInterface(Utility
+ .convertSetToVectorString(resource
+ .getResourceInterfaces()));
+ }
// Register the resource with the platform.
jSimulatorSingleResource.start();
+
+ // Read the interfaces from the native layer and set it to the
+ // interface list.
+ resource.setResourceInterfaces(Utility
+ .convertVectorToSet(jSimulatorSingleResource.getInterface()));
+
resource.setStarted(true);
} catch (SimulatorException e) {
Activator
Map<String, String> ifTypes = null;
if (resourceClass == SingleResource.class) {
ifTypes = new HashMap<String, String>();
- ifTypes.put(Constants.BASELINE_INTERFACE, "Baseline");
ifTypes.put(Constants.READ_ONLY_INTERFACE, "Read-Only");
ifTypes.put(Constants.READ_WRITE_INTERFACE, "Read-Write");
ifTypes.put(Constants.ACTUATOR_INTERFACE, "Actuator");
// interface set.
Set<String> curIfSet = resourceInSelection
.getResourceInterfaces();
+ // Adding default interface to local set if removed.
+ updatedIfSet.add(Constants.BASELINE_INTERFACE);
if (null != curIfSet && null != updatedIfSet) {
if (curIfSet.size() != updatedIfSet.size()) {
update = true;
}
// Update the model
MetaProperty prop = (MetaProperty) element;
- prop.setPropValue(newPropValue.toString());
+ StringBuilder value = new StringBuilder();
+ value.append(Constants.BASELINE_INTERFACE);
+ if (newPropValue.length() > 0) {
+ value.append(", " + newPropValue.toString());
+ }
+ prop.setPropValue(value.toString());
+
// Update the viewer in a separate UI thread.
Display.getDefault().asyncExec(new Runnable() {
@Override
package oic.simulator.serviceprovider.view.dialogs;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import java.util.ArrayList;
import java.util.Map;
-import oic.simulator.serviceprovider.utils.Constants;
-
/**
* Dialog for starting and stopping the automatic verifications.
*/
@Override
protected void okPressed() {
- String[] items = ifTypesList.getItems();
- if (null == items || items.length == 0) {
- MessageDialog
- .openInformation(
- getShell(),
- "Default Interface Type Selection",
- "As no interface types are added, the resource will be "
- + "configured with the default interface type(oic.if.baseline).");
- ifTypesList.add("Baseline" + " ("
- + Constants.DEFAULT_SINGLE_RESOURCE_INTERFACE + ")");
- }
-
// Clearing the map to freshly add selected items.
updatedResInterfaces.clear();
- for (String item : ifTypesList.getItems()) {
- String value = supportedResInterfaces.get(item);
- updatedResInterfaces.put(item, value);
+
+ String[] items = ifTypesList.getItems();
+ if (null != items && items.length > 0) {
+ for (String item : items) {
+ String value = supportedResInterfaces.get(item);
+ updatedResInterfaces.put(item, value);
+ }
}
close();
}
{
if (m_interfaces.end() != m_interfaces.find(interfaceType))
return true;
- return true;
+ return false;
}
bool OCInterfaceDetails::isRequestSupported(const std::string &interfaceType,
{
VALIDATE_INPUT(interfaceType.empty(), "Interface type list is empty!")
+ if (false == OCInterfaceDetails::getInstance()->isInterface(interfaceType))
+ {
+ OIC_LOG(ERROR, TAG, "Request is not OIC spec defined!");
+ return;
+ }
+
std::lock_guard<std::recursive_mutex> lock(m_objectLock);
if (m_resourceHandle)
{
"Resource interface can not be reset when resource is started!");
}
- m_interfaces = {interfaceType};
+ if (interfaceType != OC::DEFAULT_INTERFACE)
+ m_interfaces = {OC::DEFAULT_INTERFACE, interfaceType};
}
void SimulatorSingleResourceImpl::setInterface(const std::vector<std::string> &interfaceTypes)
"Resource interface can not be reset when resource is started!");
}
- m_interfaces.clear();
+ m_interfaces = {OC::DEFAULT_INTERFACE};
for (auto &interfaceType : interfaceTypes)
{
+ if (false == OCInterfaceDetails::getInstance()->isInterface(interfaceType))
+ continue;
+
if (m_interfaces.end() ==
std::find(m_interfaces.begin(), m_interfaces.end(), interfaceType))
{
{
VALIDATE_INPUT(interfaceType.empty(), "Interface type is empty!")
+ if (false == OCInterfaceDetails::getInstance()->isInterface(interfaceType))
+ {
+ OIC_LOG(ERROR, TAG, "Request is not OIC spec defined!");
+ return;
+ }
+
if (m_interfaces.end() != std::find(m_interfaces.begin(), m_interfaces.end(), interfaceType))
{
SIM_LOG(ILogger::ERROR, "[" << m_uri << "] "