mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +01:00
removed boot bundle (#1559)
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
parent
e228d490d8
commit
0f134996f2
@ -34,12 +34,6 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.boot</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.karaf</artifactId>
|
||||
|
@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.audio.AudioException;
|
||||
import org.openhab.core.audio.AudioManager;
|
||||
import org.openhab.core.audio.AudioSink;
|
||||
@ -37,7 +38,6 @@ import org.openhab.core.audio.FileAudioStream;
|
||||
import org.openhab.core.audio.URLAudioStream;
|
||||
import org.openhab.core.audio.UnsupportedAudioFormatException;
|
||||
import org.openhab.core.audio.UnsupportedAudioStreamException;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.config.core.ConfigOptionProvider;
|
||||
import org.openhab.core.config.core.ConfigurableService;
|
||||
import org.openhab.core.config.core.ParameterOption;
|
||||
@ -175,8 +175,7 @@ public class AudioManagerImpl implements AudioManager, ConfigOptionProvider {
|
||||
public void playFile(String fileName, @Nullable String sinkId, @Nullable PercentType volume) throws AudioException {
|
||||
Objects.requireNonNull(fileName, "File cannot be played as fileName is null.");
|
||||
|
||||
File file = new File(
|
||||
ConfigConstants.getConfigFolder() + File.separator + SOUND_DIR + File.separator + fileName);
|
||||
File file = new File(OpenHAB.getConfigFolder() + File.separator + SOUND_DIR + File.separator + fileName);
|
||||
FileAudioStream is = new FileAudioStream(file);
|
||||
play(is, sinkId, volume);
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.audio.internal.AudioManagerTest;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -57,7 +57,7 @@ public class BundledSoundFileHandler implements Closeable {
|
||||
tmpdir = Files.createTempDirectory(null);
|
||||
|
||||
final Path configdir = tmpdir.resolve("configdir");
|
||||
System.setProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT, configdir.toString());
|
||||
System.setProperty(OpenHAB.CONFIG_DIR_PROG_ARGUMENT, configdir.toString());
|
||||
|
||||
mp3FilePath = configdir.resolve("sounds/" + MP3_FILE_NAME).toString();
|
||||
copy("/configuration/sounds/mp3AudioFile.mp3", mp3FilePath);
|
||||
@ -67,7 +67,7 @@ public class BundledSoundFileHandler implements Closeable {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
System.setProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT, ConfigConstants.DEFAULT_CONFIG_FOLDER);
|
||||
System.setProperty(OpenHAB.CONFIG_DIR_PROG_ARGUMENT, OpenHAB.DEFAULT_CONFIG_FOLDER);
|
||||
|
||||
if (tmpdir != null) {
|
||||
try {
|
||||
|
@ -23,6 +23,7 @@ import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.audio.AudioManager;
|
||||
import org.openhab.core.audio.AudioSink;
|
||||
import org.openhab.core.automation.Visibility;
|
||||
@ -30,7 +31,6 @@ import org.openhab.core.automation.type.ActionType;
|
||||
import org.openhab.core.automation.type.ModuleType;
|
||||
import org.openhab.core.automation.type.ModuleTypeProvider;
|
||||
import org.openhab.core.common.registry.ProviderChangeListener;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.config.core.ConfigDescriptionParameter;
|
||||
import org.openhab.core.config.core.ConfigDescriptionParameter.Type;
|
||||
import org.openhab.core.config.core.ConfigDescriptionParameterBuilder;
|
||||
@ -115,7 +115,7 @@ public class MediaActionTypeProvider implements ModuleTypeProvider {
|
||||
*/
|
||||
private List<ParameterOption> getSoundOptions() {
|
||||
List<ParameterOption> options = new ArrayList<>();
|
||||
File soundsDir = Paths.get(ConfigConstants.getConfigFolder(), AudioManager.SOUND_DIR).toFile();
|
||||
File soundsDir = Paths.get(OpenHAB.getConfigFolder(), AudioManager.SOUND_DIR).toFile();
|
||||
if (soundsDir.isDirectory()) {
|
||||
for (String fileName : soundsDir.list()) {
|
||||
if (fileName.contains(".") && !fileName.startsWith(".")) {
|
||||
|
@ -39,9 +39,9 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.automation.module.script.ScriptEngineContainer;
|
||||
import org.openhab.core.automation.module.script.ScriptEngineManager;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.service.AbstractWatchService;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
@ -73,7 +73,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
|
||||
|
||||
@Activate
|
||||
public ScriptFileWatcher(final @Reference ScriptEngineManager manager) {
|
||||
super(ConfigConstants.getConfigFolder() + File.separator + FILE_DIRECTORY);
|
||||
super(OpenHAB.getConfigFolder() + File.separator + FILE_DIRECTORY);
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.automation.Action;
|
||||
import org.openhab.core.automation.AnnotatedActions;
|
||||
import org.openhab.core.automation.Module;
|
||||
@ -37,7 +38,6 @@ import org.openhab.core.automation.type.ActionType;
|
||||
import org.openhab.core.automation.type.ModuleType;
|
||||
import org.openhab.core.automation.type.ModuleTypeProvider;
|
||||
import org.openhab.core.common.registry.ProviderChangeListener;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
@ -196,7 +196,7 @@ public class AnnotatedActionModuleTypeProvider extends BaseModuleHandlerFactory
|
||||
}
|
||||
|
||||
private @Nullable String getConfigNameFromService(Map<String, Object> properties) {
|
||||
Object o = properties.get(ConfigConstants.SERVICE_CONTEXT);
|
||||
Object o = properties.get(OpenHAB.SERVICE_CONTEXT);
|
||||
String configName = null;
|
||||
if (o instanceof String) {
|
||||
configName = (String) o;
|
||||
|
@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.automation.parser.Parser;
|
||||
import org.openhab.core.automation.parser.ParsingException;
|
||||
import org.openhab.core.automation.template.Template;
|
||||
@ -36,7 +37,6 @@ import org.openhab.core.automation.type.ModuleType;
|
||||
import org.openhab.core.automation.type.ModuleTypeProvider;
|
||||
import org.openhab.core.common.registry.Provider;
|
||||
import org.openhab.core.common.registry.ProviderChangeListener;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -87,7 +87,7 @@ public abstract class AbstractFileProvider<@NonNull E> implements Provider<E> {
|
||||
|
||||
public AbstractFileProvider(String root) {
|
||||
this.rootSubdirectory = root;
|
||||
configurationRoots = new String[] { ConfigConstants.getConfigFolder() + File.separator + "automation" };
|
||||
configurationRoots = new String[] { OpenHAB.getConfigFolder() + File.separator + "automation" };
|
||||
}
|
||||
|
||||
public void activate(Map<String, Object> config) {
|
||||
|
@ -24,6 +24,7 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.automation.AnnotatedActions;
|
||||
import org.openhab.core.automation.Visibility;
|
||||
import org.openhab.core.automation.annotation.ActionInput;
|
||||
@ -36,7 +37,6 @@ import org.openhab.core.automation.type.ActionType;
|
||||
import org.openhab.core.automation.type.Input;
|
||||
import org.openhab.core.automation.type.ModuleType;
|
||||
import org.openhab.core.automation.type.Output;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.config.core.ConfigDescriptionParameter;
|
||||
import org.openhab.core.config.core.ParameterOption;
|
||||
import org.openhab.core.test.java.JavaTest;
|
||||
@ -87,7 +87,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest {
|
||||
AnnotatedActionModuleTypeProvider prov = new AnnotatedActionModuleTypeProvider(moduleTypeI18nService);
|
||||
|
||||
Map<String, Object> properties1 = new HashMap<>();
|
||||
properties1.put(ConfigConstants.SERVICE_CONTEXT, "conf1");
|
||||
properties1.put(OpenHAB.SERVICE_CONTEXT, "conf1");
|
||||
prov.addActionProvider(actionProviderConf1, properties1);
|
||||
|
||||
Collection<String> types = prov.getTypes();
|
||||
@ -95,7 +95,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest {
|
||||
assertTrue(types.contains(TEST_ACTION_TYPE_ID));
|
||||
|
||||
Map<String, Object> properties2 = new HashMap<>();
|
||||
properties2.put(ConfigConstants.SERVICE_CONTEXT, "conf2");
|
||||
properties2.put(OpenHAB.SERVICE_CONTEXT, "conf2");
|
||||
prov.addActionProvider(actionProviderConf2, properties2);
|
||||
|
||||
// we only have ONE type but TWO configurations for it
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.openhab.core.boot</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -1,13 +0,0 @@
|
||||
This content is produced and maintained by the openHAB project.
|
||||
|
||||
* Project home: https://www.openhab.org
|
||||
|
||||
== Declared Project Licenses
|
||||
|
||||
This program and the accompanying materials are made available under the terms
|
||||
of the Eclipse Public License 2.0 which is available at
|
||||
https://www.eclipse.org/legal/epl-2.0/.
|
||||
|
||||
== Source Code
|
||||
|
||||
https://github.com/openhab/openhab-core
|
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<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.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.reactor.bundles</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>org.openhab.core.boot</artifactId>
|
||||
|
||||
<name>openHAB Core :: Bundles :: Boot</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bom</groupId>
|
||||
<artifactId>org.openhab.core.bom.compile-model</artifactId>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.model.rule.runtime</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.model.sitemap</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,59 +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.core.internal.icon;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
import org.osgi.service.http.HttpService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This servlet answers requests to /images (which was the openHAB 1 location for icons)
|
||||
* with HTTP 301 (permanently moved) with the new location /icon
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution
|
||||
*/
|
||||
@Component(name = "org.openhab.ui.iconforwarder", immediate = true)
|
||||
public class IconForwarder extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 5220836868829415723L;
|
||||
|
||||
private static final String IMAGES_ALIAS = "/images";
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(IconForwarder.class);
|
||||
|
||||
@Reference
|
||||
protected void setHttpService(HttpService httpService) {
|
||||
try {
|
||||
httpService.registerServlet(IMAGES_ALIAS, this, null, httpService.createDefaultHttpContext());
|
||||
} catch (Exception e) {
|
||||
logger.error("Could not register icon forwarder servlet: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void unsetHttpService(HttpService httpService) {
|
||||
httpService.unregister(IMAGES_ALIAS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
resp.setStatus(301);
|
||||
resp.setHeader("Location", "/icon" + req.getPathInfo());
|
||||
resp.setHeader("Connection", "close");
|
||||
}
|
||||
}
|
@ -1,118 +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.core.internal.item;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openhab.core.model.core.ModelRepositoryChangeListener;
|
||||
import org.openhab.core.model.sitemap.SitemapProvider;
|
||||
import org.openhab.core.model.sitemap.sitemap.Sitemap;
|
||||
import org.openhab.core.model.sitemap.sitemap.SitemapFactory;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.DefaultImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.FrameImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.SitemapImpl;
|
||||
import org.openhab.core.model.sitemap.sitemap.impl.TextImpl;
|
||||
import org.openhab.core.thing.Channel;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingRegistry;
|
||||
import org.openhab.core.thing.link.ItemChannelLinkRegistry;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
/**
|
||||
* This class dynamically provides a default sitemap which comprises
|
||||
* all group items that do not have any parent group.
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution
|
||||
*/
|
||||
@Component(name = "org.openhab.defaultsitemapprovider")
|
||||
public class DefaultSitemapProvider implements SitemapProvider {
|
||||
|
||||
private static final String SITEMAP_NAME = "_default";
|
||||
|
||||
private ThingRegistry thingRegistry;
|
||||
private ItemChannelLinkRegistry linkRegistry;
|
||||
|
||||
@Reference
|
||||
protected void setThingRegistry(ThingRegistry thingRegistry) {
|
||||
this.thingRegistry = thingRegistry;
|
||||
}
|
||||
|
||||
protected void unsetThingRegistry(ThingRegistry thingRegistry) {
|
||||
this.thingRegistry = null;
|
||||
}
|
||||
|
||||
@Reference
|
||||
protected void setItemChannelLinkRegistry(ItemChannelLinkRegistry linkRegistry) {
|
||||
this.linkRegistry = linkRegistry;
|
||||
}
|
||||
|
||||
protected void unsetItemChannelLinkRegistry(ItemChannelLinkRegistry linkRegistry) {
|
||||
this.linkRegistry = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sitemap getSitemap(String sitemapName) {
|
||||
if (sitemapName.equals(SITEMAP_NAME)) {
|
||||
SitemapImpl sitemap = (SitemapImpl) SitemapFactory.eINSTANCE.createSitemap();
|
||||
FrameImpl mainFrame = (FrameImpl) SitemapFactory.eINSTANCE.createFrame();
|
||||
|
||||
FrameImpl thingFrame = (FrameImpl) SitemapFactory.eINSTANCE.createFrame();
|
||||
thingFrame.setLabel("Things");
|
||||
|
||||
sitemap.setLabel("Home");
|
||||
sitemap.setName(SITEMAP_NAME);
|
||||
|
||||
for (Thing thing : thingRegistry.getAll()) {
|
||||
TextImpl thingWidget = (TextImpl) SitemapFactory.eINSTANCE.createText();
|
||||
thingWidget.setLabel(thing.getLabel());
|
||||
thingWidget.setIcon("player");
|
||||
|
||||
for (Channel channel : thing.getChannels()) {
|
||||
Set<String> items = linkRegistry.getLinkedItemNames(channel.getUID());
|
||||
if (!items.isEmpty()) {
|
||||
DefaultImpl widget = (DefaultImpl) SitemapFactory.eINSTANCE.createDefault();
|
||||
widget.setItem(items.iterator().next());
|
||||
thingWidget.getChildren().add(widget);
|
||||
}
|
||||
}
|
||||
if (!thingWidget.getChildren().isEmpty()) {
|
||||
thingFrame.getChildren().add(thingWidget);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mainFrame.getChildren().isEmpty()) {
|
||||
sitemap.getChildren().add(mainFrame);
|
||||
}
|
||||
if (!thingFrame.getChildren().isEmpty()) {
|
||||
sitemap.getChildren().add(thingFrame);
|
||||
}
|
||||
return sitemap;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSitemapNames() {
|
||||
return Collections.singleton(SITEMAP_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModelChangeListener(ModelRepositoryChangeListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeModelChangeListener(ModelRepositoryChangeListener listener) {
|
||||
}
|
||||
}
|
@ -12,11 +12,16 @@
|
||||
*/
|
||||
package org.openhab.core.config.core;
|
||||
|
||||
import org.openhab.core.OpenHAB;
|
||||
|
||||
/**
|
||||
* This class provides constants relevant for the configuration of openHAB
|
||||
*
|
||||
* @deprecated Use {@link OpenHAB} instead.
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution
|
||||
*/
|
||||
@Deprecated
|
||||
public class ConfigConstants {
|
||||
|
||||
/** The program argument name for setting the user data directory path */
|
||||
|
@ -32,7 +32,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.Constants;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
@ -166,14 +166,14 @@ public class ConfigDispatcher {
|
||||
|
||||
private Configuration getConfigurationWithContext(String pidWithContext)
|
||||
throws IOException, InvalidSyntaxException {
|
||||
if (!pidWithContext.contains(ConfigConstants.SERVICE_CONTEXT_MARKER)) {
|
||||
if (!pidWithContext.contains(OpenHAB.SERVICE_CONTEXT_MARKER)) {
|
||||
throw new IllegalArgumentException("Given PID should be followed by a context");
|
||||
}
|
||||
String pid = pidWithContext.split(ConfigConstants.SERVICE_CONTEXT_MARKER)[0];
|
||||
String context = pidWithContext.split(ConfigConstants.SERVICE_CONTEXT_MARKER)[1];
|
||||
String pid = pidWithContext.split(OpenHAB.SERVICE_CONTEXT_MARKER)[0];
|
||||
String context = pidWithContext.split(OpenHAB.SERVICE_CONTEXT_MARKER)[1];
|
||||
|
||||
Configuration[] configs = configAdmin.listConfigurations("(&(" + ConfigurationAdmin.SERVICE_FACTORYPID + "="
|
||||
+ pid + ")(" + ConfigConstants.SERVICE_CONTEXT + "=" + context + "))");
|
||||
+ pid + ")(" + OpenHAB.SERVICE_CONTEXT + "=" + context + "))");
|
||||
|
||||
if (configs == null || configs.length == 0) {
|
||||
return null;
|
||||
@ -192,7 +192,7 @@ public class ConfigDispatcher {
|
||||
for (String orphanPID : exclusivePIDMap.getOrphanPIDs()) {
|
||||
try {
|
||||
Configuration configuration = null;
|
||||
if (orphanPID.contains(ConfigConstants.SERVICE_CONTEXT_MARKER)) {
|
||||
if (orphanPID.contains(OpenHAB.SERVICE_CONTEXT_MARKER)) {
|
||||
configuration = getConfigurationWithContext(orphanPID);
|
||||
} else {
|
||||
configuration = configAdmin.getConfiguration(orphanPID, null);
|
||||
@ -311,10 +311,10 @@ public class ConfigDispatcher {
|
||||
|
||||
pid = exclusivePID;
|
||||
|
||||
if (exclusivePID.contains(ConfigConstants.SERVICE_CONTEXT_MARKER)) {
|
||||
if (exclusivePID.contains(OpenHAB.SERVICE_CONTEXT_MARKER)) {
|
||||
// split pid and context
|
||||
pid = exclusivePID.split(ConfigConstants.SERVICE_CONTEXT_MARKER)[0];
|
||||
context = exclusivePID.split(ConfigConstants.SERVICE_CONTEXT_MARKER)[1];
|
||||
pid = exclusivePID.split(OpenHAB.SERVICE_CONTEXT_MARKER)[0];
|
||||
context = exclusivePID.split(OpenHAB.SERVICE_CONTEXT_MARKER)[1];
|
||||
}
|
||||
|
||||
lines = lines.subList(1, lines.size());
|
||||
@ -352,7 +352,7 @@ public class ConfigDispatcher {
|
||||
configMap.put(configuration, new Properties());
|
||||
} else if (context != null && exclusivePIDMap.contains(exclusivePID)) {
|
||||
Dictionary p = new Properties();
|
||||
p.put(ConfigConstants.SERVICE_CONTEXT, context);
|
||||
p.put(OpenHAB.SERVICE_CONTEXT, context);
|
||||
configMap.put(configuration, p);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.nio.file.WatchEvent.Kind;
|
||||
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.service.AbstractWatchService;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
@ -52,9 +52,9 @@ public class ConfigDispatcherFileWatcher extends AbstractWatchService {
|
||||
private static String getPathToWatch() {
|
||||
String progArg = System.getProperty(SERVICEDIR_PROG_ARGUMENT);
|
||||
if (progArg != null) {
|
||||
return ConfigConstants.getConfigFolder() + File.separator + progArg;
|
||||
return OpenHAB.getConfigFolder() + File.separator + progArg;
|
||||
} else {
|
||||
return ConfigConstants.getConfigFolder() + File.separator + SERVICES_FOLDER;
|
||||
return OpenHAB.getConfigFolder() + File.separator + SERVICES_FOLDER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -45,7 +45,7 @@ public class InstanceUUID {
|
||||
public static synchronized String get() {
|
||||
if (uuid == null) {
|
||||
try {
|
||||
File file = new File(ConfigConstants.getUserDataFolder() + File.separator + UUID_FILE_NAME);
|
||||
File file = new File(OpenHAB.getUserDataFolder() + File.separator + UUID_FILE_NAME);
|
||||
if (!file.exists()) {
|
||||
uuid = java.util.UUID.randomUUID().toString();
|
||||
writeFile(file, uuid);
|
||||
|
@ -20,7 +20,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
|
||||
/**
|
||||
* @author Kai Kreuzer - Initial contribution
|
||||
@ -39,7 +39,7 @@ public class InstanceUUIDTest {
|
||||
public void readFromPersistedFile() throws IOException {
|
||||
// we first need to remove the cached value
|
||||
InstanceUUID.uuid = null;
|
||||
Path path = Paths.get(ConfigConstants.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
||||
Path path = Paths.get(OpenHAB.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.write(path, "123".getBytes());
|
||||
String uuid = InstanceUUID.get();
|
||||
@ -50,7 +50,7 @@ public class InstanceUUIDTest {
|
||||
public void ignoreEmptyFile() throws IOException {
|
||||
// we first need to remove the cached value
|
||||
InstanceUUID.uuid = null;
|
||||
Path path = Paths.get(ConfigConstants.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
||||
Path path = Paths.get(OpenHAB.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
||||
Files.createDirectories(path.getParent());
|
||||
Files.write(path, "".getBytes());
|
||||
String uuid = InstanceUUID.get();
|
||||
|
@ -37,9 +37,9 @@ import org.jose4j.jwt.JwtClaims;
|
||||
import org.jose4j.jwt.consumer.JwtConsumer;
|
||||
import org.jose4j.jwt.consumer.JwtConsumerBuilder;
|
||||
import org.jose4j.lang.JoseException;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.auth.Authentication;
|
||||
import org.openhab.core.auth.User;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -54,7 +54,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class JwtHelper {
|
||||
private final Logger logger = LoggerFactory.getLogger(JwtHelper.class);
|
||||
|
||||
private static final String KEY_FILE_PATH = ConfigConstants.getUserDataFolder() + File.separator + "secrets"
|
||||
private static final String KEY_FILE_PATH = OpenHAB.getUserDataFolder() + File.separator + "secrets"
|
||||
+ File.separator + "rsa_json_web_key.json";
|
||||
|
||||
private static final String ISSUER_NAME = "openhab";
|
||||
|
@ -23,7 +23,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
import org.osgi.framework.Constants;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
@ -95,7 +95,7 @@ public class ConfigurationService {
|
||||
*/
|
||||
public Configuration update(String configId, Configuration newConfiguration, boolean override) throws IOException {
|
||||
org.osgi.service.cm.Configuration configuration = null;
|
||||
if (newConfiguration.containsKey(ConfigConstants.SERVICE_CONTEXT)) {
|
||||
if (newConfiguration.containsKey(OpenHAB.SERVICE_CONTEXT)) {
|
||||
try {
|
||||
configuration = getConfigurationWithContext(configId);
|
||||
} catch (InvalidSyntaxException e) {
|
||||
|
@ -37,8 +37,8 @@ import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.auth.Role;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.config.core.ConfigDescription;
|
||||
import org.openhab.core.config.core.ConfigDescriptionRegistry;
|
||||
import org.openhab.core.config.core.ConfigUtil;
|
||||
@ -283,7 +283,7 @@ public class ConfigurableServiceResource implements RESTResource {
|
||||
String label = (String) serviceReference.getProperty(ConfigurableService.SERVICE_PROPERTY_LABEL);
|
||||
if (label == null) { // for multi context services the label can be changed and must be read from config
|
||||
// admin.
|
||||
label = configurationService.getProperty(id, ConfigConstants.SERVICE_CONTEXT);
|
||||
label = configurationService.getProperty(id, OpenHAB.SERVICE_CONTEXT);
|
||||
}
|
||||
String category = (String) serviceReference.getProperty(ConfigurableService.SERVICE_PROPERTY_CATEGORY);
|
||||
String configDescriptionURI = (String) serviceReference
|
||||
|
@ -34,7 +34,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.model.core.ModelParser;
|
||||
import org.openhab.core.model.core.ModelRepository;
|
||||
import org.openhab.core.service.AbstractWatchService;
|
||||
@ -80,7 +80,7 @@ public class FolderObserver extends AbstractWatchService {
|
||||
|
||||
@Activate
|
||||
public FolderObserver(final @Reference ModelRepository modelRepo, final @Reference ReadyService readyService) {
|
||||
super(ConfigConstants.getConfigFolder());
|
||||
super(OpenHAB.getConfigFolder());
|
||||
|
||||
this.modelRepository = modelRepo;
|
||||
this.readyService = readyService;
|
||||
@ -123,7 +123,7 @@ public class FolderObserver extends AbstractWatchService {
|
||||
folderFileExtMap.put(foldername, fileExts);
|
||||
} else {
|
||||
logger.warn("Directory '{}' does not exist in '{}'. Please check your configuration settings!",
|
||||
foldername, ConfigConstants.getConfigFolder());
|
||||
foldername, OpenHAB.getConfigFolder());
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ public class FolderObserver extends AbstractWatchService {
|
||||
* @return the corresponding {@link File}
|
||||
*/
|
||||
private File getFile(String filename) {
|
||||
return new File(ConfigConstants.getConfigFolder() + File.separator + filename);
|
||||
return new File(OpenHAB.getConfigFolder() + File.separator + filename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@ import java.nio.file.Paths;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
/**
|
||||
@ -28,23 +27,30 @@ import org.osgi.framework.FrameworkUtil;
|
||||
*/
|
||||
public class OpenHAB {
|
||||
|
||||
/** the service pid used for the definition of the base package and addons */
|
||||
/** The program argument name for setting the user data directory path */
|
||||
public static final String USERDATA_DIR_PROG_ARGUMENT = "openhab.userdata";
|
||||
|
||||
/** The program argument name for setting the main config directory path */
|
||||
public static final String CONFIG_DIR_PROG_ARGUMENT = "openhab.conf";
|
||||
|
||||
/** The default main configuration directory name */
|
||||
public static final String DEFAULT_CONFIG_FOLDER = "conf";
|
||||
|
||||
/** The default user data directory name */
|
||||
public static final String DEFAULT_USERDATA_FOLDER = "userdata";
|
||||
|
||||
/** The property to recognize a service instance created by a service factory */
|
||||
public static final String SERVICE_CONTEXT = "openhab.servicecontext";
|
||||
|
||||
/** The property to separate service PIDs from their contexts */
|
||||
public static final String SERVICE_CONTEXT_MARKER = "#";
|
||||
|
||||
/** the service pid used for the definition of the base package and add-ons */
|
||||
public static final String ADDONS_SERVICE_PID = "org.openhab.addons";
|
||||
|
||||
/** the configuraton parameter name used for the base package */
|
||||
public static final String CFG_PACKAGE = "package";
|
||||
|
||||
private static String substringAfterLast(String str, String separator) {
|
||||
int index = str.lastIndexOf(separator);
|
||||
return index == -1 || index == str.length() - separator.length() ? ""
|
||||
: str.substring(index + separator.length());
|
||||
}
|
||||
|
||||
private static String substringBeforeLast(String str, String separator) {
|
||||
int index = str.lastIndexOf(separator);
|
||||
return index == -1 ? str : str.substring(0, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current openHAB version, retrieving the information from the core bundle version.
|
||||
*
|
||||
@ -63,9 +69,14 @@ public class OpenHAB {
|
||||
return versionString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the build number as it can be found in the version.properties file.
|
||||
*
|
||||
* @return The build string or "Unknown Build No." if none can be identified.
|
||||
*/
|
||||
public static String buildString() {
|
||||
Properties prop = new Properties();
|
||||
Path versionFilePath = Paths.get(ConfigConstants.getUserDataFolder(), "etc", "version.properties");
|
||||
Path versionFilePath = Paths.get(getUserDataFolder(), "etc", "version.properties");
|
||||
try (FileInputStream fis = new FileInputStream(versionFilePath.toFile())) {
|
||||
prop.load(fis);
|
||||
String buildNo = prop.getProperty("build-no");
|
||||
@ -77,4 +88,47 @@ public class OpenHAB {
|
||||
}
|
||||
return "Unknown Build No.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration folder path name. The main config folder <code><openhab-home>/conf</code> can be
|
||||
* overwritten by setting the System property <code>openhab.conf</code>.
|
||||
*
|
||||
* @return the configuration folder path name
|
||||
*/
|
||||
public static String getConfigFolder() {
|
||||
String progArg = System.getProperty(CONFIG_DIR_PROG_ARGUMENT);
|
||||
if (progArg != null) {
|
||||
return progArg;
|
||||
} else {
|
||||
return DEFAULT_CONFIG_FOLDER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user data folder path name. The main user data folder <code><openhab-home>/userdata</code> can
|
||||
* be
|
||||
* overwritten by setting
|
||||
* the System property <code>openhab.userdata</code>.
|
||||
*
|
||||
* @return the user data folder path name
|
||||
*/
|
||||
public static String getUserDataFolder() {
|
||||
String progArg = System.getProperty(USERDATA_DIR_PROG_ARGUMENT);
|
||||
if (progArg != null) {
|
||||
return progArg;
|
||||
} else {
|
||||
return DEFAULT_USERDATA_FOLDER;
|
||||
}
|
||||
}
|
||||
|
||||
private static String substringAfterLast(String str, String separator) {
|
||||
int index = str.lastIndexOf(separator);
|
||||
return index == -1 || index == str.length() - separator.length() ? ""
|
||||
: str.substring(index + separator.length());
|
||||
}
|
||||
|
||||
private static String substringBeforeLast(String str, String separator) {
|
||||
int index = str.lastIndexOf(separator);
|
||||
return index == -1 ? str : str.substring(0, index);
|
||||
}
|
||||
}
|
@ -45,7 +45,6 @@
|
||||
<module>org.openhab.core.thing.xml</module>
|
||||
<module>org.openhab.core.transform</module>
|
||||
<module>org.openhab.core.voice</module>
|
||||
<module>org.openhab.core.boot</module>
|
||||
<module>org.openhab.core.karaf</module>
|
||||
<module>org.openhab.core.io.bin2json</module>
|
||||
<module>org.openhab.core.io.console</module>
|
||||
|
@ -455,7 +455,6 @@
|
||||
<!-- This bundle needs to be started early as it registers the 404 and startup pages on Jetty -->
|
||||
<!-- It is temperarily disabled due to https://github.com/openhab/openhab-core/issues/422 -->
|
||||
<!-- <bundle start-level="30">mvn:org.openhab.core.bundles/org.openhab.ui.start/${project.version}</bundle> -->
|
||||
<bundle start-level="90">mvn:org.openhab.core.bundles/org.openhab.core.boot/${project.version}</bundle>
|
||||
<bundle>mvn:org.openhab.core.bundles/org.openhab.core.karaf/${project.version}</bundle>
|
||||
<config name="org.openhab.core.audio">
|
||||
defaultSink = enhancedjavasound
|
||||
|
@ -39,7 +39,7 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.openhab.core.config.core.ConfigConstants;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.model.core.ModelParser;
|
||||
import org.openhab.core.model.core.ModelRepository;
|
||||
import org.openhab.core.model.core.ModelRepositoryChangeListener;
|
||||
@ -113,12 +113,12 @@ public class FolderObserverTest extends JavaOSGiTest {
|
||||
* The main configuration folder's path is saved in the defaultWatchedDir variable
|
||||
* in order to be restored after all the tests are finished.
|
||||
* For the purpose of the FolderObserverTest class a new folder is created.
|
||||
* Its path is set to the ConfigConstants.CONFIG_DIR_PROG_ARGUMENT property.
|
||||
* Its path is set to the OpenHAB.CONFIG_DIR_PROG_ARGUMENT property.
|
||||
*/
|
||||
private void setupWatchedDirectory() {
|
||||
defaultWatchedDir = System.getProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT);
|
||||
defaultWatchedDir = System.getProperty(OpenHAB.CONFIG_DIR_PROG_ARGUMENT);
|
||||
WATCHED_DIRECTORY.mkdirs();
|
||||
System.setProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT, WATCHED_DIRECTORY.getPath());
|
||||
System.setProperty(OpenHAB.CONFIG_DIR_PROG_ARGUMENT, WATCHED_DIRECTORY.getPath());
|
||||
EXISTING_SUBDIR_PATH.mkdirs();
|
||||
}
|
||||
|
||||
@ -147,9 +147,9 @@ public class FolderObserverTest extends JavaOSGiTest {
|
||||
|
||||
modelRepo.clean();
|
||||
if (defaultWatchedDir != null) {
|
||||
System.setProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT, defaultWatchedDir);
|
||||
System.setProperty(OpenHAB.CONFIG_DIR_PROG_ARGUMENT, defaultWatchedDir);
|
||||
} else {
|
||||
System.clearProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT);
|
||||
System.clearProperty(OpenHAB.CONFIG_DIR_PROG_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user