本文整理汇总了Java中javax.ws.rs.core.UriBuilderException类的典型用法代码示例。如果您正苦于以下问题:Java UriBuilderException类的具体用法?Java UriBuilderException怎么用?Java UriBuilderException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriBuilderException类属于javax.ws.rs.core包,在下文中一共展示了UriBuilderException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rewriteURL
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
@Override
public String rewriteURL(@Nullable RuntimeIdentity identity, @Nullable String name, String url)
throws InfrastructureException {
if (externalIpOfContainers != null) {
try {
URI uri = UriBuilder.fromUri(url).host(externalIpOfContainers).build();
url = uri.toString();
} catch (UriBuilderException | IllegalArgumentException e) {
throw new InternalInfrastructureException(
format(
"Rewriting of host '%s' in URL '%s' failed. Error: %s",
externalIpOfContainers, url, e.getMessage()));
}
}
return url;
}
示例2: configureClient
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
/**
* Returns a Rest client configured with the specified properties.
*
* @param path
* : path where the client is going to connect (e.g.
* /infrastructures/asdalk-asd34/vms)
* @param parameters
* : extra parameters for the call (if needed)
* @return : REST client
*/
public Builder configureClient(final String path,
final RestParameter... parameters) throws ImClientException {
try {
WebTarget webtarget = getClient()
.target(UriBuilder.fromUri(getTargetUrl()).build()).path(path);
if (parameters != null && parameters.length > 0
&& parameters[0] != null) {
for (RestParameter parameter : parameters) {
webtarget.queryParam(parameter.getName(), parameter.getValues());
}
}
return webtarget.request(MediaType.APPLICATION_JSON)
.header(AUTH_HEADER_TAG, getParsedAuthFile());
} catch (IllegalArgumentException | UriBuilderException exception) {
ImJavaApiLogger.severe(this.getClass(), exception);
throw exception;
}
}
示例3: prepareGETInvocationBuilder
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
/**
* @param baseUri
*
* @return
*
* @throws UnsupportedEncodingException
* @throws UriBuilderException
* @throws IllegalArgumentException
*/
private Invocation prepareGETInvocationBuilder(final String mimeType, final String query)
throws IllegalArgumentException, UriBuilderException, UnsupportedEncodingException {
final UriBuilder baseBuilder = UriBuilder.fromUri(HOST).port(PORT);
final URI targetUri = baseBuilder.path(QueryExecutor.ENDPOINT_NAME)
.queryParam(QUERY_PARAM, URLEncoder.encode(query, "UTF-8").replace("+", "%20")).build();
final Client client = ClientBuilder.newClient();
final WebTarget resourceTarget = client.target(targetUri);
final Builder invocationBuilder = resourceTarget.request(mimeType);
final Invocation invocation = invocationBuilder.buildGet();
return invocation;
}
示例4: preparePOSTInvocationBuilder
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
/**
* @param baseUri
*
* @return
*
* @throws UnsupportedEncodingException
* @throws UriBuilderException
* @throws IllegalArgumentException
*/
private Invocation preparePOSTInvocationBuilder(final String mimeType, final String contentType, final String query)
throws IllegalArgumentException, UriBuilderException, UnsupportedEncodingException {
final UriBuilder baseBuilder = UriBuilder.fromUri(HOST).port(PORT);
final URI targetUri = baseBuilder.path(QueryExecutor.ENDPOINT_NAME).build();
final Client client = ClientBuilder.newClient();
final WebTarget resourceTarget = client.target(targetUri);
final Builder invocationBuilder = resourceTarget.request(mimeType);
final Entity<String> entity = Entity.entity(query,
Variant.mediaTypes(MediaType.valueOf(contentType))
.encodings("UTF-8")
.build()
.get(0),
null);
final Invocation invocation = invocationBuilder.buildPost(entity);
return invocation;
}
示例5: testQueryExecutionSuccessfulGET
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
/**
* @throws IllegalMimeTypeException
* @throws UnsupportedEncodingException
* @throws UriBuilderException
* @throws IllegalArgumentException
*/
@Test
public void testQueryExecutionSuccessfulGET()
throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
UnsupportedEncodingException {
testSuccessfulMethod(Method.GET);
}
示例6: testQueryExecutionSuccessfulURLPOST
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
/**
* @throws IllegalMimeTypeException
* @throws UnsupportedEncodingException
* @throws UriBuilderException
* @throws IllegalArgumentException
*/
@Test
public void testQueryExecutionSuccessfulURLPOST()
throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
UnsupportedEncodingException {
testSuccessfulMethod(Method.URL_ENCODED_POST);
}
示例7: asJson
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
/**
* Returns the resource formatted as json
*
* @return JSONObject * @throws JSONException
*/
@SuppressWarnings("unchecked")
public JSONObject asJson() throws JSONException {
JSONObject messagesAsJson = super.asJson();
// fill data
JSONArray queuesArray = new JSONArray();
List<?> items = getItems();
if (items.size() > 0) {
if (null != queueEntity){
for (Object[] messageEntity : (List<Object[]>) items) {
try {
queuesArray.put(GroupMessageResource.asJson(
messageEntity,
isMessageInQueue,
needsPayload,UriBuilder.fromPath(getUriInfo().getPath())
.path(messageEntity[0].toString()).build()
.getPath()));
} catch (IllegalArgumentException | UriBuilderException
| ParseException e) {
// TODO Auto-generated catch block
}
}
}
}
messagesAsJson.put("groupmessages", queuesArray);
return messagesAsJson;
}
示例8: testCurlyBrackets
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
/**
* Test http://dev.gbif.org/issues/browse/POR-2688
* We expect a client handler or uniform interface exception cause we did not setup the entire jersey stack properly.
* We only want to make sure there is no UriBuilderException thrown
*/
@Test
public void testCurlyBrackets() {
try {
WebResource api = Client.create().resource("http://api.gbif.org/v1/species/match");
WebResource q = api.queryParam("name", "Nereis southerni %7B%7Bnowrap Abdel-Moez & Humphries, 1955");
assertEquals(
"http://api.gbif.org/v1/species/match?name=Nereis+southerni+%7B%7Bnowrap+Abdel-Moez+%26+Humphries,+1955",
q.toString());
NameUsageMatchWsClient client = new NameUsageMatchWsClient(api);
client.match("Nereis southerni {{nowrap Abdel-Moez & Humphries, 1955", null, null, false, false);
} catch (RuntimeException e) {
if (e instanceof UriBuilderException) {
throw e;
}
System.out.println(e.toString());
}
}
示例9: init
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
testCOPY = false;
Command com = new Command();
com.setName("Reaction Command");
com.setHardwareLevel(false);
Trigger t = new Trigger();
t.setName("Reaction trigger");
Trigger t2 = new Trigger();
t2.setName("Second Trigger");
getApi().triggers().create(t);
getApi().triggers().create(t2);
getApi().commands().create(com);
Reaction r = new Reaction(t, com);
setItem(new ReactionRepresentation(r));
initPath(ReactionResource.class);
setListType(new GenericType<List<ReactionRepresentation>>(){});
setSingleType(new GenericType<ReactionRepresentation>(){});
}
示例10: init
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
setItem(new Zone());
getItem().setName("Test Zone");
getItem().setAsRoom(true);
getItem().setDescription("Before editing");
e.setName("Test env for zone");
e.setUUID(getUuid());
el.setPojo(e);
el.init();
getApi().environments().create(el);
initPath(UriBuilder.fromResource(EnvironmentResource.class).path(e.getUUID()).path("/rooms").build().toString());
setListType(new GenericType<List<Zone>>(){});
setSingleType(new GenericType<Zone>(){});
}
示例11: getCallbackUri
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
private String getCallbackUri() throws UriBuilderException, IllegalArgumentException {
return uriInfo.getBaseUriBuilder()
.path("auth")
.path("callback")
.build()
.toASCIIString();
}
示例12: getResponse
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
Response getResponse(boolean updated, UriInfo info) throws UriBuilderException, IllegalArgumentException {
if (updated) {
return Response.
noContent().
build();
} else {
URI uri = info.getAbsolutePathBuilder().
build();
return Response.
created(uri).
build();
}
}
示例13: createURI
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
private URI createURI(String uri) {
try {
return new URI(uri);
} catch (URISyntaxException ex) {
throw new UriBuilderException(ex);
}
}
示例14: createHttpServer
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
private HttpServer createHttpServer()
throws IOException, IllegalArgumentException, UriBuilderException, URISyntaxException {
ResourceConfig resourceConfig = new ResourceConfig()
.packages(true, Configuration.instance().getStrings("APP.Jersey.Resources").toArray(new String[0]))
.register(FrontendFeature.class);
EncodingFilter.enableFor(resourceConfig, GZipEncoder.class);
return GrizzlyHttpServerFactory.createHttpServer(getURI(), resourceConfig, false);
}
示例15: build
import javax.ws.rs.core.UriBuilderException; //导入依赖的package包/类
@Override
public URI build(Object... values) throws IllegalArgumentException, UriBuilderException {
String url = null;
try {
url = new Formatter().format(_pathFormat, values).toString();
} catch (Exception ex) {
throw new UriBuilderException("Problem building url from format[" + _pathFormat + "] and values[" + values + "]", ex);
}
return URI.create(url);
}