本文整理汇总了Java中javax.ws.rs.core.UriInfo.getAbsolutePathBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java UriInfo.getAbsolutePathBuilder方法的具体用法?Java UriInfo.getAbsolutePathBuilder怎么用?Java UriInfo.getAbsolutePathBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.UriInfo
的用法示例。
在下文中一共展示了UriInfo.getAbsolutePathBuilder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{projectName}/statuses/{commit}")
@POST
public Response save(@PathParam("projectName") String projectName, @PathParam("commit") String commit,
Map<String, String> commitStatus, @Context UriInfo uriInfo) {
Project project = getProject(projectName);
if (!SecurityUtils.canWrite(project))
throw new UnauthorizedException();
String state = commitStatus.get("state").toUpperCase();
if (state.equals("PENDING"))
state = "RUNNING";
Verification verification = new Verification(Verification.Status.valueOf(state),
new Date(), commitStatus.get("description"), commitStatus.get("target_url"));
String context = commitStatus.get("context");
if (context == null)
context = "default";
verificationManager.saveVerification(project, commit, context, verification);
UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder();
uriBuilder.path(context);
commitStatus.put("id", "1");
return Response.created(uriBuilder.build()).entity(commitStatus).type(RestConstants.JSON_UTF8).build();
}
示例2: update
import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
Response update(final ScannerModel model, final boolean replace,
final UriInfo uriInfo) {
servlet.getMetrics().incrementRequests(1);
if (servlet.isReadOnly()) {
return Response.status(Response.Status.FORBIDDEN)
.type(MIMETYPE_TEXT).entity("Forbidden" + CRLF)
.build();
}
byte[] endRow = model.hasEndRow() ? model.getEndRow() : null;
RowSpec spec = null;
if (model.getLabels() != null) {
spec = new RowSpec(model.getStartRow(), endRow, model.getColumns(), model.getStartTime(),
model.getEndTime(), model.getMaxVersions(), model.getLabels());
} else {
spec = new RowSpec(model.getStartRow(), endRow, model.getColumns(), model.getStartTime(),
model.getEndTime(), model.getMaxVersions());
}
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
try {
Filter filter = ScannerResultGenerator.buildFilterFromModel(model);
String tableName = tableResource.getName();
ScannerResultGenerator gen =
new ScannerResultGenerator(tableName, spec, filter, model.getCaching(),
model.getCacheBlocks());
String id = gen.getID();
ScannerInstanceResource instance =
new ScannerInstanceResource(tableName, id, gen, model.getBatch());
scanners.put(id, instance);
if (LOG.isDebugEnabled()) {
LOG.debug("new scanner: " + id);
}
UriBuilder builder = uriInfo.getAbsolutePathBuilder();
URI uri = builder.path(id).build();
servlet.getMetrics().incrementSucessfulPutRequests(1);
return Response.created(uri).build();
} catch (Exception e) {
servlet.getMetrics().incrementFailedPutRequests(1);
if (e instanceof TableNotFoundException) {
return Response.status(Response.Status.NOT_FOUND)
.type(MIMETYPE_TEXT).entity("Not found" + CRLF)
.build();
} else if (e instanceof RuntimeException) {
return Response.status(Response.Status.BAD_REQUEST)
.type(MIMETYPE_TEXT).entity("Bad request" + CRLF)
.build();
}
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
.type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
.build();
}
}