Skip to content

Commit d3271f6

Browse files
committed
Fixes aasx-unpack issue in Jar
Signed-off-by: Mohammad Ghazanfar Ali Danish <[email protected]>
1 parent f3b9f8d commit d3271f6

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/aasx/AASXPackageManager.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
******************************************************************************/
2525
package org.eclipse.basyx.components.aas.aasx;
2626

27-
import java.io.File;
2827
import java.io.IOException;
29-
import java.net.URI;
3028
import java.net.URISyntaxException;
3129
import java.nio.file.Path;
32-
import java.nio.file.Paths;
3330
import java.util.Set;
3431
import java.util.stream.Collectors;
3532

@@ -52,11 +49,13 @@ public AASXPackageManager(String path) {
5249
super(path);
5350
}
5451

52+
/**
53+
* @deprecated This method is deprecated. Please use the {@link AASXToMetamodelConverter#getTemporaryDirPath()}
54+
*/
5555
@Override
56-
protected Path getRootFolder() throws IOException, URISyntaxException {
57-
URI uri = AASXPackageManager.class.getProtectionDomain().getCodeSource().getLocation().toURI();
58-
URI parent = new File(uri).getParentFile().toURI();
59-
return Paths.get(parent);
56+
@Deprecated(since = "1.4.0", forRemoval = true)
57+
protected Path getRootFolder() throws URISyntaxException {
58+
return getTemporaryDirPath();
6059
}
6160

6261
@SuppressWarnings("unchecked")

basyx.components/basyx.components.docker/basyx.components.AASServer/src/test/java/org/eclipse/basyx/regression/AASServer/TestAASXAASServer.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@
2424
******************************************************************************/
2525
package org.eclipse.basyx.regression.AASServer;
2626

27-
import java.io.File;
2827
import java.io.IOException;
2928
import java.net.URISyntaxException;
29+
import java.nio.file.Paths;
3030

3131
import javax.servlet.ServletException;
3232
import javax.xml.parsers.ParserConfigurationException;
3333

34+
import org.apache.commons.io.FileUtils;
3435
import org.eclipse.basyx.aas.aggregator.restapi.AASAggregatorProvider;
36+
import org.eclipse.basyx.aas.factory.aasx.AASXToMetamodelConverter;
3537
import org.eclipse.basyx.components.aas.AASServerComponent;
3638
import org.eclipse.basyx.components.aas.configuration.AASServerBackend;
3739
import org.eclipse.basyx.components.aas.configuration.BaSyxAASServerConfiguration;
38-
import org.eclipse.basyx.components.aas.executable.AASServerExecutable;
3940
import org.eclipse.basyx.components.configuration.BaSyxContextConfiguration;
4041
import org.junit.AfterClass;
4142
import org.junit.BeforeClass;
@@ -60,10 +61,8 @@ public static void setUpClass() throws ParserConfigurationException, SAXExceptio
6061
contextConfig.loadFromResource(BaSyxContextConfiguration.DEFAULT_CONFIG_PATH);
6162
BaSyxAASServerConfiguration aasConfig = new BaSyxAASServerConfiguration(AASServerBackend.INMEMORY, "aasx/01_Festo.aasx");
6263

63-
// Load the additional file path relative to the executed jar file
64-
String rootPath = new File(AASServerExecutable.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile().getPath();
65-
String docBasePath = rootPath;
66-
contextConfig.setDocBasePath(docBasePath);
64+
String docBasepath = Paths.get(FileUtils.getTempDirectory().getAbsolutePath(), AASXToMetamodelConverter.TEMP_DIRECTORY).toAbsolutePath().toString();
65+
contextConfig.setDocBasePath(docBasepath);
6766

6867
// Start the component
6968
component = new AASServerComponent(contextConfig, aasConfig);

basyx.components/basyx.components.docker/basyx.components.AASServer/src/test/java/org/eclipse/basyx/regression/AASServer/TestAASXPackageManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.xml.parsers.ParserConfigurationException;
4141
import javax.xml.transform.TransformerException;
4242

43+
import org.apache.commons.io.FileUtils;
4344
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
4445
import org.eclipse.basyx.aas.factory.aasx.AASXFactory;
4546
import org.eclipse.basyx.aas.factory.aasx.InMemoryFile;
@@ -101,7 +102,7 @@ public class TestAASXPackageManager {
101102
/**
102103
* Files that are unzipped
103104
*/
104-
private static String[] unzipFiles = { "target/files/aasx/Document/docu.pdf", "target/files/icon.png" };
105+
private static String[] unzipFiles = { "/basyx-temp/files/aasx/Document/docu.pdf", "/basyx-temp/files/icon.png" };
105106

106107
/**
107108
* AAS bundle which will be generated by the XMLAASBundleFactory
@@ -196,10 +197,12 @@ public void testLoadGeneratedAASX() throws InvalidFormatException, IOException,
196197

197198
// Unzip files from the .aasx
198199
packageManager.unzipRelatedFiles();
200+
201+
String tempDirectory = FileUtils.getTempDirectory().getAbsolutePath();
199202

200203
// Check if all expected files are present
201204
for (String path : unzipFiles) {
202-
assertTrue(new java.io.File(path).exists());
205+
assertTrue(new java.io.File(tempDirectory + path).exists());
203206
}
204207

205208
}

0 commit comments

Comments
 (0)