aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/controller
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java4
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java11
2 files changed, 5 insertions, 10 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
index dfcb8a3..15a741a 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.ufund.api.ufundapi.model.Need;
import com.ufund.api.ufundapi.model.Need.GoalType;
import com.ufund.api.ufundapi.service.CupboardService;
-import com.ufund.api.ufundapi.service.CupboardService.DuplicateKeyException;
+import com.ufund.api.ufundapi.DuplicateKeyException;
@RestController
@RequestMapping("cupboard")
@@ -50,7 +50,7 @@ public class CupboardController {
public ResponseEntity<Need> createNeed(@RequestBody Map<String, String> params) {
String name = params.get("name");
int maxGoal = Integer.parseInt(params.get("maxGoal"));
- Need.GoalType goalType = GoalType.valueOf(params.get("maxGoal"));
+ Need.GoalType goalType = GoalType.valueOf(params.get("goalType"));
try {
Need need = cupboardService.createNeed(name, maxGoal, goalType);
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java
index 02526af..21cd1b3 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java
@@ -5,6 +5,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.ufund.api.ufundapi.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -20,12 +21,6 @@ public class UserController {
private final UserService userService;
private final AuthService authService;
- /**
- * Creates a UserController
- *
- * @param userService
- * @param authService
- */
public UserController(UserService userService, AuthService authService) {
this.userService = userService;
this.authService = authService;
@@ -49,7 +44,8 @@ public class UserController {
} else {
return new ResponseEntity<>(HttpStatus.CONFLICT);
}
-
+ } catch (DuplicateKeyException ex) {
+ return new ResponseEntity<>(HttpStatus.CONFLICT);
} catch (IOException ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
@@ -93,7 +89,6 @@ public class UserController {
*/
@PutMapping("/{username}")
public ResponseEntity<User> updateUser(@RequestBody User user, @PathVariable String username, @RequestHeader("jelly-api-key") String key) {
-
try {
authService.authenticate(username, key);
user = userService.updateUser(user, username);