Skip to content
Merged
60 changes: 17 additions & 43 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.starlight</groupId>
<artifactId>tabemonpal</artifactId>
<version>1.0-ALPHA</version>
<version>1.1-ALPHA</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -99,6 +99,12 @@
<version>17.0.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -144,66 +150,34 @@
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>com.starlight.App</mainClass>
<commandlineArgs>
--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED
--add-exports=javafx.base/com.sun.javafx.logging=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui=org.testfx
--add-opens=javafx.graphics/com.sun.glass.ui.monocle=ALL-UNNAMED
--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.glass.ui.monocle.input.devices=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.glass.ui.monocle=org.testfx
--add-exports=javafx.graphics/com.sun.glass.ui.monocle=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED,org.testfx.monocle
--add-opens=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui.monocle.input=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui.monocle.input.devices=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.javafx.application.HostServicesDelegate=ALL-UNNAMED
</commandlineArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M9</version>
<configuration>
<!-- Run tests on the classpath (not module path) so TestFX/Monocle can access internal Glass classes -->
<useModulePath>false</useModulePath>
<!-- Minimal internal access + headless flags (removed invalid/duplicate opens to silence warnings) -->
<argLine>
--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED
--add-exports=javafx.base/com.sun.javafx.logging=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui=org.testfx
--add-opens=javafx.graphics/com.sun.glass.ui.monocle=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui.monocle=ALL-UNNAMED
--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.glass.ui.monocle.input.devices=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.glass.ui.monocle=org.testfx
--add-exports=javafx.graphics/com.sun.glass.ui.monocle=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED,org.testfx.monocle
--add-opens=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui.monocle.input=ALL-UNNAMED
--add-exports=javafx.graphics/com.sun.glass.ui.monocle.input.devices=ALL-UNNAMED
--add-opens=javafx.graphics/com.sun.javafx.application.HostServicesDelegate=ALL-UNNAMED
--add-opens=com.starlight/com.starlight=ALL-UNNAMED
--add-opens=com.starlight/com.starlight.api=ALL-UNNAMED
--add-opens=com.starlight/com.starlight.model=ALL-UNNAMED
--add-opens=com.starlight/com.starlight.util=ALL-UNNAMED
--add-opens=com.starlight/com.starlight.controller=ALL-UNNAMED
-Dtestfx.headless=true -Dprism.order=sw -Dprism.verbose=false -Djava.awt.headless=true
</argLine>
<systemPropertyVariables>
<testfx.headless>true</testfx.headless>
<prism.order>sw</prism.order>
<java.awt.headless>true</java.awt.headless>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/starlight/api/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public User login(String emailOrUsername, String password) throws ApiException {
conn.setDoOutput(true);

User creds = new User();
creds.email = emailOrUsername;
creds.password = password;
creds.setEmail(emailOrUsername);
creds.setPassword(password);

writeXmlToConnection(conn, creds);

Expand Down Expand Up @@ -85,9 +85,9 @@ public User register(String username, String email, String password) throws ApiE
conn.setDoOutput(true);

User newUser = new User();
newUser.username = username;
newUser.email = email;
newUser.password = password;
newUser.setUsername(username);
newUser.setEmail(email);
newUser.setPassword(password);

writeXmlToConnection(conn, newUser);

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/starlight/api/UserApiServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ public void handle(HttpExchange exchange) throws IOException {
User creds = (User) xstream.fromXML(body);

// First check local users (admin and user accounts)
String loginIdentifier = creds.email; // This could be username or email
User localUser = localRepository.validateCredentials(loginIdentifier, creds.password);
String loginIdentifier = creds.getEmail(); // This could be username or email
User localUser = localRepository.validateCredentials(loginIdentifier, creds.getPassword());

if (localUser != null) {
logger.log(Level.INFO, "Local user authenticated: {0}", localUser.username);
logger.log(Level.INFO, "Local user authenticated: {0}", localUser.getUsername());
sendXml(exchange, 200, xstream.toXML(localUser));
return;
}
Expand All @@ -128,9 +128,9 @@ public void handle(HttpExchange exchange) throws IOException {

// Check for either email or username match
Optional<User> match = users.stream()
.filter(u -> ((u.email != null && u.email.equals(creds.email)) ||
(u.username != null && u.username.equals(creds.email))) &&
u.password != null && u.password.equals(creds.password))
.filter(u -> ((u.getEmail() != null && u.getEmail().equals(creds.getEmail())) ||
(u.getUsername() != null && u.getUsername().equals(creds.getEmail()))) &&
u.getPassword() != null && u.getPassword().equals(creds.getPassword()))
.findFirst();

if (match.isPresent()) {
Expand Down Expand Up @@ -162,12 +162,12 @@ public void handle(HttpExchange exchange) throws IOException {
User newUser = (User) xstream.fromXML(body);

// Set default profile picture for new users
if (newUser.profilepicture == null || newUser.profilepicture.trim().isEmpty()) {
newUser.profilepicture = "src/main/resources/com/starlight/images/dummy/profiledefault.png";
if (newUser.getProfilepicture() == null || newUser.getProfilepicture().trim().isEmpty()) {
newUser.setProfilepicture("src/main/resources/com/starlight/images/dummy/profiledefault.png");
}

List<User> users = repository.loadUsers(false);
boolean exists = users.stream().anyMatch(u -> newUser.email.equals(u.email));
boolean exists = users.stream().anyMatch(u -> newUser.getEmail().equals(u.getEmail()));
if (exists) {
sendXml(exchange, 409, "<error/>");
return;
Expand Down Expand Up @@ -240,7 +240,7 @@ private void handleGetUser(HttpExchange exchange, String username) throws IOExce
// Fallback to regular repository users
List<User> users = repository.loadUsers();
Optional<User> user = users.stream()
.filter(u -> u.username != null && u.username.equals(username))
.filter(u -> u.getUsername() != null && u.getUsername().equals(username))
.findFirst();

if (user.isPresent()) {
Expand Down Expand Up @@ -303,7 +303,7 @@ private void updateUserInRepository(HttpExchange exchange, String username, User

for (int i = 0; i < users.size(); i++) {
User existingUser = users.get(i);
if (existingUser.username != null && existingUser.username.equals(username)) {
if (existingUser.getUsername() != null && existingUser.getUsername().equals(username)) {
updateUserFields(existingUser, updated);
repository.saveUsers(users);
sendXml(exchange, 200, xstream.toXML(existingUser));
Expand All @@ -318,9 +318,9 @@ private void updateUserInRepository(HttpExchange exchange, String username, User
* Updates user fields from the updated user object
*/
private void updateUserFields(User existingUser, User updated) {
if (updated.email != null) existingUser.email = updated.email;
if (updated.password != null) existingUser.password = updated.password;
if (updated.birthDay != null) existingUser.birthDay = updated.birthDay;
if (updated.getEmail() != null) existingUser.setEmail(updated.getEmail());
if (updated.getPassword() != null) existingUser.setPassword(updated.getPassword());
if (updated.getBirthDay() != null) existingUser.setBirthDay(updated.getBirthDay());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ public void initialize(URL location, ResourceBundle resources) {
* Shows the login view in the right section of the BorderPane.
*/
public void showLoginView() {
authPanel.setRight(loginView);
if (authPanel != null && loginView != null) {
authPanel.setRight(loginView);
}
}

/**
* Shows the register view in the right section of the BorderPane.
*/
public void showRegisterView() {
authPanel.setRight(registerView);
if (authPanel != null && registerView != null) {
authPanel.setRight(registerView);
}
}
}
60 changes: 30 additions & 30 deletions src/main/java/com/starlight/controller/CommunityController.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public String getProfilePictureForUser(String username) {

List<User> users = userRepository.loadUsers();
for (User user : users) {
if (username.equals(user.username)) {
return user.profilepicture;
if (username.equals(user.getUsername())) {
return user.getProfilepicture();
}
}
return null;
Expand All @@ -142,10 +142,10 @@ public String getDisplayUsernameForUser(String username) {

List<User> users = userRepository.loadUsers();
for (User user : users) {
if (username.equals(user.username)) {
if (username.equals(user.getUsername())) {
// Return fullname if available, otherwise return username
return user.fullname != null && !user.fullname.trim().isEmpty()
? user.fullname : user.username;
return user.getFullname() != null && !user.getFullname().trim().isEmpty()
? user.getFullname() : user.getUsername();
}
}
return username; // fallback to original username if not found
Expand All @@ -170,12 +170,12 @@ private void loadPosts() {

for (int i = 0; i < posts.size(); i++) {
Post p = posts.get(i);
String tits = p.title;
String usr = p.username;
String desc = p.description;
String image = p.image;
String time = p.uploadtime;
String likes = p.likecount;
String tits = p.getTitle();
String usr = p.getUsername();
String desc = p.getDescription();
String image = p.getImage();
String time = p.getUploadtime();
String likes = p.getLikecount();

// Get profile picture and display username from UserData.xml instead of Post data
String pp = getProfilePictureForUser(usr);
Expand All @@ -193,7 +193,7 @@ private void loadPosts() {
c.likecounter.setText(likes);

// Set comment count (default to 0 if not set)
String commentCount = p.commentcount != null ? p.commentcount : "0";
String commentCount = p.getCommentcount() != null ? p.getCommentcount() : "0";
c.commentcounter.setText(commentCount);

// Set the post data for the controller
Expand All @@ -203,8 +203,8 @@ private void loadPosts() {
c.setMainController(main);

// Initialize isLiked field if not set
if (p.isLiked == null) {
p.isLiked = "false";
if (p.getIsLiked() == null) {
p.setIsLiked("false");
}

// Load profile picture
Expand Down Expand Up @@ -250,31 +250,31 @@ private void loadDailyPosts() {
Post post = shuffledPosts.get(i);
switch (i) {
case 0:
dailytitle1.setText(post.title);
starrating.setText(post.rating);
dailylikecounter.setText(post.likecount);
ImageUtils.loadImage(dailyphoto1, post.image, ImageUtils.DEFAULT_MISSING_IMAGE);
dailytitle1.setText(post.getTitle());
starrating.setText(post.getRating());
dailylikecounter.setText(post.getLikecount());
ImageUtils.loadImage(dailyphoto1, post.getImage(), ImageUtils.DEFAULT_MISSING_IMAGE);
ImageUtils.scaleToFit(dailyphoto1, 280, 174, 30);
break;
case 1:
dailytitle2.setText(post.title);
starrating2.setText(post.rating);
dailylikecounter2.setText(post.likecount);
ImageUtils.loadImage(dailyphoto2, post.image, ImageUtils.DEFAULT_MISSING_IMAGE);
dailytitle2.setText(post.getTitle());
starrating2.setText(post.getRating());
dailylikecounter2.setText(post.getLikecount());
ImageUtils.loadImage(dailyphoto2, post.getImage(), ImageUtils.DEFAULT_MISSING_IMAGE);
ImageUtils.scaleToFit(dailyphoto2, 280, 174, 30);
break;
case 2:
dailytitle3.setText(post.title);
starrating3.setText(post.rating);
dailylikecounter3.setText(post.likecount);
ImageUtils.loadImage(dailyphoto3, post.image, ImageUtils.DEFAULT_MISSING_IMAGE);
dailytitle3.setText(post.getTitle());
starrating3.setText(post.getRating());
dailylikecounter3.setText(post.getLikecount());
ImageUtils.loadImage(dailyphoto3, post.getImage(), ImageUtils.DEFAULT_MISSING_IMAGE);
ImageUtils.scaleToFit(dailyphoto3, 280, 174, 30);
break;
case 3:
dailytitle4.setText(post.title);
starrating4.setText(post.rating);
dailylikecounter4.setText(post.likecount);
ImageUtils.loadImage(dailyphoto4, post.image, ImageUtils.DEFAULT_MISSING_IMAGE);
dailytitle4.setText(post.getTitle());
starrating4.setText(post.getRating());
dailylikecounter4.setText(post.getLikecount());
ImageUtils.loadImage(dailyphoto4, post.getImage(), ImageUtils.DEFAULT_MISSING_IMAGE);
ImageUtils.scaleToFit(dailyphoto4, 280, 174, 30);
break;
default:
Expand Down
Loading
Loading