@@ -133,8 +133,8 @@ public String toString() {
133
133
* Finds the install directories and returns the {@link InstallLocations}
134
134
* instance describing those locations.
135
135
*
136
- * @param senzingDir The optional Senzing installation directory if one has
137
- * been provided, <code>null</code> otherwise.
136
+ * @param senzingDir The optional Senzing installation directory if one has been
137
+ * provided, <code>null</code> otherwise.
138
138
*
139
139
* @return The {@link InstallLocations} instance describing the install
140
140
* locations.
@@ -148,12 +148,14 @@ public static InstallLocations findLocations() {
148
148
String lowerOSName = osName .toLowerCase ().trim ();
149
149
if (lowerOSName .startsWith ("windows" )) {
150
150
windows = true ;
151
- } else if (lowerOSName .startsWith ("mac" )
152
- || lowerOSName .indexOf ("darwin" ) >= 0 )
153
- {
151
+ } else if (lowerOSName .startsWith ("mac" ) || lowerOSName .indexOf ("darwin" ) >= 0 ) {
154
152
macOS = true ;
155
153
}
156
154
155
+ File homeDir = new File (System .getProperty ("user.home" ));
156
+ File homeSenzing = new File (homeDir , "senzing" );
157
+ File homeInstall = new File (homeSenzing , "er" );
158
+ File homeSupport = new File (homeInstall , "data" );
157
159
File installDir = null ;
158
160
File configDir = null ;
159
161
File resourceDir = null ;
@@ -165,14 +167,14 @@ public static InstallLocations findLocations() {
165
167
String defaultSupportPath = null ;
166
168
167
169
if (windows ) {
168
- defaultInstallPath = "C: \\ Program Files \\ Senzing \\ er" ;
169
- defaultSupportPath = "C: \\ Program Files \\ Senzing \\ er \\ data" ;
170
+ defaultInstallPath = homeInstall . getCanonicalPath () ;
171
+ defaultSupportPath = homeSupport . getCanonicalPath () ;
170
172
} else if (macOS ) {
171
- defaultInstallPath = "/opt/senzing/er" ;
172
- defaultSupportPath = "/opt/senzing/er/data" ;
173
+ defaultInstallPath = homeInstall . getCanonicalPath () ;
174
+ defaultSupportPath = homeSupport . getCanonicalPath () ;
173
175
} else {
174
176
defaultInstallPath = "/opt/senzing/er" ;
175
- defaultConfigPath = "/etc/opt/senzing" ;
177
+ defaultConfigPath = "/etc/opt/senzing" ;
176
178
defaultSupportPath = "/opt/senzing/data" ;
177
179
}
178
180
@@ -214,22 +216,18 @@ public static InstallLocations findLocations() {
214
216
System .err .println (" " + installDir );
215
217
System .err .println ();
216
218
if (installPath != null ) {
217
- System .err .println (
218
- "Check the -Dsenzing.install.dir=[path] command line option." );
219
+ System .err .println ("Check the -Dsenzing.install.dir=[path] command line option." );
219
220
} else {
220
- System .err .println (
221
- "Use the -Dsenzing.install.dir=[path] command line option to "
222
- + "specify a path" );
221
+ System .err
222
+ .println ("Use the -Dsenzing.install.dir=[path] command line option to " + "specify a path" );
223
223
}
224
224
225
225
return null ;
226
226
}
227
227
228
228
// normalize the senzing directory
229
229
String dirName = installDir .getName ();
230
- if (installDir .isDirectory () && !dirName .equalsIgnoreCase ("er" )
231
- && dirName .equalsIgnoreCase ("senzing" ))
232
- {
230
+ if (installDir .isDirectory () && !dirName .equalsIgnoreCase ("er" ) && dirName .equalsIgnoreCase ("senzing" )) {
233
231
// for windows or linux allow the "Senzing" dir as well
234
232
installDir = new File (installDir , "er" );
235
233
}
@@ -239,12 +237,10 @@ public static InstallLocations findLocations() {
239
237
System .err .println (" " + installDir );
240
238
System .err .println ();
241
239
if (installPath != null ) {
242
- System .err .println (
243
- "Check the -Dsenzing.install.dir=[path] command line option." );
240
+ System .err .println ("Check the -Dsenzing.install.dir=[path] command line option." );
244
241
} else {
245
- System .err .println (
246
- "Use the -Dsenzing.install.dir=[path] command line option to "
247
- + "specify a path" );
242
+ System .err
243
+ .println ("Use the -Dsenzing.install.dir=[path] command line option to " + "specify a path" );
248
244
}
249
245
250
246
return null ;
@@ -260,7 +256,7 @@ public static InstallLocations findLocations() {
260
256
supportDir = new File (installDir , "data" );
261
257
} else {
262
258
// no explicit path, try the default support path
263
- supportDir = new File (defaultSupportPath );
259
+ supportDir = new File (defaultSupportPath );
264
260
}
265
261
266
262
} else {
@@ -274,8 +270,8 @@ public static InstallLocations findLocations() {
274
270
if (supportPath != null ) {
275
271
System .err .println ("Check the -Dsenzing.support.dir=[path] command line option." );
276
272
} else {
277
- System .err . println ( "Use the -Dsenzing.support.dir=[path] command line option to "
278
- + "specify a path" );
273
+ System .err
274
+ . println ( "Use the -Dsenzing.support.dir=[path] command line option to " + "specify a path" );
279
275
}
280
276
281
277
throw new IllegalStateException ("The support directory does not exist: " + supportDir );
@@ -287,8 +283,8 @@ public static InstallLocations findLocations() {
287
283
if (supportPath != null ) {
288
284
System .err .println ("Check the -Dsenzing.support.dir=[path] command line option." );
289
285
} else {
290
- System .err . println ( "Use the -Dsenzing.support.dir=[path] command line option to "
291
- + "specify a path" );
286
+ System .err
287
+ . println ( "Use the -Dsenzing.support.dir=[path] command line option to " + "specify a path" );
292
288
}
293
289
throw new IllegalStateException ("The support directory is invalid: " + supportDir );
294
290
@@ -317,24 +313,21 @@ public static InstallLocations findLocations() {
317
313
configDir = new File (installDir , "etc" );
318
314
if (!configDir .exists ()) {
319
315
configDir = null ;
320
- }
316
+ }
321
317
}
322
318
323
319
if (configPath != null && !configDir .exists ()) {
324
- System .err .println (
325
- "The -Dsenzing.config.dir=[path] option specifies a path that does not exist:" );
320
+ System .err .println ("The -Dsenzing.config.dir=[path] option specifies a path that does not exist:" );
326
321
System .err .println (" " + configPath );
327
322
328
323
throw new IllegalStateException ("Explicit config path does not exist: " + configPath );
329
324
}
330
325
if (configDir != null && configDir .exists ()) {
331
326
if (!configDir .isDirectory ()) {
332
- System .err .println (
333
- "The -Dsenzing.config.dir=[path] option specifies a file, not a directory:" );
327
+ System .err .println ("The -Dsenzing.config.dir=[path] option specifies a file, not a directory:" );
334
328
System .err .println (" " + configPath );
335
329
336
- throw new IllegalStateException (
337
- "Explicit config path is not directory: " + configPath );
330
+ throw new IllegalStateException ("Explicit config path is not directory: " + configPath );
338
331
}
339
332
340
333
String [] requiredFiles = { "cfgVariant.json" };
@@ -348,13 +341,11 @@ public static InstallLocations findLocations() {
348
341
}
349
342
}
350
343
if (missingFiles .size () > 0 && configPath != null ) {
351
- System .err .println (
352
- "The -Dsenzing.config.dir=[path] option specifies an invalid config directory:" );
344
+ System .err .println ("The -Dsenzing.config.dir=[path] option specifies an invalid config directory:" );
353
345
for (String missing : missingFiles ) {
354
346
System .err .println (" " + missing + " was not found" );
355
347
}
356
- throw new IllegalStateException (
357
- "Explicit config path missing required files: " + missingFiles );
348
+ throw new IllegalStateException ("Explicit config path missing required files: " + missingFiles );
358
349
}
359
350
}
360
351
@@ -372,22 +363,19 @@ public static InstallLocations findLocations() {
372
363
373
364
if (resourcePath != null ) {
374
365
if (!resourceDir .exists ()) {
375
- System .err . println (
376
- "The -Dsenzing.resource.dir=[path] option specifies a path that does not exist:" );
366
+ System .err
367
+ . println ( "The -Dsenzing.resource.dir=[path] option specifies a path that does not exist:" );
377
368
System .err .println (" " + resourcePath );
378
369
379
- throw new IllegalStateException (
380
- "Explicit resource path does not exist: " + resourcePath );
370
+ throw new IllegalStateException ("Explicit resource path does not exist: " + resourcePath );
381
371
}
382
372
383
373
if (!resourceDir .isDirectory () || !templatesDir .exists () || !templatesDir .isDirectory ()) {
384
374
System .err .println (
385
- "The -Dsenzing.resource.dir=[path] option specifies an invalid "
386
- + "resource directory:" );
375
+ "The -Dsenzing.resource.dir=[path] option specifies an invalid " + "resource directory:" );
387
376
System .err .println (" " + resourcePath );
388
377
389
- throw new IllegalStateException (
390
- "Explicit resource path is not valid: " + resourcePath );
378
+ throw new IllegalStateException ("Explicit resource path is not valid: " + resourcePath );
391
379
}
392
380
393
381
} else if (!resourceDir .exists () || !resourceDir .isDirectory () || !templatesDir .exists ()
0 commit comments