|
5 | 5 |
|
6 | 6 | import com.fasterxml.jackson.core.JsonProcessingException;
|
7 | 7 | import io.securecodebox.persistence.defectdojo.model.Model;
|
| 8 | +import lombok.NonNull; |
8 | 9 |
|
9 | 10 | import java.net.URISyntaxException;
|
10 | 11 | import java.util.List;
|
|
13 | 14 |
|
14 | 15 | /**
|
15 | 16 | * Basic CRUD interface for DefectDojo REST API
|
| 17 | + * |
| 18 | + * @param <T> Type of model the implementation deals with |
16 | 19 | */
|
17 | 20 | public interface DefectDojoService<T extends Model> {
|
| 21 | + /** |
| 22 | + * Get a single model object by its id from DefectDojo |
| 23 | + * <p> |
| 24 | + * TODO: Use Optional here instead of null as return value |
| 25 | + * |
| 26 | + * @param id must not be less than 1 |
| 27 | + * @return maybe {@code null} |
| 28 | + */ |
18 | 29 | T get(long id);
|
19 | 30 |
|
20 |
| - List<T> search(Map<String, Object> queryParams) throws URISyntaxException, JsonProcessingException; |
| 31 | + /** |
| 32 | + * Search for model objects by query parameters (name value pairs) in DefectDojo |
| 33 | + * |
| 34 | + * @param queryParams not {@code null} |
| 35 | + * @return not {@code null}, maybe empty |
| 36 | + * @throws URISyntaxException |
| 37 | + * @throws JsonProcessingException |
| 38 | + */ |
| 39 | + List<T> search(@NonNull Map<String, Object> queryParams) throws URISyntaxException, JsonProcessingException; |
21 | 40 |
|
| 41 | + /** |
| 42 | + * Get list of all model objects in DefectDojo |
| 43 | + * |
| 44 | + * @return never {@code null}, maybe empty |
| 45 | + * @throws URISyntaxException |
| 46 | + * @throws JsonProcessingException |
| 47 | + */ |
22 | 48 | List<T> search() throws URISyntaxException, JsonProcessingException;
|
23 | 49 |
|
24 |
| - Optional<T> searchUnique(T searchObject) throws URISyntaxException, JsonProcessingException; |
| 50 | + /** |
| 51 | + * Search for a single model object in DefectDojo |
| 52 | + * <p> |
| 53 | + * If multiple objects were found the first one will be returned. |
| 54 | + * </p> |
| 55 | + * |
| 56 | + * @param searchObject not {@code null} |
| 57 | + * @return never {@code null} |
| 58 | + * @throws URISyntaxException |
| 59 | + * @throws JsonProcessingException |
| 60 | + */ |
| 61 | + Optional<T> searchUnique(@NonNull T searchObject) throws URISyntaxException, JsonProcessingException; |
25 | 62 |
|
26 |
| - Optional<T> searchUnique(Map<String, Object> queryParams) throws URISyntaxException, JsonProcessingException; |
| 63 | + /** |
| 64 | + * Search for a single model object in DefectDojo |
| 65 | + * <p> |
| 66 | + * If multiple objects were found the first one will be returned. |
| 67 | + * </p> |
| 68 | + * |
| 69 | + * @param queryParams not {@code null} |
| 70 | + * @return never {@code null} |
| 71 | + * @throws URISyntaxException |
| 72 | + * @throws JsonProcessingException |
| 73 | + */ |
| 74 | + Optional<T> searchUnique(@NonNull Map<String, Object> queryParams) throws URISyntaxException, JsonProcessingException; |
27 | 75 |
|
28 |
| - T create(T object); |
| 76 | + /** |
| 77 | + * Create the given model object in DefectDojo |
| 78 | + * <p> |
| 79 | + * Use the returned object for further processing because DefectDojo may alter it (e.g. the id). |
| 80 | + * </p> |
| 81 | + * |
| 82 | + * @param object not {@code null} |
| 83 | + * @return never {@code null} |
| 84 | + */ |
| 85 | + T create(@NonNull T object); |
29 | 86 |
|
| 87 | + /** |
| 88 | + * Delete the given model object in DefectDojo identified by its id |
| 89 | + * |
| 90 | + * @param id must not be less than 1 |
| 91 | + */ |
30 | 92 | void delete(long id);
|
31 | 93 |
|
32 |
| - T update(T object, long objectId); |
| 94 | + /** |
| 95 | + * Update the given model object in DefectDojo identified by its id |
| 96 | + * |
| 97 | + * <p> |
| 98 | + * Use the returned object for further processing because DefectDojo may alter it (e.g. the id). |
| 99 | + * </p> |
| 100 | + * |
| 101 | + * @param object not {@code null} |
| 102 | + * @param id must not be less than 1 |
| 103 | + * @return never {@code null} |
| 104 | + */ |
| 105 | + T update(@NonNull T object, long id); |
33 | 106 | }
|
0 commit comments