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

[innogysmarthome] Remove org.apache.commons #14407

Merged
merged 6 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Special {@link Action} needed to control shutters.
*
* @author Marco Mans
* @author Marco Mans - Initial contribution
*/
public class ShutterAction extends Action {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
Expand All @@ -58,6 +57,7 @@
import org.openhab.binding.innogysmarthome.internal.listener.EventListener;
import org.openhab.binding.innogysmarthome.internal.manager.DeviceStructureManager;
import org.openhab.binding.innogysmarthome.internal.manager.FullDeviceManager;
import org.openhab.binding.innogysmarthome.internal.util.ExceptionUtils;
import org.openhab.core.auth.client.oauth2.AccessTokenRefreshListener;
import org.openhab.core.auth.client.oauth2.AccessTokenResponse;
import org.openhab.core.auth.client.oauth2.OAuthClientService;
Expand Down Expand Up @@ -954,7 +954,7 @@ private boolean handleClientException(final Exception e) {
isReinitialize = false;
Thread.currentThread().interrupt();
} else if (e instanceof ExecutionException) {
logger.debug("ExecutionException: {}", ExceptionUtils.getRootCauseMessage(e));
logger.debug("ExecutionException: {}", ExceptionUtils.getRootThrowable(e).getMessage());
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
updateStatus(ThingStatus.OFFLINE);
} else {
logger.debug("Unknown exception", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public FullDeviceManager(InnogyClient client) {
* states. Calling this may take a while...
*/
public List<Device> getFullDevices() throws IOException, ApiException, AuthenticationException {

final Map<String, Location> locationMap = createLocationMap(client);
final Map<String, Capability> capabilityMap = createCapabilityMap(client);
final Map<String, DeviceState> deviceStateMap = createDeviceStateMap(client);
Expand Down Expand Up @@ -91,7 +90,6 @@ public Device getFullDeviceById(final String deviceId) throws IOException, ApiEx

private void initializeDevice(Device device, @Nullable DeviceState deviceState, Map<String, Location> locationMap,
Map<String, Capability> capabilityMap, List<Message> messageList) {

device.setDeviceState(deviceState);

if (isBatteryPowered(device)) {
Expand Down Expand Up @@ -135,7 +133,6 @@ private static Map<String, CapabilityState> createCapabilityStateMap(InnogyClien

private static Map<String, Capability> createCapabilityMap(InnogyClient client)
throws IOException, ApiException, AuthenticationException {

final Map<String, CapabilityState> capabilityStateMap = createCapabilityStateMap(client);
final List<Capability> capabilityList = client.getCapabilities();

Expand All @@ -144,7 +141,6 @@ private static Map<String, Capability> createCapabilityMap(InnogyClient client)

private static Map<String, Capability> createCapabilityMap(String deviceId, InnogyClient client)
throws IOException, ApiException, AuthenticationException {

final Map<String, CapabilityState> capabilityStateMap = createCapabilityStateMap(client);
final List<Capability> capabilityList = client.getCapabilitiesForDevice(deviceId);

Expand All @@ -167,7 +163,6 @@ private static Map<String, Capability> initializeCapabilities(Map<String, Capabi

private static Map<String, Capability> createDeviceCapabilityMap(Device device,
Map<String, Capability> capabilityMap) {

final HashMap<String, Capability> deviceCapabilityMap = new HashMap<>();
for (final String capabilityValue : device.getCapabilities()) {
final Capability capability = capabilityMap.get(Link.getId(capabilityValue));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) 2010-2023 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.innogysmarthome.internal.util;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* The {@link ExceptionUtils} class defines static Exception related methods
*
* @author Leo Siepel - Initial contribution
*/
@NonNullByDefault
public class ExceptionUtils {

public static @Nullable Throwable getRootThrowable(@Nullable Throwable throwable) {
List<Throwable> list = new ArrayList<>();
while (throwable != null && !list.contains(throwable)) {
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
list.add(throwable);
throwable = throwable.getCause();
}
return throwable;
}
}