本文整理了Java中javax.ws.rs.core.UriBuilder.fromPath()
方法的一些代码示例,展示了UriBuilder.fromPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UriBuilder.fromPath()
方法的具体详情如下:
包路径:javax.ws.rs.core.UriBuilder
类名称:UriBuilder
方法名:fromPath
[英]Create a new instance representing a relative URI initialized from a URI path.
[中]创建一个新实例,表示从URI路径初始化的相对URI。
代码示例来源:origin: Graylog2/graylog2-server
@GET
public Response getIndex(@Context ContainerRequest request, @Context HttpHeaders headers) {
final URI originalLocation = request.getRequestUri();
if (originalLocation.getPath().endsWith("/")) {
return get(request, headers, originalLocation.getPath());
}
final URI redirect = UriBuilder.fromPath(originalLocation.getPath() + "/").build();
return Response.temporaryRedirect(redirect).build();
}
代码示例来源:origin: graphhopper/graphhopper
@GET
public Response redirectToWebapp() {
return Response.seeOther(UriBuilder.fromPath("maps/").build()).build();
}
代码示例来源:origin: liferay/liferay-portal
private String _constructResourceURL(String uriPrefix) {
UriBuilder uriBuilder = UriBuilder.fromPath(uriPrefix);
URI resourceURI = uriBuilder.path(
uriPrefix.contains("/p/") ? "" : "p"
).path(
"{resource}"
).build(
getValue()
);
return resourceURI.toString();
}
代码示例来源:origin: jersey/jersey
private static UriBuilder applyLinkStyle(String template, InjectLink.Style style, UriInfo uriInfo) {
UriBuilder ub = null;
switch (style) {
case ABSOLUTE:
ub = uriInfo.getBaseUriBuilder().path(template);
break;
case ABSOLUTE_PATH:
String basePath = uriInfo.getBaseUri().getPath();
ub = UriBuilder.fromPath(basePath).path(template);
break;
case RELATIVE_PATH:
ub = UriBuilder.fromPath(template);
break;
}
return ub;
}
代码示例来源:origin: Netflix/conductor
private UriBuilder getURIBuilder(String path, Object[] queryParams) {
if (path == null) {
path = "";
}
UriBuilder builder = UriBuilder.fromPath(path);
if (queryParams != null) {
for (int i = 0; i < queryParams.length; i += 2) {
String param = queryParams[i].toString();
Object value = queryParams[i + 1];
if (value != null) {
if (value instanceof Collection) {
Object[] values = ((Collection<?>) value).toArray();
builder.queryParam(param, values);
} else {
builder.queryParam(param, value);
}
}
}
}
return builder;
}
}
代码示例来源:origin: liferay/liferay-portal
public String getWebSiteURL() {
UriBuilder uriBuilder = UriBuilder.fromPath(getHost());
URI webSiteURI = uriBuilder.path(
"p"
).path(
"commerce-web-site"
).path(
"{webSiteId}"
).build(
getValue()
);
return webSiteURI.toString();
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Create new instance using existing Client instance, and the URI from which the parameters will be extracted
*
*/
public PathIdRevisions( com.sun.jersey.api.client.Client client, URI uri ) {
_client = client;
StringBuilder template = new StringBuilder( BASE_URI.toString() );
if ( template.charAt( ( template.length() - 1 ) ) != '/' ) {
template.append( "/pur-repository-plugin/api/revision/{pathId : .+}/revisions" );
} else {
template.append( "pur-repository-plugin/api/revision/{pathId : .+}/revisions" );
}
_uriBuilder = UriBuilder.fromPath( template.toString() );
_templateAndMatrixParameterValues = new HashMap<String, Object>();
com.sun.jersey.api.uri.UriTemplate uriTemplate = new com.sun.jersey.api.uri.UriTemplate( template.toString() );
HashMap<String, String> parameters = new HashMap<String, String>();
uriTemplate.match( uri.toString(), parameters );
_templateAndMatrixParameterValues.putAll( parameters );
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Create new instance using existing Client instance, and the URI from which the parameters will be extracted
*
*/
public PathIdVersioningConfiguration( com.sun.jersey.api.client.Client client, URI uri ) {
_client = client;
StringBuilder template = new StringBuilder( BASE_URI.toString() );
if ( template.charAt( ( template.length() - 1 ) ) != '/' ) {
template.append( "/pur-repository-plugin/api/revision/{pathId}/versioningConfiguration" );
} else {
template.append( "pur-repository-plugin/api/revision/{pathId}/versioningConfiguration" );
}
_uriBuilder = UriBuilder.fromPath( template.toString() );
_templateAndMatrixParameterValues = new HashMap<String, Object>();
com.sun.jersey.api.uri.UriTemplate uriTemplate = new com.sun.jersey.api.uri.UriTemplate( template.toString() );
HashMap<String, String> parameters = new HashMap<String, String>();
uriTemplate.match( uri.toString(), parameters );
_templateAndMatrixParameterValues.putAll( parameters );
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Create new instance using existing Client instance, and the URI from which the parameters will be extracted
*
*/
public PathIdPurge( com.sun.jersey.api.client.Client client, URI uri ) {
_client = client;
StringBuilder template = new StringBuilder( BASE_URI.toString() );
if ( template.charAt( ( template.length() - 1 ) ) != '/' ) {
template.append( "/pur-repository-plugin/api/purge/{pathId : .+}/purge" );
} else {
template.append( "pur-repository-plugin/api/purge/{pathId : .+}/purge" );
}
_uriBuilder = UriBuilder.fromPath( template.toString() );
_templateAndMatrixParameterValues = new HashMap<String, Object>();
com.sun.jersey.api.uri.UriTemplate uriTemplate = new com.sun.jersey.api.uri.UriTemplate( template.toString() );
HashMap<String, String> parameters = new HashMap<String, String>();
uriTemplate.match( uri.toString(), parameters );
_templateAndMatrixParameterValues.putAll( parameters );
}
代码示例来源:origin: liferay/liferay-portal
public void doDelete(IndexedRecord indexedRecord) throws IOException {
String resourceId = getIndexedRecordId(indexedRecord);
String resourceURL =
_tLiferayOutputProperties.resource.resourceProperty.
getSingleResourceOperationURL();
UriBuilder uriBuilder = UriBuilder.fromPath(resourceURL);
URI singleResourceUri = uriBuilder.path(
"/{resourceId}"
).build(
resourceId
);
try {
_liferaySink.doApioDeleteRequest(
_runtimeContainer, singleResourceUri.toASCIIString());
}
catch (IOException ioe) {
if (_log.isDebugEnabled()) {
_log.debug("Unable to delete the resource", ioe);
}
throw ioe;
}
}
代码示例来源:origin: Netflix/Priam
/**
* Creates a new instance with the given parameters
*
* @param id the node id
* @return Response (201) if the instance was created
*/
@POST
public Response createInstance(
@QueryParam("id") int id,
@QueryParam("instanceID") String instanceID,
@QueryParam("hostname") String hostname,
@QueryParam("ip") String ip,
@QueryParam("rack") String rack,
@QueryParam("token") String token) {
log.info(
"Creating instance [id={}, instanceId={}, hostname={}, ip={}, rack={}, token={}",
id,
instanceID,
hostname,
ip,
rack,
token);
PriamInstance instance =
factory.create(
config.getAppName(), id, instanceID, hostname, ip, rack, null, token);
URI uri = UriBuilder.fromPath("/{id}").build(instance.getId());
return Response.created(uri).build();
}
代码示例来源:origin: liferay/liferay-portal
public void doUpdate(IndexedRecord indexedRecord) throws IOException {
ObjectNode objectNode = _createApioExpectedForm(indexedRecord, true);
String resourceId = getIndexedRecordId(indexedRecord);
String resourceURL =
_tLiferayOutputProperties.resource.resourceProperty.
getSingleResourceOperationURL();
UriBuilder uriBuilder = UriBuilder.fromPath(resourceURL);
URI singleResourceUri = uriBuilder.path(
"/{resourceId}"
).build(
resourceId
);
try {
_liferaySink.doApioPutRequest(
_runtimeContainer, singleResourceUri.toASCIIString(),
objectNode);
}
catch (IOException ioe) {
if (_log.isDebugEnabled()) {
_log.debug("Unable to update the resource: ", ioe);
}
throw ioe;
}
}
代码示例来源:origin: jersey/jersey
? UriBuilder.fromPath(root).path("/application.wadl/") : UriBuilder.fromPath("./application.wadl/");
final URI rootURI = root != null ? UriBuilder.fromPath(root).build() : null;
代码示例来源:origin: jersey/jersey
? UriBuilder.fromPath(root).path("/application.wadl/") : UriBuilder.fromPath("./application.wadl/");
final URI rootURI = root != null ? UriBuilder.fromPath(root).build() : null;
代码示例来源:origin: com.sun.jersey/jersey-server
? UriBuilder.fromPath(root).path("/application.wadl/")
: UriBuilder.fromPath("./application.wadl/");
URI rootURI = root != null ? UriBuilder.fromPath(root).build() : null;
代码示例来源:origin: soabase/exhibitor
public Result makeRequest(RemoteInstanceRequestClient client, String methodName, Object... values)
{
String remoteResponse;
String errorMessage;
{
try
{
URI remoteUri = UriBuilder
.fromPath(getPath())
.scheme(exhibitor.getRestScheme())
.host(hostname)
.port(exhibitor.getRestPort())
.path(ClusterResource.class, methodName)
.build(values);
remoteResponse = client.getWebResource(remoteUri, MediaType.APPLICATION_JSON_TYPE, String.class);
errorMessage = "";
}
catch ( Exception e )
{
remoteResponse = "{}";
errorMessage = e.getMessage();
if ( errorMessage == null )
{
errorMessage = "Unknown";
}
}
}
return new Result(remoteResponse, errorMessage);
}
代码示例来源:origin: HubSpot/Singularity
@GET
@Path("/")
public Response getIndex(@Context UriInfo info) {
return Response.status(Status.MOVED_PERMANENTLY).location(UriBuilder.fromPath(singularityUriBase).path(UiResource.UI_RESOURCE_LOCATION).build()).build();
}
}
代码示例来源:origin: resteasy/Resteasy
public static URI relativize(URI from, URI to)
{
if (!compare(from.getScheme(), to.getScheme())) return to;
if (!compare(from.getHost(), to.getHost())) return to;
if (from.getPort() != to.getPort()) return to;
if (from.getPath() == null && to.getPath() == null) return URI.create("");
else if (from.getPath() == null) return URI.create(to.getPath());
else if (to.getPath() == null) return to;
String fromPath = from.getPath();
if (fromPath.startsWith("/")) fromPath = fromPath.substring(1);
String[] fsplit = fromPath.split("/");
String toPath = to.getPath();
if (toPath.startsWith("/")) toPath = toPath.substring(1);
String[] tsplit = toPath.split("/");
int f = 0;
for (;f < fsplit.length && f < tsplit.length; f++)
{
if (!fsplit[f].equals(tsplit[f])) break;
}
UriBuilder builder = UriBuilder.fromPath("");
for (int i = f; i < fsplit.length; i++) builder.path("..");
for (int i = f; i < tsplit.length; i++) builder.path(tsplit[i]);
return builder.build();
}
代码示例来源:origin: camunda/camunda-bpm-platform
public static HalTaskList fromTaskList(List<Task> tasks, long count) {
HalTaskList taskList = new HalTaskList();
// embed tasks
List<HalResource<?>> embeddedTasks = new ArrayList<HalResource<?>>();
for (Task task : tasks) {
embeddedTasks.add(HalTask.fromTask(task));
}
taskList.addEmbedded("task", embeddedTasks);
// links
taskList.addLink("self", fromPath(TaskRestService.PATH).build());
taskList.count = count;
return taskList;
}
代码示例来源:origin: camunda/camunda-bpm-platform
public static HalTaskList fromTaskList(List<Task> tasks, long count) {
HalTaskList taskList = new HalTaskList();
// embed tasks
List<HalResource<?>> embeddedTasks = new ArrayList<HalResource<?>>();
for (Task task : tasks) {
embeddedTasks.add(HalTask.fromTask(task));
}
taskList.addEmbedded("task", embeddedTasks);
// links
taskList.addLink("self", fromPath(TaskRestService.PATH).build());
taskList.count = count;
return taskList;
}
内容来源于网络,如有侵权,请联系作者删除!