handle services list messages
handle float typed values
Introduce icon resource specific update messages recognition
diff --git a/services/org.eclipse.sensinact.studio.http.messages/META-INF/MANIFEST.MF b/services/org.eclipse.sensinact.studio.http.messages/META-INF/MANIFEST.MF
index 855f756..a90c6d3 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/META-INF/MANIFEST.MF
+++ b/services/org.eclipse.sensinact.studio.http.messages/META-INF/MANIFEST.MF
@@ -7,7 +7,6 @@
Require-Bundle: org.eclipse.core.runtime,
org.json,
org.restlet,
- org.eclipse.sensinact.studio.model.resource,
org.apache.log4j,
org.eclipse.sensinact.studio.preferences,
com.fasterxml.jackson.core.jackson-databind,
@@ -25,6 +24,7 @@
org.eclipse.sensinact.studio.http.messages.snamessage.getresponse,
org.eclipse.sensinact.studio.http.messages.snamessage.lifecycle,
org.eclipse.sensinact.studio.http.messages.snamessage.resourceslist,
+ org.eclipse.sensinact.studio.http.messages.snamessage.serviceslist,
org.eclipse.sensinact.studio.http.messages.snamessage.setresponse,
org.eclipse.sensinact.studio.http.messages.snamessage.subscriberesponse,
org.eclipse.sensinact.studio.http.messages.snamessage.tokencreation
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgFactory.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgFactory.java
index f08d9d2..61b871e 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgFactory.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgFactory.java
@@ -10,13 +10,10 @@
*/
package org.eclipse.sensinact.studio.http.messages.snamessage;
-import java.io.IOException;
-
import org.apache.log4j.Logger;
import org.eclipse.sensinact.studio.http.messages.snamessage.basic.MsgExceptionError;
import org.eclipse.sensinact.studio.http.messages.snamessage.basic.MsgHttpError;
import org.eclipse.sensinact.studio.http.messages.snamessage.basic.MsgOk;
-import org.eclipse.sensinact.studio.model.resource.utils.Segments;
import org.json.JSONObject;
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -74,7 +71,7 @@
try {
Object object = mapper.readValue(jsonObject.toString(), registeredType.getTargetClass());
return (MsgSensinact) object;
- } catch (IOException e) {
+ } catch (Exception e) {
String msg = "Error while unmarshalling json " + jsonObject.toString();
logger.error(msg);
@@ -104,7 +101,7 @@
return mapper;
}
- public static MsgSensinact build(String json, Exception e, Segments segments) {
- return new MsgExceptionError(json, e, segments);
+ public static MsgSensinact build(String json, Exception e) {
+ return new MsgExceptionError(json, e);
}
}
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgNotification.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgNotification.java
new file mode 100644
index 0000000..f9a84aa
--- /dev/null
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgNotification.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2018 CEA.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA - initial API and implementation and/or initial documentation
+ */
+package org.eclipse.sensinact.studio.http.messages.snamessage;
+
+/**
+ * @author Etienne Gandrille
+ */
+public abstract class MsgNotification<V> extends MsgSensinact {
+
+ protected V notification;
+
+ public MsgNotification(String type) {
+ super(type);
+ }
+
+ public V getNotification() {
+ return notification;
+ }
+
+ public void setNotification(V notification) {
+ this.notification = notification;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((notification == null) ? 0 : notification.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MsgNotification<?> other = (MsgNotification<?>) obj;
+ if (notification == null) {
+ if (other.notification != null)
+ return false;
+ } else if (!notification.equals(other.notification))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (uri == null) {
+ if (other.uri != null)
+ return false;
+ } else if (!uri.equals(other.uri))
+ return false;
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgSensinact.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgSensinact.java
index eb413aa..7692394 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgSensinact.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgSensinact.java
@@ -10,18 +10,34 @@
*/
package org.eclipse.sensinact.studio.http.messages.snamessage;
+import java.util.List;
+
/**
* @author Etienne Gandrille
*/
public abstract class MsgSensinact {
+
+ public static final String KEY = "KEY";
+ public static final int PRIME = 31;
protected final String type;
+ protected String uri;
+ private List<ObjectFilter> filters;
+
public MsgSensinact(String type) {
this.type = type;
}
- public final String getType() {
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getType() {
return type;
}
@@ -29,7 +45,22 @@
if (! this.type.equals(type))
throw new IllegalArgumentException();
}
+
+ public List<ObjectFilter> getFilters() {
+ return filters;
+ }
+ public ObjectFilter getFilter(String filterType) {
+ for (ObjectFilter filter : filters)
+ if (filter.getType().equals(filterType))
+ return filter;
+ return null;
+ }
+
+ public void setFilters(List<ObjectFilter> filters) {
+ this.filters = filters;
+ }
+
public boolean isValid() {
return true;
}
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgTypes.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgTypes.java
index 85f4e5b..a059b3c 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgTypes.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/MsgTypes.java
@@ -17,6 +17,7 @@
import org.eclipse.sensinact.studio.http.messages.snamessage.getresponse.MsgGetResponse;
import org.eclipse.sensinact.studio.http.messages.snamessage.lifecycle.*;
import org.eclipse.sensinact.studio.http.messages.snamessage.resourceslist.MsgResourcesList;
+import org.eclipse.sensinact.studio.http.messages.snamessage.serviceslist.MsgServicesList;
import org.eclipse.sensinact.studio.http.messages.snamessage.setresponse.MsgSetResponse;
import org.eclipse.sensinact.studio.http.messages.snamessage.subscriberesponse.MsgSubscribeResponse;
import org.eclipse.sensinact.studio.http.messages.snamessage.tokencreation.MsgTokenCreation;
@@ -33,6 +34,7 @@
// List and describe (there will be much more than this two...)
COMPLETE_LIST (MsgCompleteList.KEY, MsgCompleteList.class),
+ SERVICES_LIST (MsgServicesList.KEY, MsgServicesList.class),
RESOURCES_LIST (MsgResourcesList.KEY, MsgResourcesList.class),
DESCRIBE_RESOURCE (MsgDescribeRessource.KEY, MsgDescribeRessource.class),
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ObjectFilter.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ObjectFilter.java
new file mode 100644
index 0000000..ec7c6c2
--- /dev/null
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ObjectFilter.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright (c) 2018 CEA.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA - initial API and implementation and/or initial documentation
+ */
+package org.eclipse.sensinact.studio.http.messages.snamessage;
+
+/**
+ * @author Etienne Gandrille
+ */
+public class ObjectFilter {
+
+ private String type;
+ private String definition;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(String definition) {
+ this.definition = definition;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((definition == null) ? 0 : definition.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ObjectFilter other = (ObjectFilter) obj;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (definition == null) {
+ if (other.definition != null)
+ return false;
+ } else if (!definition.equals(other.definition))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ObjectFilter [definition=" + definition + ", type=" + type + "]";
+ }
+}
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ObjectNameTypeValue.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ObjectNameTypeValue.java
index c351b8f..7ea8519 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ObjectNameTypeValue.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ObjectNameTypeValue.java
@@ -98,7 +98,6 @@
@Override
public String toString() {
- return "ObjectNameTypeValue [name=" + name + ", type=" + type + ", value=" + value + ", timestamp=" + timestamp
- + "]";
+ return "ObjectNameTypeValue [name=" + name + ", type=" + type + ", value=" + value + ", timestamp=" + timestamp + "]";
}
}
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ValueType.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ValueType.java
index 7094b7c..bb821db 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ValueType.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/ValueType.java
@@ -26,13 +26,12 @@
// Should be temporary, since the gateway does not implements the enums yet.
// Remove this when gateway will be updated
- TMP_MODIFIABLE("org.eclipse.sensinact.gateway.common.primitive.Modifiable", n -> n.asText()),
- TMP_CONSTRAINT("Array of org.eclipse.sensinact.gateway.common.constraint.Constraint", n -> n.asText()),
-
+ OTHER("other", n -> n.asText()),
OBJECT("object", n -> n.toString()), /* do NOT use asText with 'object' */
STRING("string", n -> n.asText()),
LONG("long", n -> n.asLong()),
DOUBLE("double", n -> n.asDouble()),
+ FLOAT("float", n -> n.asDouble()),
INT("int", n -> n.asInt()),
BOOLEAN("boolean", n -> n.asBoolean()),
ARRAY("array", n -> computeArray(n));
@@ -52,8 +51,7 @@
if (value.getName().equals(name))
return value;
}
- logger.error("ValueName with type " + name + " NOT found");
- return null;
+ return OTHER;
}
public String getName() {
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/attributevalueupdated/MsgAttributeValueUpdated.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/attributevalueupdated/MsgAttributeValueUpdated.java
index 5fe065d..971f059 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/attributevalueupdated/MsgAttributeValueUpdated.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/attributevalueupdated/MsgAttributeValueUpdated.java
@@ -47,8 +47,13 @@
}
public boolean isLocationValue() {
- return uri != null && uri.contains("/admin/location/value");
+ return uri != null && uri.endsWith("/admin/location/value");
}
+
+
+ public boolean isIconValue() {
+ return uri != null && uri.endsWith("/admin/icon/value");
+ }
public void setUri(String uri) {
this.uri = uri;
@@ -88,5 +93,5 @@
@Override
public String toString() {
return "MsgAttributeValueUpdated [notification=" + notification + ", uri=" + uri + "]";
- }
+ }
}
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/basic/MsgExceptionError.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/basic/MsgExceptionError.java
index eb7510c..4e28785 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/basic/MsgExceptionError.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/basic/MsgExceptionError.java
@@ -11,7 +11,6 @@
package org.eclipse.sensinact.studio.http.messages.snamessage.basic;
import org.eclipse.sensinact.studio.http.messages.snamessage.MsgCategory;
-import org.eclipse.sensinact.studio.model.resource.utils.Segments;
/**
* @author Etienne Gandrille
@@ -20,12 +19,10 @@
private final String jsonObject;
private final Exception exception;
- private final Segments segments;
- public MsgExceptionError(String jsonObject, Exception exception, Segments segments) {
+ public MsgExceptionError(String jsonObject, Exception exception) {
this.jsonObject = jsonObject;
this.exception = exception;
- this.segments = segments;
}
@Override
@@ -41,17 +38,12 @@
return exception;
}
- public Segments getSegments() {
- return segments;
- }
-
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((exception == null) ? 0 : exception.hashCode());
result = prime * result + ((jsonObject == null) ? 0 : jsonObject.hashCode());
- result = prime * result + ((segments == null) ? 0 : segments.hashCode());
return result;
}
@@ -74,17 +66,11 @@
return false;
} else if (!jsonObject.equals(other.jsonObject))
return false;
- if (segments == null) {
- if (other.segments != null)
- return false;
- } else if (!segments.equals(other.segments))
- return false;
return true;
}
@Override
public String toString() {
- return "MsgExceptionError [jsonObject=" + jsonObject + ", exception=" + exception + ", segments=" + segments
- + "]";
+ return "MsgExceptionError [jsonObject=" + jsonObject + ", exception=" + exception + "]";
}
}
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/MsgCompleteList.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/MsgCompleteList.java
index 0378bc8..3aad20e 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/MsgCompleteList.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/MsgCompleteList.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.sensinact.studio.http.messages.snamessage.completelist;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.sensinact.studio.http.messages.snamessage.MsgCategory;
@@ -38,6 +40,13 @@
public List<ObjectProvider> getProviders() {
return providers;
}
+
+ public List<String> getProvidersId() {
+ List<ObjectProvider> providers = getProviders();
+ if(providers == null || providers.isEmpty())
+ return Collections.emptyList();
+ return providers.stream().collect(ArrayList::new,(l,o) -> l.add(o.getName()),List::addAll);
+ }
public ObjectProvider getProvider(String providerName) {
for (ObjectProvider provider : providers)
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/ObjectProvider.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/ObjectProvider.java
index 235e7b4..7112255 100644
--- a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/ObjectProvider.java
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/completelist/ObjectProvider.java
@@ -20,6 +20,7 @@
private String name;
private String location;
private List<ObjectService> services;
+ private String icon;
public String getName() {
return name;
@@ -44,6 +45,15 @@
public void setServices(List<ObjectService> services) {
this.services = services;
}
+
+ public String getIcon() {
+ return this.icon;
+ }
+
+ public void setIcon(String icon) {
+ this.icon = icon;
+ }
+
@Override
public int hashCode() {
@@ -52,6 +62,7 @@
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((services == null) ? 0 : services.hashCode());
+ result = prime * result + ((icon == null) ? 0 : icon.hashCode());
return result;
}
@@ -84,6 +95,6 @@
@Override
public String toString() {
- return "ObjectProviders [name=" + name + ", location=" + location + ", services=" + services + "]";
+ return "ObjectProviders [name=" + name + ", location=" + location + ", services=" + services + (icon==null?"":", icon=" + icon)+"]";
}
}
diff --git a/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/serviceslist/MsgServicesList.java b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/serviceslist/MsgServicesList.java
new file mode 100644
index 0000000..a1040ea
--- /dev/null
+++ b/services/org.eclipse.sensinact.studio.http.messages/src/org/eclipse/sensinact/studio/http/messages/snamessage/serviceslist/MsgServicesList.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2019 CEA.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA - initial API and implementation and/or initial documentation
+ */
+package org.eclipse.sensinact.studio.http.messages.snamessage.serviceslist;
+
+import java.util.List;
+
+import org.eclipse.sensinact.studio.http.messages.snamessage.MsgCategory;
+import org.eclipse.sensinact.studio.http.messages.snamessage.MsgSensinact;
+
+/**
+ * @author Etienne Gandrille
+ */
+public class MsgServicesList extends MsgSensinact {
+
+ public static final String KEY = "SERVICES_LIST";
+
+ private String uri;
+ private int statusCode;
+ private List<String> services;
+
+ public MsgServicesList() {
+ super(KEY);
+ }
+
+ @Override
+ public MsgCategory getCategory() {
+ return MsgCategory.OTHER;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ public List<String> getServices() {
+ return services;
+ }
+
+ public void setServices(List<String> services) {
+ this.services = services;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((services == null) ? 0 : services.hashCode());
+ result = prime * result + statusCode;
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MsgServicesList other = (MsgServicesList) obj;
+ if (services == null) {
+ if (other.services != null)
+ return false;
+ } else if (!services.equals(other.services))
+ return false;
+ if (statusCode != other.statusCode)
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (uri == null) {
+ if (other.uri != null)
+ return false;
+ } else if (!uri.equals(other.uri))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "MsgServicesList [type=" + type + ", uri=" + uri + ", statusCode=" + statusCode + ", services="
+ + services + "]";
+ }
+}