diff --git a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java index c38dd322..9414df8a 100644 --- a/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java +++ b/dataformat-aasx/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/AASXSerializer.java @@ -19,8 +19,8 @@ import java.io.OutputStream; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.UUID; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; @@ -95,7 +95,6 @@ public AASXSerializer(XmlSerializer xmlSerializer) { */ public void write(Environment environment, Collection files, OutputStream os) throws SerializationException, IOException { - prepareFilePaths(environment); OPCPackage rootPackage = OPCPackage.create(os); @@ -234,7 +233,7 @@ private void writeDataToPart(PackagePart part, byte[] content) { * @return the found Files */ private Collection findFileElements(Environment environment) { - Collection files = new ArrayList<>(); + Collection files = new HashSet<>(); new AssetAdministrationShellElementWalkerVisitor() { @Override public void visit(File file) { @@ -246,15 +245,6 @@ public void visit(File file) { return files; } - /** - * Replaces the path in all File Elements with the result of preparePath - * - * @param environment the Environment - */ - private void prepareFilePaths(Environment environment) { - findFileElements(environment).forEach(f -> f.setValue(preparePath(f.getValue()))); - } - /** * Finds an InMemoryFile by its path * @@ -271,17 +261,4 @@ private InMemoryFile findFileByPath(Collection files, String path) throw new RuntimeException("The wanted file '" + path + "' was not found in the given files."); } - /** - * Removes the serverpart from a path and ensures it starts with "file://" - * - * @param path the path to be prepared - * @return the prepared path - */ - private String preparePath(String path) { - if (path.startsWith("/")) { - path = "file://" + path; - } - return path; - } - } diff --git a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java index a6234172..9d77fbf0 100644 --- a/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java +++ b/dataformat-aasx/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/aasx/deserialization/ValidationTest.java @@ -48,8 +48,11 @@ public class ValidationTest { public void validateXmlInsideAasx() throws SerializationException, IOException, InvalidFormatException, DeserializationException, ParserConfigurationException, SAXException { List fileList = new ArrayList<>(); byte[] operationManualContent = { 0, 1, 2, 3, 4 }; + byte[] thumbnail = { 0, 1, 2, 3, 4 }; InMemoryFile inMemoryFile = new InMemoryFile(operationManualContent, "file:///aasx/OperatingManual.pdf"); + InMemoryFile inMemoryFileThumbnail = new InMemoryFile(thumbnail, "file:///master/verwaltungsschale-detail-part1.png"); fileList.add(inMemoryFile); + fileList.add(inMemoryFileThumbnail); File file = tempFolder.newFile("output.aasx");