Class RestClientUtil
java.lang.Object
org.apache.directory.scim.client.rest.RestClientUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkForFourOhFour
(jakarta.ws.rs.client.WebTarget target, jakarta.ws.rs.core.Response response) static void
checkForSuccess
(jakarta.ws.rs.core.Response response) static void
close
(jakarta.ws.rs.core.Response response) Closesresponse
and suppresses any known/expected exceptions from closing it.static void
Closesresponse
and passes any known/expected exceptions from closing it toconsumer
(e.g.extractIdFromLocationTag
(jakarta.ws.rs.core.Response response) static boolean
isSuccessful
(jakarta.ws.rs.core.Response response) static <T> Optional<T>
readEntity
(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> entityType) Read an entity from the response if it was found.static <T> Optional<T>
readEntity
(jakarta.ws.rs.core.Response response, Class<T> entityType) Read an entity from the response if it was found.<T> Optional<T>
tryReadEntity
(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> entityType) Read an entity from the response if it was found and returned.<T> Optional<T>
tryReadEntity
(jakarta.ws.rs.core.Response response, Class<T> entityType) Read an entity from the response if it was found and returned.static void
verifyNotFourOhFour
(jakarta.ws.rs.client.WebTarget target, jakarta.ws.rs.core.Response response)
-
Method Details
-
checkForSuccess
- Throws:
RestException
-
checkForFourOhFour
public static boolean checkForFourOhFour(jakarta.ws.rs.client.WebTarget target, jakarta.ws.rs.core.Response response) -
verifyNotFourOhFour
public static void verifyNotFourOhFour(jakarta.ws.rs.client.WebTarget target, jakarta.ws.rs.core.Response response) throws RestException - Throws:
RestException
-
isSuccessful
public static boolean isSuccessful(jakarta.ws.rs.core.Response response) -
close
public static void close(jakarta.ws.rs.core.Response response) Closesresponse
and suppresses any known/expected exceptions from closing it.- Parameters:
response
-
-
close
Closesresponse
and passes any known/expected exceptions from closing it toconsumer
(e.g. for logging).- Parameters:
response
-consumer
-
-
tryReadEntity
public <T> Optional<T> tryReadEntity(jakarta.ws.rs.core.Response response, Class<T> entityType) throws RestException, jakarta.ws.rs.ProcessingException, IllegalStateException Read an entity from the response if it was found and returned.- Parameters:
response
- theResponse
to read fromentityType
- the type of entity- Returns:
Optional.empty()
if Not Found or empty response, otherwiseOptional.ofNullable(T)
- Throws:
RestException
- ifresponse
is an error response other than404 Not Found
jakarta.ws.rs.ProcessingException
- seeResponse.readEntity(Class)
IllegalStateException
- seeResponse.readEntity(Class)
RestException
-
tryReadEntity
public <T> Optional<T> tryReadEntity(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> entityType) throws RestException, jakarta.ws.rs.ProcessingException, IllegalStateException Read an entity from the response if it was found and returned.- Parameters:
response
- theResponse
to read fromentityType
- the type of entity- Returns:
Optional.empty()
ifNot Found
or empty response, otherwiseOptional.ofNullable(T)
- Throws:
RestException
- ifresponse
is an error response other than404 Not Found
jakarta.ws.rs.ProcessingException
- seeResponse.readEntity(GenericType)
IllegalStateException
- seeResponse.readEntity(GenericType)
RestException
-
readEntity
public static <T> Optional<T> readEntity(jakarta.ws.rs.core.Response response, Class<T> entityType) throws RestException, jakarta.ws.rs.ProcessingException, IllegalStateException Read an entity from the response if it was found.
Useful for REST endpoints that MUST return an entity.
- Parameters:
response
- theResponse
to read fromentityType
- the type of entity- Returns:
Optional.empty()
ifNot Found
, otherwiseOptional.of(T)
- Throws:
RestException
- ifresponse
is an error response other than404 Not Found
jakarta.ws.rs.ProcessingException
- seeResponse.readEntity(Class)
IllegalStateException
- seeResponse.readEntity(Class)
RestException
-
readEntity
public static <T> Optional<T> readEntity(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> entityType) throws RestException, jakarta.ws.rs.ProcessingException, IllegalStateException Read an entity from the response if it was found.
Useful for REST endpoints that MUST return an entity.
- Parameters:
response
- theResponse
to read fromentityType
- the type of entity- Returns:
Optional.empty()
ifNot Found
, otherwiseOptional.of(T)
- Throws:
RestException
- ifresponse
is an error response other than404 Not Found
jakarta.ws.rs.ProcessingException
- seeResponse.readEntity(GenericType)
IllegalStateException
- seeResponse.readEntity(GenericType)
RestException
-
extractIdFromLocationTag
-