Skip to content

Commit

Permalink
Merge pull request #821 from NASA-PDS/241021_Namespace_JUICE_Port_Bac…
Browse files Browse the repository at this point in the history
…k_Namespace_Issue

Get namespaces from the lastest version of the config.properties file to address the JUICE port-back problem
  • Loading branch information
jordanpadams authored Oct 29, 2024
2 parents 728f3cd + 0acf8a1 commit 700fa44
Showing 1 changed file with 112 additions and 84 deletions.
196 changes: 112 additions & 84 deletions model-dmdocument/src/main/java/gov/nasa/pds/model/plugin/DMDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ public class DMDocument extends Object {
static Integer lMessageFatalErrorCount = 0;

// Property List for Config.Properties
static Properties props = new Properties();
static Properties configProps = new Properties();
static Properties nameSpaceProps = new Properties();

static ArrayList<String> propertyMapFileName = new ArrayList<>();

Expand Down Expand Up @@ -345,6 +346,7 @@ public static void run(String[] args) throws Throwable {

// get the command line arguments using argparse4j
Namespace argparse4jNamespace = getArgumentParserNamespace(args);
String nameSpaceDataDirPath = null;

// process first set of arguments
// this must be done before config file processing
Expand All @@ -357,6 +359,7 @@ public static void run(String[] args) throws Throwable {
sysDataHome = sysDataHome.replace('\\', '/');
parentDir = sysDataHome + "/";
dataDirPath = parentDir;
nameSpaceDataDirPath = dataDirPath;
// if this is an LDDTool run then an alternate path is allowed (option "V")
// IMTool runs ignore the -V option
if (LDDToolFlag && alternateIMVersionFlag) {
Expand All @@ -375,12 +378,13 @@ public static void run(String[] args) throws Throwable {
sysUserDir = sysUserDir.replace('\\', '/');
parentDir = sysUserDir;
String dirExt = "/model-ontology/src/ontology/Data/";
// if (debugFlag) dirExt = "/bin/../Data/";
dataDirPath = parentDir + dirExt;
nameSpaceDataDirPath = dataDirPath;
if (debugFlag) {
parentDir = System.getProperty("user.home") + "/git/pds4-information-model/model-ontology/src/ontology";
dataDirPath = System.getProperty("user.home") + "/git/pds4-information-model/model-ontology/src/ontology/Data/";
}
nameSpaceDataDirPath = dataDirPath;
}
// if this is an LDDTool run then an alternate path is allowed (option "V")
// IMTool runs ignore the -V option
if (LDDToolFlag && alternateIMVersionFlag) {
Expand All @@ -391,91 +395,87 @@ public static void run(String[] args) throws Throwable {
}
Utility.registerMessage("0>info - Parent Directory:" + parentDir);
Utility.registerMessage("0>info - IM Directory Path:" + dataDirPath);
Utility.registerMessage("0>info - NS Directory Path:" + nameSpaceDataDirPath);
Utility.registerMessage("0>info - IM Versions Available:" + alternateIMVersionArr);

// read the configuration file and initialize key attributes; SchemaFileDefn map is initialized
// below (setupNameSpaceInfoAll)
// "props" are used again below in setupNameSpaceInfoAll)
String configInputFile = dataDirPath + "config.properties";
String configInputFileSpecName = dataDirPath + "config.properties";
String configInputStr;
File configFile = new File(configInputFile);
FileReader reader = null;
try {
reader = new FileReader(configFile);
// Properties props = new Properties();
props.load(reader);
configInputStr = props.getProperty("infoModelVersionId");
if (configInputStr != null) {
infoModelVersionId = configInputStr;
}
configInputStr = props.getProperty("schemaLabelVersionId");
if (configInputStr != null) {
schemaLabelVersionId = configInputStr;
}
configInputStr = props.getProperty("pds4BuildId");
if (configInputStr != null) {
pds4BuildId = configInputStr;
}
configInputStr = props.getProperty("imSpecDocTitle");
if (configInputStr != null) {
imSpecDocTitle = configInputStr;
}
configInputStr = props.getProperty("imSpecDocAuthor");
if (configInputStr != null) {
imSpecDocAuthor = configInputStr;
}
configInputStr = props.getProperty("imSpecDocSubTitle");
if (configInputStr != null) {
imSpecDocSubTitle = configInputStr;
}
configInputStr = props.getProperty("ddDocTitle");
if (configInputStr != null) {
ddDocTitle = configInputStr;
}
configInputStr = props.getProperty("debugFlag");
if (configInputStr != null && configInputStr.compareTo("true") == 0) {
debugFlag = true;
}
// configInputStr= props.getProperty("lSchemaFileDefn.pds.regAuthId");
configInputStr = props.getProperty("mastRegAuthId");
if (configInputStr != null) {
registrationAuthorityIdentifierValue = configInputStr;
registeredByValue = "RA_" + registrationAuthorityIdentifierValue;
}
configInputStr = props.getProperty("ddDocTeam");
if (configInputStr != null) {
ddDocTeam = configInputStr;
}
configInputStr = props.getProperty("pds4ModelFlag");
if (configInputStr != null && configInputStr.compareTo("true") == 0) {
pds4ModelFlag = true;
}
configInputStr = props.getProperty("mastModelId");
if (configInputStr != null) {
mastModelId = configInputStr;
}
configProps = getConfigProperties(configInputFileSpecName);
configInputStr = configProps.getProperty("infoModelVersionId");
if (configInputStr != null) {
infoModelVersionId = configInputStr;
}
configInputStr = configProps.getProperty("schemaLabelVersionId");
if (configInputStr != null) {
schemaLabelVersionId = configInputStr;
}
configInputStr = configProps.getProperty("pds4BuildId");
if (configInputStr != null) {
pds4BuildId = configInputStr;
}
configInputStr = configProps.getProperty("imSpecDocTitle");
if (configInputStr != null) {
imSpecDocTitle = configInputStr;
}
configInputStr = configProps.getProperty("imSpecDocAuthor");
if (configInputStr != null) {
imSpecDocAuthor = configInputStr;
}
configInputStr = configProps.getProperty("imSpecDocSubTitle");
if (configInputStr != null) {
imSpecDocSubTitle = configInputStr;
}
configInputStr = configProps.getProperty("ddDocTitle");
if (configInputStr != null) {
ddDocTitle = configInputStr;
}
configInputStr = configProps.getProperty("debugFlag");
if (configInputStr != null && configInputStr.compareTo("true") == 0) {
debugFlag = true;
}
// configInputStr= props.getProperty("lSchemaFileDefn.pds.regAuthId");
configInputStr = configProps.getProperty("mastRegAuthId");
if (configInputStr != null) {
registrationAuthorityIdentifierValue = configInputStr;
registeredByValue = "RA_" + registrationAuthorityIdentifierValue;
}
configInputStr = configProps.getProperty("ddDocTeam");
if (configInputStr != null) {
ddDocTeam = configInputStr;
}
configInputStr = configProps.getProperty("pds4ModelFlag");
if (configInputStr != null && configInputStr.compareTo("true") == 0) {
pds4ModelFlag = true;
}
configInputStr = configProps.getProperty("mastModelId");
if (configInputStr != null) {
mastModelId = configInputStr;
}

configInputStr = props.getProperty("toolVersionId");
if (configInputStr != null) {
DMDocVersionId = LDDToolVersionId = configInputStr;
}
configInputStr = props.getProperty("buildDate");
if (configInputStr != null) {
buildDate = configInputStr;
}
} catch (FileNotFoundException ex) {
// file does not exist
Utility.registerMessage("3>error Configuration file does not exist. [config.properties]");
} catch (IOException ex) {
// I/O error
Utility.registerMessage("3>error Configuration file IO Exception. [config.properties]");
} finally {
try {
reader.close();
} catch (IOException|NullPointerException e) {
// Do nothing
}
}
configInputStr = configProps.getProperty("toolVersionId");
if (configInputStr != null) {
DMDocVersionId = LDDToolVersionId = configInputStr;
}
configInputStr = configProps.getProperty("buildDate");
if (configInputStr != null) {
buildDate = configInputStr;
}
// } catch (FileNotFoundException ex) {
// // file does not exist
// Utility.registerMessage("3>error Configuration file does not exist. [config.properties]");
// } catch (IOException ex) {
// // I/O error
// Utility.registerMessage("3>error Configuration file IO Exception. [config.properties]");
// } finally {
// try {
// reader.close();
// } catch (IOException|NullPointerException e) {
// // Do nothing
// }
// }

// process second set of arguments
processArgumentParserNamespacePhase2(argparse4jNamespace);
Expand All @@ -496,7 +496,10 @@ public static void run(String[] args) throws Throwable {
// intialize the masterAllSchemaFileSortMap - all namespaces in config.properties file
// set up the Master Schema Information for both normal and LDD processing (dirpath, namespaces,
// etc)
setupNameSpaceInfoAll(props);

String nsConfigInputFileSpecName = nameSpaceDataDirPath + "config.properties";
Properties nameSpaceConfigProps = getConfigProperties(nsConfigInputFileSpecName);
setupNameSpaceInfoAll(nameSpaceConfigProps);

// output the context info
if (!LDDToolFlag) {
Expand Down Expand Up @@ -554,6 +557,30 @@ public static void run(String[] args) throws Throwable {
*
* @throws IOException
***********************************************************************************************************/

// get the config.properties file
static private Properties getConfigProperties (String configInputFileSpecName) {
Properties properties = new Properties();
File configFile = new File(configInputFileSpecName);
FileReader reader = null;
try {
reader = new FileReader(configFile);
properties.load(reader);
} catch (FileNotFoundException ex) {
// file does not exist
Utility.registerMessage("3>error Configuration file does not exist. [config.properties]");
} catch (IOException ex) {
// I/O error
Utility.registerMessage("3>error Configuration file IO Exception. [config.properties]");
} finally {
try {
reader.close();
} catch (IOException|NullPointerException e) {
// Do nothing
}
}
return properties;
}

static private void cleanupLDDInputFileName(SchemaFileDefn lSchemaFileDefn) throws IOException {
String lSourceFileSpec = lSchemaFileDefn.sourceFileName;
Expand Down Expand Up @@ -693,7 +720,8 @@ static private void init() {
lMessageWarningCount = 0;
lMessageErrorCount = 0;
lMessageFatalErrorCount = 0;
props = new Properties();
configProps = new Properties();
nameSpaceProps = new Properties();
propertyMapFileName = new ArrayList<>();

// process state for used flags, files, and directories
Expand Down

0 comments on commit 700fa44

Please sign in to comment.