From 210ed4879aa29717ced1d9a34308d5eddacc3689 Mon Sep 17 00:00:00 2001 From: Chris Jackson Date: Mon, 17 Oct 2022 00:46:40 +1300 Subject: [PATCH] Fix dependencies and headers in firmware provider (#782) --- feature/pom.xml | 50 ++++++++++--------- org.openhab.binding.zigbee.firmware/pom.xml | 2 +- .../firmware/ZigBeeFirmwareProvider.java | 9 +--- .../firmware/internal/DirectoryFileEntry.java | 16 +++--- .../internal/GithubLibraryReader.java | 27 +++++----- .../zigbee/handler/ZigBeeFirmwareVersion.java | 12 +++++ .../converter/ZigBeeConverterTuyaButton.java | 2 +- .../command/TuyaButtonPressCommand.java | 2 +- .../ZigBeeConverterTuyaButtonTest.java | 2 +- 9 files changed, 67 insertions(+), 55 deletions(-) diff --git a/feature/pom.xml b/feature/pom.xml index ee60f7260..cd62dd770 100644 --- a/feature/pom.xml +++ b/feature/pom.xml @@ -1,11 +1,13 @@ - + + 4.0.0 org.openhab.addons.bundles org.openhab.addons.zigbee.reactor - 3.4.0-SNAPSHOT + 3.4.0-SNAPSHOT org.openhab.addons.features.karaf @@ -50,16 +52,16 @@ org.openhab.binding.zigbee.telegesis ${project.version} - - org.openhab.addons.bundles - org.openhab.binding.zigbee.xbee - ${project.version} - - - org.openhab.addons.bundles - org.openhab.binding.zigbee.firmware - ${project.version} - + + org.openhab.addons.bundles + org.openhab.binding.zigbee.xbee + ${project.version} + + + org.openhab.addons.bundles + org.openhab.binding.zigbee.firmware + ${project.version} + org.openhab.addons.bundles org.openhab.binding.zigbee.serial @@ -122,18 +124,18 @@ true false - - - create-kar - - kar - - - ${project.build.directory}/kar - true - - - + + + create-kar + + kar + + + ${project.build.directory}/kar + true + + + diff --git a/org.openhab.binding.zigbee.firmware/pom.xml b/org.openhab.binding.zigbee.firmware/pom.xml index 4cd537aa4..6aa512a0d 100644 --- a/org.openhab.binding.zigbee.firmware/pom.xml +++ b/org.openhab.binding.zigbee.firmware/pom.xml @@ -5,7 +5,7 @@ org.openhab.addons.bundles org.openhab.addons.zigbee.reactor - 3.3.0-SNAPSHOT + 3.4.0-SNAPSHOT org.openhab.binding.zigbee.firmware diff --git a/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/ZigBeeFirmwareProvider.java b/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/ZigBeeFirmwareProvider.java index c66d1d33f..b1e88fc47 100644 --- a/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/ZigBeeFirmwareProvider.java +++ b/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/ZigBeeFirmwareProvider.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2021 Contributors to the openHAB project + * Copyright (c) 2010-2022 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -60,8 +60,7 @@ protected void activate() { directoryReader.create("https://raw.githubusercontent.com/Koenkk/zigbee-OTA/master"); directoryReader.updateRemoteDirectory(); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("Exception activating ZigBee firmware provider ", e); } } @@ -146,10 +145,6 @@ private Firmware getZigBeeFirmware(@NonNull ThingTypeUID thingTypeUID, Directory builder.withPrerequisiteVersion(directoryEntry.getPrerequisiteVersion()); } - // BufferedInputStream inputStream = new BufferedInputStream(new URL("").openStream()); - - // builder.withInputStream(inputStream); - return builder.build(); } diff --git a/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/DirectoryFileEntry.java b/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/DirectoryFileEntry.java index 9a50ec1dc..2df5c9110 100644 --- a/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/DirectoryFileEntry.java +++ b/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/DirectoryFileEntry.java @@ -1,10 +1,14 @@ /** - * Copyright (c) 2018-2021 by Z-Smart Systems Ltd. + * Copyright (c) 2010-2022 Contributors to the openHAB project * - * 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 + * 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.binding.zigbee.firmware.internal; @@ -13,12 +17,12 @@ import org.openhab.binding.zigbee.handler.ZigBeeFirmwareVersion; /** + * Contains the information describing a firmware directory entry * * @author Chris Jackson * */ public class DirectoryFileEntry { - // private String filename; private Integer manufacturerCode; private Integer imageType; private Integer fileVersion; diff --git a/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/GithubLibraryReader.java b/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/GithubLibraryReader.java index 1cf212bf1..2f9f118c6 100644 --- a/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/GithubLibraryReader.java +++ b/org.openhab.binding.zigbee.firmware/src/main/java/org/openhab/binding/zigbee/firmware/internal/GithubLibraryReader.java @@ -1,10 +1,14 @@ /** - * Copyright (c) 2018-2021 by Z-Smart Systems Ltd. + * Copyright (c) 2010-2022 Contributors to the openHAB project * - * 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 + * 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.binding.zigbee.firmware.internal; @@ -96,7 +100,6 @@ public boolean create(String repositoryAddress) throws Exception { this.httpClient.setExecutor(executor); try { - // httpClient.setFollowRedirects(false); this.httpClient.start(); } catch (Exception e) { logger.debug("ZigBee Firmware Provider: Cannot start HttpClient for GitHub connection!"); @@ -219,8 +222,7 @@ public boolean createLocal(DirectoryFileEntry entry) { try { createMd5Hash(data, entry); } catch (NoSuchAlgorithmException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + logger.error("System does not support MD5"); return false; } @@ -234,11 +236,9 @@ public boolean createLocal(DirectoryFileEntry entry) { outputStream.write(data, 0, data.length); outputStream.close(); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("Can't find file {}", local.getName()); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("IO Exception writing file {}", local.getName(), e); } return true; @@ -260,8 +260,7 @@ public InputStream getInputStream(DirectoryFileEntry entry) { } return inputStream; } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("IO Exception reading file {}", local.getName(), e); return null; } } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeFirmwareVersion.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeFirmwareVersion.java index 7b46db073..daec86eaa 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeFirmwareVersion.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeFirmwareVersion.java @@ -1,3 +1,15 @@ +/** + * Copyright (c) 2010-2022 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.binding.zigbee.handler; import java.util.Objects; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButton.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButton.java index 5311374c2..1fd660512 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButton.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButton.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2021 Contributors to the openHAB project + * Copyright (c) 2010-2022 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/command/TuyaButtonPressCommand.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/command/TuyaButtonPressCommand.java index 1d1b48d41..48c386e97 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/command/TuyaButtonPressCommand.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/command/TuyaButtonPressCommand.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2021 Contributors to the openHAB project + * Copyright (c) 2010-2022 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButtonTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButtonTest.java index 842fa9670..514ba94d5 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButtonTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTuyaButtonTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2021 Contributors to the openHAB project + * Copyright (c) 2010-2022 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information.