fix path for JAR
This commit is contained in:
		| @@ -24,7 +24,7 @@ public class DatabaseConnector implements DataPointListener { | ||||
|     private boolean initialized = false;                        // Boolean to know if the database connector is initialized | ||||
|     private final TimeManager _timeManager = new TimeManager(3); // Time manager to manage the time of the data points | ||||
|     private long _timestamp = 0;                                // Timestamp of the data points | ||||
|     String default_token = System.getenv("SECRET_TOKEN"); // Token to access the InfluxDB server | ||||
|     public static String token = System.getenv("SECRET_TOKEN"); // Token to access the InfluxDB server | ||||
|     public static String url = null;                            // URL of the InfluxDB server | ||||
|     public static String org = null;                            // Organization of the InfluxDB server | ||||
|     public static String bucket = null;                         // Bucket of the InfluxDB server | ||||
| @@ -38,7 +38,8 @@ public class DatabaseConnector implements DataPointListener { | ||||
|      */ | ||||
|     private DatabaseConnector (){ | ||||
|         // Read the config.properties file | ||||
|         try (InputStream input = Files.newInputStream(Paths.get("src/config.properties"))) { | ||||
|         /* | ||||
|         try (InputStream input = Files.newInputStream(Paths.get("config.properties"))) { | ||||
|             properties.load(input); | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
| @@ -54,6 +55,7 @@ public class DatabaseConnector implements DataPointListener { | ||||
|         if (bucket == null){ | ||||
|             bucket = properties.getProperty("DB.BUCKET"); | ||||
|         } | ||||
|         */ | ||||
|  | ||||
|         // Subscribe to the update of DataPoints | ||||
|         DataPointListener.subscribeUpdate(this); | ||||
| @@ -79,9 +81,11 @@ public class DatabaseConnector implements DataPointListener { | ||||
|         String fullURL; | ||||
|         try{ | ||||
|             if(urlForWrite == null){ | ||||
|                 /* | ||||
|                 if(url == null){ | ||||
|                     url = properties.getProperty("DB.URL"); | ||||
|                 } | ||||
|                 */ | ||||
|                 fullURL = url + "/api/v2/write?org=" + org + "&bucket=" + bucket; | ||||
|                 Utility.pDebug("URL: " + fullURL); | ||||
|                 urlForWrite = new URL(fullURL); | ||||
| @@ -102,7 +106,7 @@ public class DatabaseConnector implements DataPointListener { | ||||
|                 // Create the connection to the database | ||||
|                 con = (HttpURLConnection) urlForDelete.openConnection(); | ||||
|                 con.setRequestMethod("POST"); | ||||
|                 con.setRequestProperty("Authorization", "Token " + default_token); | ||||
|                 con.setRequestProperty("Authorization", "Token " + token); | ||||
|                 con.setRequestProperty("Content-Type", "text/plain"); | ||||
|                 con.setRequestProperty("Accept", "application/json"); | ||||
|                 con.setDoOutput(true); | ||||
| @@ -152,7 +156,7 @@ public class DatabaseConnector implements DataPointListener { | ||||
|             if(con == null){ | ||||
|                 con = (HttpURLConnection) urlForWrite.openConnection(); | ||||
|                 con.setRequestMethod("POST"); | ||||
|                 con.setRequestProperty("Authorization", "Token " + default_token); | ||||
|                 con.setRequestProperty("Authorization", "Token " + token); | ||||
|                 con.setRequestProperty("Content-Type", "application/json"); | ||||
|                 con.setDoOutput(true); | ||||
|             } | ||||
|   | ||||
| @@ -47,7 +47,8 @@ public class FieldConnector implements DataPointListener { | ||||
|      */ | ||||
|     public static void createRegister(String pathToFile){ | ||||
|         try{ | ||||
|             BufferedReader csvFile = new BufferedReader(new FileReader(pathToFile)); | ||||
|             //BufferedReader csvFile = new BufferedReader(new FileReader(pathToFile)); | ||||
|             BufferedReader csvFile = Utility.fileParser(null, "ModbusMap.csv"); | ||||
|             csvFile.readLine(); | ||||
|  | ||||
|             while(csvFile.ready()){ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user