diff --git a/nginx/hackerupdates.com.conf b/nginx/hackerupdates.com.conf index 2afe662..4d4c9f8 100644 --- a/nginx/hackerupdates.com.conf +++ b/nginx/hackerupdates.com.conf @@ -1,7 +1,7 @@ server { listen 80; listen [::]:80; - server_name hackerupdate.com www.hackerupdates.com; + server_name hackerupdates.com www.hackerupdates.com; location /api { proxy_pass http://hsw-service:8080; @@ -19,17 +19,21 @@ server { server { listen 443 ssl; listen [::]:443 ssl; - server_name hackerupdate.com www.hackerupdates.com; + server_name hackerupdates.com www.hackerupdates.com; ssl_certificate /etc/ssl/certs/server.pem; ssl_certificate_key /etc/ssl/private/server.key; location / { - rewrite ^/([^\.]+)$ /$1.html; + if ($http_host !~ "^www.hackerupdates.com") { + rewrite ^(.*)$ https://www.$server_name$1; + } + rewrite ^/([^\.]+)$ /$1.html break; } location /api { proxy_pass http://hsw-service:8080; } + } \ No newline at end of file diff --git a/src/main/java/com/hackerupdates/hsw/domain/entity/Activity.java b/src/main/java/com/hackerupdates/hsw/domain/entity/Activity.java index 96207a5..bb6c1a1 100644 --- a/src/main/java/com/hackerupdates/hsw/domain/entity/Activity.java +++ b/src/main/java/com/hackerupdates/hsw/domain/entity/Activity.java @@ -1,5 +1,6 @@ package com.hackerupdates.hsw.domain.entity; +import java.io.Serial; import java.io.Serializable; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -24,6 +25,7 @@ @Getter public class Activity implements Serializable { + @Serial private static final long serialVersionUID = -2241699815447690916L; @Id diff --git a/src/main/java/com/hackerupdates/hsw/domain/entity/Connection.java b/src/main/java/com/hackerupdates/hsw/domain/entity/Connection.java index 2d6d7ed..d4199fa 100644 --- a/src/main/java/com/hackerupdates/hsw/domain/entity/Connection.java +++ b/src/main/java/com/hackerupdates/hsw/domain/entity/Connection.java @@ -1,5 +1,6 @@ package com.hackerupdates.hsw.domain.entity; +import java.io.Serial; import java.io.Serializable; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -24,6 +25,7 @@ @Getter public class Connection implements Serializable { + @Serial private static final long serialVersionUID = 1858746340416571229L; @Id diff --git a/src/main/java/com/hackerupdates/hsw/domain/entity/Person.java b/src/main/java/com/hackerupdates/hsw/domain/entity/Person.java index 0beea83..cfa10f8 100644 --- a/src/main/java/com/hackerupdates/hsw/domain/entity/Person.java +++ b/src/main/java/com/hackerupdates/hsw/domain/entity/Person.java @@ -1,6 +1,8 @@ package com.hackerupdates.hsw.domain.entity; import com.hackerupdates.hsw.enums.Status; + +import java.io.Serial; import java.time.Instant; import lombok.*; @@ -18,6 +20,7 @@ @Setter public class Person implements Serializable { + @Serial private static final long serialVersionUID = 5581667625001993382L; @Id diff --git a/src/main/java/com/hackerupdates/hsw/domain/entity/Share.java b/src/main/java/com/hackerupdates/hsw/domain/entity/Share.java index 52b4560..ca95669 100644 --- a/src/main/java/com/hackerupdates/hsw/domain/entity/Share.java +++ b/src/main/java/com/hackerupdates/hsw/domain/entity/Share.java @@ -1,5 +1,6 @@ package com.hackerupdates.hsw.domain.entity; +import java.io.Serial; import java.io.Serializable; import java.time.Instant; import jakarta.persistence.Entity; @@ -26,6 +27,7 @@ @Getter public class Share implements Serializable { + @Serial private static final long serialVersionUID = -445626973360837740L; @Id diff --git a/src/main/java/com/hackerupdates/hsw/domain/entity/Token.java b/src/main/java/com/hackerupdates/hsw/domain/entity/Token.java index 6559ae7..cd1e9c2 100644 --- a/src/main/java/com/hackerupdates/hsw/domain/entity/Token.java +++ b/src/main/java/com/hackerupdates/hsw/domain/entity/Token.java @@ -1,5 +1,6 @@ package com.hackerupdates.hsw.domain.entity; +import java.io.Serial; import java.io.Serializable; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -27,6 +28,7 @@ }) public class Token implements Serializable { + @Serial private static final long serialVersionUID = 3018776368057112848L; @Id diff --git a/src/main/java/com/hackerupdates/hsw/enums/ValidationRule.java b/src/main/java/com/hackerupdates/hsw/enums/ValidationRule.java index 4fcf0d5..7f9df25 100644 --- a/src/main/java/com/hackerupdates/hsw/enums/ValidationRule.java +++ b/src/main/java/com/hackerupdates/hsw/enums/ValidationRule.java @@ -8,6 +8,7 @@ public enum ValidationRule { PERSON_NOT_FOUND("Person not found"), PERSON_ALREADY_EXISTS("You cannot register with this username. Already registered"), SHARE_NOT_FOUND("Share not found"), + SHARE_IS_BLANK("Share is blank"), COULD_NOT_SIGN_IN("Could not sign in"), INVALID_TOKEN("Invalid token"), INVALID_USER_OR_PASSWORD("Username or password is incorrect"), diff --git a/src/main/java/com/hackerupdates/hsw/service/ConnectionShareService.java b/src/main/java/com/hackerupdates/hsw/service/ConnectionShareService.java index 1655033..d78762f 100644 --- a/src/main/java/com/hackerupdates/hsw/service/ConnectionShareService.java +++ b/src/main/java/com/hackerupdates/hsw/service/ConnectionShareService.java @@ -8,7 +8,6 @@ import com.hackerupdates.hsw.service.person.PersonQueryService; import com.hackerupdates.hsw.service.share.ShareQueryService; import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/hackerupdates/hsw/service/share/ShareCommandService.java b/src/main/java/com/hackerupdates/hsw/service/share/ShareCommandService.java index 2e0cb23..3ca625f 100644 --- a/src/main/java/com/hackerupdates/hsw/service/share/ShareCommandService.java +++ b/src/main/java/com/hackerupdates/hsw/service/share/ShareCommandService.java @@ -20,6 +20,8 @@ public class ShareCommandService { public Share add(Long personId, Share share) { share.setCreatedTime(Instant.now()); share.setPersonId(personId); + if (share.getText().isBlank()) + throw new HswException(ValidationRule.SHARE_IS_BLANK); return shareRepository.save(share); }