diff --git a/bundles/org.openhab.ui.cometvisu.php/pom.xml.versionsBackup b/bundles/org.openhab.ui.cometvisu.php/pom.xml.versionsBackup
deleted file mode 100644
index 8227902e8..000000000
--- a/bundles/org.openhab.ui.cometvisu.php/pom.xml.versionsBackup
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
- 4.0.0
-
-
- org.openhab.ui.bundles
- org.openhab.ui.reactor.bundles
- 2.5.0
-
-
- org.openhab.ui.cometvisu.php
-
- openHAB UI :: Bundles :: CometVisu :: PHP Support
-
-
-
- org.openhab
- com.caucho.quercus
- 4.0.45
-
-
- org.openhab.ui.bundles
- org.openhab.ui.cometvisu
- ${project.version}
-
-
- org.openhab.core.bundles
- org.openhab.core
- ${project.version}
-
-
- org.openhab.ui.bundles
- org.openhab.ui.dashboard
- ${project.version}
-
-
- org.openhab.core.bundles
- org.openhab.core.model.sitemap
- ${project.version}
-
-
- org.openhab.core.bundles
- org.openhab.core.ui
- ${project.version}
-
-
- org.openhab.core.bundles
- org.openhab.core.ui.icon
- ${project.version}
-
-
-
-
diff --git a/bundles/org.openhab.ui.cometvisu/.classpath b/bundles/org.openhab.ui.cometvisu/.classpath
index a2f8d9d5f..e7791d4d9 100644
--- a/bundles/org.openhab.ui.cometvisu/.classpath
+++ b/bundles/org.openhab.ui.cometvisu/.classpath
@@ -28,19 +28,16 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/bundles/org.openhab.ui.cometvisu/bnd.bnd b/bundles/org.openhab.ui.cometvisu/bnd.bnd
deleted file mode 100644
index 82333b824..000000000
--- a/bundles/org.openhab.ui.cometvisu/bnd.bnd
+++ /dev/null
@@ -1,2 +0,0 @@
-Bundle-SymbolicName: ${project.artifactId}
-Bundle-Activator: org.openhab.ui.cometvisu.internal.CvActivator
diff --git a/bundles/org.openhab.ui.cometvisu/pom.xml b/bundles/org.openhab.ui.cometvisu/pom.xml
index e9a7ac4c5..33c02374c 100644
--- a/bundles/org.openhab.ui.cometvisu/pom.xml
+++ b/bundles/org.openhab.ui.cometvisu/pom.xml
@@ -68,11 +68,6 @@
jackson-annotations
2.9.10
-
- org.glassfish.jersey.media
- jersey-media-multipart
- 2.22.2
-
diff --git a/bundles/org.openhab.ui.cometvisu/pom.xml.versionsBackup b/bundles/org.openhab.ui.cometvisu/pom.xml.versionsBackup
deleted file mode 100644
index e9bad0aed..000000000
--- a/bundles/org.openhab.ui.cometvisu/pom.xml.versionsBackup
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
- 4.0.0
-
-
- org.openhab.ui.bundles
- org.openhab.ui.reactor.bundles
- 2.5.0
-
-
- org.openhab.ui.cometvisu
-
- openHAB UI :: Bundles :: CometVisu :: Backend
-
-
-
- com.sun.xml.bind
- jaxb-core
- 2.2.11
- provided
-
-
- com.sun.xml.bind
- jaxb-impl
- 2.2.11
- provided
-
-
- javax.activation
- activation
- 1.1.1
- provided
-
-
- javax.xml.bind
- jaxb-api
- 2.2.12
- provided
-
-
- org.openhab.core.bundles
- org.openhab.core
- ${project.version}
-
-
- org.openhab.ui.bundles
- org.openhab.ui.dashboard
- ${project.version}
-
-
- org.openhab.core.bundles
- org.openhab.core.model.sitemap
- ${project.version}
-
-
- org.openhab.core.bundles
- org.openhab.core.ui
- ${project.version}
-
-
- org.openhab.core.bundles
- org.openhab.core.ui.icon
- ${project.version}
-
-
- org.rrd4j
- rrd4j
- 3.4
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- src/gen/java
-
-
-
- org.codehaus.mojo
- jaxb2-maven-plugin
- 2.2
-
-
- org.openhab.ui.cometvisu.internal.config.beans
-
- src/main/resources/visu_config.xsd
-
- src/gen/java
- en
- false
- false
-
-
-
-
-
-
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/CvActivator.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/CvActivator.java
deleted file mode 100644
index c8c2fd5de..000000000
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/CvActivator.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (c) 2010-2020 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.ui.cometvisu.internal;
-
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
-import org.glassfish.jersey.media.sse.SseFeature;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Bundle activator for CometVisu backend.
- *
- * @author Tobias Bräutigam - Initial Contribution and API
- *
- */
-public class CvActivator implements BundleActivator {
-
- private final Logger logger = LoggerFactory.getLogger(CvActivator.class);
-
- private static BundleContext context;
-
- private ServiceRegistration> sseFeatureRegistration;
-
- private ServiceRegistration> blockingAsyncFeatureRegistration;
-
- private ServiceRegistration> multiPartRegistration;
-
- /**
- * Called whenever the OSGi framework starts our bundle
- */
- @Override
- public void start(BundleContext bc) throws Exception {
- context = bc;
-
- String featureName = SseFeature.class.getName();
- if (bc.getServiceReference(featureName) == null) {
- sseFeatureRegistration = bc.registerService(featureName, new SseFeature(), null);
-
- logger.debug("CometVisu - SseFeature registered.");
- }
- featureName = MultiPartFeature.class.getName();
- if (bc.getServiceReference(featureName) == null) {
- multiPartRegistration = bc.registerService(featureName, new MultiPartFeature(), null);
-
- logger.debug("CometVisu - MultiPartFeature registered.");
- }
-
- logger.debug("CometVisu has been started.");
- }
-
- /**
- * Called whenever the OSGi framework stops our bundle
- */
- @Override
- public void stop(BundleContext bc) throws Exception {
- context = null;
-
- if (sseFeatureRegistration != null) {
- sseFeatureRegistration.unregister();
- logger.debug("CometVisu - SseFeature unregistered.");
- }
-
- if (blockingAsyncFeatureRegistration != null) {
- blockingAsyncFeatureRegistration.unregister();
- logger.debug("CometVisu - BlockingAsyncFeature unregistered.");
- }
-
- if (multiPartRegistration != null) {
- multiPartRegistration.unregister();
- logger.debug("CometVisu - MultiPartFeature unregistered.");
- }
-
- logger.debug("CometVisu has been stopped.");
- }
-
- /**
- * Returns the bundle context of this bundle
- *
- * @return the bundle context
- */
- public static BundleContext getContext() {
- return context;
- }
-}
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncBinder.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncBinder.java
deleted file mode 100644
index 6c3164be1..000000000
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncBinder.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) 2010-2020 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.ui.cometvisu.internal.async;
-
-import org.glassfish.hk2.utilities.binding.AbstractBinder;
-import org.glassfish.jersey.internal.inject.CustomAnnotationLiteral;
-import org.glassfish.jersey.servlet.spi.AsyncContextDelegateProvider;
-
-/**
- * An {@link AbstractBinder} implementation that registers our custom
- * {@link BlockingAsyncContextDelegateProvider} class as an implementation of
- * the {@link AsyncContextDelegateProvider} SPI interface.
- *
- * @author Tobias Bräutigam - Initial Contribution and API
- *
- */
-public class BlockingAsyncBinder extends AbstractBinder {
-
- @Override
- protected void configure() {
- // the qualifiedBy is needed in order for our implementation to be used
- // if there are multiple implementations of AsyncContextDelegateProvider
- bind(new BlockingAsyncContextDelegateProvider()).to(AsyncContextDelegateProvider.class)
- .qualifiedBy(CustomAnnotationLiteral.INSTANCE);
- }
-}
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncContextDelegateProvider.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncContextDelegateProvider.java
deleted file mode 100644
index 3ecee6836..000000000
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncContextDelegateProvider.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Copyright (c) 2010-2020 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.ui.cometvisu.internal.async;
-
-import java.io.IOException;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.glassfish.jersey.media.sse.SseFeature;
-import org.glassfish.jersey.servlet.spi.AsyncContextDelegate;
-import org.glassfish.jersey.servlet.spi.AsyncContextDelegateProvider;
-import org.openhab.ui.cometvisu.internal.util.SseUtil;
-
-/**
- * An {@link AsyncContextDelegateProvider} implementation that returns a
- * blocking {@link AsyncContextDelegate}, which blocks while the connection is
- * alive if the response content-type is {@link SseFeature #SERVER_SENT_EVENTS}
- * or throws an UnsupportedOperationException otherwise. The blocking continues
- * until the response can longer be written to.
- *
- * @author Tobias Bräutigam - Initial Contribution and API
- *
- */
-public class BlockingAsyncContextDelegateProvider implements AsyncContextDelegateProvider {
-
- @Override
- public final AsyncContextDelegate createDelegate(final HttpServletRequest request,
- final HttpServletResponse response) {
- return new BlockingAsyncContextDelegate(request, response);
- }
-
- private static final class BlockingAsyncContextDelegate implements AsyncContextDelegate {
- private static final int PING_TIMEOUT = 15 * 1000;
-
- private final HttpServletResponse response;
-
- private volatile boolean isRunning;
-
- private BlockingAsyncContextDelegate(final HttpServletRequest request, final HttpServletResponse response) {
- this.response = response;
- }
-
- @Override
- public void complete() {
- isRunning = false;
- }
-
- @Override
- public void suspend() throws IllegalStateException {
- if (SseUtil.shouldAsyncBlock()) {
- isRunning = true;
-
- synchronized (this) {
- while (isRunning) {
- try {
- this.wait(PING_TIMEOUT);
- ServletOutputStream outputStream = response.getOutputStream();
-
- // write a new line to the OutputStream and flush to
- // check connectivity. If the other peer closes the
- // connection, the first flush() should generate a
- // TCP reset that is detected on the second flush()
- outputStream.write('\n');
- response.flushBuffer();
-
- outputStream.write('\n');
- response.flushBuffer();
- } catch (Exception exception) {
- // If an exception has occurred during write and
- // flush we consider the connection closed, attempt
- // to close the output stream and stop blocking.
- try {
- response.getOutputStream().close();
- } catch (IOException e) {
- }
-
- isRunning = false;
- }
- }
- }
- } else {
- throw new UnsupportedOperationException("ASYNCHRONOUS PROCESSING IS NOT SUPPORTED!");
- }
- }
- }
-}
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncFeature.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncFeature.java
deleted file mode 100644
index ca5f47bc8..000000000
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/async/BlockingAsyncFeature.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2010-2020 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.ui.cometvisu.internal.async;
-
-import javax.ws.rs.core.Feature;
-import javax.ws.rs.core.FeatureContext;
-
-/**
- * A {@link Feature} implementation that registers our custom
- * {@link BlockingAsyncBinder}.
- *
- * @author Tobias Bräutigam - Initial Contribution and API
- *
- */
-public class BlockingAsyncFeature implements Feature {
-
- @Override
- public boolean configure(FeatureContext context) {
- if (context.getConfiguration().isEnabled(BlockingAsyncFeature.class)) {
- return false;
- }
-
- context.register(new BlockingAsyncBinder());
-
- return true;
- }
-}
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ChartResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ChartResource.java
index 16f47d094..c7644f539 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ChartResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ChartResource.java
@@ -39,6 +39,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.core.items.GroupItem;
import org.openhab.core.items.Item;
@@ -55,6 +56,11 @@ import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import org.rrd4j.ConsolFun;
import org.rrd4j.core.FetchData;
import org.rrd4j.core.FetchRequest;
@@ -73,9 +79,13 @@ import io.swagger.annotations.ApiResponses;
* used by the diagram plugin
*
* @author Tobias Bräutigam - Initial contribution
- *
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_CHART_ALIAS)
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_CHART_ALIAS)
@Api(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_CHART_ALIAS)
public class ChartResource implements RESTResource {
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/CheckResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/CheckResource.java
index 4e4b6d904..d12b758ca 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/CheckResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/CheckResource.java
@@ -21,12 +21,18 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.ui.cometvisu.internal.Config;
import org.openhab.ui.cometvisu.internal.ManagerSettings;
import org.openhab.ui.cometvisu.internal.backend.model.rest.CheckResponse;
import org.openhab.ui.cometvisu.internal.backend.model.rest.EnvironmentState;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -37,9 +43,13 @@ import io.swagger.annotations.ApiResponses;
* Check filesystem backend for the cometvisu manager.
*
* @author Tobias Bräutigam - Initial contribution
- *
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/fs/check")
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/fs/check")
@Api(Config.COMETVISU_BACKEND_ALIAS + "/fs/check")
public class CheckResource implements RESTResource {
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ConfigResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ConfigResource.java
index b00de86b3..59d707891 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ConfigResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/ConfigResource.java
@@ -19,13 +19,20 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.ui.cometvisu.internal.Config;
import org.openhab.ui.cometvisu.internal.util.ClientInstaller;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
@@ -35,9 +42,15 @@ import io.swagger.annotations.ApiResponses;
* Allows certain actions to configure the CometVisu backend through the REST api.
*
* @author Tobias Bräutigam - Initial contribution
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_CONFIG_ALIAS)
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_CONFIG_ALIAS)
+@Api(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_CONFIG_ALIAS)
public class ConfigResource implements RESTResource {
private final Logger logger = LoggerFactory.getLogger(ConfigResource.class);
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/DataProviderResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/DataProviderResource.java
index 4aee5fad4..b6cf8b704 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/DataProviderResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/DataProviderResource.java
@@ -26,6 +26,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.core.items.GroupItem;
import org.openhab.core.items.Item;
@@ -43,6 +44,11 @@ import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,9 +61,13 @@ import io.swagger.annotations.ApiResponses;
* DataProvider backend for the cometvisu manager.
*
* @author Tobias Bräutigam - Initial contribution
- *
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/data")
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/data")
@Api(Config.COMETVISU_BACKEND_ALIAS + "/data")
public class DataProviderResource implements RESTResource {
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/EventBroadcaster.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/EventBroadcaster.java
index 36deafa4d..69e25631f 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/EventBroadcaster.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/EventBroadcaster.java
@@ -14,6 +14,8 @@ package org.openhab.ui.cometvisu.internal.backend.rest;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;
import org.openhab.core.types.State;
@@ -22,6 +24,7 @@ import org.openhab.core.types.State;
*
* @author Tobias Bräutigam - Initial contribution
*/
+@NonNullByDefault
public interface EventBroadcaster {
/**
* Broadcasts an event described by the given parameters to all currently
@@ -65,5 +68,5 @@ public interface EventBroadcaster {
* - the item that is listened to
* @return
*/
- public Map> getClientItems(Item item);
+ public Map> getClientItems(Item item);
}
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/FsResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/FsResource.java
index 4db28d344..2b30bfe66 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/FsResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/FsResource.java
@@ -13,27 +13,29 @@
package org.openhab.ui.cometvisu.internal.backend.rest;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
+import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
-import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
-import org.glassfish.jersey.media.multipart.FormDataParam;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.ui.cometvisu.internal.Config;
import org.openhab.ui.cometvisu.internal.ManagerSettings;
@@ -42,6 +44,11 @@ import org.openhab.ui.cometvisu.internal.util.FileOperationException;
import org.openhab.ui.cometvisu.internal.util.FsUtil;
import org.openhab.ui.cometvisu.internal.util.MountedFile;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,9 +62,13 @@ import io.swagger.annotations.ApiResponses;
* Filesystem backend for the cometvisu manager.
*
* @author Tobias Bräutigam - Initial contribution
- *
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/fs")
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/fs")
@Api(Config.COMETVISU_BACKEND_ALIAS + "/fs")
public class FsResource implements RESTResource {
@@ -103,21 +114,22 @@ public class FsResource implements RESTResource {
@ApiOperation(value = "Create a binary file")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 403, message = "not allowed"),
@ApiResponse(code = 406, message = "File already exists") })
- public Response createBinary(
+ public Response createBinary(@Context HttpServletRequest request,
@ApiParam(value = "Relative path inside the config folder", required = true) @QueryParam("path") String path,
@QueryParam("type") String type,
@ApiParam(value = "CRC32 hash of the file content") @QueryParam("hash") String hash,
- @ApiParam(value = "force overriding existing file") @DefaultValue("false") @FormDataParam("force") Boolean force,
- @ApiParam(value = "file content") @FormDataParam("file") InputStream fileInputStream,
- @FormDataParam("file") FormDataContentDisposition fileMetaData) {
+ @ApiParam(value = "force overriding existing file") @DefaultValue("false") @FormParam("force") Boolean force,
+ @ApiParam(value = "file content") @FormParam("file") Object fileParam) {
MountedFile target;
try {
- target = new MountedFile(Paths.get(path, fileMetaData.getFileName()).toString());
+ MultipartRequestMap map = new MultipartRequestMap(request);
+ File file = map.getFileParameter("file");
+ target = new MountedFile(Paths.get(path, file.getName()).toString());
File folder = target.toFile().toPath().getParent().toFile();
if (!target.exists() || force) {
if (!target.isReadonlyMount() && folder.canWrite()) {
try {
- FsUtil.getInstance().saveFile(target.toFile(), fileInputStream, hash);
+ FsUtil.getInstance().saveFile(target.toFile(), new FileInputStream(file), hash);
return Response.ok().build();
} catch (FileOperationException e) {
return FsUtil.createErrorResponse(e);
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/HiddenConfigResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/HiddenConfigResource.java
index 7c4b580bb..2e8a8c7d1 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/HiddenConfigResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/HiddenConfigResource.java
@@ -30,6 +30,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.ui.cometvisu.internal.Config;
import org.openhab.ui.cometvisu.internal.ManagerSettings;
@@ -37,6 +38,11 @@ import org.openhab.ui.cometvisu.internal.backend.model.rest.ConfigSection;
import org.openhab.ui.cometvisu.internal.backend.model.rest.HiddenConfig;
import org.openhab.ui.cometvisu.internal.util.FsUtil;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,9 +59,13 @@ import io.swagger.annotations.ApiResponses;
* Hidden configuration backend for the cometvisu manager.
*
* @author Tobias Bräutigam - Initial contribution
- *
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/config")
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/config")
@Api(Config.COMETVISU_BACKEND_ALIAS + "/config")
public class HiddenConfigResource implements RESTResource {
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/LoginResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/LoginResource.java
index db6ce14f2..728348d38 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/LoginResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/LoginResource.java
@@ -22,12 +22,18 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.ui.cometvisu.internal.Config;
import org.openhab.ui.cometvisu.internal.backend.model.ConfigBean;
import org.openhab.ui.cometvisu.internal.backend.model.LoginBean;
import org.openhab.ui.cometvisu.internal.backend.model.ResourcesBean;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -39,8 +45,13 @@ import io.swagger.annotations.ApiResponses;
* currently this is just a placeholder and does no real authentification
*
* @author Tobias Bräutigam - Initial contribution
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_LOGIN_ALIAS)
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_LOGIN_ALIAS)
@Api(Config.COMETVISU_BACKEND_ALIAS + "/" + Config.COMETVISU_BACKEND_LOGIN_ALIAS)
public class LoginResource implements RESTResource {
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/MoveResource.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/MoveResource.java
index eed7c0adb..cbdc0a8e8 100644
--- a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/MoveResource.java
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/MoveResource.java
@@ -23,12 +23,18 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.openhab.core.io.rest.RESTConstants;
import org.openhab.core.io.rest.RESTResource;
import org.openhab.ui.cometvisu.internal.Config;
import org.openhab.ui.cometvisu.internal.util.FileOperationException;
import org.openhab.ui.cometvisu.internal.util.FsUtil;
import org.openhab.ui.cometvisu.internal.util.MountedFile;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;
+import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,9 +48,13 @@ import io.swagger.annotations.ApiResponses;
* Move/renames files for the CometVisu manager.
*
* @author Tobias Bräutigam - Initial contribution
- *
+ * @author Wouter Born - Migrated to JAX-RS Whiteboard Specification
*/
@Component
+@JaxrsResource
+@JaxrsName(Config.COMETVISU_BACKEND_ALIAS + "/fs/move")
+@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
+@JSONRequired
@Path(Config.COMETVISU_BACKEND_ALIAS + "/fs/move")
@Api(Config.COMETVISU_BACKEND_ALIAS + "/fs/move")
public class MoveResource implements RESTResource {
diff --git a/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/MultipartRequestMap.java b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/MultipartRequestMap.java
new file mode 100644
index 000000000..447e7362a
--- /dev/null
+++ b/bundles/org.openhab.ui.cometvisu/src/main/java/org/openhab/ui/cometvisu/internal/backend/rest/MultipartRequestMap.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2010-2020 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.ui.cometvisu.internal.backend.rest;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.Part;
+
+/**
+ * Helper object for getting files from multi-part {@link HttpServletRequest}s.
+ *
+ * @author Wouter Born - Initial contribution
+ */
+public class MultipartRequestMap extends HashMap> {
+
+ private static final long serialVersionUID = 1L;
+ private static final String DEFAULT_ENCODING = "UTF-8";
+
+ private String encoding;
+ private String tempLocation;
+
+ public MultipartRequestMap(HttpServletRequest request) {
+ this(request, System.getProperty("java.io.tmpdir"));
+ }
+
+ public MultipartRequestMap(HttpServletRequest request, String tempLocation) {
+ super();
+ try {
+ this.tempLocation = tempLocation;
+
+ encoding = request.getCharacterEncoding();
+ if (encoding == null) {
+ try {
+ encoding = DEFAULT_ENCODING;
+ request.setCharacterEncoding(DEFAULT_ENCODING);
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException("Unsupported encoding: " + encoding, e);
+ }
+ }
+
+ for (Part part : request.getParts()) {
+ String fileName = part.getSubmittedFileName();
+ if (fileName == null) {
+ putMulti(part.getName(), getValue(part));
+ } else {
+ processFilePart(part, fileName);
+ }
+ }
+ } catch (IOException | ServletException e) {
+ throw new IllegalStateException("Failed to get request parts", e);
+ }
+ }
+
+ public String getStringParameter(String name) {
+ List