本文整理汇总了Java中javax.ws.rs.core.UriBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java UriBuilder.build方法的具体用法?Java UriBuilder.build怎么用?Java UriBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.UriBuilder
的用法示例。
在下文中一共展示了UriBuilder.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTargetUri
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
/**
* Get the configured target URI as specified by its component parts.
* <p>
* <b>NOTE</b>: The target URI is assembled from following components:
* {@link SeleniumSettings#TARGET_SCHEME scheme}, {@link SeleniumSettings#TARGET_CREDS credentials},
* {@link SeleniumSettings#TARGET_HOST host}, {@link SeleniumSettings#TARGET_PORT port}, and
* {@link SeleniumSettings#TARGET_PATH base path}
*
* @return assembled target URI
*/
public URI getTargetUri() {
if (targetUri == null) {
UriBuilder builder = UriBuilder.fromPath(getString(SeleniumSettings.TARGET_PATH.key()))
.scheme(getString(SeleniumSettings.TARGET_SCHEME.key()))
.host(getString(SeleniumSettings.TARGET_HOST.key()));
String creds = getString(SeleniumSettings.TARGET_CREDS.key());
if (creds != null) {
builder.userInfo(creds);
}
String port = getString(SeleniumSettings.TARGET_PORT.key());
if (port != null) {
builder.port(Integer.parseInt(port));
}
targetUri = builder.build();
}
return targetUri;
}
示例2: buildAuthenticationRequestUri
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
public URI buildAuthenticationRequestUri(final URI redirectUri,
final String state,
final String nonce) {
openIdConfiguration.getAuthorizationEndpoint();
final UriBuilder b = UriBuilder.fromUri(openIdConfiguration.getAuthorizationEndpoint())
.queryParam("response_type", "code")
.queryParam("scope", scope)
.queryParam("client_id", clientId)
.queryParam("redirect_uri", redirectUri)
.queryParam("nonce", nonce);
if (state != null) {
b.queryParam("state", state);
}
if (display != null) {
b.queryParam("display", display);
}
if (prompt != null) {
b.queryParam("prompt", prompt);
}
return b
.build();
}
示例3: filter
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
UriInfo uriInfo = requestContext.getUriInfo();
UriBuilder hostUriBuilder = uriInfo.getRequestUriBuilder();
// get host from header forwarded host if set
String forwardedHost = requestContext.getHeaderString(HttpHeaders.X_FORWARDED_HOST);
LOG.debug("x-forwarded-host: {}", forwardedHost);
URI builtRequestUri = hostUriBuilder.build();
String replacementUri = builtRequestUri.getHost() + builtRequestUri.getPath();
if (forwardedHost != null) {
UriBuilder forwardedHostUriBuilder =
UriBuilder.fromUri("http://" + forwardedHost.split(",")[0]);
replacementUri = forwardedHostUriBuilder.build().getHost() + builtRequestUri.getPath();
}
hostUriBuilder.replacePath(replacementUri);
LOG.debug("Set new request path to {} (was {})", hostUriBuilder, uriInfo.getAbsolutePath());
requestContext.setRequestUri(hostUriBuilder.build());
}
示例4: getConnectorQueriesForItem
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
/**
* Provided the user has at least the basic CONNECTOR privilege, get a list
* of all connectors, and from that list exclude any of those Connectors for
* which the user lacks the PRIV_VIEWCONTENT_VIA_CONNECTOR privilege.
*
* @param uuid Item uuid, not relevant to the query per se, but used in
* composing result set
* @param version Item version, not relevant to the query per se, but used
* in composing result set
* @return
*/
@GET
@Path("/{uuid}/{version}")
@ApiOperation(value = "List of connectors and usage links")
public List<ConnectorBean> getConnectorQueriesForItem(@ApiParam("Item UUID") @PathParam("uuid") String uuid,
@ApiParam("Item version") @PathParam("version") int version)
{
List<ConnectorBean> connectorBeans = Lists.newArrayList();
Iterable<BaseEntityLabel> connectorDescriptors = connectorService.listForViewing();
UriBuilder uriBuilder = urlLinkService.getMethodUriBuilder(getClass(), "getUsagesOfItemForConnector");
for( BaseEntityLabel bent : connectorDescriptors )
{
Connector connector = connectorService.get(bent.getId());
ConnectorBean bean = serializer.serialize(connector, null, true);
Map<String, URI> links = Maps.newHashMap();
URI uri = uriBuilder.build(uuid, version, bent.getUuid());
links.put("usage", uri);
bean.set("links", links);
connectorBeans.add(bean);
}
return connectorBeans;
}
示例5: getSessionStatus
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
@Override
public SessionStatus getSessionStatus(SessionStatusRequest request) throws SessionNotFoundException {
logger.debug("Getting session status for " + request.getSessionId());
UriBuilder uriBuilder = UriBuilder
.fromUri(endpointUrl)
.path(SESSION_STATUS_URI);
addResponseSocketOpenTimeUrlParameter(request, uriBuilder);
URI uri = uriBuilder.build(request.getSessionId());
try {
SessionStatus result = prepareClient(uri).get(SessionStatus.class);
return result;
} catch (NotFoundException e) {
logger.warn("Session " + request + " not found: " + e.getMessage());
throw new SessionNotFoundException();
}
}
示例6: initializeMissionControlServiceURI
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
private void initializeMissionControlServiceURI() {
String host = System.getProperty(LAUNCHER_MISSIONCONTROL_SERVICE_HOST,
System.getenv(LAUNCHER_MISSIONCONTROL_SERVICE_HOST));
if (host == null) {
host = "launchpad-missioncontrol";
}
UriBuilder uri = UriBuilder.fromPath("/api/missioncontrol/upload").host(host).scheme("http");
String port = System.getProperty(LAUNCHER_MISSIONCONTROL_SERVICE_PORT,
System.getenv(LAUNCHER_MISSIONCONTROL_SERVICE_PORT));
uri.port(port != null ? Integer.parseInt(port) : 8080);
missionControlURI = uri.build();
}
示例7: validateOpenShiftProjectExists
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
/**
* Validates if the OpenShift project exists
*
* @param authHeader
* @param project
* @return a validation message, returns {@link #VALIDATION_MESSAGE_OK} if the project does not exist
*/
public String validateOpenShiftProjectExists(String authHeader, String project, String cluster) {
String validationMessage;
try {
UriBuilder builder = UriBuilder.fromUri(missionControlValidationURI).path("/project/" + project);
if (cluster != null) {
builder.queryParam("cluster", cluster);
}
URI targetURI = builder.build();
if (head(targetURI, authHeader) == Response.Status.OK.getStatusCode()) {
validationMessage = "OpenShift Project '" + project + "' already exists";
} else {
validationMessage = VALIDATION_MESSAGE_OK;
}
} catch (Exception e) {
String message = e.getMessage();
Throwable root = rootException(e);
if (root instanceof UnknownHostException || root instanceof ConnectException) {
validationMessage = "Mission Control is offline and cannot validate the OpenShift Project Name";
} else {
if (root.getMessage() != null) {
message = root.getMessage();
}
validationMessage = "Error while validating OpenShift Project Name: " + message;
}
}
return validationMessage;
}
示例8: validateOpenShiftTokenExists
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
public String validateOpenShiftTokenExists(String authHeader, String cluster) {
String validationMessage;
try {
UriBuilder builder = UriBuilder.fromUri(missionControlValidationURI).path("/token/openshift");
if (cluster != null) {
builder.queryParam("cluster", cluster);
}
URI targetURI = builder.build();
if (head(targetURI, authHeader) == Response.Status.OK.getStatusCode()) {
validationMessage = VALIDATION_MESSAGE_OK;
} else {
validationMessage = "OpenShift Token does not exist";
}
} catch (Exception e) {
String message = e.getMessage();
Throwable root = rootException(e);
if (root instanceof UnknownHostException || root instanceof ConnectException) {
validationMessage = "Mission Control is offline and cannot validate if the OpenShift token exists";
} else {
if (root.getMessage() != null) {
message = root.getMessage();
}
validationMessage = "Error while validating if the OpenShift Token exists: " + message;
}
}
return validationMessage;
}
示例9: getMatchingServices
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
@Timed
public Collection<MatchingServiceConfigEntityDataDto> getMatchingServices() {
UriBuilder uriBuilder = UriBuilder
.fromUri(configUri)
.path(Urls.ConfigUrls.ENABLED_MATCHING_SERVICES_RESOURCE);
URI uri = uriBuilder.build();
return jsonClient.get(uri, new GenericType<Collection<MatchingServiceConfigEntityDataDto>>() {});
}
示例10: getEnabledIdentityProviders
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
@Timed
public List<String> getEnabledIdentityProviders(Optional<String> transactionEntityId) {
final UriBuilder uriBuilder = UriBuilder
.fromUri(configUri)
.path(Urls.ConfigUrls.ENABLED_IDENTITY_PROVIDERS_RESOURCE);
if (transactionEntityId.isPresent()) {
uriBuilder.queryParam(Urls.ConfigUrls.TRANSACTION_ENTITY_ID_PARAM, transactionEntityId.get());
}
URI uri = uriBuilder.build();
return jsonClient.get(uri, new GenericType<List<String>>() {
});
}
示例11: findURI
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
private static URI findURI(MethodFinder method, Object... params) {
Method m = method.method();
UriInfo uriInfo = ResteasyProviderFactory.getContextData(UriInfo.class);
UriBuilder builder = uriInfo.getBaseUriBuilder().path(m.getDeclaringClass());
if(m.isAnnotationPresent(Path.class))
builder.path(m);
return builder.build(params);
}
示例12: respondByTransitionToPromptLanguage
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
private String respondByTransitionToPromptLanguage() {
UriBuilder uriBuilder = UriBuilder.fromPath(getEventUrl())
.queryParam(KEY_STATE, STATE_PROMPT_LANGUAGE);
this.parameters.keySet().forEach(key -> {
uriBuilder.queryParam(key, this.parameters.get(key));
});
URI uri = uriBuilder.build();
String eventUrl = uri.toString();
InputNcco input = new InputNcco();
input.setEventUrl(eventUrl);
input.setMaxDigits(1);
input.setTimeOut(5);
TalkNcco welcome = new TalkNcco(MSG_WELCOME);
welcome.setVoiceName(VOICE_ENGLISH);
TalkNcco language = new TalkNcco(MSG_PROMPT_LANGUAGE);
language.setVoiceName(VOICE_SPANISH);
language.setBargeIn(true);
// preparing a response
NccoResponseBuilder builder = new NccoResponseBuilder();
builder.appendNcco(welcome);
builder.appendNcco(language);
builder.appendNcco(input);
// respond
NccoResponse nccoResponse = builder.getValue();
return nccoResponse.toJson();
}
示例13: rebuildQuery
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
/** Rebuild the URI query with lower case parameter names. */
private static URI rebuildQuery(final URI uri,
final MultivaluedMap<String, String> parameters) {
UriBuilder b = UriBuilder.fromUri(uri).replaceQuery("");
for(Map.Entry<String, List<String>> e : parameters.entrySet()) {
final String key = StringUtils.toLowerCase(e.getKey());
for(String v : e.getValue()) {
b = b.queryParam(key, v);
}
}
return b.build();
}
示例14: advertisedUrl
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
/**
* Get the URL to advertise to other workers and clients. This uses the default connector from the embedded Jetty
* server, unless overrides for advertised hostname and/or port are provided via configs.
*/
public URI advertisedUrl() {
UriBuilder builder = UriBuilder.fromUri(jettyServer.getURI());
String advertisedHostname = config.getString(WorkerConfig.REST_ADVERTISED_HOST_NAME_CONFIG);
if (advertisedHostname != null && !advertisedHostname.isEmpty())
builder.host(advertisedHostname);
Integer advertisedPort = config.getInt(WorkerConfig.REST_ADVERTISED_PORT_CONFIG);
if (advertisedPort != null)
builder.port(advertisedPort);
else
builder.port(config.getInt(WorkerConfig.REST_PORT_CONFIG));
return builder.build();
}
示例15: createAndAddHost
import javax.ws.rs.core.UriBuilder; //导入方法依赖的package包/类
/**
* Creates a new host based on JSON input and adds it to the current
* host inventory.
*
* @param stream input JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel HostPut
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createAndAddHost(InputStream stream) {
URI location;
try {
// Parse the input stream
ObjectNode root = (ObjectNode) mapper().readTree(stream);
HostProviderRegistry hostProviderRegistry = get(HostProviderRegistry.class);
InternalHostProvider hostProvider = new InternalHostProvider();
HostProviderService hostProviderService = hostProviderRegistry.register(hostProvider);
hostProvider.setHostProviderService(hostProviderService);
HostId hostId = hostProvider.parseHost(root);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
.path("hosts")
.path(hostId.mac().toString())
.path(hostId.vlanId().toString());
location = locationBuilder.build();
hostProviderRegistry.unregister(hostProvider);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response
.created(location)
.build();
}