unprotected file scenario
This commit is contained in:
parent
7ad223b981
commit
a08ca53a0d
|
|
@ -84,14 +84,20 @@ public class Controller {
|
|||
void browsePressed(ActionEvent event) {
|
||||
|
||||
invalidFileText.setVisible(false);
|
||||
progressBarRemove.setVisible(false);
|
||||
|
||||
progressBarBrowse.setVisible(true);
|
||||
progressBarBrowse.setImage(progressOnGoing);
|
||||
|
||||
filePathText.setVisible(false);
|
||||
|
||||
try {
|
||||
fileChooser = new FileChooser();
|
||||
fileChooser.setTitle("Please Select a File");
|
||||
file = fileChooser.showOpenDialog(null);
|
||||
filePath = file.toString();
|
||||
fileName = file.getName();
|
||||
filePathText.setVisible(true);
|
||||
filePathText.setText(filePath);
|
||||
fileType = getFileType();
|
||||
|
||||
|
|
@ -106,6 +112,7 @@ public class Controller {
|
|||
|
||||
@FXML
|
||||
void removePasswordPressed(ActionEvent event) {
|
||||
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -125,7 +132,7 @@ public class Controller {
|
|||
|
||||
XMLParser parser = new XMLParser(manipulator); // create new object to parse the XML
|
||||
|
||||
if (parser.isExistSecurityElement()) // if the file has a password
|
||||
if (parser.isExistSecurityElement()) // if the file has a password protection as a read-only file
|
||||
{
|
||||
parser.removeElementOfSecurity(); // remove hash node from XML file
|
||||
|
||||
|
|
@ -133,17 +140,17 @@ public class Controller {
|
|||
|
||||
manipulator.insertFile(); // write back to file
|
||||
|
||||
manipulator.removeXMLFile(); // cleans the xml extracted from origin file
|
||||
|
||||
fileText.setText(fileFinishedMessage());
|
||||
|
||||
progressBarRemove.setImage(progressFinished);
|
||||
}
|
||||
else // if there is no security element in the xml file, there is no read-only protection on it
|
||||
} else // if there is no security element in the xml file, there is no read-only protection on it
|
||||
{
|
||||
manipulator.removeXMLFile(); // cleans the xml extracted from origin file
|
||||
fileText.setText(notReadOnlyMessage());
|
||||
}
|
||||
|
||||
manipulator.removeXMLFile(); // cleans the xml extracted from origin file
|
||||
|
||||
progressBarRemove.setImage(progressFinished);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -219,4 +226,9 @@ public class Controller {
|
|||
return messageOnScreen;
|
||||
}
|
||||
|
||||
private String notReadOnlyMessage() {
|
||||
String messageOnScreen = "Officer Breaker couldn't find any \"read-only\" restriction on the file. \n \nTry another file?";
|
||||
return messageOnScreen;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue