Skip to content

Commit d6a0794

Browse files
authored
multiple proj locations and 9.3 (#3)
1 parent 733dd17 commit d6a0794

File tree

3 files changed

+13
-38
lines changed

3 files changed

+13
-38
lines changed

xtraplatform-nativ-loader/src/main/java/de/ii/xtraplatform/nativ/loader/domain/XtraplatformNative.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public static Path getLibPath(String parentName) {
6565
return TMP_DIR.resolve(parentName).resolve(LIB_DIR_NAME);
6666
}
6767

68+
public static Path getDataPath(String parentName) {
69+
return TMP_DIR.resolve(parentName).resolve(DATA_DIR_NAME);
70+
}
71+
6872
private static void copyLibToTmpDir(Class<?> contextClass, String parentName, String resource) {
6973
File lib = getLibPath(parentName).resolve(resource).toFile();
7074
if (!lib.exists()) {

xtraplatform-proj/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ maturity = 'CANDIDATE'
66

77
ext {
88
//TODO: when changed, adjust ProjLoaderImpl.getName (can we inject it?)
9-
projVersion = '9.1.0'
9+
projVersion = '9.3.0'
1010
buildVersion = '1'
1111
generatedResourcesDir = new File(buildDir, 'generated/src/main/resources/')
1212
embeddedLibDir = new File(generatedResourcesDir, "proj-${projVersion}-${buildVersion}/lib")

xtraplatform-proj/src/main/java/de/ii/xtraplatform/proj/domain/ProjLoaderImpl.java

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111
import com.google.common.collect.ImmutableList;
1212
import com.google.common.collect.ImmutableMap;
1313
import de.ii.xtraplatform.base.domain.AppLifeCycle;
14-
import de.ii.xtraplatform.base.domain.LogContext;
15-
import de.ii.xtraplatform.blobs.domain.BlobStore;
16-
import java.io.IOException;
14+
import de.ii.xtraplatform.nativ.loader.domain.XtraplatformNative;
1715
import java.nio.file.Path;
1816
import java.util.List;
1917
import java.util.Map;
20-
import java.util.Objects;
21-
import java.util.Optional;
2218
import javax.inject.Inject;
2319
import javax.inject.Singleton;
2420
import org.slf4j.Logger;
@@ -29,42 +25,21 @@
2925
public class ProjLoaderImpl implements ProjLoader, AppLifeCycle {
3026

3127
private static final Logger LOGGER = LoggerFactory.getLogger(ProjLoaderImpl.class);
32-
private static final String RESOURCES_PATH = "proj";
33-
34-
private final BlobStore blobStore;
35-
private Optional<Path> dataDirectory;
28+
private final Path dataDirectory;
3629

3730
@Inject
38-
public ProjLoaderImpl(BlobStore blobStore) {
39-
this.blobStore = blobStore.with(RESOURCES_PATH);
40-
this.dataDirectory = Optional.empty();
31+
public ProjLoaderImpl() {
32+
this.dataDirectory = XtraplatformNative.getDataPath(getName());
4133
}
4234

4335
// for unit tests only
4436
ProjLoaderImpl(Path dataDirectory) {
45-
this.dataDirectory = Optional.ofNullable(dataDirectory);
46-
this.blobStore = null;
47-
}
48-
49-
@Override
50-
public int getPriority() {
51-
return 900;
52-
}
53-
54-
@Override
55-
public void onStart() {
56-
if (dataDirectory.isEmpty() && Objects.nonNull(blobStore)) {
57-
try {
58-
this.dataDirectory = blobStore.asLocalPath(Path.of(""), true);
59-
} catch (IOException e) {
60-
LogContext.error(LOGGER, e, "Could not initialize PROJ data directory");
61-
}
62-
}
37+
this.dataDirectory = dataDirectory;
6338
}
6439

6540
@Override
6641
public String getName() {
67-
return "proj-9.1.0-1";
42+
return "proj-9.3.0-1";
6843
}
6944

7045
@Override
@@ -83,12 +58,8 @@ public List<String> getLibraries() {
8358

8459
@Override
8560
public Map<Path, List<String>> getResources() {
86-
if (dataDirectory.isEmpty()) {
87-
return ImmutableMap.of();
88-
}
89-
9061
return ImmutableMap.of(
91-
dataDirectory.get(),
62+
dataDirectory,
9263
ImmutableList.of(
9364
"CH",
9465
"deformation_model.schema.json",
@@ -109,6 +80,6 @@ public Map<Path, List<String>> getResources() {
10980

11081
@Override
11182
public Path getDataDirectory() {
112-
return dataDirectory.orElseThrow();
83+
return dataDirectory;
11384
}
11485
}

0 commit comments

Comments
 (0)