Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit 4372c90

Browse files
committed
ByteString JAXBElement not applicable with byte[] as Base64
1 parent ad3d534 commit 4372c90

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

dataformat-uanodeset/src/main/java/io/adminshell/aas/v3/dataformat/i4aas/mappers/ByteStringPropertyMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.opcfoundation.ua._2008._02.types.ObjectFactory;
66
import org.opcfoundation.ua._2011._03.uanodeset.UAVariable;
77

8-
import io.adminshell.aas.v3.dataformat.i4aas.mappers.utils.I4AASUtils;
98
import io.adminshell.aas.v3.dataformat.i4aas.mappers.utils.MappingContext;
109
import io.adminshell.aas.v3.dataformat.i4aas.mappers.utils.UaId;
1110

@@ -20,7 +19,7 @@ public ByteStringPropertyMapper(String key, byte[] src, MappingContext ctx) {
2019

2120
@Override
2221
protected UAVariable createTargetObject() {
23-
JAXBElement<byte[]> byteStringValue = new ObjectFactory().createByteString(source);
22+
JAXBElement<String> byteStringValue = new ObjectFactory().createByteString(source);
2423
org.opcfoundation.ua._2011._03.uanodeset.UAVariable.Builder<Void> idVarBuilder = UAVariable.builder()
2524
.withValue().withAny(byteStringValue).end().withDisplayName(createLocalizedText(key))
2625
.withDataType(UaId.ByteString.getName()).withNodeId(ctx.newModelNodeIdAsString())

dataformat-uanodeset/src/main/java/org/opcfoundation/ua/_2008/_02/types/ObjectFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
package org.opcfoundation.ua._2008._02.types;
1010

1111
import java.math.BigInteger;
12+
import java.util.Base64;
13+
1214
import javax.xml.bind.JAXBElement;
1315
import javax.xml.bind.annotation.XmlElementDecl;
1416
import javax.xml.bind.annotation.XmlRegistry;
@@ -5106,8 +5108,9 @@ public JAXBElement<ListOfGuid> createListOfGuid(ListOfGuid value) {
51065108
* the new instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}
51075109
*/
51085110
@XmlElementDecl(namespace = "http://opcfoundation.org/UA/2008/02/Types.xsd", name = "ByteString")
5109-
public JAXBElement<byte[]> createByteString(byte[] value) {
5110-
return new JAXBElement<byte[]>(_ByteString_QNAME, byte[].class, null, ((byte[]) value));
5111+
public JAXBElement<String> createByteString(byte[] value) {
5112+
String encodeToString = Base64.getEncoder().encodeToString(value);
5113+
return new JAXBElement<String>(_ByteString_QNAME, String.class, null, encodeToString);
51115114
}
51125115

51135116
/**

0 commit comments

Comments
 (0)