3636
3737// FIXME: Should be package private bc implementation detail.
3838public abstract class GenericDefectDojoService <T extends Model > {
39- protected Config config ;
39+ private static final String API_PREFIX = "/api/v2/" ;
40+ protected Config config ;
4041
4142 protected ObjectMapper objectMapper ;
4243 protected ObjectMapper searchStringMapper ;
@@ -94,7 +95,7 @@ public T get(long id) {
9495 HttpEntity <String > payload = new HttpEntity <>(getDefectDojoAuthorizationHeaders ());
9596
9697 ResponseEntity <T > response = restTemplate .exchange (
97- this .config .getUrl () + "/api/v2/" + this .getUrlPath () + "/" + id ,
98+ this .config .getUrl () + API_PREFIX + this .getUrlPath () + "/" + id ,
9899 HttpMethod .GET ,
99100 payload ,
100101 getModelClass ()
@@ -117,7 +118,7 @@ protected Response<T> internalSearch(Map<String, Object> queryParams, long limit
117118 multiValueMap .set (entry .getKey (), String .valueOf (entry .getValue ()));
118119 }
119120
120- var url = new URI (this .config .getUrl () + "/api/v2/" + this .getUrlPath () + "/" );
121+ var url = new URI (this .config .getUrl () + API_PREFIX + this .getUrlPath () + "/" );
121122 var uriBuilder = UriComponentsBuilder .fromUri (url ).queryParams (multiValueMap );
122123
123124 ResponseEntity <String > responseString = restTemplate .exchange (
@@ -175,22 +176,22 @@ public T create(T object) {
175176 var restTemplate = this .getRestTemplate ();
176177 HttpEntity <T > payload = new HttpEntity <>(object , getDefectDojoAuthorizationHeaders ());
177178
178- ResponseEntity <T > response = restTemplate .exchange (this .config .getUrl () + "/api/v2/" + getUrlPath () + "/" , HttpMethod .POST , payload , getModelClass ());
179+ ResponseEntity <T > response = restTemplate .exchange (this .config .getUrl () + API_PREFIX + getUrlPath () + "/" , HttpMethod .POST , payload , getModelClass ());
179180 return response .getBody ();
180181 }
181182
182183 public void delete (long id ) {
183184 var restTemplate = this .getRestTemplate ();
184185 HttpEntity <String > payload = new HttpEntity <>(getDefectDojoAuthorizationHeaders ());
185186
186- restTemplate .exchange (this .config .getUrl () + "/api/v2/" + getUrlPath () + "/" + id + "/" , HttpMethod .DELETE , payload , String .class );
187+ restTemplate .exchange (this .config .getUrl () + API_PREFIX + getUrlPath () + "/" + id + "/" , HttpMethod .DELETE , payload , String .class );
187188 }
188189
189190 public T update (T object , long objectId ) {
190191 var restTemplate = this .getRestTemplate ();
191192 HttpEntity <T > payload = new HttpEntity <>(object , getDefectDojoAuthorizationHeaders ());
192193
193- ResponseEntity <T > response = restTemplate .exchange (this .config .getUrl () + "/api/v2/" + getUrlPath () + "/" + objectId + "/" , HttpMethod .PUT , payload , getModelClass ());
194+ ResponseEntity <T > response = restTemplate .exchange (this .config .getUrl () + API_PREFIX + getUrlPath () + "/" + objectId + "/" , HttpMethod .PUT , payload , getModelClass ());
194195 return response .getBody ();
195196 }
196197}
0 commit comments