Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update fork #1

Merged
merged 52 commits into from
Apr 13, 2020
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c03217d
[bluetooth] Fix for AM43 and Airthings devices not being discovered. …
cpmeister Apr 1, 2020
0f863af
Fixing docs from ipAddress to host (#7267)
oybed Apr 1, 2020
1c4d85a
[checkstyle] Treat packages containing .dto. the same way as java cla…
seime Apr 1, 2020
dcf07de
[rfxcom] EOF fix (#7272)
paulianttila Apr 2, 2020
552b54b
[insteon] add console commands to help with troubleshooting (#7251)
robnielsen Apr 3, 2020
5cef8d3
[Jeelink] Declaration of Bridges in Items Files (#7268)
dsgrafiniert Apr 3, 2020
a58ffb4
[gardena] Adapt to the official wording (#7277)
rettichschnidi Apr 3, 2020
c1e6d5a
[etherrain] EtherRain Binding initial contribution (#5634)
dfad1469 Apr 3, 2020
2102cb0
Fix errors and changes after importing add-ons in Eclipse (#7270)
wborn Apr 3, 2020
d8c7e00
[miio] adding new devices (#7273)
marcelrv Apr 3, 2020
286f4b6
[bluetooth] Refactor and unify BluetoothAdapter implementation logic …
cpmeister Apr 4, 2020
6b95a8b
[fronius] Add new channels and fix documentation (#7247)
hypetsch Apr 4, 2020
cf962f2
Use diamond operator and loose coupling (#7280)
wborn Apr 4, 2020
3d9a35d
[marytts] Fix java.lang.NoClassDefFoundError: Jama/Matrix (#7284)
wborn Apr 4, 2020
dbc0144
[boschindigo] Fix dependency version for indego library (#7288)
J-N-K Apr 4, 2020
660b858
Fix trivial SAT findings (#7290)
wborn Apr 4, 2020
9a16309
[doorbird] Minor Documentation updates (#7293)
mhilbush Apr 4, 2020
dcfab82
Increase timeout to account for slower machines. (#7287)
cpmeister Apr 4, 2020
09b4416
[tradfri] Add missing representation property 'host' in in gateway de…
seime Apr 5, 2020
a985e07
Fix SAT NoEmptyLineSeparatorCheck findings (#7296)
wborn Apr 5, 2020
e9f3b7c
[mihome] Update README.md (#7281)
Terr4 Apr 5, 2020
1ededc4
[pjlink] enhanced logging (show byte array in addition to string) (#7…
nils Apr 5, 2020
02c1bcb
[mail] Correctly named STARTTLS and a few small improvements (#7292)
kaikreuzer Apr 5, 2020
3b49fb9
[satel] Action for reading the event log added (#7282)
druciak Apr 5, 2020
669ec98
[lgwebos] Fix initialize and dispose (#7301)
lolodomo Apr 5, 2020
2f2736b
[hueemulation] Fix broken fallback address (#7305)
wborn Apr 5, 2020
0ef20dc
[sagercaster] Sager Weather Caster Binding initial contribution (#4754)
clinique Apr 5, 2020
4d6ba4c
[lgwebos] Ignore power off command when the TV is already off (#7300)
lolodomo Apr 5, 2020
46c6cab
[lgwebos] Update the thing configuration only if the key is different…
lolodomo Apr 5, 2020
b891413
[insteon] Add support for Beep and LED on/off features to various mod…
tommycw1 Apr 5, 2020
233f516
Use .isEmpty() instead of counting elements with .size() (#7307)
wborn Apr 5, 2020
5673628
[nikohomecontrol] Small README updates. (#7311)
mherwege Apr 6, 2020
45cf759
[nikohomecontrol] Removed dead code (#7314)
mherwege Apr 6, 2020
bb95861
Update maintainers team in CODEOWNERS (#7317)
wborn Apr 7, 2020
cc61af2
[miio] Add Xiaomi cloud logon (token download) and map download (#7255)
marcelrv Apr 7, 2020
e2279f2
Add null annotations to MarketplaceRuleTemplateProvider (#7319)
wborn Apr 7, 2020
415f6b6
[neohub] bug fix for new hub firmware (#7323)
andrewfg Apr 8, 2020
051f3e4
[chromecast] Update API lib to 0.11.3 (#7327)
wborn Apr 9, 2020
4b714d4
[wemo] Fix InboxFilterCriteria deprecation (#7329)
wborn Apr 9, 2020
efab78f
[nikohomecontrol] Small README update. (#7330)
Dries-Vandenneucker Apr 9, 2020
5d01bb7
[nikohomecontrol] Small README update. (#7331)
Dries-Vandenneucker Apr 9, 2020
8a99893
[lgwebos] Avoid thing updates when the thing handler is already dispo…
lolodomo Apr 10, 2020
9527486
[openweathermap] Added apparent temperature channel (#7335)
cweitkamp Apr 11, 2020
9267183
[daikin] Support AUTO fan mode with Airbase (#7340)
jimtng Apr 11, 2020
b091ac6
[daikin] Update doc to include fandir channel previously omitted (#7341)
jimtng Apr 11, 2020
66354b7
[insteon] Improved support for 2334 Keypad Dimmer and 2487S Keypad Sw…
tommycw1 Apr 12, 2020
715322a
[dwdpollenflug] Initial Contribution (#7298)
DerOetzi Apr 12, 2020
b19b0b2
[miio] change brightness for Philips bulbs (#7349)
marcelrv Apr 13, 2020
83eabef
[homematic] Replaced deprecated constructors and use builders (#7352)
MHerbst Apr 13, 2020
7ba2503
[insteon] Improve hub message processing (#7347)
jsetton Apr 13, 2020
850c2c2
[weathercompany] Fix language in thing example (#7357)
mhilbush Apr 13, 2020
b59f3cf
[extensionservice] Add more null annotations (#7348)
wborn Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[extensionservice] Add more null annotations (openhab#7348)
* [extensionservice] Add more null annotations
* Use cachedNodes array again for easy atomic assignments
* Prevent code from messing with cachedNodes

Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn authored Apr 13, 2020
commit b59f3cfdb1a41ec3da64d2c6fd4072912bfd07e2
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
*/
package org.openhab.extensionservice.marketplace;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.extension.Extension;

/**
@@ -20,6 +22,7 @@
* @author Kai Kreuzer - Initial contribution and API
*
*/
@NonNullByDefault
public class MarketplaceExtension extends Extension {

// constants used to construct extension IDs
@@ -39,7 +42,8 @@ public class MarketplaceExtension extends Extension {
private transient String packageFormat;

public MarketplaceExtension(String id, String type, String label, String version, String link, boolean installed,
String description, String backgroundColor, String imageLink, String downloadUrl, String packageFormat) {
String description, @Nullable String backgroundColor, String imageLink, String downloadUrl,
String packageFormat) {
super(id, type, label, version, link, installed, description, backgroundColor, imageLink);
this.downloadUrl = downloadUrl;
this.packageFormat = packageFormat;
Original file line number Diff line number Diff line change
@@ -12,8 +12,7 @@
*/
package org.openhab.extensionservice.marketplace;

import org.openhab.extensionservice.marketplace.MarketplaceExtension;
import org.openhab.extensionservice.marketplace.MarketplaceHandlerException;
import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* This interface can be implemented by services that want to register as handlers for specific marketplace extension
@@ -27,6 +26,7 @@
* @author Kai Kreuzer - Initial contribution and API
*
*/
@NonNullByDefault
public interface MarketplaceExtensionHandler {

/**
Original file line number Diff line number Diff line change
@@ -12,14 +12,15 @@
*/
package org.openhab.extensionservice.marketplace;

import org.openhab.extensionservice.marketplace.MarketplaceExtensionHandler;
import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* This is an exception that can be thrown by {@link MarketplaceExtensionHandler}s if some operation fails.
*
* @author Kai Kreuzer - Initial contribution and API
*
*/
@NonNullByDefault
public class MarketplaceHandlerException extends Exception {

private static final long serialVersionUID = -5652014141471618161L;
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.config.xml.util.XmlDocumentReader;
import org.openhab.extensionservice.marketplace.internal.MarketplaceProxy;
import org.openhab.extensionservice.marketplace.internal.MarketplaceXMLReader;
import org.openhab.extensionservice.marketplace.internal.model.Marketplace;
import org.openhab.extensionservice.marketplace.internal.model.Node;
import org.slf4j.Logger;
@@ -40,27 +40,27 @@
* @author Kai Kreuzer - Initial contribution and API
*
*/
@NonNullByDefault
public class MarketplaceProxy {

private static final String MP_URL = "https://marketplace.eclipse.org/taxonomy/term/4988%2C4396/api/p?client=org.eclipse.smarthome";
private static final long REFRESH_INTERVAL = 3600;
private static final long RETRY_DELAY = 60;

private final Logger logger = LoggerFactory.getLogger(MarketplaceProxy.class);

private static final String MP_URL = "https://marketplace.eclipse.org/taxonomy/term/4988%2C4396/api/p?client=org.eclipse.smarthome";
private Node[] cachedNodes = new Node[0];
private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
private final ScheduledFuture<?> refreshJob;
private final URL url;
private Node[] cachedNodes = null;
private long refresh_interval = 3600;
private long retry_delay = 60;
private ScheduledExecutorService executorService;
private ScheduledFuture<?> refreshJob;

/**
* Creates a new instance, which immediately schedules a synchronization with the marketplace content.
*/
public MarketplaceProxy() {
try {
url = new URL(MP_URL);
this.executorService = Executors.newSingleThreadScheduledExecutor();
this.refreshJob = this.executorService.scheduleWithFixedDelay(() -> refresh(), 0, refresh_interval,
TimeUnit.SECONDS);
refreshJob = executorService.scheduleWithFixedDelay(this::refresh, 0, REFRESH_INTERVAL, TimeUnit.SECONDS);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Something is very wrong - cannot instantiate URL " + MP_URL);
}
@@ -72,7 +72,7 @@ public MarketplaceProxy() {
* @return list of marketplace nodes
*/
public List<Node> getNodes() {
return cachedNodes != null ? Arrays.asList(cachedNodes) : Collections.emptyList();
return Collections.unmodifiableList(Arrays.asList(cachedNodes));
}

/**
@@ -81,24 +81,26 @@ public List<Node> getNodes() {
public synchronized void refresh() {
XmlDocumentReader<Marketplace> reader = new MarketplaceXMLReader();
try {
@Nullable
Marketplace result = reader.readFromXML(url);
cachedNodes = result.categories[0].nodes;
if (result != null) {
cachedNodes = result.categories[0].nodes;
}
} catch (Exception e) {
if (cachedNodes == null) {
if (cachedNodes.length == 0) {
logger.warn("Failed downloading Marketplace entries: {}", e.getMessage());
logger.warn("Retrying again in a minute");
this.executorService.schedule(() -> refresh(), retry_delay, TimeUnit.SECONDS);
executorService.schedule(this::refresh, RETRY_DELAY, TimeUnit.SECONDS);
} else {
logger.debug("Cannot access IoT Marketplace - will continue to use cached results: {}", e.getMessage());
}
}
}

public void dispose() {
if (this.refreshJob != null && !this.refreshJob.isCancelled()) {
this.refreshJob.cancel(true);
this.refreshJob = null;
if (!refreshJob.isCancelled()) {
refreshJob.cancel(true);
}
this.executorService.shutdown();
executorService.shutdown();
}
}
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
*/
package org.openhab.extensionservice.marketplace.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.config.xml.util.XmlDocumentReader;
import org.openhab.extensionservice.marketplace.internal.model.Category;
import org.openhab.extensionservice.marketplace.internal.model.Marketplace;
@@ -25,18 +26,19 @@
* @author Kai Kreuzer - Initial contribution and API
*
*/
@NonNullByDefault
public class MarketplaceXMLReader extends XmlDocumentReader<Marketplace> {

public MarketplaceXMLReader() {
super.setClassLoader(Marketplace.class.getClassLoader());
}

@Override
public void registerConverters(XStream xstream) {
public void registerConverters(@NonNullByDefault({}) XStream xstream) {
}

@Override
public void registerAliases(XStream xstream) {
public void registerAliases(@NonNullByDefault({}) XStream xstream) {
xstream.alias("marketplace", Marketplace.class);
xstream.addImplicitArray(Marketplace.class, "categories");
xstream.alias("category", Category.class);
Original file line number Diff line number Diff line change
@@ -12,8 +12,6 @@
*/
package org.openhab.extensionservice.marketplace.internal.model;

import org.openhab.extensionservice.marketplace.internal.model.Node;

/**
* This is a category that holds the nodes as individual entries of the marketplace.
*
Original file line number Diff line number Diff line change
@@ -12,17 +12,18 @@
*/
package org.openhab.extensionservice.marketplace.internal.model;

import org.openhab.extensionservice.marketplace.internal.model.Category;
import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* This is the parent object that holds the category of the market.
*
* @author Kai Kreuzer - Initial contribution and API
*/
@NonNullByDefault
public class Marketplace {

/**
* The category of the marketplace
*/
public Category[] categories;
public Category[] categories = new Category[0];
}