Skip to content
Permalink
Browse files

MERG CBUS Node Manager getUserFilesPath

Changes node dir to getUserFilesPath / cbus/nodes/
Puts CBUS event table path back to getUserFilesPath as changed in error.
  • Loading branch information...
icklesteve committed Aug 7, 2019
1 parent 9ac9350 commit 389a28b925755d207558d5cfdf884171710410ac
@@ -541,7 +541,7 @@ protected void storeEventsToXml() {
}

public static class CbusEventTableXmlFile extends XmlFile {
private static String fileLocation = FileUtil.getProfilePath() + "cbus/"; // NOI18N
private static String fileLocation = FileUtil.getUserFilesPath() + "cbus" + File.separator; // NOI18N
private static String baseFileName = "EventTableData.xml"; // NOI18N

public static String getDefaultFileName() {
@@ -580,7 +580,7 @@ public static String getFileName() {
*/
public static String getFileLocation() {
if(fileLocation==null){
fileLocation = FileUtil.getProfilePath() + "cbus/"; // NOI18N
fileLocation = FileUtil.getUserFilesPath() + "cbus" + File.separator; // NOI18N
}
return fileLocation;
}
@@ -939,18 +939,16 @@ public void removeRow(int row, boolean removeXml) {
*/
public void startupSearchNodeXmlFile() {
// ensure preferences will be found for read
FileUtil.createDirectory(fileLocation);
FileUtil.createDirectory(CbusNodeXml.CbusNodeBackupFile.getFileLocation());
// create an array of file names from node dir in preferences, then loop
List<String> names = new ArrayList<>();
log.debug("directory of TrainInfoFiles is {}", fileLocation);
File fp = new File(fileLocation);
File fp = new File(CbusNodeXml.CbusNodeBackupFile.getFileLocation());
if (fp.exists()) {
String[] fpList = fp.list(new XmlFilenameFilter());
if (fpList !=null ) {
names.addAll(Arrays.asList(fpList));
}
}
log.debug("directory: {} nodes found : {}",fileLocation,names);
names.forEach((nb) -> {
log.debug("Node: {}",nb);
int nodeNum = jmri.util.StringUtil.getFirstIntFromString(nb);
@@ -962,9 +960,6 @@ public void startupSearchNodeXmlFile() {
});
}

private String fileLocation = FileUtil.getProfilePath()
+ "cbus" + File.separator;

/**
* Disconnect from the network
* <p>
@@ -322,12 +322,10 @@ public boolean doStore( boolean createNew) {
* Add an xml entry advising Node Not on Network
*/
protected void nodeNotOnNetwork(){

CbusNodeFromBackup newBup = new CbusNodeFromBackup(_node,new Date());
newBup.setBackupResult(BackupType.NOTONNETWORK);
_backupInfos.add(0,newBup);
doStore(false);

}

/**
@@ -361,23 +359,16 @@ protected boolean removeNode( boolean rotate){

public static class CbusNodeBackupFile extends XmlFile {

private String fileLocation = FileUtil.getProfilePath()
+ "cbus" + File.separator; // NOI18N
private static String fileLocation = FileUtil.getUserFilesPath()
+ "cbus" + File.separator + "nodes" + File.separator; // NOI18N

public String getDefaultFileName(int nodeNum) {
return getFileLocation() + getFileName(nodeNum);
}

public File getFile(int nodeNum, boolean store) {
// Verify that cbus:node directory exists
File chkdir = new File(getFileLocation());
if (!chkdir.exists()) {
if (!chkdir.mkdir()) {
log.error("Create directory: cbus/ failed for node {} directory {}",
nodeNum,getFileLocation());
return null;
}
}
// Verify that cbus/node/ directory exists
FileUtil.createDirectory(getFileLocation());

File file = findFile(getDefaultFileName(nodeNum));
if (file == null && store) {
@@ -396,7 +387,7 @@ public String getFileName(int nodeNum) {
*
* @return path to location
*/
public String getFileLocation() {
public static String getFileLocation() {
return fileLocation;
}

0 comments on commit 389a28b

Please sign in to comment.
You can’t perform that action at this time.