Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CPSC329-PM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sean Kim
CPSC329-PM
Commits
7d0d11da
Commit
7d0d11da
authored
1 week ago
by
Syed OMAR
Browse files
Options
Downloads
Patches
Plain Diff
There is now error handling for add services when the service already exists in the json file
parent
adc52264
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#8320
canceled
1 week ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/cpsc329pm/AddServiceSceneController.java
+16
-0
16 additions, 0 deletions
src/main/java/com/cpsc329pm/AddServiceSceneController.java
with
16 additions
and
0 deletions
src/main/java/com/cpsc329pm/AddServiceSceneController.java
+
16
−
0
View file @
7d0d11da
...
...
@@ -60,6 +60,19 @@ public class AddServiceSceneController {
if
(
password
.
equals
(
confirmUser
))
{
try
{
DataStorage
ds
=
new
DataStorage
(
"master_login.json"
);
// Check if the service already exists
if
(
ds
.
getData
(
platform
,
username
)
!=
null
)
{
// If service exists, show error message
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
);
alert
.
setTitle
(
"Add Service"
);
alert
.
setHeaderText
(
"Error"
);
alert
.
setContentText
(
"Service already exists for this platform and username."
);
alert
.
showAndWait
();
return
;
// Exit method early if service already exists
}
// Add new service if it doesn't exist
ds
.
addData
(
platform
,
username
,
password
);
ds
.
saveToJSON
();
...
...
@@ -69,6 +82,7 @@ public class AddServiceSceneController {
alert
.
setContentText
(
"Service added successfully."
);
alert
.
showAndWait
();
// Load MainPage.fxml after success
Parent
root
=
FXMLLoader
.
load
(
getClass
().
getResource
(
"MainPage.fxml"
));
Stage
stage
=
(
Stage
)
((
Node
)
event
.
getSource
()).
getScene
().
getWindow
();
stage
.
setScene
(
new
Scene
(
root
));
...
...
@@ -77,6 +91,7 @@ public class AddServiceSceneController {
e
.
printStackTrace
();
}
}
else
{
// Show error if passwords don't match
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
);
alert
.
setTitle
(
"Add Service"
);
alert
.
setHeaderText
(
"Error"
);
...
...
@@ -85,4 +100,5 @@ public class AddServiceSceneController {
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment