Allow to use some admin service's resources as attributes of the global set of resources description
cosmetic : move filtering data structures to 'filtering' packages
creates the attributes-filter module allowing to ask for attributes in global set of resources description
diff --git a/platform/northbound/attributes-filtering/attributes-filter/about.html b/platform/northbound/attributes-filtering/attributes-filter/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/platform/northbound/attributes-filtering/attributes-filter/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/platform/northbound/attributes-filtering/attributes-filter/pom.xml b/platform/northbound/attributes-filtering/attributes-filter/pom.xml
new file mode 100644
index 0000000..c34ae2b
--- /dev/null
+++ b/platform/northbound/attributes-filtering/attributes-filter/pom.xml
@@ -0,0 +1,337 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
+ <artifactId>attributes-filtering</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>attributes-filter</artifactId>
+ <packaging>bundle</packaging>
+
+ <name>sensiNact IoT Gateway - Attributes filter</name>
+
+ <properties>
+ <tmp.repository>${project.build.directory}</tmp.repository>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-utils</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sensinact.gateway.tools</groupId>
+ <artifactId>sensinact-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.main</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sensinact.gateway.protocol</groupId>
+ <artifactId>http</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.jetty</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.skyscreamer</groupId>
+ <artifactId>jsonassert</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.sensinact.gateway.simulated.devices</groupId>
+ <artifactId>slider</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>keystoreCopy</id>
+ <phase>generate-test-resources</phase>
+ <configuration>
+ <target description="Copying keystore.jks">
+ <copy file="../../../sensinact-security/cert/keystore.jks"
+ tofile="${project.build.directory}/felix/bundle/keystore.jks" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_nouses>true</_nouses>
+ <_failok>true</_failok>
+ <_noee>true</_noee>
+ </instructions>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ <phase>generate-test-resources</phase>
+ <configuration>
+ <manifestLocation>${project.basedir}/target/generated-test-sources/META-INF</manifestLocation>
+ <instructions>
+ <_noee>true</_noee>
+ <_exportcontents>*</_exportcontents>
+ <_nouses>true</_nouses>
+ </instructions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <phase>generate-test-resources</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.annotation</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>osgi.annotation.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.component.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.cm</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.cm.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.metatype.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.namespace.extender</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.namespace.extender.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.promise</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.util.promise.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.function</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.util.function.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.pushstream</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.util.pushstream.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.log</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.log.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.log.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.fileinstall</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.fileinstall.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.configadmin.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework.security</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.framework.security.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.scr.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-utils</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-utils.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-common</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-common.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-datastore-api</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-datastore-api.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway.sthbnd.mqtt</groupId>
+ <artifactId>mqtt-utils</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>mqtt-utils.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.paho</groupId>
+ <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.eclipse.paho.client.mqttv3.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-core</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-core.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-signature-validator</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-signature-validator.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-security-none</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-security-none.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-generic</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-generic.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
+ <artifactId>sensinact-northbound-access</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-northbound-access.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
+ <artifactId>rest-access</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>rest-access.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>slf4j-api.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>slf4j-simple.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway.protocol</groupId>
+ <artifactId>http</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>http.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.servlet-api</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.http.servlet-api.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.jetty</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.http.jetty.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway.simulated.devices</groupId>
+ <artifactId>slider</artifactId>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>slider.jar</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/platform/northbound/attributes-filtering/attributes-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/AttributesFiltering.java b/platform/northbound/attributes-filtering/attributes-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/AttributesFiltering.java
new file mode 100644
index 0000000..017870f
--- /dev/null
+++ b/platform/northbound/attributes-filtering/attributes-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/AttributesFiltering.java
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2020 Kentyou.
+ * 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:
+* Kentyou - initial API and implementation
+ */
+package org.eclipse.sensinact.gateway.nthbnd.filter.attributes;
+
+import java.util.Arrays;
+
+import org.eclipse.sensinact.gateway.common.bundle.Mediator;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * {@link Filtering} implementation allowing to search for specific attributes
+ *
+ * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
+ */
+@Component(immediate=true, service = Filtering.class, property = "type=attrs")
+public class AttributesFiltering implements Filtering {
+ @Override
+ public boolean handle(String type) {
+ return "attrs".equals(type);
+ }
+
+ @Override
+ public String apply(String definition, Object result) {
+ return String.valueOf(result);
+ }
+
+ @Override
+ public String getLDAPComponent(String definition) {
+ String definitionContent = definition;
+
+ if(definition.startsWith("{") ||definition.startsWith("[") )
+ definitionContent = definition.substring(1, definition.length()-1);
+
+ final String[] defs = definitionContent.split(",");
+
+ StringBuilder builder = Arrays.asList(defs).stream(
+ ).<StringBuilder>collect(
+ ()->{return new StringBuilder();},
+ (sb,s)->{
+ if(sb.length()==0 && defs.length>1)
+ sb.append("(&");
+ sb.append("(admin.");
+ sb.append(s);
+ sb.append(".value=*)");
+ },
+ (sb1,sb2)-> {sb1.append(sb2.toString());});
+
+ if(defs.length>1)
+ builder.append(")");
+ return builder.toString();
+ }
+}
diff --git a/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/http/test/HttpServiceTestClient.java b/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/http/test/HttpServiceTestClient.java
new file mode 100644
index 0000000..daf2539
--- /dev/null
+++ b/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/http/test/HttpServiceTestClient.java
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2020 Kentyou.
+ * 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:
+* Kentyou - initial API and implementation
+ */
+package org.eclipse.sensinact.gateway.nthbnd.filter.attributes.http.test;
+
+import org.eclipse.sensinact.gateway.common.bundle.Mediator;
+import org.eclipse.sensinact.gateway.protocol.http.client.ConnectionConfigurationImpl;
+import org.eclipse.sensinact.gateway.protocol.http.client.SimpleRequest;
+import org.eclipse.sensinact.gateway.protocol.http.client.SimpleResponse;
+import org.eclipse.sensinact.gateway.util.json.JSONValidator;
+import org.json.JSONException;
+
+import java.io.IOException;
+
+public class HttpServiceTestClient {
+ public static String newRequest(Mediator mediator, String url, String content, String method) {
+ SimpleResponse response;
+ ConnectionConfigurationImpl<SimpleResponse, SimpleRequest> builder = new ConnectionConfigurationImpl<SimpleResponse, SimpleRequest>();
+ builder.setUri(url);
+ builder.setAccept("application/json");
+ /*builder.addHeader("Authorization",
+ "Basic " + Base64.encodeBytes(
+ "cea:sensiNact_team".getBytes()));*/
+ try {
+ if (method.equals("GET")) {
+ builder.setHttpMethod("GET");
+
+ } else if (method.equals("POST")) {
+ builder.setContentType("application/json");
+ builder.setHttpMethod("POST");
+ if (content != null && content.length() > 0) {
+ if (new JSONValidator(content).valid()) {
+ builder.setContent(content);
+ }
+ }
+ } else {
+ return null;
+ }
+ SimpleRequest request = new SimpleRequest(builder);
+ response = request.send();
+ byte[] responseContent = response.getContent();
+ String contentStr = (responseContent == null ? null : new String(responseContent));
+ return contentStr;
+ } catch (JSONException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/test/TestAttributesFiltering.java b/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/test/TestAttributesFiltering.java
new file mode 100644
index 0000000..e748ab3
--- /dev/null
+++ b/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/test/TestAttributesFiltering.java
@@ -0,0 +1,241 @@
+/*
+* Copyright (c) 2020 Kentyou.
+ * 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:
+* Kentyou - initial API and implementation
+ */
+package org.eclipse.sensinact.gateway.nthbnd.filter.attributes.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.eclipse.sensinact.gateway.common.bundle.Mediator;
+import org.eclipse.sensinact.gateway.nthbnd.filter.attributes.http.test.HttpServiceTestClient;
+import org.eclipse.sensinact.gateway.nthbnd.filter.attributes.ws.test.WsServiceTestClient;
+import org.eclipse.sensinact.gateway.test.MidOSGiTest;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+
+/**
+ * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
+ */
+public class TestAttributesFiltering extends MidOSGiTest {
+ //********************************************************************//
+ // NESTED DECLARATIONS //
+ //********************************************************************//
+ //********************************************************************//
+ // ABSTRACT DECLARATIONS //
+ //********************************************************************//
+ //********************************************************************//
+ // STATIC DECLARATIONS //
+ //********************************************************************//
+
+ protected static final String HTTP_ROOTURL = "http://127.0.0.1:8899";
+ protected static final String WS_ROOTURL = "/sensinact";
+
+ //********************************************************************//
+ // INSTANCE DECLARATIONS //
+ //********************************************************************//
+
+ public TestAttributesFiltering() throws Exception {
+ super();
+ }
+
+ public boolean isExcluded(String fileName) {
+ if ("org.apache.felix.framework.security.jar".equals(fileName)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ protected void doInit(Map configuration) {
+ configuration.put("felix.auto.start.1",
+ "file:target/felix/bundle/org.osgi.service.component.jar "+
+ "file:target/felix/bundle/org.osgi.service.cm.jar "+
+ "file:target/felix/bundle/org.osgi.service.metatype.jar "+
+ "file:target/felix/bundle/org.osgi.namespace.extender.jar "+
+ "file:target/felix/bundle/org.osgi.util.promise.jar "+
+ "file:target/felix/bundle/org.osgi.util.function.jar "+
+ "file:target/felix/bundle/org.osgi.util.pushstream.jar "+
+ "file:target/felix/bundle/org.osgi.service.log.jar " +
+ "file:target/felix/bundle/org.apache.felix.log.jar " +
+ "file:target/felix/bundle/org.apache.felix.scr.jar " +
+ "file:target/felix/bundle/org.apache.felix.fileinstall.jar " +
+ "file:target/felix/bundle/org.apache.felix.configadmin.jar " +
+ "file:target/felix/bundle/org.apache.felix.framework.security.jar ");
+ configuration.put("felix.auto.install.2",
+ "file:target/felix/bundle/org.eclipse.paho.client.mqttv3.jar " +
+ "file:target/felix/bundle/mqtt-utils.jar " +
+ "file:target/felix/bundle/sensinact-utils.jar " +
+ "file:target/felix/bundle/sensinact-common.jar " +
+ "file:target/felix/bundle/sensinact-datastore-api.jar " +
+ "file:target/felix/bundle/sensinact-security-none.jar " +
+ "file:target/felix/bundle/sensinact-generic.jar " +
+ "file:target/felix/bundle/slf4j-api.jar " +
+ "file:target/felix/bundle/slf4j-simple.jar");
+ configuration.put("felix.auto.start.2",
+ "file:target/felix/bundle/sensinact-signature-validator.jar " +
+ "file:target/felix/bundle/sensinact-core.jar ");
+ configuration.put("felix.auto.start.3",
+ "file:target/felix/bundle/org.apache.felix.http.servlet-api.jar " +
+ "file:target/felix/bundle/org.apache.felix.http.jetty.jar " +
+ "file:target/felix/bundle/http.jar " +
+ "file:target/felix/bundle/sensinact-northbound-access.jar " +
+ "file:target/felix/bundle/rest-access.jar");
+ configuration.put("felix.auto.start.4",
+ "file:target/felix/bundle/slider.jar " +
+ "file:target/felix/bundle/dynamicBundle.jar ");
+ configuration.put("org.eclipse.sensinact.gateway.security.jks.filename", "target/felix/bundle/keystore.jks");
+ configuration.put("org.eclipse.sensinact.gateway.security.jks.password", "sensiNact_team");
+
+ configuration.put("org.eclipse.sensinact.gateway.location.latitude", "45.2d");
+ configuration.put("org.eclipse.sensinact.gateway.location.longitude", "5.7d");
+
+ configuration.put("org.osgi.service.http.port", "8899");
+ configuration.put("org.apache.felix.http.jettyEnabled", true);
+ configuration.put("org.apache.felix.http.whiteboardEnabled", true);
+ }
+
+ @Test
+ public void testHttpFiltered() throws Exception {
+ Mediator mediator = new Mediator(context);
+ String response = HttpServiceTestClient.newRequest(mediator, HTTP_ROOTURL + "/sensinact?attrs=[friendlyName]", null, "GET");
+ JSONObject result = new JSONObject(response);
+ JSONObject expected = new JSONObject(
+ "{\"filters\":[{\"definition\":\"[friendlyName]\",\"type\":\"attrs\"}],"
+ + "\"providers\":" + "[{\"name\":\"slider\",\"services\":[{\"name\":\"admin\","
+ + "\"resources\":" + "[{\"name\":\"friendlyName\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"location\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"bridge\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"icon\",\"type\":\"PROPERTY\"}]},"
+ + "{\"name\":\"cursor\",\"resources\":"
+ + "[{\"name\":\"position\",\"type\":\"SENSOR\"}]"
+ + "}]"
+ + ",\"location\":\"45.2:5.7\""
+ + ",\"friendlyName\":\"slider\"}]}");
+ JSONAssert.assertEquals(expected, new JSONObject(response), false);
+
+ response = HttpServiceTestClient.newRequest(mediator, HTTP_ROOTURL + "/sensinact?attrs={friendlyName,icon}", null, "GET");
+ result = new JSONObject(response);
+ expected = new JSONObject(
+ "{\"filters\":[{\"definition\":\"{friendlyName,icon}\",\"type\":\"attrs\"}],"
+ + "\"providers\":" + "[{\"name\":\"slider\",\"services\":[{\"name\":\"admin\","
+ + "\"resources\":" + "[{\"name\":\"friendlyName\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"location\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"bridge\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"icon\",\"type\":\"PROPERTY\"}]},"
+ + "{\"name\":\"cursor\",\"resources\":"
+ + "[{\"name\":\"position\",\"type\":\"SENSOR\"}]"
+ + "}]"
+ + ",\"location\":\"45.2:5.7\""
+ + ",\"icon\":null"
+ + ",\"friendlyName\":\"slider\"}]}");
+ JSONAssert.assertEquals(expected, result, false);
+
+ response = HttpServiceTestClient.newRequest(mediator, HTTP_ROOTURL + "/sensinact?attrs=friendlyName,icon,bridge", null, "GET");
+ result = new JSONObject(response);
+ expected = new JSONObject(
+ "{\"filters\":[{\"definition\":\"friendlyName,icon,bridge\",\"type\":\"attrs\"}],"
+ + "\"providers\":" + "[{\"name\":\"slider\",\"services\":[{\"name\":\"admin\","
+ + "\"resources\":" + "[{\"name\":\"friendlyName\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"location\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"bridge\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"icon\",\"type\":\"PROPERTY\"}]},"
+ + "{\"name\":\"cursor\",\"resources\":"
+ + "[{\"name\":\"position\",\"type\":\"SENSOR\"}]"
+ + "}]"
+ + ",\"location\":\"45.2:5.7\""
+ + ",\"friendlyName\":\"slider\""
+ + ",\"icon\":null"
+ + ",\"bridge\":\"slider\"}]}");
+ JSONAssert.assertEquals(expected, result, false);
+ }
+
+ @Test
+ public void testWsFiltered() throws Exception {
+ WsServiceTestClient client = new WsServiceTestClient();
+ new Thread(client).start();
+
+ String response = this.synchronizedRequest(client, "/sensinact", "[{\"name\":\"attrs\",\"type\":\"string\",\"value\":\"[friendlyName]\"}]");
+ JSONObject result = new JSONObject(response);
+ JSONObject expected = new JSONObject(
+ "{\"filters\":[{\"definition\":\"[friendlyName]\",\"type\":\"attrs\"}],"
+ + "\"providers\":" + "[{\"name\":\"slider\",\"services\":[{\"name\":\"admin\","
+ + "\"resources\":" + "[{\"name\":\"friendlyName\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"location\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"bridge\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"icon\",\"type\":\"PROPERTY\"}]},"
+ + "{\"name\":\"cursor\",\"resources\":"
+ + "[{\"name\":\"position\",\"type\":\"SENSOR\"}]"
+ + "}]"
+ + ",\"location\":\"45.2:5.7\""
+ + ",\"friendlyName\":\"slider\"}]}");
+ JSONAssert.assertEquals(expected, result, false);
+
+ response = this.synchronizedRequest(client, "/sensinact", "[{\"name\":\"attrs\",\"type\":\"string\",\"value\":\"{friendlyName,icon}\"}]");
+ result = new JSONObject(response);
+ expected = new JSONObject(
+ "{\"filters\":[{\"definition\":\"{friendlyName,icon}\",\"type\":\"attrs\"}],"
+ + "\"providers\":" + "[{\"name\":\"slider\",\"services\":[{\"name\":\"admin\","
+ + "\"resources\":" + "[{\"name\":\"friendlyName\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"location\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"bridge\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"icon\",\"type\":\"PROPERTY\"}]},"
+ + "{\"name\":\"cursor\",\"resources\":"
+ + "[{\"name\":\"position\",\"type\":\"SENSOR\"}]"
+ + "}]"
+ + ",\"location\":\"45.2:5.7\""
+ + ",\"icon\":null"
+ + ",\"friendlyName\":\"slider\"}]}");
+ JSONAssert.assertEquals(expected, result, false);
+
+ response = this.synchronizedRequest(client, "/sensinact", "[{\"name\":\"attrs\",\"type\":\"string\",\"value\":\"friendlyName,icon,bridge\"}]");
+ result = new JSONObject(response);
+ expected = new JSONObject(
+ "{\"filters\":[{\"definition\":\"friendlyName,icon,bridge\",\"type\":\"attrs\"}],"
+ + "\"providers\":" + "[{\"name\":\"slider\",\"services\":[{\"name\":\"admin\","
+ + "\"resources\":" + "[{\"name\":\"friendlyName\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"location\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"bridge\",\"type\":\"PROPERTY\"},"
+ + "{\"name\":\"icon\",\"type\":\"PROPERTY\"}]},"
+ + "{\"name\":\"cursor\",\"resources\":"
+ + "[{\"name\":\"position\",\"type\":\"SENSOR\"}]"
+ + "}]"
+ + ",\"location\":\"45.2:5.7\""
+ + ",\"friendlyName\":\"slider\""
+ + ",\"icon\":null"
+ + ",\"bridge\":\"slider\"}]}");
+ JSONAssert.assertEquals(expected, result, false);
+ client.close();
+ }
+
+ private String synchronizedRequest(WsServiceTestClient client, String url, String content) {
+ String simulated = null;
+ long wait = 1000;
+
+ client.newRequest(url, content);
+
+ while (!client.isAvailable() && wait > 0) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+ }
+ if (client.isAvailable()) {
+ simulated = client.getResponseMessage();
+ }
+ return simulated;
+ }
+}
diff --git a/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/ws/test/WsServiceTestClient.java b/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/ws/test/WsServiceTestClient.java
new file mode 100644
index 0000000..217af4b
--- /dev/null
+++ b/platform/northbound/attributes-filtering/attributes-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/attributes/ws/test/WsServiceTestClient.java
@@ -0,0 +1,187 @@
+/*
+* Copyright (c) 2020 Kentyou.
+ * 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:
+* Kentyou - initial API and implementation
+ */
+package org.eclipse.sensinact.gateway.nthbnd.filter.attributes.ws.test;
+
+import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
+import org.eclipse.jetty.websocket.client.WebSocketClient;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.net.URI;
+import java.util.Stack;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+@WebSocket(maxTextMessageSize = 64 * 1024)
+public class WsServiceTestClient implements Runnable {
+ String destUri = "ws://127.0.0.1:8899/ws/sensinact";
+ WebSocketClient client = null;
+ Session session;
+ AtomicBoolean available;
+ private String lastMessage;
+
+ public WsServiceTestClient() {
+ this.available = new AtomicBoolean(false);
+ try {
+ client = new WebSocketClient();
+ client.setMaxIdleTimeout(1000 * 3600);
+ client.start();
+ URI echoUri = new URI(destUri);
+ Future<Session> future = client.connect(this, echoUri);
+ future.get();
+
+ } catch (Throwable t) {
+ t.printStackTrace();
+ try {
+ client.stop();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ public void setAvailable(boolean available) {
+ this.available.set(available);
+ }
+
+ public boolean isAvailable() {
+ return this.available.get();
+ }
+
+ public String getResponseMessage() {
+ return this.lastMessage;
+ }
+
+ public void newRequest(String url, String content) {
+ this.setAvailable(false);
+ this.lastMessage = null;
+
+ synchronized (this.stack) {
+ this.stack.push(new WsRequest(url, content));
+ }
+ }
+
+ /**
+ * @param message
+ */
+ protected void send(String message) {
+ if(this.session == null) {
+ throw new NullPointerException("Null webSocket session");
+ }
+ try {
+ Future<Void> future = this.session.getRemote().sendStringByFuture(message);
+ future.get(1, TimeUnit.SECONDS);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @OnWebSocketConnect
+ public void onConnect(Session session) {
+ this.session = session;
+ }
+
+ /**
+ * @inheritDoc
+ * @see WebSocketEndpoint#onClose(int, java.lang.String)
+ */
+ @OnWebSocketClose
+ public void onClose(int statusCode, String reason) {
+ this.session = null;
+ this.close();
+ }
+
+ public void close() {
+ this.running = false;
+ }
+
+ /**
+ * @inheritDoc
+ * @see WebSocketEndpoint#onMessage(java.lang.String)
+ */
+ @OnWebSocketMessage
+ public void onMessage(String message) {
+ this.setAvailable(true);
+ this.lastMessage = message;
+ }
+
+ @OnWebSocketError
+ public void handleError(Throwable error) {
+ error.printStackTrace();
+ }
+
+ private boolean running = false;
+ private Stack<WsRequest> stack = new Stack<WsRequest>();
+
+ @Override
+ public void run() {
+ running = true;
+ boolean locked = true;
+ WsRequest request = null;
+
+ while (true) {
+ if (!running && !locked) {
+ break;
+ }
+ request = null;
+
+ synchronized (this.stack) {
+ if (!this.stack.isEmpty()) {
+ request = this.stack.pop();
+ }
+ locked = !this.stack.isEmpty();
+ }
+ if (request != null) {
+ JSONObject json = new JSONObject();
+ json.put("uri", request.url);
+ if (request.content != null) {
+ json.put("parameters", new JSONArray(request.content));
+ }
+ try {
+ this.send(json.toString());
+ } catch(NullPointerException e){
+ //e.printStackTrace();
+ synchronized (this.stack) {
+ this.stack.push(request);
+ }
+ }
+ } else {
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ break;
+ }
+ }
+ }
+ try {
+ this.client.stop();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ class WsRequest {
+ public final String url;
+ public final String content;
+
+ WsRequest(String url, String content) {
+ this.url = url;
+ this.content = content;
+ }
+ }
+}
diff --git a/platform/northbound/attributes-filtering/pom.xml b/platform/northbound/attributes-filtering/pom.xml
new file mode 100644
index 0000000..0830f44
--- /dev/null
+++ b/platform/northbound/attributes-filtering/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (c) 2020 Kentyou.
+ ~ 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:
+* Kentyou - initial API and implementation
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
+ <artifactId>parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>attributes-filtering</artifactId>
+ <packaging>pom</packaging>
+
+ <name>sensiNact IoT Gateway - Attributes filtering parent module</name>
+
+ <modules>
+ <module>attributes-filter</module>
+ </modules>
+
+</project>
diff --git a/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/internal/GeoJSONFiltering.java b/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/internal/GeoJSONFiltering.java
index 4888cdc..020e886 100644
--- a/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/internal/GeoJSONFiltering.java
+++ b/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/internal/GeoJSONFiltering.java
@@ -11,9 +11,9 @@
package org.eclipse.sensinact.gateway.nthbnd.filter.geojson.internal;
import org.eclipse.sensinact.gateway.common.bundle.Mediator;
-import org.eclipse.sensinact.gateway.core.Filtering;
import org.eclipse.sensinact.gateway.core.LocationResource;
import org.eclipse.sensinact.gateway.core.Resource;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
import org.eclipse.sensinact.gateway.util.LocationUtils;
import org.eclipse.sensinact.gateway.util.json.JSONObjectStatement;
import org.eclipse.sensinact.gateway.util.json.JSONTokenerStatement;
diff --git a/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/osgi/Activator.java b/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/osgi/Activator.java
index ab24e2c..c30a98b 100644
--- a/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/osgi/Activator.java
+++ b/platform/northbound/geo-filtering/geojson-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/geojson/osgi/Activator.java
@@ -12,7 +12,7 @@
import org.eclipse.sensinact.gateway.common.bundle.AbstractActivator;
import org.eclipse.sensinact.gateway.common.bundle.Mediator;
-import org.eclipse.sensinact.gateway.core.Filtering;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
import org.eclipse.sensinact.gateway.nthbnd.filter.geojson.internal.GeoJSONFiltering;
import org.osgi.framework.BundleContext;
diff --git a/platform/northbound/ldap-filtering/ldap-filter/extra-src/test/resources/MANIFEST.MF b/platform/northbound/ldap-filtering/ldap-filter/extra-src/test/resources/MANIFEST.MF
index bd67602..bc2595a 100644
--- a/platform/northbound/ldap-filtering/ldap-filter/extra-src/test/resources/MANIFEST.MF
+++ b/platform/northbound/ldap-filtering/ldap-filter/extra-src/test/resources/MANIFEST.MF
@@ -11,9 +11,8 @@
.0",org.eclipse.sensinact.gateway.util;version="1.5.0"
,org.eclipse.sensinact.gateway.common.execution;versio
n="1.5.0",org.json;version="20080701",org.eclipse.sens
- inact.gateway.nthbnd.filter.ldap.internal;version="1.5
- .0",org.eclipse.sensinact.gateway.nthbnd.filter.ldap.o
- sgi;version="1.5.0",org.osgi.framework
+ inact.gateway.nthbnd.filter.ldap;version="1.5.0",org.o
+ sgi.framework
Tool: Bnd-2.3.0.201405100607
Bundle-Name: sensiNact IoT Gateway - Device Moke
Created-By: 1.6.0_45 (Sun Microsystems Inc.)
diff --git a/platform/northbound/ldap-filtering/ldap-filter/pom.xml b/platform/northbound/ldap-filtering/ldap-filter/pom.xml
index 77537f3..3411369 100644
--- a/platform/northbound/ldap-filtering/ldap-filter/pom.xml
+++ b/platform/northbound/ldap-filtering/ldap-filter/pom.xml
@@ -108,7 +108,6 @@
<_nouses>true</_nouses>
<_failok>true</_failok>
<_noee>true</_noee>
- <Bundle-Activator>org.eclipse.sensinact.gateway.nthbnd.filter.ldap.osgi.Activator</Bundle-Activator>
</instructions>
</configuration>
<executions>
diff --git a/platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/internal/LdapFiltering.java b/platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/LdapFiltering.java
similarity index 68%
rename from platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/internal/LdapFiltering.java
rename to platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/LdapFiltering.java
index 3734e7d..27c4e2c 100644
--- a/platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/internal/LdapFiltering.java
+++ b/platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/LdapFiltering.java
@@ -8,16 +8,17 @@
* Contributors:
* Kentyou - initial API and implementation
*/
-package org.eclipse.sensinact.gateway.nthbnd.filter.ldap.internal;
+package org.eclipse.sensinact.gateway.nthbnd.filter.ldap;
-import org.eclipse.sensinact.gateway.common.bundle.Mediator;
-import org.eclipse.sensinact.gateway.core.Filtering;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
+import org.osgi.service.component.annotations.Component;
/**
* {@link Filtering} implementation allowing to apply an LDAP filter
*
* @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
*/
+@Component(immediate=true, service=Filtering.class, property="type=ldap")
public class LdapFiltering implements Filtering {
//********************************************************************//
// NESTED DECLARATIONS //
@@ -33,44 +34,17 @@
//********************************************************************//
// INSTANCE DECLARATIONS //
//********************************************************************//
- private Mediator mediator;
-
- /**
- * Constructor
- *
- * @param mediator the {@link Mediator} allowing the
- * LdapFiltering to be instantiated to interact with
- * the OSGi host environment
- */
- public LdapFiltering(Mediator mediator) {
- this.mediator = mediator;
- }
-
- /**
- * @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.Filtering#
- * handle(java.lang.String)
- */
+
@Override
public boolean handle(String type) {
return "ldap".equals(type);
}
-
- /**
- * @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.Filtering#
- * apply(java.lang.String, java.lang.Object)
- */
@Override
public String apply(String definition, Object result) {
return String.valueOf(result);
}
- /**
- * @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.Filtering#getLDAPComponent()
- */
@Override
public String getLDAPComponent(String definition) {
String ldapFilter = definition;
diff --git a/platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/osgi/Activator.java b/platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/osgi/Activator.java
deleted file mode 100644
index 27b3a5e..0000000
--- a/platform/northbound/ldap-filtering/ldap-filter/src/main/java/org/eclipse/sensinact/gateway/nthbnd/filter/ldap/osgi/Activator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2020 Kentyou.
- * 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:
-* Kentyou - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.filter.ldap.osgi;
-
-import org.eclipse.sensinact.gateway.common.bundle.AbstractActivator;
-import org.eclipse.sensinact.gateway.common.bundle.Mediator;
-import org.eclipse.sensinact.gateway.core.Filtering;
-import org.eclipse.sensinact.gateway.nthbnd.filter.ldap.internal.LdapFiltering;
-import org.osgi.framework.BundleContext;
-
-import java.util.Hashtable;
-
-/**
- */
-public class Activator extends AbstractActivator<Mediator> {
- private static final String TYPE = "ldap";
-
- @Override
- public void doStart() throws Exception {
- super.mediator.info("Registering LDAP filter");
- super.mediator.register(new LdapFiltering(super.mediator), Filtering.class, new Hashtable() {{
- put("type", TYPE);
- }});
- }
-
- @Override
- public void doStop() throws Exception {
- super.mediator.info("Unregistering LDAP filter");
- }
-
- @Override
- public Mediator doInstantiate(BundleContext context) {
- return new Mediator(context);
- }
-}
diff --git a/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/HttpServiceTestClient.java b/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/HttpServiceTestClient.java
index 76fc024..ed41dec 100644
--- a/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/HttpServiceTestClient.java
+++ b/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/HttpServiceTestClient.java
@@ -25,24 +25,19 @@
ConnectionConfigurationImpl<SimpleResponse, SimpleRequest> builder = new ConnectionConfigurationImpl<SimpleResponse, SimpleRequest>();
builder.setUri(url);
builder.setAccept("application/json");
- /*builder.addHeader("Authorization",
- "Basic " + Base64.encodeBytes(
- "cea:sensiNact_team".getBytes()));*/
- try {
- if (method.equals("GET")) {
- builder.setHttpMethod("GET");
- } else if (method.equals("POST")) {
+ try {
+ if (method.equals("GET"))
+ builder.setHttpMethod("GET");
+ else if (method.equals("POST")) {
builder.setContentType("application/json");
builder.setHttpMethod("POST");
if (content != null && content.length() > 0) {
- if (new JSONValidator(content).valid()) {
- builder.setContent(content);
- }
+ if (new JSONValidator(content).valid())
+ builder.setContent(content);
}
- } else {
+ } else
return null;
- }
SimpleRequest request = new SimpleRequest(builder);
response = request.send();
byte[] responseContent = response.getContent();
diff --git a/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestLdapFiltering.java b/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestLdapFiltering.java
index 422a9f0..c17d249 100644
--- a/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestLdapFiltering.java
+++ b/platform/northbound/ldap-filtering/ldap-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestLdapFiltering.java
@@ -10,25 +10,20 @@
*/
package org.eclipse.sensinact.gateway.nthbnd.filter.jsonpath.test;
-import org.eclipse.sensinact.gateway.util.IOUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.sensinact.gateway.common.bundle.Mediator;
-import org.eclipse.sensinact.gateway.test.MidOSGiTest;
-import org.json.JSONObject;
-import org.junit.Test;
-
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.eclipse.sensinact.gateway.common.bundle.Mediator;
+import org.eclipse.sensinact.gateway.test.MidOSGiTest;
+import org.json.JSONObject;
+import org.junit.Test;
/**
* @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
@@ -123,17 +118,6 @@
configuration.put("org.osgi.service.http.port", "8899");
configuration.put("org.apache.felix.http.jettyEnabled", true);
configuration.put("org.apache.felix.http.whiteboardEnabled", true);
-
- try {
- String fileName = "sensinact.config";
- File testFile = new File(new File("src/test/resources"), fileName);
- URL testFileURL = testFile.toURI().toURL();
- FileOutputStream output = new FileOutputStream(new File(loadDir,fileName));
- byte[] testCng = IOUtils.read(testFileURL.openStream(), true);
- IOUtils.write(testCng, output);
- } catch (Exception e) {
- e.printStackTrace();
- }
}
@Test
diff --git a/platform/northbound/ldap-filtering/ldap-filter/src/test/resources/sensinact.config b/platform/northbound/ldap-filtering/ldap-filter/src/test/resources/sensinact.config
deleted file mode 100644
index 7b88e10..0000000
--- a/platform/northbound/ldap-filtering/ldap-filter/src/test/resources/sensinact.config
+++ /dev/null
@@ -1,3 +0,0 @@
-namespace=SERVER
-broker=tcp://sensinact-cea.ddns.net:5269
-broker.topic.prefix=/
\ No newline at end of file
diff --git a/platform/northbound/pom.xml b/platform/northbound/pom.xml
index 5d5ac58..5840b6b 100644
--- a/platform/northbound/pom.xml
+++ b/platform/northbound/pom.xml
@@ -30,6 +30,7 @@
<!--<module>jsonpath-filtering</module>-->
<module>geo-filtering</module>
<module>ldap-filtering</module>
+ <module>attributes-filtering</module>
<module>mqtt</module>
<module>generic-storage-agent</module>
<module>http-storage-agent</module>
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/AllRequest.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/AllRequest.java
index c2ee89a..a04d361 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/AllRequest.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/AllRequest.java
@@ -10,7 +10,7 @@
*/
package org.eclipse.sensinact.gateway.nthbnd.endpoint;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
public class AllRequest extends NorthboundRequest {
/**
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/DefaultNorthboundRequestHandler.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/DefaultNorthboundRequestHandler.java
index 225f6b5..5a14d8f 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/DefaultNorthboundRequestHandler.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/DefaultNorthboundRequestHandler.java
@@ -25,8 +25,8 @@
import org.eclipse.sensinact.gateway.common.execution.ErrorHandler;
import org.eclipse.sensinact.gateway.common.primitive.InvalidValueException;
-import org.eclipse.sensinact.gateway.core.Filtering;
-import org.eclipse.sensinact.gateway.core.FilteringDefinition;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringDefinition;
import org.eclipse.sensinact.gateway.core.message.SnaFilter;
import org.eclipse.sensinact.gateway.core.message.SnaMessage;
import org.eclipse.sensinact.gateway.core.method.AccessMethod;
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundEndpoint.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundEndpoint.java
index cb0ef1c..aa00c09 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundEndpoint.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundEndpoint.java
@@ -11,8 +11,8 @@
package org.eclipse.sensinact.gateway.nthbnd.endpoint;
import org.eclipse.sensinact.gateway.core.AnonymousSession;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
import org.eclipse.sensinact.gateway.core.Session;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback;
import org.eclipse.sensinact.gateway.core.message.SnaFilter;
import org.eclipse.sensinact.gateway.core.method.AccessMethodResponse;
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequest.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequest.java
index faab27d..2f62a1a 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequest.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequest.java
@@ -12,7 +12,7 @@
import org.eclipse.sensinact.gateway.common.primitive.Nameable;
import org.eclipse.sensinact.gateway.common.primitive.PathElement;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequestBuilder.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequestBuilder.java
index 58af25f..1d76b8b 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequestBuilder.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/NorthboundRequestBuilder.java
@@ -14,8 +14,8 @@
import java.util.List;
import org.eclipse.sensinact.gateway.common.execution.ErrorHandler;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
-import org.eclipse.sensinact.gateway.core.FilteringDefinition;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringDefinition;
import org.eclipse.sensinact.gateway.core.message.SnaFilter;
import org.eclipse.sensinact.gateway.util.CastUtils;
import org.json.JSONArray;
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ResourcesRequest.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ResourcesRequest.java
index 15652ce..8b7a411 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ResourcesRequest.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ResourcesRequest.java
@@ -10,7 +10,7 @@
*/
package org.eclipse.sensinact.gateway.nthbnd.endpoint;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.util.UriUtils;
public class ResourcesRequest extends ServiceRequest {
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProviderRequest.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProviderRequest.java
index c376a4d..ed14f9c 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProviderRequest.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProviderRequest.java
@@ -10,7 +10,7 @@
*/
package org.eclipse.sensinact.gateway.nthbnd.endpoint;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.util.UriUtils;
public class ServiceProviderRequest extends ServiceProvidersRequest {
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProvidersRequest.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProvidersRequest.java
index 11115b6..6002910 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProvidersRequest.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceProvidersRequest.java
@@ -10,7 +10,7 @@
*/
package org.eclipse.sensinact.gateway.nthbnd.endpoint;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.util.UriUtils;
public class ServiceProvidersRequest extends NorthboundRequest {
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceRequest.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceRequest.java
index d6d98b6..a0cb68b 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceRequest.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServiceRequest.java
@@ -10,7 +10,7 @@
*/
package org.eclipse.sensinact.gateway.nthbnd.endpoint;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.util.UriUtils;
public class ServiceRequest extends ServicesRequest {
diff --git a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServicesRequest.java b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServicesRequest.java
index 13002a5..3e4a078 100644
--- a/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServicesRequest.java
+++ b/platform/northbound/sensinact-access/src/main/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/ServicesRequest.java
@@ -10,7 +10,7 @@
*/
package org.eclipse.sensinact.gateway.nthbnd.endpoint;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.util.UriUtils;
public class ServicesRequest extends ServiceProviderRequest {
diff --git a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/NorthboundRequestHandlerTest.java b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/NorthboundRequestHandlerTest.java
index 64e8695..28fe707 100644
--- a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/NorthboundRequestHandlerTest.java
+++ b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/NorthboundRequestHandlerTest.java
@@ -1,11 +1,11 @@
package org.eclipse.sensinact.gateway.nthbnd.endpoint.test;
import org.eclipse.sensinact.gateway.core.ActionResource;
-import org.eclipse.sensinact.gateway.core.FilteringDefinition;
import org.eclipse.sensinact.gateway.core.InvalidServiceProviderException;
import org.eclipse.sensinact.gateway.core.ResourceImpl;
import org.eclipse.sensinact.gateway.core.ServiceImpl;
import org.eclipse.sensinact.gateway.core.StateVariableResource;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringDefinition;
import org.eclipse.sensinact.gateway.core.method.AccessMethod;
import org.eclipse.sensinact.gateway.core.method.AccessMethodResponse;
import org.eclipse.sensinact.gateway.core.method.Parameter;
diff --git a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/TestContext.java b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/TestContext.java
index 4dd419c..1a92b4c 100644
--- a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/TestContext.java
+++ b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/TestContext.java
@@ -19,7 +19,6 @@
import java.util.List;
import org.eclipse.sensinact.gateway.core.Core;
-import org.eclipse.sensinact.gateway.core.Filtering;
import org.eclipse.sensinact.gateway.core.InvalidServiceProviderException;
import org.eclipse.sensinact.gateway.core.ModelConfiguration;
import org.eclipse.sensinact.gateway.core.ModelConfigurationBuilder;
@@ -27,6 +26,7 @@
import org.eclipse.sensinact.gateway.core.ModelInstanceBuilder;
import org.eclipse.sensinact.gateway.core.SensiNact;
import org.eclipse.sensinact.gateway.core.SensiNactResourceModel;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
import org.eclipse.sensinact.gateway.core.message.SnaAgent;
import org.eclipse.sensinact.gateway.core.security.AuthenticationService;
import org.eclipse.sensinact.gateway.core.security.AuthorizationService;
diff --git a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/XFilter.java b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/XFilter.java
index dcbe48e..750ef78 100644
--- a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/XFilter.java
+++ b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/XFilter.java
@@ -1,6 +1,6 @@
package org.eclipse.sensinact.gateway.nthbnd.endpoint.test;
-import org.eclipse.sensinact.gateway.core.Filtering;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
/**
* @author <a href="mailto:cmunilla@kentyou.com">Christophe Munilla</a>
@@ -27,7 +27,7 @@
/**
* @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.api.filtering.Filtering#handle(java.lang.String)
+ * @see org.eclipse.sensinact.gateway.core.filtering.api.filtering.Filtering#handle(java.lang.String)
*/
@Override
public boolean handle(String type) {
@@ -36,7 +36,7 @@
/**
* @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.api.filtering.Filtering#apply(java.lang.String, java.lang.Object)
+ * @see org.eclipse.sensinact.gateway.core.filtering.api.filtering.Filtering#apply(java.lang.String, java.lang.Object)
*/
@Override
public String apply(String definition, Object result) {
@@ -47,7 +47,7 @@
/**
* @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.api.filtering.Filtering#getLDAPComponent()
+ * @see org.eclipse.sensinact.gateway.core.filtering.api.filtering.Filtering#getLDAPComponent()
*/
@Override
public String getLDAPComponent(String definition) {
diff --git a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/YFilter.java b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/YFilter.java
index 8e6bce6..80acba2 100644
--- a/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/YFilter.java
+++ b/platform/northbound/sensinact-access/src/test/java/org/eclipse/sensinact/gateway/nthbnd/endpoint/test/YFilter.java
@@ -1,6 +1,6 @@
package org.eclipse.sensinact.gateway.nthbnd.endpoint.test;
-import org.eclipse.sensinact.gateway.core.Filtering;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
/**
* @author <a href="mailto:cmunilla@kentyou.com">Christophe Munilla</a>
@@ -27,7 +27,7 @@
/**
* @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.api.filtering.Filtering#handle(java.lang.String)
+ * @see org.eclipse.sensinact.gateway.core.filtering.api.filtering.Filtering#handle(java.lang.String)
*/
@Override
public boolean handle(String type) {
@@ -36,7 +36,7 @@
/**
* @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.api.filtering.Filtering#apply(java.lang.String, java.lang.Object)
+ * @see org.eclipse.sensinact.gateway.core.filtering.api.filtering.Filtering#apply(java.lang.String, java.lang.Object)
*/
@Override
public String apply(String definition, Object result) {
@@ -47,7 +47,7 @@
/**
* @inheritDoc
- * @see org.eclipse.sensinact.gateway.core.api.filtering.Filtering#getLDAPComponent()
+ * @see org.eclipse.sensinact.gateway.core.filtering.api.filtering.Filtering#getLDAPComponent()
*/
@Override
public String getLDAPComponent(String definition) {
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/AbstractSession.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/AbstractSession.java
index 46e61d1..c3d2870 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/AbstractSession.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/AbstractSession.java
@@ -18,6 +18,7 @@
import org.eclipse.sensinact.gateway.common.primitive.Nameable;
import org.eclipse.sensinact.gateway.common.execution.ErrorHandler;
import org.eclipse.sensinact.gateway.common.execution.Executable;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.core.message.MidAgentCallback;
import org.eclipse.sensinact.gateway.core.message.Recipient;
import org.eclipse.sensinact.gateway.core.message.SnaErrorfulMessage;
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/ModelInstanceRegistration.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/ModelInstanceRegistration.java
index e3e5d60..4271054 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/ModelInstanceRegistration.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/ModelInstanceRegistration.java
@@ -12,6 +12,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.Arrays;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
@@ -39,13 +40,15 @@
/**
* Wraps the {@link ServiceRegistration} of a {@link SensiNactResourceModel}
- * instance and updates the properties of its associated
- * {@link ServiceReference}.
+ * instance and updates the properties of its associated {@link ServiceReference}.
*
* @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
*/
public class ModelInstanceRegistration extends AbstractMidCallback {
public static final String LOCATION_PROPERTY = "admin.".concat(LocationResource.LOCATION);
+ public static final String ICON_PROPERTY = "admin.".concat(ServiceProvider.ICON);
+ public static final String BRIDGE_PROPERTY = "admin.".concat(ServiceProvider.BRIDGE);
+ public static final String FRIENDLY_NAME_PROPERTY = "admin.".concat(ServiceProvider.FRIENDLY_NAME);
private boolean registered;
private ServiceRegistration<?> instanceRegistration;
@@ -99,19 +102,23 @@
list = new ArrayList<String>();
this.observed.put(key, list);
}
- if (!list.contains(attribute)) {
+ if (!list.contains(attribute))
list.add(attribute);
- }
}
}
- List<String> list = this.observed.get(LOCATION_PROPERTY);
- if (list == null) {
- list = new ArrayList<String>();
- this.observed.put(LOCATION_PROPERTY, list);
- }
- if (!list.contains(DataResource.VALUE)) {
- list.add(DataResource.VALUE);
- }
+
+ Arrays.asList(LOCATION_PROPERTY, ICON_PROPERTY, FRIENDLY_NAME_PROPERTY, BRIDGE_PROPERTY).stream().forEach(
+ p -> {
+ List<String> list = ModelInstanceRegistration.this.observed.get(p);
+ if (list == null) {
+ list = new ArrayList<String>();
+ ModelInstanceRegistration.this.observed.put(p, list);
+ }
+ if (!list.contains(DataResource.VALUE))
+ list.add(DataResource.VALUE);
+ }
+ );
+
this.instanceRegistration = registration;
this.configuration = configuration;
this.registered = true;
@@ -145,12 +152,13 @@
String message = e.getMessage();
String duplicateMessage = "Duplicate service property: ";
String duplicateProperty = null;
- if (message.startsWith(duplicateMessage)) {
+
+ if (message.startsWith(duplicateMessage))
duplicateProperty = message.substring(duplicateMessage.length());
- }
- if (duplicateProperty != null && properties.remove(duplicateProperty) != null) {
+
+ if (duplicateProperty != null && properties.remove(duplicateProperty) != null)
update(properties);
- }
+
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/RegistryEndpoint.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/RegistryEndpoint.java
index 0068dad..4cfa8f8 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/RegistryEndpoint.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/RegistryEndpoint.java
@@ -155,9 +155,9 @@
Collection<ServiceReference<SensiNactResourceModel>> references =
this.getReferences(tree, filter);
- if(references.size()!=1) {
+ if(references.size()!=1)
return false;
- }
+
ServiceReference<SensiNactResourceModel> reference = references.iterator().next();
AccessMethod.Type describe = AccessMethod.Type.valueOf(AccessMethod.DESCRIBE);
@@ -219,14 +219,22 @@
public String getAll(SessionKey sessionKey, boolean resolveNamespace, String filter) {
StringBuilder builder = new StringBuilder();
int index = -1;
-
+
Collection<ServiceReference<SensiNactResourceModel>> references =
RegistryEndpoint.this.getReferences(sessionKey, filter);
+
Iterator<ServiceReference<SensiNactResourceModel>> iterator =
references.iterator();
AccessTree<? extends AccessNode> tree = sessionKey.getAccessTree();
+ AccessNode root = sessionKey.getAccessTree().getRoot();
+
AccessMethod.Type describe = AccessMethod.Type.valueOf(AccessMethod.DESCRIBE);
+ AccessMethod.Type get = AccessMethod.Type.valueOf(AccessMethod.GET);
+
+ boolean addBridge = filter == null ?false:filter.indexOf("admin.bridge.value=*") > -1;
+ boolean addIcon = filter == null ?false:filter.indexOf("admin.icon.value=*") > -1;
+ boolean addFriendlyName = filter == null ?false:filter.indexOf("admin.friendlyName.value=*") > -1;
String namespace = namespace();
String prefix = "";
@@ -235,15 +243,76 @@
index++;
ServiceReference<SensiNactResourceModel> reference = iterator.next();
String name = (String) reference.getProperty("name");
-
String provider = new StringBuilder().append(prefix).append(name).toString();
-
+
String location = null;
Object obj = reference.getProperty(ModelInstanceRegistration.LOCATION_PROPERTY.concat(".value"));
- if (obj != null) {
- location = String.valueOf(obj).replace('"', '\'');
- }
- location = (location == null || location.length() == 0) ? defaultLocation : location;
+ if (obj == null || "null".equals(String.valueOf(obj)))
+ location = defaultLocation;
+ else
+ location = String.valueOf(obj).replace('"', '\'');
+
+ Integer locationGetLevel = (Integer) reference.getProperty(ModelInstanceRegistration.LOCATION_PROPERTY.concat(".GET"));
+ if (locationGetLevel == null)
+ locationGetLevel = Integer.valueOf(AccessLevelOption.OWNER.getAccessLevel().getLevel());
+
+ String resourceUri = UriUtils.getUri(new String[] { name, ServiceProvider.ADMINISTRATION_SERVICE_NAME, LocationResource.LOCATION });
+ AccessNode node = root.get(resourceUri);
+ if (node == null)
+ node = tree.getRoot();
+ int locationAccessLevel = node.getAccessLevelOption(get).getAccessLevel().getLevel();
+
+ String friendlyName = null;
+ obj = reference.getProperty(ModelInstanceRegistration.FRIENDLY_NAME_PROPERTY.concat(".value"));
+ if (obj == null || "null".equals(String.valueOf(obj)))
+ friendlyName = name;
+ else
+ friendlyName = String.valueOf(obj).replace('"', '\'');
+
+ Integer friendlyNameGetLevel = (Integer) reference.getProperty(ModelInstanceRegistration.FRIENDLY_NAME_PROPERTY.concat(".GET"));
+ if (friendlyNameGetLevel == null)
+ friendlyNameGetLevel = Integer.valueOf(AccessLevelOption.OWNER.getAccessLevel().getLevel());
+
+ resourceUri = UriUtils.getUri(new String[] { name, ServiceProvider.ADMINISTRATION_SERVICE_NAME, ServiceProvider.FRIENDLY_NAME});
+ node = root.get(resourceUri);
+ if (node == null)
+ node = tree.getRoot();
+ int friendlyNameAccessLevel = node.getAccessLevelOption(get).getAccessLevel().getLevel();
+
+ String bridge;
+ obj = reference.getProperty(ModelInstanceRegistration.BRIDGE_PROPERTY.concat(".value"));
+ if (obj == null || "null".equals(String.valueOf(obj)))
+ bridge = null;
+ else
+ bridge = String.valueOf(obj).replace('"', '\'');
+
+ Integer bridgeGetLevel = (Integer) reference.getProperty(ModelInstanceRegistration.BRIDGE_PROPERTY.concat(".GET"));
+ if (bridgeGetLevel == null)
+ bridgeGetLevel = Integer.valueOf(AccessLevelOption.OWNER.getAccessLevel().getLevel());
+
+ resourceUri = UriUtils.getUri(new String[] { name, ServiceProvider.ADMINISTRATION_SERVICE_NAME, ServiceProvider.BRIDGE});
+ node = root.get(resourceUri);
+ if (node == null)
+ node = tree.getRoot();
+ int bridgeAccessLevel = node.getAccessLevelOption(get).getAccessLevel().getLevel();
+
+ String icon;
+ obj = reference.getProperty(ModelInstanceRegistration.ICON_PROPERTY.concat(".value"));
+ if (obj == null || "null".equals(String.valueOf(obj)))
+ icon = null;
+ else
+ icon = String.valueOf(obj).replace('"', '\'');
+
+ Integer iconGetLevel = (Integer) reference.getProperty(ModelInstanceRegistration.ICON_PROPERTY.concat(".GET"));
+ if (iconGetLevel == null)
+ iconGetLevel = Integer.valueOf(AccessLevelOption.OWNER.getAccessLevel().getLevel());
+
+ resourceUri = UriUtils.getUri(new String[] { name, ServiceProvider.ADMINISTRATION_SERVICE_NAME, ServiceProvider.ICON});
+ node = root.get(resourceUri);
+ if (node == null)
+ node = tree.getRoot();
+ int iconAccessLevel = node.getAccessLevelOption(get).getAccessLevel().getLevel();
+
List<String> serviceList = (List<String>) reference.getProperty("services");
builder.append(index > 0 ? ',' : "");
@@ -262,10 +331,38 @@
builder.append(namespace);
builder.append('"');
}
- builder.append(",\"location\":");
- builder.append('"');
- builder.append(location);
- builder.append('"');
+ if (locationAccessLevel >= locationGetLevel.intValue()) {
+ builder.append(",\"location\":");
+ if(location!=null)
+ builder.append('"');
+ builder.append(location);
+ if(location!=null)
+ builder.append('"');
+ }
+ if (addBridge && bridgeAccessLevel >= bridgeGetLevel.intValue()) {
+ builder.append(",\"bridge\":");
+ if(bridge!=null)
+ builder.append('"');
+ builder.append(bridge);
+ if(bridge!=null)
+ builder.append('"');
+ }
+ if (addIcon && iconAccessLevel >= iconGetLevel.intValue()) {
+ builder.append(",\"icon\":");
+ if(icon!=null)
+ builder.append('"');
+ builder.append(icon);
+ if(icon!=null)
+ builder.append('"');
+ }
+ if (addFriendlyName && friendlyNameAccessLevel >= friendlyNameGetLevel.intValue()) {
+ builder.append(",\"friendlyName\":");
+ if(friendlyName!=null)
+ builder.append('"');
+ builder.append(friendlyName);
+ if(friendlyName!=null)
+ builder.append('"');
+ }
builder.append(",\"services\":");
builder.append('[');
@@ -275,19 +372,17 @@
String service = serviceList.get(sindex);
String serviceUri = UriUtils.getUri(new String[] { name, service });
Integer serviceLevel = (Integer) reference.getProperty(service.concat(".DESCRIBE"));
- if (serviceLevel == null) {
+ if (serviceLevel == null)
serviceLevel = Integer.valueOf(AccessLevelOption.OWNER.getAccessLevel().getLevel());
- }
- AccessNode node = sessionKey.getAccessTree().getRoot().get(serviceUri);
- if (node == null) {
+
+ node = root.get(serviceUri);
+ if (node == null)
node = tree.getRoot();
- }
+
int describeAccessLevel = node.getAccessLevelOption(describe).getAccessLevel().getLevel();
- int serviceLevelLevel = serviceLevel.intValue();
-
- if (node.getAccessLevelOption(describe).getAccessLevel().getLevel() < serviceLevel.intValue()) {
+ if (describeAccessLevel < serviceLevel.intValue())
continue;
- }
+
List<String> resourceList = (List<String>) reference.getProperty(service.concat(".resources"));
builder.append(sindex > 0 ? ',' : "");
@@ -304,17 +399,18 @@
for (; rindex < rlength; rindex++) {
String resource = resourceList.get(rindex);
String resolvedResource = new StringBuilder().append(service).append(".").append(resource).toString();
- String resourceUri = UriUtils.getUri(new String[] { name, service, resource });
- Integer resourceLevel = (Integer) reference.getProperty(resolvedResource.concat(".DESCRIBE"));
+ resourceUri = UriUtils.getUri(new String[] { name, service, resource });
+ Integer resourceLevel = (Integer) reference.getProperty(resolvedResource.concat(".DESCRIBE"));
if (resourceLevel == null)
resourceLevel = Integer.valueOf(AccessLevelOption.OWNER.getAccessLevel().getLevel());
-
- node = sessionKey.getAccessTree().getRoot().get(resourceUri);
+
+ node = root.get(resourceUri);
if (node == null)
node = tree.getRoot();
-
- if (node.getAccessLevelOption(describe).getAccessLevel().getLevel() < resourceLevel.intValue())
+
+ describeAccessLevel = node.getAccessLevelOption(describe).getAccessLevel().getLevel();
+ if (describeAccessLevel < resourceLevel.intValue())
continue;
String type = (String) reference.getProperty(resolvedResource.concat(".type"));
@@ -391,9 +487,9 @@
ServiceReference<SensiNactResourceModel> reference = iterator.next();
String name = (String) reference.getProperty("name");
String provider = new StringBuilder().append(prefix).append(name).toString();
- if (index > 0) {
+ if (index > 0)
builder.append(",");
- }
+
builder.append('"');
builder.append(provider);
builder.append('"');
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/SensiNact.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/SensiNact.java
index 64c3a10..e218704 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/SensiNact.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/SensiNact.java
@@ -37,6 +37,7 @@
import org.eclipse.sensinact.gateway.common.execution.Executable;
import org.eclipse.sensinact.gateway.core.Sessions.KeyExtractor;
import org.eclipse.sensinact.gateway.core.Sessions.KeyExtractorType;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback;
import org.eclipse.sensinact.gateway.core.message.LocalAgent;
import org.eclipse.sensinact.gateway.core.message.LocalAgentImpl;
@@ -534,12 +535,11 @@
DescribeResponseBuilder<String> builder = method.createAccessMethodResponseBuilder(null);
final String ldapFilter;
- if (filterCollection != null) {
+ if (filterCollection != null)
ldapFilter = filterCollection.composeLDAPFormatedFilter(filter);
-
- } else {
+ else
ldapFilter = filter;
- }
+
String all = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
@@ -559,9 +559,9 @@
}
String result = new StringBuilder().append("[").append(all).append("]").toString();
- if (filterCollection != null) {
+ if (filterCollection != null)
result = filterCollection.apply(result);
- }
+
builder.setAccessMethodObjectResult(result);
response = builder.createAccessMethodResponse(Status.SUCCESS);
@@ -2185,9 +2185,9 @@
return local;
}
final StringBuilder content = new StringBuilder();
- if (local != null && local.length() > 0) {
+ if (local != null && local.length() > 0)
content.append(local);
- }
+
final String localNamespace = this.namespace();
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/Session.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/Session.java
index 66adfe5..93ecb1d 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/Session.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/Session.java
@@ -14,6 +14,7 @@
import org.eclipse.sensinact.gateway.core.message.Recipient;
import org.eclipse.sensinact.gateway.common.execution.Executable;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
import org.eclipse.sensinact.gateway.core.message.MidAgentCallback;
import org.eclipse.sensinact.gateway.core.message.SnaFilter;
import org.eclipse.sensinact.gateway.core.method.ActResponse;
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/Filtering.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/Filtering.java
similarity index 71%
rename from platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/Filtering.java
rename to platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/Filtering.java
index 2de36a7..eeb717a 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/Filtering.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/Filtering.java
@@ -8,7 +8,7 @@
* Contributors:
* Kentyou - initial API and implementation
*/
-package org.eclipse.sensinact.gateway.core;
+package org.eclipse.sensinact.gateway.core.filtering;
/**
* Filter to be applied on the response of an sensiNact's access method call
@@ -20,14 +20,12 @@
* Returns true if this Filtering service is able to handle the String type of
* filter passed as parameter; returns false otherwise
*
- * @param type
- * the String type of filter
+ * @param type the String type of filter
*
* @return
* <ul>
- * <li>true if the specified type of filter is handled by this
- * {@link Filtering} service</li>
- * <li>false otherwise</li>
+ * <li>true if the specified type of filter is handled by this {@link Filtering} service</li>
+ * <li>false otherwise</li>
* </ul>
*/
boolean handle(String type);
@@ -37,9 +35,7 @@
* This filter is used to discriminate the elements on which this Filtering
* service will be applied on
*
- * @param definition
- * the String definition describing the Filtering service's
- * parameters
+ * @param definition the String definition describing the Filtering service's parameters
*
* @return the String formated LDAP component part of this Filtering service
*/
@@ -49,11 +45,8 @@
* Applies the String filter passed as parameter on the Object also passed as
* parameter and returned the String filtered result, in the same format
*
- * @param definition
- * the String definition describing the Filtering service's
- * parameters
- * @param obj
- * the Object to be filtered
+ * @param definition the String definition describing the Filtering service's parameters
+ * @param obj the Object to be filtered
*
* @return the String filtered result
*/
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringAccessor.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringAccessor.java
similarity index 83%
rename from platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringAccessor.java
rename to platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringAccessor.java
index ab3a97a..9f4a4a2 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringAccessor.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringAccessor.java
@@ -8,7 +8,7 @@
* Contributors:
* Kentyou - initial API and implementation
*/
-package org.eclipse.sensinact.gateway.core;
+package org.eclipse.sensinact.gateway.core.filtering;
import java.util.Collection;
import java.util.NoSuchElementException;
@@ -30,12 +30,10 @@
/**
* Constructor
*
- * @param mediator
- * the {@link Mediator} allowing the FilteringAccessor to be
- * instantiated to interact with the OSGi host environment
- * @param filterDefinition
- * the {@link FilteringDefinition} parameterizing the instantiation
- * of the FilteringAccessor to be created
+ * @param mediator the {@link Mediator} allowing the FilteringAccessor to be
+ * instantiated to interact with the OSGi host environment
+ * @param filterDefinition the {@link FilteringDefinition} parameterizing the
+ * instantiation of the FilteringAccessor to be created
*/
public FilteringAccessor(Mediator mediator, FilteringDefinition filteringDefinition) {
super(filteringDefinition.type, filteringDefinition.filter);
@@ -60,14 +58,12 @@
* FilteringAccessor is able to handle the String type of filter passed as
* parameter; returns false otherwise
*
- * @param type
- * the String type of filter
+ * @param type the String type of filter
*
* @return
* <ul>
- * <li>true if the specified type of filter is handled by the wrapped
- * {@link Filtering} service</li>
- * <li>false otherwise</li>
+ * <li>true if the specified type of filter is handled by the wrapped {@link Filtering} service</li>
+ * <li>false otherwise</li>
* </ul>
*/
public boolean handle(String type) {
@@ -91,8 +87,7 @@
* discriminate the elements on which the wrapped {@link Filtering} service will
* be applied on
*
- * @return the String formated LDAP component part of the wrapped Filtering
- * service
+ * @return the String formated LDAP component part of the wrapped Filtering service
*/
public String getLDAPComponent() {
Filtering filtering = this.mediator.getContext().getService(reference);
@@ -109,8 +104,7 @@
* Applies the {@link Filtering} service wrapped by this FilteringAccessor on
* the specified object argument and returns the String result
*
- * @param obj
- * the Object value to be filtered
+ * @param obj the Object value to be filtered
*
* @return the String result of the filtering process
*/
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringCollection.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringCollection.java
similarity index 98%
rename from platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringCollection.java
rename to platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringCollection.java
index 272695a..e1aa242 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringCollection.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringCollection.java
@@ -8,7 +8,7 @@
* Contributors:
* Kentyou - initial API and implementation
*/
-package org.eclipse.sensinact.gateway.core;
+package org.eclipse.sensinact.gateway.core.filtering;
import java.util.ArrayList;
import java.util.Iterator;
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringDefinition.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringDefinition.java
similarity index 97%
rename from platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringDefinition.java
rename to platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringDefinition.java
index e26d55e..1b7c75b 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/FilteringDefinition.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/filtering/FilteringDefinition.java
@@ -8,7 +8,7 @@
* Contributors:
* Kentyou - initial API and implementation
*/
-package org.eclipse.sensinact.gateway.core;
+package org.eclipse.sensinact.gateway.core.filtering;
/**
* Gather the type and the String representation of an {@link Filtering} service
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/annotation/Filter.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/annotation/Filter.java
index 79a5a25..b1faf3d 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/annotation/Filter.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/annotation/Filter.java
@@ -31,6 +31,7 @@
@Retention(RUNTIME)
@Target(TYPE)
public @interface Filter {
+
/**
* Returns the path defining accepted source(s) of messages - A message
* coming from a different source will not be propagated
@@ -38,6 +39,7 @@
* @return the accepted source(s) path
*/
String sender() default "(/[^/]+)+";
+
/**
* Returns true if the sender attribute is an regular expression -
* returns false otherwise
@@ -49,6 +51,7 @@
* </ul>
*/
boolean isPattern() default true;
+
/**
* Returns true if the filtering process refers to the logical complement
* of both sender and conditions arguments for message validation - returns
@@ -61,6 +64,7 @@
* </ul>
*/
boolean isComplement() default false;
+
/**
* Returns the array of filtered message types - A message of a different type
* will not be propagated
@@ -68,6 +72,7 @@
* @return the array of filtered message types
*/
SnaMessage.Type[] handled() default {};
+
/**
* Returns the array of the JSON formated string representations of
* the constraints applying on the filtered messages - A message that does
diff --git a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/whiteboard/AgentFactory.java b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/whiteboard/AgentFactory.java
index 36bf1f9..287b9e2 100644
--- a/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/whiteboard/AgentFactory.java
+++ b/platform/sensinact-core/src/main/java/org/eclipse/sensinact/gateway/core/message/whiteboard/AgentFactory.java
@@ -54,41 +54,26 @@
private final class EmptyFilterDefinition implements MessageFilterDefinition {
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#handledTypes()
- */
@Override
public SnaMessage.Type[] handledTypes() {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#conditions()
- */
@Override
public List<Constraint> conditions() {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#sender()
- */
@Override
public String sender() {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#isPattern()
- */
@Override
public boolean isPattern() {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#isComplement()
- */
@Override
public boolean isComplement() {
return false;
@@ -103,9 +88,6 @@
this.filter = filter;
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#handledTypes()
- */
@Override
public SnaMessage.Type[] handledTypes() {
SnaMessage.Type[] arr = filter.handled();
@@ -115,9 +97,6 @@
return arr;
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#conditions()
- */
@Override
public List<Constraint> conditions() {
String[] cds = filter.conditions();
@@ -141,25 +120,16 @@
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#sender()
- */
@Override
public String sender() {
return filter.sender();
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#isPattern()
- */
@Override
public boolean isPattern() {
return filter.isPattern();
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#isComplement()
- */
@Override
public boolean isComplement() {
return filter.isComplement();
@@ -191,106 +161,67 @@
}
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#propagate()
- */
+
@Override
public boolean propagate() {
return agentRelay.propagate();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaLifecycleMessageImpl)
- */
+
@Override
public void doHandle(SnaLifecycleMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaUpdateMessageImpl)
- */
+
@Override
public void doHandle(SnaUpdateMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaRemoteMessageImpl)
- */
+
@Override
public void doHandle(SnaRemoteMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaErrorMessageImpl)
- */
@Override
public void doHandle(SnaErrorMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaResponseMessage)
- */
@Override
public void doHandle(SnaResponseMessage<?, ?> message) throws MidCallbackException {
agentRelay.doHandle(message);
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AgentRelay#getRelayIdentifier()
- */
@Override
public String getRelayIdentifier() {
return agentRelay.getRelayIdentifier();
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.AgentRelay#lifetime()
- */
@Override
public long lifetime() {
return agentRelay.lifetime();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#handledTypes()
- */
+
@Override
public SnaMessage.Type[] handledTypes() {
return this.filterDefinition.handledTypes();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#conditions()
- */
+
@Override
public List<Constraint> conditions() {
return this.filterDefinition.conditions();
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#sender()
- */
@Override
public String sender() {
return this.filterDefinition.sender();
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#isPattern()
- */
@Override
public boolean isPattern() {
return this.filterDefinition.isPattern();
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.api.message.FilterDefinition#isComplement()
- */
@Override
public boolean isComplement() {
return this.filterDefinition.isComplement();
@@ -312,58 +243,37 @@
super(true,true,ID_GENERATOR(agentRelay));
this.agentRelay = agentRelay;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#propagate()
- */
+
@Override
public boolean propagate() {
return agentRelay.propagate();
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaLifecycleMessageImpl)
- */
+
@Override
public void doHandle(SnaLifecycleMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaUpdateMessageImpl)
- */
+
@Override
public void doHandle(SnaUpdateMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaRemoteMessageImpl)
- */
+
@Override
public void doHandle(SnaRemoteMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaErrorMessageImpl)
- */
@Override
public void doHandle(SnaErrorMessageImpl message) throws MidCallbackException {
agentRelay.doHandle(message);
}
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback#doHandle(org.eclipse.sensinact.gateway.core.message.SnaResponseMessage)
- */
@Override
public void doHandle(SnaResponseMessage<?, ?> message) throws MidCallbackException {
agentRelay.doHandle(message);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.sensinact.gateway.core.message.AbstractMidCallback#setTimeout(long)
- */
+
@Override
protected void setTimeout(long timeout) {
super.setTimeout(timeout);
diff --git a/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestContext.java b/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestContext.java
index f93bcfa..3d7ace4 100644
--- a/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestContext.java
+++ b/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestContext.java
@@ -18,7 +18,6 @@
import java.util.List;
import org.eclipse.sensinact.gateway.common.bundle.Mediator;
-import org.eclipse.sensinact.gateway.core.Filtering;
import org.eclipse.sensinact.gateway.core.InvalidServiceProviderException;
import org.eclipse.sensinact.gateway.core.ModelConfiguration;
import org.eclipse.sensinact.gateway.core.ModelConfigurationBuilder;
@@ -26,6 +25,7 @@
import org.eclipse.sensinact.gateway.core.ModelInstanceBuilder;
import org.eclipse.sensinact.gateway.core.SensiNact;
import org.eclipse.sensinact.gateway.core.SensiNactResourceModel;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
import org.eclipse.sensinact.gateway.core.message.SnaAgent;
import org.eclipse.sensinact.gateway.core.security.AuthenticationService;
import org.eclipse.sensinact.gateway.core.security.AuthorizationService;
diff --git a/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestResourceBuilder.java b/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestResourceBuilder.java
index 158f7eb..fe62d98 100644
--- a/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestResourceBuilder.java
+++ b/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/TestResourceBuilder.java
@@ -36,8 +36,6 @@
import org.eclipse.sensinact.gateway.core.ActionResource;
import org.eclipse.sensinact.gateway.core.Attribute;
import org.eclipse.sensinact.gateway.core.DataResource;
-import org.eclipse.sensinact.gateway.core.FilteringCollection;
-import org.eclipse.sensinact.gateway.core.FilteringDefinition;
import org.eclipse.sensinact.gateway.core.InvalidServiceProviderException;
import org.eclipse.sensinact.gateway.core.LocationResource;
import org.eclipse.sensinact.gateway.core.Metadata;
@@ -50,6 +48,8 @@
import org.eclipse.sensinact.gateway.core.ServiceProvider;
import org.eclipse.sensinact.gateway.core.Session;
import org.eclipse.sensinact.gateway.core.StateVariableResource;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringCollection;
+import org.eclipse.sensinact.gateway.core.filtering.FilteringDefinition;
import org.eclipse.sensinact.gateway.core.message.AbstractMidAgentCallback;
import org.eclipse.sensinact.gateway.core.message.Recipient;
import org.eclipse.sensinact.gateway.core.message.SnaErrorMessageImpl;
diff --git a/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/XFilter.java b/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/XFilter.java
index 22440ff..15f4a98 100644
--- a/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/XFilter.java
+++ b/platform/sensinact-core/src/test/java/org/eclipse/sensinact/gateway/core/test/XFilter.java
@@ -1,6 +1,6 @@
package org.eclipse.sensinact.gateway.core.test;
-import org.eclipse.sensinact.gateway.core.Filtering;
+import org.eclipse.sensinact.gateway.core.filtering.Filtering;
/**
*
@@ -32,7 +32,7 @@
/**
* @inheritDoc
*
- * @see org.eclipse.sensinact.gateway.core.Filtering#handle(java.lang.String)
+ * @see org.eclipse.sensinact.gateway.core.filtering.Filtering#handle(java.lang.String)
*/
@Override
public boolean handle(String type) {
@@ -42,7 +42,7 @@
/**
* @inheritDoc
*
- * @see org.eclipse.sensinact.gateway.core.Filtering#apply(java.lang.String,
+ * @see org.eclipse.sensinact.gateway.core.filtering.Filtering#apply(java.lang.String,
* java.lang.Object)
*/
@Override
@@ -55,7 +55,7 @@
/**
* @inheritDoc
*
- * @see org.eclipse.sensinact.gateway.core.Filtering#getLDAPComponent()
+ * @see org.eclipse.sensinact.gateway.core.filtering.Filtering#getLDAPComponent()
*/
@Override
public String getLDAPComponent(String definition) {