1111import com .google .common .collect .ImmutableList ;
1212import com .google .common .collect .ImmutableMap ;
1313import 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 ;
1715import java .nio .file .Path ;
1816import java .util .List ;
1917import java .util .Map ;
20- import java .util .Objects ;
21- import java .util .Optional ;
2218import javax .inject .Inject ;
2319import javax .inject .Singleton ;
2420import org .slf4j .Logger ;
2925public 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