2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.upnpcontrol.internal.config;
15 import static org.openhab.binding.upnpcontrol.internal.UpnpControlBindingConstants.DEFAULT_PATH;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.upnpcontrol.internal.util.UpnpControlUtil;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * Class containing the binding configuration parameters. Some helper methods take care of updating the relevant classes
26 * with parameter changes.
28 * @author Mark Herwege - Initial contribution
31 public class UpnpControlBindingConfiguration {
32 private final Logger logger = LoggerFactory.getLogger(UpnpControlBindingConfiguration.class);
34 public String path = DEFAULT_PATH;
36 public void update(UpnpControlBindingConfiguration newConfig) {
37 String newPath = newConfig.path;
39 if (newPath.isEmpty()) {
42 File file = new File(newPath);
43 if (!file.isDirectory()) {
44 file = file.getParentFile();
47 if (!(newPath.endsWith(File.separator) || newPath.endsWith("/"))) {
48 newPath = newPath + File.separator;
56 logger.debug("Storage path updated to {}", path);
58 UpnpControlUtil.bindingConfigurationChanged(path);