Skip to content

Commit fd99062

Browse files
committed
Upgrading CXF and OpenSearch
1 parent d3848d5 commit fd99062

24 files changed

Lines changed: 71 additions & 100 deletions

File tree

‎client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/MIMETypesLoader.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.HashMap;
2828
import java.util.List;
2929
import java.util.Map;
30-
import org.apache.wicket.util.io.IOUtils;
3130
import org.slf4j.Logger;
3231
import org.slf4j.LoggerFactory;
3332

@@ -46,7 +45,7 @@ public class MIMETypesLoader implements Serializable {
4645
public void load() {
4746
mimeTypesMap = new HashMap<>();
4847
try {
49-
JsonNode jsonNode = MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream("/MIMETypes.json")));
48+
JsonNode jsonNode = MAPPER.readTree(getClass().getResourceAsStream("/MIMETypes.json").readAllBytes());
5049
for (JsonNode node : jsonNode) {
5150
JsonNode type = node.path("name");
5251
JsonNode ext = node.path("extension");

‎client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/markup/html/form/preview/BinaryTextPreviewer.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.ByteArrayInputStream;
2323
import java.io.IOException;
2424
import java.io.InputStream;
25+
import java.nio.charset.StandardCharsets;
2526
import org.apache.syncope.client.ui.commons.annotations.BinaryPreview;
2627
import org.apache.syncope.common.rest.api.RESTHeaders;
2728
import org.apache.wicket.Component;
@@ -31,7 +32,6 @@
3132
import org.apache.wicket.markup.html.form.TextArea;
3233
import org.apache.wicket.markup.html.panel.Fragment;
3334
import org.apache.wicket.model.Model;
34-
import org.apache.wicket.util.io.IOUtils;
3535

3636
@BinaryPreview(mimeTypes = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
3737
RESTHeaders.APPLICATION_YAML, "application/x-yaml", "text/x-yaml", "text/yaml" })
@@ -52,7 +52,9 @@ public Component preview(final byte[] uploadedBytes) {
5252
try {
5353
fragment = new Fragment("preview", "previewFragment", this);
5454
InputStream stream = new ByteArrayInputStream(uploadedBytes);
55-
TextArea<String> previewer = new TextArea<>("previewer", Model.of(IOUtils.toString(stream)));
55+
TextArea<String> previewer = new TextArea<>(
56+
"previewer",
57+
Model.of(new String(stream.readAllBytes(), StandardCharsets.UTF_8)));
5658
previewer.setOutputMarkupPlaceholderTag(true);
5759
previewerId = previewer.getMarkupId();
5860
fragment.add(previewer);

‎client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/ImplementationModalPanel.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.fasterxml.jackson.databind.JsonNode;
2222
import com.fasterxml.jackson.databind.json.JsonMapper;
2323
import java.io.IOException;
24+
import java.nio.charset.StandardCharsets;
2425
import java.util.List;
2526
import org.apache.commons.lang3.StringUtils;
2627
import org.apache.syncope.client.console.SyncopeConsoleSession;
@@ -44,7 +45,6 @@
4445
import org.apache.wicket.model.Model;
4546
import org.apache.wicket.model.PropertyModel;
4647
import org.apache.wicket.spring.injection.annot.SpringBean;
47-
import org.apache.wicket.util.io.IOUtils;
4848

4949
public class ImplementationModalPanel extends AbstractModalPanel<ImplementationTO> {
5050

@@ -122,9 +122,9 @@ public ImplementationModalPanel(
122122
if (templateClassName != null) {
123123
try {
124124
implementation.setBody(StringUtils.substringAfter(
125-
IOUtils.toString(ImplementationModalPanel.class.getResourceAsStream(
125+
new String(ImplementationModalPanel.class.getResourceAsStream(
126126
"/org/apache/syncope/client/console/implementations/" + templateClassName
127-
+ ".groovy")),
127+
+ ".groovy").readAllBytes(), StandardCharsets.UTF_8),
128128
"*/\n"));
129129
} catch (IOException e) {
130130
LOG.error("Could not load the expected Groovy template {} for {}",

‎client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/NotificationRestClient.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
package org.apache.syncope.client.console.rest;
2020

21+
import java.io.ByteArrayInputStream;
2122
import java.io.InputStream;
2223
import java.nio.charset.StandardCharsets;
2324
import java.util.List;
24-
import org.apache.commons.io.IOUtils;
2525
import org.apache.commons.lang3.StringUtils;
2626
import org.apache.syncope.common.lib.to.JobTO;
2727
import org.apache.syncope.common.lib.to.MailTemplateTO;
@@ -92,6 +92,6 @@ public String readTemplateFormat(final String key, final MailTemplateFormat form
9292

9393
public void updateTemplateFormat(final String key, final String content, final MailTemplateFormat format) {
9494
getService(MailTemplateService.class).setFormat(
95-
key, format, IOUtils.toInputStream(content, StandardCharsets.UTF_8));
95+
key, format, new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)));
9696
}
9797
}

‎client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/RoleRestClient.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
*/
1919
package org.apache.syncope.client.console.rest;
2020

21+
import java.io.ByteArrayInputStream;
2122
import java.io.InputStream;
2223
import java.nio.charset.StandardCharsets;
2324
import java.util.List;
2425
import java.util.stream.Collectors;
25-
import org.apache.commons.io.IOUtils;
2626
import org.apache.commons.lang3.StringUtils;
2727
import org.apache.syncope.client.console.SyncopeConsoleSession;
2828
import org.apache.syncope.common.lib.SyncopeClientException;
@@ -76,7 +76,7 @@ public String readAnyLayout(final String role) {
7676

7777
public void setAnyLayout(final String roleKey, final String content) {
7878
getService(RoleService.class).setAnyLayout(
79-
roleKey, IOUtils.toInputStream(content, StandardCharsets.UTF_8));
79+
roleKey, new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)));
8080
}
8181

8282
public void removeAnyLayout(final String roleKey) {

‎client/idrepo/lib/src/main/java/org/apache/syncope/client/lib/batch/BatchResponse.java‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@
2222
import jakarta.ws.rs.core.Response;
2323
import java.io.ByteArrayInputStream;
2424
import java.io.IOException;
25-
import java.io.InputStream;
2625
import java.net.URI;
27-
import java.nio.charset.StandardCharsets;
2826
import java.util.List;
2927
import org.apache.cxf.configuration.jsse.TLSClientParameters;
30-
import org.apache.cxf.helpers.IOUtils;
3128
import org.apache.cxf.jaxrs.client.ClientConfiguration;
3229
import org.apache.cxf.jaxrs.client.WebClient;
3330
import org.apache.cxf.transport.http.HTTPConduit;
@@ -80,7 +77,7 @@ public static Response poll(
8077
* @throws IOException if there are issues when reading the response body
8178
*/
8279
public static List<BatchResponseItem> getItems(final Response response) throws IOException {
83-
String body = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8.name());
80+
String body = response.readEntity(String.class);
8481
LOG.debug("Batch response body:\n{}", body);
8582

8683
return BatchPayloadParser.parse(

‎common/keymaster/client-api/src/main/java/org/apache/syncope/common/keymaster/client/api/model/Domain.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import com.fasterxml.jackson.annotation.JsonTypeInfo;
2424
import java.io.IOException;
2525
import java.io.Serializable;
26+
import java.nio.charset.StandardCharsets;
2627
import org.apache.commons.lang3.builder.EqualsBuilder;
2728
import org.apache.commons.lang3.builder.HashCodeBuilder;
2829
import org.apache.commons.lang3.builder.ToStringBuilder;
29-
import org.apache.cxf.helpers.IOUtils;
3030
import org.apache.syncope.common.lib.types.CipherAlgorithm;
3131
import org.slf4j.Logger;
3232
import org.slf4j.LoggerFactory;
@@ -80,7 +80,7 @@ public D build() {
8080
protected static String read(final String filename) {
8181
String read = null;
8282
try {
83-
read = IOUtils.toString(Domain.class.getResourceAsStream('/' + filename));
83+
read = new String(Domain.class.getResourceAsStream('/' + filename).readAllBytes(), StandardCharsets.UTF_8);
8484
} catch (IOException e) {
8585
LOG.error("Could not read {}", filename, e);
8686
}

‎core/idrepo/rest-cxf/src/test/java/org/apache/syncope/core/rest/cxf/service/AnyObjectServiceTest.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import java.util.List;
4343
import java.util.UUID;
4444
import org.apache.cxf.endpoint.Server;
45-
import org.apache.cxf.helpers.IOUtils;
4645
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
4746
import org.apache.cxf.jaxrs.client.WebClient;
4847
import org.apache.cxf.jaxrs.ext.MessageContext;
@@ -237,7 +236,7 @@ public void jsonList() throws IOException {
237236
InputStream in = list(MediaType.APPLICATION_JSON_TYPE);
238237

239238
PagedResult<AnyObjectTO> list = new SyncopeJsonMapper().
240-
readValue(IOUtils.toString(in), new TypeReference<>() {
239+
readValue(in.readAllBytes(), new TypeReference<>() {
241240
});
242241
checkList(list);
243242
}
@@ -247,7 +246,7 @@ public void xmlList() throws IOException {
247246
InputStream in = list(MediaType.APPLICATION_XML_TYPE);
248247

249248
PagedResult<AnyObjectTO> list = new SyncopeXmlMapper().
250-
readValue(IOUtils.toString(in), new TypeReference<>() {
249+
readValue(in.readAllBytes(), new TypeReference<>() {
251250
});
252251
checkList(list);
253252
}
@@ -257,7 +256,7 @@ public void yamlList() throws IOException {
257256
InputStream in = list(RESTHeaders.APPLICATION_YAML_TYPE);
258257

259258
PagedResult<AnyObjectTO> list = new SyncopeYAMLMapper().
260-
readValue(IOUtils.toString(in), new TypeReference<>() {
259+
readValue(in.readAllBytes(), new TypeReference<>() {
261260
});
262261
checkList(list);
263262
}

‎core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/StartupDomainLoader.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
package org.apache.syncope.core.persistence.jpa;
2020

2121
import java.io.IOException;
22+
import java.nio.charset.StandardCharsets;
2223
import java.util.Map;
2324
import java.util.stream.Collectors;
24-
import org.apache.cxf.helpers.IOUtils;
2525
import org.apache.syncope.common.keymaster.client.api.DomainOps;
2626
import org.apache.syncope.common.keymaster.client.api.model.Domain;
2727
import org.apache.syncope.common.keymaster.client.api.model.JPADomain;
@@ -97,15 +97,15 @@ public void load() {
9797
poolMinIdle(domainProps.getPoolMinIdle());
9898

9999
try {
100-
builder.content(IOUtils.toString(
101-
resourceLoader.getResource(domainProps.getContent()).getInputStream()));
100+
builder.content(new String(resourceLoader.getResource(domainProps.getContent()).
101+
getInputStream().readAllBytes(), StandardCharsets.UTF_8));
102102
} catch (IOException e) {
103103
LOG.error("While loading {}", domainProps.getContent(), e);
104104
}
105105

106106
try {
107-
builder.keymasterConfParams(IOUtils.toString(
108-
resourceLoader.getResource(domainProps.getKeymasterConfParams()).getInputStream()));
107+
builder.keymasterConfParams(new String(resourceLoader.getResource(domainProps.
108+
getKeymasterConfParams()).getInputStream().readAllBytes(), StandardCharsets.UTF_8));
109109
} catch (IOException e) {
110110
LOG.error("While loading {}", domainProps.getKeymasterConfParams(), e);
111111
}

‎core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import org.apache.commons.lang3.StringUtils;
6464
import org.apache.commons.lang3.Strings;
6565
import org.apache.commons.lang3.tuple.Pair;
66-
import org.apache.cxf.helpers.IOUtils;
6766
import org.apache.openjpa.lib.util.collections.BidiMap;
6867
import org.apache.openjpa.lib.util.collections.DualHashBidiMap;
6968
import org.apache.syncope.common.lib.SyncopeConstants;
@@ -108,14 +107,14 @@ protected static String getValues(final ResultSet rs, final String columnName, f
108107
case Types.LONGVARBINARY:
109108
InputStream is = rs.getBinaryStream(columnName);
110109
if (is != null) {
111-
value = DatatypeConverter.printHexBinary(IOUtils.toString(is).getBytes());
110+
value = DatatypeConverter.printHexBinary(is.readAllBytes());
112111
}
113112
break;
114113

115114
case Types.BLOB:
116115
Blob blob = rs.getBlob(columnName);
117116
if (blob != null) {
118-
value = DatatypeConverter.printHexBinary(IOUtils.toString(blob.getBinaryStream()).getBytes());
117+
value = DatatypeConverter.printHexBinary(blob.getBinaryStream().readAllBytes());
119118
}
120119
break;
121120

0 commit comments

Comments
 (0)