Skip to content

Commit

Permalink
Improves null value handling
Browse files Browse the repository at this point in the history
Co-authored-by: Marie Witt <[email protected]>
Signed-off-by: Jannis Jung <[email protected]>
  • Loading branch information
jannisjung and ahoimariew committed Sep 18, 2023
1 parent b06b241 commit 2a7c677
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public AasEnvironmentPreconfigurationLoader(ResourceLoader resourceLoader, Strin

@Autowired
public AasEnvironmentPreconfigurationLoader(ResourceLoader resourceLoader, @Value("${basyx.environmentPaths:#{null}}") List<String> pathsToLoad, @Value("${basyx.environmentDict:#{null}}") String directoryToLoad) {
this(resourceLoader, Stream.concat(extractFilesToLoadFromEnvironmentDirectory(directoryToLoad).stream(), pathsToLoad.stream())
this(resourceLoader, Stream.concat(extractFilesToLoadFromEnvironmentDirectory(directoryToLoad).stream(), pathsToLoad != null ? pathsToLoad.stream() : new ArrayList<String>().stream())
.collect(Collectors.toList()));
this.directoryToLoad = directoryToLoad;
}
Expand All @@ -106,12 +106,12 @@ private void loadEnvironmentFromFile(AasRepository aasRepository, SubmodelReposi
}
}

private static List<String> extractFilesToLoadFromEnvironmentDirectory(String folderToLoad) throws IllegalArgumentException {
if (folderToLoad == null) {
new ArrayList<String>();
private static List<String> extractFilesToLoadFromEnvironmentDirectory(String directoryToLoad) throws IllegalArgumentException {
if (directoryToLoad == null) {
return new ArrayList<String>();
}
folderToLoad = convertFromClassPathFormat(folderToLoad);
File rootDirectory = new File(folderToLoad);
directoryToLoad = convertFromClassPathFormat(directoryToLoad);
File rootDirectory = new File(directoryToLoad);
RecursiveDirectoryScanner directoryScanner = new RecursiveDirectoryScanner();

List<File> potentialEnvironments = directoryScanner.listFiles(rootDirectory);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*******************************************************************************
* Copyright (C) 2023 the Eclipse BaSyx Authors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
******************************************************************************/

package org.eclipse.basyx.digitaltwin.aasenvironment.http;

import static org.junit.Assert.assertEquals;
Expand Down
39 changes: 36 additions & 3 deletions basyx.aasenvironment/basyx.aasenvironment.component/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -75,6 +77,36 @@
<artifactId>httpclient5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.submodelrepository-core</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasrepository-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasrepository-core</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>
basyx.conceptdescriptionrepository-core
</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>
basyx.conceptdescriptionrepository-core
</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
</dependencies>

<build>
Expand All @@ -87,7 +119,7 @@
</configuration>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<!-- Build the docker image -->
Expand All @@ -107,7 +139,8 @@
</build>
<run>
<ports>
<port>${docker.host.port}:${docker.container.port}</port>
<port>
${docker.host.port}:${docker.container.port}</port>
</ports>
<wait>
<url>${docker.container.waitForEndpoint}</url>
Expand Down

0 comments on commit 2a7c677

Please sign in to comment.