use of jakarta.ws.rs.core.Form in project radiobrowser4j by sfuhrm.
the class RadioBrowser method listStationsPathWithLimit.
/**
* Get a list of all stations on a certain API path.
* @param limit the limit of the page to retrieve.
* @param path the path to retrieve, for example "json/stations".
* @param listParam the optional listing parameters.
* @return the partial list of the stations. Can be empty for exceeding the
* possible stations.
*/
private List<Station> listStationsPathWithLimit(final Optional<Limit> limit, final String path, final ListParameter... listParam) {
MultivaluedMap<String, String> requestParams = new MultivaluedHashMap<>();
Arrays.stream(listParam).forEach(lp -> lp.applyTo(requestParams));
Entity<Form> entity = Entity.form(requestParams);
Response response = null;
try {
WebTarget target = webTarget.path(path);
if (limit.isPresent()) {
target = target.path(Integer.toString(limit.get().getSize()));
}
response = builder(target).post(entity);
checkResponseStatus(response);
return response.readEntity(new GenericType<List<Station>>() {
});
} finally {
close(response);
}
}
use of jakarta.ws.rs.core.Form in project radiobrowser4j by sfuhrm.
the class RadioBrowser method listStationsBy.
/**
* Get a list of stations matching a certain search criteria.
* Will return a single batch.
* @param paging the offset and limit of the page to retrieve.
* @param searchMode the field to match.
* @param searchTerm the term to search for.
* @param listParam the optional listing parameters.
* @return the partial list of the stations. Can be empty for exceeding the
* number of matching stations.
*/
public List<Station> listStationsBy(@NonNull final Paging paging, @NonNull final SearchMode searchMode, @NonNull final String searchTerm, final ListParameter... listParam) {
MultivaluedMap<String, String> requestParams = new MultivaluedHashMap<>();
applyPaging(paging, requestParams);
Arrays.stream(listParam).forEach(l -> l.applyTo(requestParams));
Entity<Form> entity = Entity.form(requestParams);
Response response = null;
try {
response = builder(webTarget.path("json/stations").path(searchMode.name().toLowerCase()).path(searchTerm)).post(entity);
checkResponseStatus(response);
return response.readEntity(new GenericType<List<Station>>() {
});
} finally {
close(response);
}
}
use of jakarta.ws.rs.core.Form in project radiobrowser4j by sfuhrm.
the class RadioBrowser method listStationsPathWithPaging.
/**
* Get a list of all stations on a certain API path.
* @param paging the offset and limit of the page to retrieve.
* @param path the path to retrieve, for example "json/stations".
* @param listParam the optional listing parameters.
* @return the partial list of the stations. Can be empty for exceeding the
* possible stations.
*/
private List<Station> listStationsPathWithPaging(final Optional<Paging> paging, final String path, final ListParameter... listParam) {
MultivaluedMap<String, String> requestParams = new MultivaluedHashMap<>();
paging.ifPresent(p -> applyPaging(p, requestParams));
Arrays.stream(listParam).forEach(lp -> lp.applyTo(requestParams));
Entity<Form> entity = Entity.form(requestParams);
Response response = null;
try {
response = builder(webTarget.path(path)).post(entity);
checkResponseStatus(response);
return response.readEntity(new GenericType<List<Station>>() {
});
} finally {
close(response);
}
}
use of jakarta.ws.rs.core.Form in project minijax by minijax.
the class FormParamTest method testWholeForm.
@Test
void testWholeForm() {
final Entity<Form> form = Entity.form(new Form("test", "Hello"));
assertEquals("Hello", server.target("/wholeform").request().post(form, String.class));
}
use of jakarta.ws.rs.core.Form in project minijax by minijax.
the class FormParamTest method testFormParamDefaultValue.
@Test
void testFormParamDefaultValue() {
final Entity<Form> form = Entity.form(new Form());
assertEquals("foo", server.target("/defval").request().post(form, String.class));
}
Aggregations