|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018, 2023 Oracle and/or its affiliates. |
| 2 | + * Copyright (c) 2018, 2025 Oracle and/or its affiliates. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import java.io.IOException;
|
20 | 20 | import java.io.InputStream;
|
21 |
| -import java.net.InetSocketAddress; |
22 | 21 | import java.net.Proxy;
|
23 | 22 | import java.net.URI;
|
24 | 23 | import java.nio.file.Files;
|
25 | 24 | import java.nio.file.Path;
|
26 |
| -import java.nio.file.Paths; |
27 |
| -import java.util.Base64; |
28 | 25 | import java.util.Objects;
|
29 |
| -import java.util.Optional; |
30 |
| - |
31 |
| -import io.helidon.common.config.Config; |
32 | 26 |
|
33 | 27 | /**
|
34 | 28 | * Utilities to move private static methods from interface,
|
35 | 29 | * as javadoc fails when using source 8.
|
36 | 30 | */
|
37 | 31 | final class ResourceUtil {
|
38 |
| - private static final int DEFAULT_PROXY_PORT = 80; |
39 | 32 |
|
40 | 33 | private ResourceUtil() {
|
41 | 34 | }
|
@@ -112,43 +105,4 @@ static InputStream toIs(URI uri, Proxy proxy) {
|
112 | 105 | throw new ResourceException("Failed to open stream to uri: " + uri, e);
|
113 | 106 | }
|
114 | 107 | }
|
115 |
| - |
116 |
| - static Optional<Resource> fromConfigPath(Config config) { |
117 |
| - return config.asString() |
118 |
| - .map(Paths::get) |
119 |
| - .map(Resource::create); |
120 |
| - } |
121 |
| - |
122 |
| - static Optional<Resource> fromConfigB64Content(Config config) { |
123 |
| - return config.asString() |
124 |
| - .map(Base64.getDecoder()::decode) |
125 |
| - .map(content -> Resource.create(config.key() + ".content", content)); |
126 |
| - } |
127 |
| - |
128 |
| - static Optional<Resource> fromConfigContent(Config config) { |
129 |
| - return config.asString() |
130 |
| - .map(content -> Resource.create(config.key() + ".content-plain", content)); |
131 |
| - } |
132 |
| - |
133 |
| - static Optional<Resource> fromConfigUrl(Config config) { |
134 |
| - return config.as(URI.class) |
135 |
| - .map(uri -> config.get("proxy-host").asString() |
136 |
| - .map(proxyHost -> { |
137 |
| - if (config.get("use-proxy").asBoolean().orElse(true)) { |
138 |
| - Proxy proxy = new Proxy(Proxy.Type.HTTP, |
139 |
| - new InetSocketAddress(proxyHost, |
140 |
| - config.get("proxy-port").asInt().orElse( |
141 |
| - DEFAULT_PROXY_PORT))); |
142 |
| - return Resource.create(uri, proxy); |
143 |
| - } else { |
144 |
| - return Resource.create(uri); |
145 |
| - } |
146 |
| - }) |
147 |
| - .orElseGet(() -> Resource.create(uri))); |
148 |
| - } |
149 |
| - |
150 |
| - static Optional<Resource> fromConfigResourcePath(Config config) { |
151 |
| - return config.asString() |
152 |
| - .map(Resource::create); |
153 |
| - } |
154 | 108 | }
|
0 commit comments