本文整理匯總了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();
}
}