-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/github_actions/alldependencies-c3…
…b804ca35
- Loading branch information
Showing
32 changed files
with
6,853 additions
and
2,613 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...client/src/main/java/mil/army/usace/hec/cwms/radar/client/controllers/LockController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package mil.army.usace.hec.cwms.radar.client.controllers; | ||
|
||
import static mil.army.usace.hec.cwms.radar.client.controllers.RadarEndpointConstants.ACCEPT_HEADER_V1; | ||
import static mil.army.usace.hec.cwms.radar.client.controllers.RadarEndpointConstants.ACCEPT_QUERY_HEADER; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import mil.army.usace.hec.cwms.http.client.ApiConnectionInfo; | ||
import mil.army.usace.hec.cwms.http.client.HttpRequestBuilderImpl; | ||
import mil.army.usace.hec.cwms.http.client.HttpRequestResponse; | ||
import mil.army.usace.hec.cwms.http.client.request.HttpRequestExecutor; | ||
import mil.army.usace.hec.cwms.radar.client.model.Lock; | ||
import mil.army.usace.hec.cwms.radar.client.model.RadarObjectMapper; | ||
|
||
|
||
public final class LockController { | ||
private static final String LOCK_ENDPOINT = "projects/locks"; | ||
|
||
public Lock retrieveLock(ApiConnectionInfo apiConnectionInfo, LockEndpointInput.GetOne input) throws IOException { | ||
HttpRequestExecutor executor = new HttpRequestBuilderImpl(apiConnectionInfo, LOCK_ENDPOINT + "/" + input.lockName()) | ||
.addQueryHeader(ACCEPT_QUERY_HEADER, ACCEPT_HEADER_V1) | ||
.addEndpointInput(input) | ||
.get() | ||
.withMediaType(ACCEPT_HEADER_V1); | ||
try (HttpRequestResponse response = executor.execute()) { | ||
return RadarObjectMapper.mapJsonToObject(response.getBody(), Lock.class); | ||
} | ||
} | ||
|
||
public void storeLock(ApiConnectionInfo apiConnectionInfo, LockEndpointInput.Post input) throws IOException { | ||
String body = RadarObjectMapper.mapObjectToJson(input.lock()); | ||
new HttpRequestBuilderImpl(apiConnectionInfo, LOCK_ENDPOINT) | ||
.addQueryHeader(ACCEPT_QUERY_HEADER, ACCEPT_HEADER_V1) | ||
.addEndpointInput(input) | ||
.post() | ||
.withBody(body) | ||
.withMediaType(ACCEPT_HEADER_V1) | ||
.execute() | ||
.close(); | ||
} | ||
|
||
public void renameLock(ApiConnectionInfo apiConnectionInfo, LockEndpointInput.Patch input) throws IOException { | ||
new HttpRequestBuilderImpl(apiConnectionInfo, LOCK_ENDPOINT + "/" + input.oldLockName()) | ||
.addQueryHeader(ACCEPT_QUERY_HEADER, ACCEPT_HEADER_V1) | ||
.addEndpointInput(input) | ||
.patch() | ||
.withMediaType(ACCEPT_HEADER_V1) | ||
.execute() | ||
.close(); | ||
} | ||
|
||
public void deleteLock(ApiConnectionInfo apiConnectionInfo, LockEndpointInput.Delete input) throws IOException { | ||
new HttpRequestBuilderImpl(apiConnectionInfo, LOCK_ENDPOINT + "/" + input.lockName()) | ||
.addQueryHeader(ACCEPT_QUERY_HEADER, ACCEPT_HEADER_V1) | ||
.addEndpointInput(input) | ||
.delete() | ||
.withMediaType(ACCEPT_HEADER_V1) | ||
.execute() | ||
.close(); | ||
} | ||
|
||
public List<Lock> retrieveLocks(ApiConnectionInfo apiConnectionInfo, LockEndpointInput.GetAll input) throws IOException { | ||
HttpRequestExecutor executor = new HttpRequestBuilderImpl(apiConnectionInfo, LOCK_ENDPOINT) | ||
.addQueryHeader(ACCEPT_QUERY_HEADER, ACCEPT_HEADER_V1) | ||
.addEndpointInput(input) | ||
.get() | ||
.withMediaType(ACCEPT_HEADER_V1); | ||
try (HttpRequestResponse response = executor.execute()) { | ||
return RadarObjectMapper.mapJsonToListOfObjects(response.getBody(), Lock.class); | ||
} | ||
} | ||
} |
Oops, something went wrong.