2 * Copyright (c) 2010-2023 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.lametrictime.internal.api.impl;
17 import javax.ws.rs.client.Client;
18 import javax.ws.rs.client.ClientBuilder;
19 import javax.ws.rs.core.Response;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
24 * Implementation class for http icons.
26 * @author Gregory Moyer - Initial contribution
29 public class HTTPIcon extends AbstractDataIcon {
30 private final URI uri;
32 public HTTPIcon(String uri) {
33 this(URI.create(uri));
36 public HTTPIcon(URI uri) {
41 protected void populateFields() {
42 Client client = ClientBuilder.newBuilder().build();
43 Response response = client.target(uri).request().get();
45 setType(response.getMediaType().toString());
46 setData(response.readEntity(byte[].class));