|
1 | 1 | package edu.harvard.iq.dataverse.api; |
2 | 2 |
|
3 | | -import java.io.FileInputStream; |
4 | | -import java.io.InputStream; |
5 | | -import java.net.URL; |
6 | | -import java.nio.charset.StandardCharsets; |
7 | | -import java.util.Arrays; |
8 | | -import java.util.List; |
9 | | -import java.util.logging.Level; |
10 | 3 | import java.util.logging.Logger; |
11 | 4 |
|
12 | | -import jakarta.ws.rs.Produces; |
13 | | -import org.apache.commons.io.IOUtils; |
| 5 | +import edu.harvard.iq.dataverse.customization.CustomizationConstants; |
| 6 | +import jakarta.ws.rs.*; |
| 7 | +import jakarta.ws.rs.client.Client; |
| 8 | +import jakarta.ws.rs.client.ClientBuilder; |
| 9 | +import jakarta.ws.rs.client.WebTarget; |
14 | 10 |
|
15 | 11 | import edu.harvard.iq.dataverse.export.ExportService; |
16 | 12 | import edu.harvard.iq.dataverse.settings.JvmSettings; |
17 | 13 | import edu.harvard.iq.dataverse.settings.SettingsServiceBean; |
18 | | -import edu.harvard.iq.dataverse.util.BundleUtil; |
19 | 14 | import edu.harvard.iq.dataverse.util.SystemConfig; |
20 | 15 | import io.gdcc.spi.export.Exporter; |
21 | 16 | import io.gdcc.spi.export.ExportException; |
|
24 | 19 | import jakarta.json.Json; |
25 | 20 | import jakarta.json.JsonObjectBuilder; |
26 | 21 | import jakarta.json.JsonValue; |
27 | | -import jakarta.ws.rs.GET; |
28 | | -import jakarta.ws.rs.Path; |
29 | | -import jakarta.ws.rs.QueryParam; |
30 | 22 | import jakarta.ws.rs.core.MediaType; |
31 | 23 | import jakarta.ws.rs.core.Response; |
32 | 24 | import org.eclipse.microprofile.openapi.annotations.Operation; |
@@ -139,6 +131,26 @@ public Response getExportFormats() { |
139 | 131 | return ok(responseModel); |
140 | 132 | } |
141 | 133 |
|
| 134 | + @GET |
| 135 | + @Path("settings/customization/{customizationFileType}") |
| 136 | + public Response getCustomizationFile(@PathParam("customizationFileType") String customizationFileType) { |
| 137 | + String type = customizationFileType != null ? customizationFileType.toLowerCase() : ""; |
| 138 | + if (!CustomizationConstants.validTypes.contains(type)) { |
| 139 | + return badRequest("Customization type unknown or missing. Must be one of the following: " + CustomizationConstants.validTypes); |
| 140 | + } |
| 141 | + Client client = ClientBuilder.newClient(); |
| 142 | + WebTarget endpoint = client.target("http://localhost:8080/CustomizationFilesServlet"); |
| 143 | + Response response = endpoint.queryParam("customFileType", type) |
| 144 | + .request(MediaType.MEDIA_TYPE_WILDCARD) |
| 145 | + .get(); |
| 146 | + |
| 147 | + if (response.getLength() < 1) { |
| 148 | + return notFound(type + " not found."); |
| 149 | + } else { |
| 150 | + return response; |
| 151 | + } |
| 152 | + } |
| 153 | + |
142 | 154 | private Response getSettingResponseByKey(SettingsServiceBean.Key key) { |
143 | 155 | String setting = settingsService.getValueForKey(key); |
144 | 156 | if (setting != null) { |
|
0 commit comments