diff --git a/00-backend/src/main/java/de/htwsaar/webshop/config/WebConfig.java b/00-backend/src/main/java/de/htwsaar/webshop/config/WebConfig.java index a5b58b3..b668194 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/config/WebConfig.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/config/WebConfig.java @@ -12,9 +12,9 @@ public class WebConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") - .allowedOrigins("http://localhost:5173") // Erlaube Anfragen von der Frontend-Domain - .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // Erlaube spezifische HTTP-Methoden - .allowedHeaders("*") // Erlaube alle Header - .allowCredentials(true); // Erlaube Cookies + .allowedOrigins("http://localhost:5173") // Erlaube Anfragen von der Frontend-Domain + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // Erlaube spezifische HTTP-Methoden + .allowedHeaders("*") // Erlaube alle Header + .allowCredentials(true); // Erlaube Cookies } } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/controller/AccountController.java b/00-backend/src/main/java/de/htwsaar/webshop/controller/AccountController.java index 446b922..ab5db5b 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/controller/AccountController.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/controller/AccountController.java @@ -45,11 +45,11 @@ public class AccountController { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); return ResponseEntity.badRequest().build(); } - if(accountService.existsWithEmail(account.getEmail())) { + if (accountService.existsWithEmail(account.getEmail())) { log.warn("[{}] Account cant be created, Email is already in use", request.getRequestURI()); return ResponseEntity.unprocessableEntity().build(); } - if(accountService.saveNew(account).getId() == null) { + if (accountService.saveNew(account).getId() == null) { return ResponseEntity.internalServerError().build(); } return ResponseEntity.ok().build(); @@ -63,10 +63,10 @@ public class AccountController { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); return ResponseEntity.badRequest().build(); } - if(accountService.existsWithEmail(account.getEmail())) { + if (accountService.existsWithEmail(account.getEmail())) { return ResponseEntity.badRequest().build(); } - if(!accountService.deleteIfExists(account)) { + if (!accountService.deleteIfExists(account)) { return ResponseEntity.badRequest().build(); } return ResponseEntity.ok().build(); @@ -74,15 +74,15 @@ public class AccountController { @RequestMapping(path = ACCOUNT_BASE, method = RequestMethod.GET, produces = "application/json") public ResponseEntity getAccount(HttpServletRequest request, - @RequestParam(PARAM_EMAIL) String email, - @RequestParam(PARAM_PASSWORD) String password) { + @RequestParam(PARAM_EMAIL) String email, + @RequestParam(PARAM_PASSWORD) String password) { logRequest(request); - if(!accountService.existsWithEmail(email)) { + if (!accountService.existsWithEmail(email)) { log.warn("[{}] Account doesn't exist", request.getRequestURI()); return ResponseEntity.badRequest().build(); } Account acc = accountService.isValidLogin(email, password); - if(acc == null) { + if (acc == null) { log.warn("[{}] Invalid Credentials", request.getRequestURI()); return ResponseEntity.badRequest().build(); } @@ -95,22 +95,22 @@ public class AccountController { @RequestParam(PARAM_PASSWORD) String password, @RequestBody Account account) { logRequest(request); - if(validatorService.isInvalid(account)) { + if (validatorService.isInvalid(account)) { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); return ResponseEntity.badRequest().build(); } - if(!accountService.existsWithEmail(email)) { + if (!accountService.existsWithEmail(email)) { log.warn("[{}] Account doesn't exist", request.getRequestURI()); return ResponseEntity.badRequest().build(); } Account loggedIn = accountService.isValidLogin(email, password); - if(loggedIn == null) { + if (loggedIn == null) { log.warn("[{}] Invalid Credentials", request.getRequestURI()); return ResponseEntity.badRequest().build(); } account.setId(loggedIn.getId()); Account saved = accountService.save(account); - if(saved == null) { + if (saved == null) { return ResponseEntity.internalServerError().build(); } return ResponseEntity.ok(saved); diff --git a/00-backend/src/main/java/de/htwsaar/webshop/controller/CustomerController.java b/00-backend/src/main/java/de/htwsaar/webshop/controller/CustomerController.java index 89fa650..291f95c 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/controller/CustomerController.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/controller/CustomerController.java @@ -28,7 +28,7 @@ public class CustomerController { @RequestMapping(path = CUSTOMER_BASE, method = RequestMethod.GET, produces = "application/json") public ResponseEntity getCustomerById(HttpServletRequest request, - @RequestParam(PARAM_ID) Long customerId) { + @RequestParam(PARAM_ID) Long customerId) { logRequest(request); if (customerId == null) { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); @@ -43,14 +43,14 @@ public class CustomerController { @RequestMapping(path = CUSTOMER_BASE, method = RequestMethod.POST, produces = "application/json") public ResponseEntity createCustomer(HttpServletRequest request, - @RequestBody Customer customer) { + @RequestBody Customer customer) { logRequest(request); if (validatorService.isInvalid(customer)) { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); return ResponseEntity.badRequest().build(); } Customer saved = customerService.save(customer); - if(saved.getId() == null) { + if (saved.getId() == null) { return ResponseEntity.internalServerError().build(); } return ResponseEntity.ok(saved); @@ -58,7 +58,7 @@ public class CustomerController { @RequestMapping(path = CUSTOMER_BASE, method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity deleteCustomer(HttpServletRequest request, - @RequestBody Customer customer) { + @RequestBody Customer customer) { logRequest(request); if (validatorService.isInvalid(customer)) { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); @@ -77,7 +77,7 @@ public class CustomerController { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); return ResponseEntity.badRequest().build(); } - if(customerService.findById(id) == null) { + if (customerService.findById(id) == null) { log.warn("[{}] AccountID doesn't exist", request.getRequestURI()); return ResponseEntity.badRequest().build(); } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/controller/ImageController.java b/00-backend/src/main/java/de/htwsaar/webshop/controller/ImageController.java index 9126a5e..6daee52 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/controller/ImageController.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/controller/ImageController.java @@ -15,7 +15,8 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import static de.htwsaar.webshop.config.ControllerPathConfig.*; +import static de.htwsaar.webshop.config.ControllerPathConfig.IMAGE_ALL; +import static de.htwsaar.webshop.config.ControllerPathConfig.IMAGE_BASE; import static de.htwsaar.webshop.config.ParameterConfig.*; import static de.htwsaar.webshop.util.LoggerUtil.logRequest; @@ -33,10 +34,10 @@ public class ImageController { @RequestMapping(path = IMAGE_ALL, method = RequestMethod.GET, produces = "application/json") public ResponseEntity> getAll(HttpServletRequest request, - @RequestParam(value = PARAM_UUID) UUID uuid) { + @RequestParam(value = PARAM_UUID) UUID uuid) { logRequest(request); List images = imageService.getImagesByUUID(uuid); - if(images.isEmpty()) { + if (images.isEmpty()) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } List images_base = new ArrayList<>(); @@ -47,10 +48,10 @@ public class ImageController { @RequestMapping(path = IMAGE_BASE, method = RequestMethod.GET, produces = "text/plain") public ResponseEntity getFirst(HttpServletRequest request, - @RequestParam(value = PARAM_UUID) UUID uuid) { + @RequestParam(value = PARAM_UUID) UUID uuid) { logRequest(request); Image image = imageService.getImageByUUID(uuid); - if(image == null) { + if (image == null) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } return ResponseEntity.ok(image.getBase64()); @@ -58,8 +59,8 @@ public class ImageController { @RequestMapping(path = IMAGE_BASE, method = RequestMethod.POST, produces = "application/json") public ResponseEntity add(HttpServletRequest request, - @RequestParam(value = PARAM_UUID) UUID articleUuid, - @RequestParam(value = PARAM_IMAGE) MultipartFile file) { + @RequestParam(value = PARAM_UUID) UUID articleUuid, + @RequestParam(value = PARAM_IMAGE) MultipartFile file) { logRequest(request); if (articleUuid == null || articleService.findByUUID(articleUuid) == null @@ -74,8 +75,8 @@ public class ImageController { @RequestMapping(path = IMAGE_ALL, method = RequestMethod.POST, produces = "application/json") public ResponseEntity addAll(HttpServletRequest request, - @RequestParam(value = PARAM_UUID) UUID articleUuid, - @RequestParam(value = PARAM_IMAGE) List files) { + @RequestParam(value = PARAM_UUID) UUID articleUuid, + @RequestParam(value = PARAM_IMAGE) List files) { logRequest(request); if (articleUuid == null || articleService.findByUUID(articleUuid) == null diff --git a/00-backend/src/main/java/de/htwsaar/webshop/controller/OrderController.java b/00-backend/src/main/java/de/htwsaar/webshop/controller/OrderController.java index 69517a2..509adb6 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/controller/OrderController.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/controller/OrderController.java @@ -14,7 +14,8 @@ import java.util.List; import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_BASE; import static de.htwsaar.webshop.config.ControllerPathConfig.ORDER_GET_ALL; -import static de.htwsaar.webshop.config.ParameterConfig.*; +import static de.htwsaar.webshop.config.ParameterConfig.PARAM_CUSTOMER_ID; +import static de.htwsaar.webshop.config.ParameterConfig.PARAM_ID; import static de.htwsaar.webshop.util.LoggerUtil.logRequest; @RestController @@ -32,10 +33,10 @@ public class OrderController { @RequestMapping(path = ORDER_GET_ALL, method = RequestMethod.GET, produces = "application/json") public ResponseEntity> getAll(HttpServletRequest request, - @RequestParam(value = PARAM_CUSTOMER_ID) Long customerId) { + @RequestParam(value = PARAM_CUSTOMER_ID) Long customerId) { logRequest(request); List orders = orderService.getAllOrders(customerId); - if(orders.isEmpty()) { + if (orders.isEmpty()) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } return ResponseEntity.ok(orders); @@ -43,10 +44,10 @@ public class OrderController { @RequestMapping(path = ORDER_BASE, method = RequestMethod.GET, produces = "application/json") public ResponseEntity get(HttpServletRequest request, - @RequestParam(value = PARAM_ID) Long orderId) { + @RequestParam(value = PARAM_ID) Long orderId) { logRequest(request); Order image = orderService.getOrderById(orderId); - if(image == null) { + if (image == null) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } return ResponseEntity.ok(image); diff --git a/00-backend/src/main/java/de/htwsaar/webshop/controller/ReviewController.java b/00-backend/src/main/java/de/htwsaar/webshop/controller/ReviewController.java index 7224de5..22ec83b 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/controller/ReviewController.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/controller/ReviewController.java @@ -13,7 +13,8 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.UUID; -import static de.htwsaar.webshop.config.ControllerPathConfig.*; +import static de.htwsaar.webshop.config.ControllerPathConfig.REVIEW_BASE; +import static de.htwsaar.webshop.config.ControllerPathConfig.REVIEW_GET_ALL; import static de.htwsaar.webshop.config.ParameterConfig.*; import static de.htwsaar.webshop.util.LoggerUtil.logRequest; @@ -35,7 +36,7 @@ public class ReviewController { @RequestParam(value = PARAM_UUID) UUID uuid) { logRequest(request); List review = reviewService.getAllByUUID(uuid).stream().map(reviewService::toModel).toList(); - if(review.isEmpty()) { + if (review.isEmpty()) { return ResponseEntity.noContent().build(); } return ResponseEntity.ok(review); @@ -46,7 +47,7 @@ public class ReviewController { @RequestParam(value = PARAM_ID) Long reviewId) { logRequest(request); Review review = reviewService.getReviewById(reviewId); - if(review == null) { + if (review == null) { return ResponseEntity.noContent().build(); } return ResponseEntity.ok(review); @@ -60,7 +61,7 @@ public class ReviewController { logRequest(request); if (uuid == null || articleService.findByUUID(uuid) == null - || rating < 0 || rating > 10) { + || rating < 0 || rating > 10) { log.warn("[{}] failed Validation, sending bad request", request.getRequestURI()); return ResponseEntity.badRequest().body(false); } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/controller/SessionController.java b/00-backend/src/main/java/de/htwsaar/webshop/controller/SessionController.java index 1852587..8dba0e7 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/controller/SessionController.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/controller/SessionController.java @@ -47,12 +47,12 @@ public class SessionController { @RequestMapping(value = SESSION_BASE, method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity delete(@RequestParam String email, @RequestParam UUID token) { - if(email == null || token == null) { + if (email == null || token == null) { log.warn("Got bad request, email and token"); return ResponseEntity.badRequest().body(false); } Session session = sessionService.getByToken(token); - if(!sessionService.isValid(session, email)) { + if (!sessionService.isValid(session, email)) { log.warn("Got bad request, session is invalid"); return ResponseEntity.badRequest().body(false); } @@ -62,16 +62,16 @@ public class SessionController { @RequestMapping(value = SESSION_BASE, method = RequestMethod.GET, produces = "application/json") public ResponseEntity isValid(@RequestParam String email, @RequestParam UUID token) { - if(email == null || token == null) { + if (email == null || token == null) { log.warn("Got bad request, email and token"); return ResponseEntity.badRequest().body(false); } Session session = sessionService.getByToken(token); - if(session == null) { + if (session == null) { log.warn("Got bad request, session is invalid"); return ResponseEntity.notFound().build(); } - if(sessionService.isValid(session, email)) { + if (sessionService.isValid(session, email)) { return ResponseEntity.ok(true); } return ResponseEntity.notFound().build(); diff --git a/00-backend/src/main/java/de/htwsaar/webshop/model/SessionModel.java b/00-backend/src/main/java/de/htwsaar/webshop/model/SessionModel.java index 0f7bd4e..8169123 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/model/SessionModel.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/model/SessionModel.java @@ -1,9 +1,7 @@ package de.htwsaar.webshop.model; -import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Null; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -23,5 +21,4 @@ public class SessionModel { @Min(VALID_MIN_MILLIS_TIMESTAMP) long timeout; - } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/repository/ArticleRepository.java b/00-backend/src/main/java/de/htwsaar/webshop/repository/ArticleRepository.java index 735036d..3e99a36 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/repository/ArticleRepository.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/repository/ArticleRepository.java @@ -3,7 +3,6 @@ package de.htwsaar.webshop.repository; import de.htwsaar.webshop.repository.entities.Article; import lombok.NonNull; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.util.Optional; diff --git a/00-backend/src/main/java/de/htwsaar/webshop/repository/ReviewRepository.java b/00-backend/src/main/java/de/htwsaar/webshop/repository/ReviewRepository.java index a0fb8f6..977471c 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/repository/ReviewRepository.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/repository/ReviewRepository.java @@ -1,15 +1,14 @@ package de.htwsaar.webshop.repository; -import java.util.List; -import java.util.UUID; -import java.util.stream.Stream; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - import de.htwsaar.webshop.repository.entities.Review; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Stream; @Repository public interface ReviewRepository extends JpaRepository { diff --git a/00-backend/src/main/java/de/htwsaar/webshop/repository/entities/Article.java b/00-backend/src/main/java/de/htwsaar/webshop/repository/entities/Article.java index 1bfa0f3..b056edf 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/repository/entities/Article.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/repository/entities/Article.java @@ -3,11 +3,7 @@ package de.htwsaar.webshop.repository.entities; import jakarta.persistence.*; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; +import lombok.*; import java.util.ArrayList; import java.util.List; diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/AccountService.java b/00-backend/src/main/java/de/htwsaar/webshop/service/AccountService.java index d23d46c..313a417 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/AccountService.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/AccountService.java @@ -4,8 +4,12 @@ import de.htwsaar.webshop.repository.entities.Account; public interface AccountService { Account saveNew(Account account); + Account save(Account account); + boolean deleteIfExists(Account account); + Account isValidLogin(String email, String password); + boolean existsWithEmail(String email); } \ No newline at end of file diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/CustomerService.java b/00-backend/src/main/java/de/htwsaar/webshop/service/CustomerService.java index 6f66c38..697bed8 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/CustomerService.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/CustomerService.java @@ -4,6 +4,8 @@ import de.htwsaar.webshop.repository.entities.Customer; public interface CustomerService { Customer save(Customer customer); + void delete(Customer customer); + Customer findById(Long id); } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/OrderService.java b/00-backend/src/main/java/de/htwsaar/webshop/service/OrderService.java index 9a6c2b4..b3d13ba 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/OrderService.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/OrderService.java @@ -6,7 +6,10 @@ import java.util.List; public interface OrderService { Order save(Order order); + void delete(Long orderId); + Order getOrderById(Long orderId); + List getAllOrders(Long customerId); } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/PasswordService.java b/00-backend/src/main/java/de/htwsaar/webshop/service/PasswordService.java index 5dbc1e0..694ce58 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/PasswordService.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/PasswordService.java @@ -2,5 +2,6 @@ package de.htwsaar.webshop.service; public interface PasswordService { String hashPassword(String password); + boolean verifyPassword(String password, String hashedPassword); } \ No newline at end of file diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/ReviewService.java b/00-backend/src/main/java/de/htwsaar/webshop/service/ReviewService.java index cd03232..f621ab8 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/ReviewService.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/ReviewService.java @@ -1,16 +1,21 @@ package de.htwsaar.webshop.service; -import java.util.List; -import java.util.UUID; - import de.htwsaar.webshop.model.ReviewModel; import de.htwsaar.webshop.repository.entities.Review; +import java.util.List; +import java.util.UUID; + public interface ReviewService { Review save(Review review); + Review save(UUID articleUuid, int rating, String content); + void delete(Long reviewId); + Review getReviewById(Long id); + List getAllByUUID(UUID uuid); + ReviewModel toModel(Review review); } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/SessionService.java b/00-backend/src/main/java/de/htwsaar/webshop/service/SessionService.java index 95d3e05..b7e53c6 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/SessionService.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/SessionService.java @@ -1,6 +1,5 @@ package de.htwsaar.webshop.service; -import de.htwsaar.webshop.model.SessionModel; import de.htwsaar.webshop.repository.entities.Account; import de.htwsaar.webshop.repository.entities.Session; @@ -8,9 +7,14 @@ import java.util.UUID; public interface SessionService { Session create(Account account); + void delete(Session session); + Session findByAccount(Account account); + Session getByToken(UUID token); + boolean isValid(Session session, String email); + boolean isValid(UUID token, String email); } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/AccountServiceImpl.java b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/AccountServiceImpl.java index 32419d0..0f4ae38 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/AccountServiceImpl.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/AccountServiceImpl.java @@ -32,7 +32,7 @@ public class AccountServiceImpl implements AccountService { @Override public boolean deleteIfExists(Account account) { Account tbd = accountRepository.getAccountByEmail(account.getEmail()); - if(tbd == null) { + if (tbd == null) { return false; } accountRepository.delete(tbd); @@ -42,7 +42,7 @@ public class AccountServiceImpl implements AccountService { @Override public Account isValidLogin(String email, String password) { Account acc = accountRepository.getAccountByEmail(email); - if(acc == null) { + if (acc == null) { return null; } return passwordService.verifyPassword(password, acc.getPassword()) ? acc : null; diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ImageServiceImpl.java b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ImageServiceImpl.java index 4694f82..43c0aa5 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ImageServiceImpl.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ImageServiceImpl.java @@ -53,7 +53,7 @@ public class ImageServiceImpl implements ImageService { @Transactional public Image save(UUID uuid, String uri) { Article article = articleService.findByUUID(uuid); - if(article == null) { + if (article == null) { return null; } Image image = new Image(null, article, uri); @@ -63,12 +63,12 @@ public class ImageServiceImpl implements ImageService { @Override public Image save(UUID uuid, MultipartFile file) { - if(uuid == null) { + if (uuid == null) { log.warn("Got no UUID, aborting"); return null; } Article article = articleService.findByUUID(uuid); - if(article == null) { + if (article == null) { log.warn("Could not find article with id {}", uuid); return null; } @@ -79,7 +79,7 @@ public class ImageServiceImpl implements ImageService { try { String based64 = Base64.getEncoder().encodeToString(file.getBytes()); - if(based64 == null || based64.isEmpty()) { + if (based64 == null || based64.isEmpty()) { log.warn("Could not save image with id {} and file size {}", uuid, file.getSize()); return null; } diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ReviewServiceImpl.java b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ReviewServiceImpl.java index e0d7027..f79701a 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ReviewServiceImpl.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/ReviewServiceImpl.java @@ -32,7 +32,7 @@ public class ReviewServiceImpl implements ReviewService { @Override public Review save(UUID articleUuid, int rating, String content) { - if(articleUuid == null) { + if (articleUuid == null) { return null; } Review review = new Review(null, content, articleService.findByUUID(articleUuid), rating, System.currentTimeMillis()); diff --git a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/SessionServiceImpl.java b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/SessionServiceImpl.java index f250ec7..c3f2b75 100644 --- a/00-backend/src/main/java/de/htwsaar/webshop/service/impl/SessionServiceImpl.java +++ b/00-backend/src/main/java/de/htwsaar/webshop/service/impl/SessionServiceImpl.java @@ -1,6 +1,5 @@ package de.htwsaar.webshop.service.impl; -import de.htwsaar.webshop.model.SessionModel; import de.htwsaar.webshop.repository.AccountRepository; import de.htwsaar.webshop.repository.SessionRepository; import de.htwsaar.webshop.repository.entities.Account; @@ -51,14 +50,14 @@ public class SessionServiceImpl implements SessionService { @Override public boolean isValid(Session session, String email) { - if(session == null || email == null) { + if (session == null || email == null) { return false; } Account accountEmail = accountRepository.getAccountByEmail(email); - if(!session.getAccount().equals(accountEmail)) { + if (!session.getAccount().equals(accountEmail)) { return false; } - if(session.getTimeout() >= System.currentTimeMillis()) { + if (session.getTimeout() >= System.currentTimeMillis()) { log.info("Session with email {} is expired", email); delete(session); return false;