-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from MicroFocus/daniel_rebrand_product_name
removing or changing "LoadRunner" and "LRE" expressions to "OpenText Enterprise Performance Engineering"
- Loading branch information
Showing
10 changed files
with
521 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
java/src/main/java/com/opentext/lre/actions/common/helpers/OutputUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.opentext.lre.actions.common.helpers; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
import com.opentext.lre.actions.common.helpers.utils.LogHelper; | ||
import org.json.JSONObject; | ||
|
||
public class OutputUpdater { | ||
private String parameterKey = "lre_run_id"; | ||
private String filePath; | ||
public OutputUpdater(Path workspace) | ||
{ | ||
String directoryPath = workspace != null ? workspace.toString() : System.getProperty("user.dir"); | ||
filePath = directoryPath + File.separator + parameterKey + ".conf"; | ||
} | ||
|
||
// Method to update or create the config file with the specified parameter | ||
public void updateParameter(String parameterValue) { | ||
JSONObject json = new JSONObject(); | ||
json.put(parameterKey, parameterValue); | ||
|
||
// Check if the file exists and whether it has write permissions | ||
File file = new File(filePath); | ||
|
||
// If the file exists, check if it's writable | ||
if (file.exists()) { | ||
if (file.canWrite()) { | ||
// File exists and is writable, so proceed with writing | ||
writeToFile(file, json); | ||
} else { | ||
// If the file exists but cannot be written to, print a message | ||
LogHelper.error("OutputUpdater - Error: File is not writable."); | ||
} | ||
} else { | ||
// File doesn't exist, create a new file | ||
writeToFile(file, json); | ||
} | ||
} | ||
|
||
// Method to write the JSON data to the file | ||
private void writeToFile(File file, JSONObject json) { | ||
try (FileWriter fileWriter = new FileWriter(file)) { | ||
// Write or update the file with the new parameter value | ||
fileWriter.write(json.toString()); | ||
LogHelper.info("File updated: " + file.getAbsolutePath()); | ||
} catch (IOException e) { | ||
LogHelper.logStackTrace("OutputUpdater - Error while writing to file.", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.