diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-02-16 13:28:28 -0500 | 
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-02-16 13:28:28 -0500 | 
| commit | 43523d16696b0dcbbd1d44af3e31f08de702d921 (patch) | |
| tree | 44dc309cc6b58155b65f068da5f9bf16ca662848 | |
| parent | a4aa226955df2284a298b6ae35ee72d4996978a3 (diff) | |
| parent | 384ba7ea4205196085a060b18db43f29aac3079b (diff) | |
| download | JellySolutions-43523d16696b0dcbbd1d44af3e31f08de702d921.tar.gz JellySolutions-43523d16696b0dcbbd1d44af3e31f08de702d921.tar.bz2 JellySolutions-43523d16696b0dcbbd1d44af3e31f08de702d921.zip  | |
Merge remote-tracking branch 'origin/main'
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | docs/domain-model-placeholder.png | bin | 28823 -> 0 bytes | |||
| -rw-r--r-- | docs/domain-model.png | bin | 0 -> 56620 bytes | |||
| -rw-r--r-- | docs/u-fund.drawio.png (renamed from u-fund.drawio.png) | bin | 90269 -> 90269 bytes | |||
| -rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 37 | 
5 files changed, 35 insertions, 4 deletions
@@ -1,4 +1,4 @@ -# U-Fund:  _____ _replace with your particular fundraising type_ _____ +# U-Fund: Coral Reefs  # Modify this document to expand any and all sections that are applicable for a better understanding from your users/testers/collaborators (remove this comment and other instructions areas for your FINAL release)  An online U-Fund system built in Java **21** and ___ _replace with other platform requirements_ ___ diff --git a/docs/domain-model-placeholder.png b/docs/domain-model-placeholder.png Binary files differdeleted file mode 100644 index ba1ef65..0000000 --- a/docs/domain-model-placeholder.png +++ /dev/null diff --git a/docs/domain-model.png b/docs/domain-model.png Binary files differnew file mode 100644 index 0000000..75b4377 --- /dev/null +++ b/docs/domain-model.png diff --git a/u-fund.drawio.png b/docs/u-fund.drawio.png Binary files differindex e607a2b..e607a2b 100644 --- a/u-fund.drawio.png +++ b/docs/u-fund.drawio.png 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 c99a95b..27185b0 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 @@ -1,19 +1,27 @@  package com.ufund.api.ufundapi.controller; +import java.util.logging.Level; +import java.util.logging.Logger; +  import com.ufund.api.ufundapi.model.Cupboard;  import com.ufund.api.ufundapi.model.Need; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity;  import org.springframework.web.bind.annotation.*; +import java.io.IOException;  import java.util.ArrayList;  @RestController  @RequestMapping("cupboard")  public class CupboardController { +    private static final Logger LOG = Logger.getLogger(CupboardController.class.getName());      private ArrayList<Need> needs;      private Cupboard cupboard;      @PostMapping("") -    public void createNeed(@RequestBody Need need) {; +    public void createNeed(@RequestBody Need need) {          cupboard.createNeed(need);      } @@ -27,9 +35,32 @@ public class CupboardController {          return cupboard.findNeeds(name);      } +    /** +     * Responds to the GET request for a {@linkplain Need need} for the given id +     *  +     * @param id The id used to locate the {@link Need need} +     *  +     * @return ResponseEntity with {@link Need need} object and HTTP status of OK if found<br> +     * ResponseEntity with HTTP status of NOT_FOUND if not found<br> +     * ResponseEntity with HTTP status of INTERNAL_SERVER_ERROR otherwise +     */      @GetMapping("/{id}") -    public Need getNeed(@PathVariable int id) { -        return cupboard.getNeed(id); +    public ResponseEntity<Need> getNeed(@PathVariable int id) { +        LOG.log(Level.INFO, "GET /need/{0}", id); + +        try { +            Need need = cupboard.getNeed(id); +            if (need != null) { +                return new ResponseEntity<>(need, HttpStatus.OK); +            } else { +                return new ResponseEntity<>(HttpStatus.NOT_FOUND); +            } +             +        } catch (IOException e) { +            LOG.log(Level.SEVERE, e.getLocalizedMessage()); +            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); +        } +      }      @PutMapping("")  | 
