本文整理汇总了Java中javax.ws.rs.POST类的典型用法代码示例。如果您正苦于以下问题:Java POST类的具体用法?Java POST怎么用?Java POST使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
POST类属于javax.ws.rs包,在下文中一共展示了POST类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import javax.ws.rs.POST; //导入依赖的package包/类
@POST
@Path(value = "/validation")
@Consumes("application/json")
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses({//
@ApiResponse(code = 204, message = "All validations pass"), //
@ApiResponse(code = 400, message = "Found violations in validation", responseContainer = "Set",
response = Violation.class)//
})
default Response validate(@NotNull final T obj) {
final Set<ConstraintViolation<T>> constraintViolations = getValidator().validate(obj, AllValidations.class);
if (constraintViolations.isEmpty()) {
return Response.noContent().build();
}
throw new ConstraintViolationException(constraintViolations);
}
示例2: createApplianceManagerConnector
import javax.ws.rs.POST; //导入依赖的package包/类
@ApiOperation(value = "Creates an Manager Connector",
notes = "Creates an Manager Connector and sync's it immediately.<br/> "
+ "If we are unable to connect to the manager using the credentials provided, this call will fail.<br/>"
+ "To skip validation of IP and credentials 'skipRemoteValidation' flag can be used.",
response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400,
message = "In case of any error validating the information",
response = ErrorCodeDto.class) })
@POST
public Response createApplianceManagerConnector(@Context HttpHeaders headers,
@ApiParam(required = true) ApplianceManagerConnectorRequest amcRequest) {
logger.info("Creating Appliance Manager Connector...");
this.userContext.setUser(OscAuthFilter.getUsername(headers));
Response responseForBaseRequest = this.apiUtil.getResponseForBaseRequest(this.addService,
new DryRunRequest<>(amcRequest, amcRequest.isSkipRemoteValidation()));
return responseForBaseRequest;
}
示例3: updateUser
import javax.ws.rs.POST; //导入依赖的package包/类
@RolesAllowed({"admin", "user"})
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public UserUI updateUser(UserForm userForm, @PathParam("userName") UserName userName)
throws IOException, IllegalArgumentException, NamespaceException, UserNotFoundException, DACUnauthorizedException {
checkUser(userName, "update");
User userConfig = userForm.getUserConfig();
if (userConfig != null && userConfig.getUserName() != null && !userConfig.getUserName().equals(userName.getName())) {
final UserName newUserName = new UserName(userForm.getUserConfig().getUserName());
userConfig = userService.updateUserName(userName.getName(),
newUserName.getName(),
userConfig, userForm.getPassword());
// TODO: rename home space and all uploaded files along with it
// new username
return new UserUI(new UserResourcePath(newUserName), newUserName, userConfig);
} else {
User newUser = SimpleUser.newBuilder(userForm.getUserConfig()).setUserName(userName.getName()).build();
newUser = userService.updateUser(newUser, userForm.getPassword());
return new UserUI(new UserResourcePath(userName), userName, newUser);
}
}
示例4: updateCatalog
import javax.ws.rs.POST; //导入依赖的package包/类
/**
* Update the catalog prices of related provider. Asynchronous operation.
*
* @param node
* The node (provider) to update.
* @return The catalog status.
*/
@POST
@Path("catalog/{node:service:prov:.+}")
public ImportCatalogStatus updateCatalog(@PathParam("node") final String node) {
final Node entity = nodeResource.checkWritableNode(node).getTool();
final ImportCatalogService catalogService = locator.getResource(entity.getId(), ImportCatalogService.class);
final ImportCatalogStatus task = startTask(entity.getId(), t -> {
t.setLocation(null);
t.setNbInstancePrices(null);
t.setNbInstanceTypes(null);
t.setNbStorageTypes(null);
t.setWorkload(0);
t.setDone(0);
t.setPhase(null);
});
final String user = securityHelper.getLogin();
// The import execution will done into another thread
Executors.newSingleThreadExecutor().submit(() -> {
Thread.sleep(50);
securityHelper.setUserName(user);
updateCatalog(catalogService, entity.getId());
return null;
});
return task;
}
示例5: authenticate
import javax.ws.rs.POST; //导入依赖的package包/类
/**
* Validate user credentials and issue a token for the user.
*
* @param credentials
* @return
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response authenticate(UserCredentials credentials) {
Authentication authenticationRequest =
new UsernamePasswordAuthenticationToken(credentials.getUsername(), credentials.getPassword());
Authentication authenticationResult = authenticationManager.authenticate(authenticationRequest);
SecurityContextHolder.getContext().setAuthentication(authenticationResult);
String username = SecurityContextHolder.getContext().getAuthentication().getName();
Set<Authority> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities().stream()
.map(grantedAuthority -> Authority.valueOf(grantedAuthority.toString()))
.collect(Collectors.toSet());
String token = authenticationTokenService.issueToken(username, authorities);
AuthenticationToken authenticationToken = new AuthenticationToken();
authenticationToken.setToken(token);
return Response.ok(authenticationToken).build();
}
示例6: checkLogin
import javax.ws.rs.POST; //导入依赖的package包/类
@POST
@Path("checkLogin")
@Produces(MediaType.APPLICATION_JSON)
public BaseDTO checkLogin(@HeaderParam("sessionId") String sessionId) {
logger.info("sessionId : {}", sessionId);
PimDevice pimDevice = pimDeviceManager.findUniqueBy("sessionId",
sessionId);
logger.info("pimDevice : {}", pimDevice);
if (pimDevice == null) {
return null;
}
BaseDTO result = new BaseDTO();
result.setCode(200);
return result;
}
示例7: register
import javax.ws.rs.POST; //导入依赖的package包/类
@POST
@Path("register")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String register(@FormParam("userName") String userName,
@FormParam("password") String password,
@FormParam("phone") Long phone, @FormParam("email") String email,
@FormParam("nick") String nick, @FormParam("addr") String addr,
@FormParam("gender") String gender) {
// check not null
User u = new User();// dao 应该查询
u.setAddr(addr);
u.setEmail(email);
u.setGender(gender);
u.setNick(nick);
u.setPassword(password);
u.setPhone(phone);
u.setUsername(userName);
return JsonUtil.bean2Json(u);
}
示例8: update
import javax.ws.rs.POST; //导入依赖的package包/类
@POST
@Path("{resourceId}")
@ApiOperation(
value = "Update an existing Plan",
notes = "Update some properties of an existing Plan")
@ApiResponses({
@ApiResponse(code = 204, message = "Successful operation"),
@ApiResponse(code = 400, message = "Invalid ID supplied",
response = ExceptionPresentation.class),
@ApiResponse(code = 404, message = "Plan not found",
response = ExceptionPresentation.class),
@ApiResponse(code = 405, message = "Validation exception",
response = ExceptionPresentation.class)})
public void update(
@ApiParam(value = "ID of the plan to be updated") @PathParam("resourceId") String resourceId,
@ApiParam(value = "UpdatePlanArg object representing parameters of the Plan to be updated",
required = true) UpdatePlanArg planArg)
throws CommsRouterException {
LOGGER.debug("Updating plan {}", planArg);
RouterObjectRef objectId =
RouterObjectRef.builder().setRef(resourceId).setRouterRef(routerRef).build();
planService.update(planArg, objectId);
}
示例9: receiveSlackCommand
import javax.ws.rs.POST; //导入依赖的package包/类
/**
* Slack command endpoint. This is where the application is receiving slash commands from Slack
* and returning synchronous responses to them.
*
* @param params parameters posted from Slack
* @return synchronous response for the command
*/
@Path("/command")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public SlackCommandResponse receiveSlackCommand(final MultivaluedMap<String, String> params) {
LOGGER.debug("Received Slack command: {}", params);
final String token = params.getFirst("token");
if (slackConfig().getCommandVerificationTokens().contains(token)) {
final String command = params.getFirst("command");
switch (command) {
case LIST_COMMAND:
return listDevices();
case SHOW_COMMAND:
return showDevice(params);
case CLAIM_COMMAND:
return claim(params);
case UNCLAIM_COMMAND:
return unclaim(params);
default:
throw new IllegalArgumentException("Unknown command: " + command);
}
} else {
throw new IllegalStateException("Token error");
}
}
示例10: getDataFormByFormNo
import javax.ws.rs.POST; //导入依赖的package包/类
@POST
@Path("/registrations/applicant/{applicantNo}/agency/{agencyNo}/forms/{formNo}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN })
@ApiOperation(value = "Get list dataform by applicantNo, agencyNo and formNo")
@ApiResponses(value = {
@ApiResponse (code = HttpURLConnection.HTTP_OK, message = "Return a list dataform"),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not Found", response = ExceptionModel.class),
@ApiResponse (code = HttpURLConnection.HTTP_FORBIDDEN, message = "Accsess denied", response = ExceptionModel.class) })
public Response getDataFormByFormNo (@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@ApiParam(value = "id for applicant", required = true) @PathParam("applicantNo") String applicantNo,
@ApiParam(value = "id for agency", required = true) @PathParam("agencyNo") String agencyNo,
@ApiParam(value = "id for forms", required = true) @PathParam("formNo") String formNo,
@FormParam("keyword") String keyword);
示例11: upgrade
import javax.ws.rs.POST; //导入依赖的package包/类
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Upgrade Presto")
@ApiResponses(value = {
@ApiResponse(code = 207, message = "Multiple responses available"),
@ApiResponse(code = 400, message = "Request contains invalid parameters")})
public Response upgrade(String urlToFetchPackage,
@QueryParam("checkDependencies") @DefaultValue("true") boolean checkDependencies,
@QueryParam("forceUpgrade") @DefaultValue("false") boolean forceUpgrade,
@QueryParam("preserveConfig") @DefaultValue("true") boolean preserveConfig,
@QueryParam("scope") String scope,
@QueryParam("nodeId") List<String> nodeId)
{
ApiRequester.Builder apiRequester = requesterBuilder(ControllerPackageAPI.class)
.httpMethod(POST)
.accept(MediaType.TEXT_PLAIN)
.entity(Entity.entity(urlToFetchPackage, MediaType.TEXT_PLAIN));
optionalQueryParam(apiRequester, "checkDependencies", checkDependencies);
optionalQueryParam(apiRequester, "preserveConfig", preserveConfig);
optionalQueryParam(apiRequester, "forceUpgrade", forceUpgrade);
return forwardRequest(scope, apiRequester.build(), nodeId);
}
示例12: createFlows
import javax.ws.rs.POST; //导入依赖的package包/类
/**
* Creates new flow rules. Creates and installs a new flow rules.<br>
* Instructions description:
* https://wiki.onosproject.org/display/ONOS/Flow+Rule+Instructions
* <br>
* Criteria description:
* https://wiki.onosproject.org/display/ONOS/Flow+Rule+Criteria
*
* @param stream flow rules JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel FlowsBatchPost
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createFlows(@QueryParam("appId") String appId, InputStream stream) {
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
ArrayNode flowsArray = (ArrayNode) jsonTree.get(FLOWS);
if (appId != null) {
flowsArray.forEach(flowJson -> ((ObjectNode) flowJson).put("appId", appId));
}
List<FlowRule> rules = codec(FlowRule.class).decode(flowsArray, this);
service.applyFlowRules(rules.toArray(new FlowRule[rules.size()]));
rules.forEach(flowRule -> {
ObjectNode flowNode = mapper().createObjectNode();
flowNode.put(DEVICE_ID, flowRule.deviceId().toString())
.put(FLOW_ID, flowRule.id().value());
flowsNode.add(flowNode);
});
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
return Response.ok(root).build();
}
示例13: addTenantId
import javax.ws.rs.POST; //导入依赖的package包/类
/**
* Creates a tenant with the given tenant identifier.
*
* @param stream TenantId JSON stream
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel TenantId
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addTenantId(InputStream stream) {
try {
final TenantId tid = getTenantIdFromJsonStream(stream);
vnetAdminService.registerTenantId(tid);
final TenantId resultTid = getExistingTenantId(vnetAdminService, tid);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
.path("tenants")
.path(resultTid.id());
return Response
.created(locationBuilder.build())
.build();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
示例14: upload
import javax.ws.rs.POST; //导入依赖的package包/类
/**
* Upload a file of quote in add mode.
*
* @param subscription
* The subscription identifier, will be used to filter the locations
* from the associated provider.
* @param uploadedFile
* Instance entries files to import. Currently support only CSV
* format.
* @param columns
* the CSV header names.
* @param term
* The default {@link ProvInstancePriceTerm} used when no one is
* defined in the CSV line
* @param ramMultiplier
* The multiplier for imported RAM values. Default is 1.
* @param encoding
* CSV encoding. Default is UTF-8.
* @throws IOException
* When the CSV stream cannot be written.
*/
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("{subscription:\\d+}/upload")
public void upload(@PathParam("subscription") final int subscription, @Multipart(value = "csv-file") final InputStream uploadedFile,
@Multipart(value = "columns", required = false) final String[] columns,
@Multipart(value = "term", required = false) final String term,
@Multipart(value = "memoryUnit", required = false) final Integer ramMultiplier,
@Multipart(value = "encoding", required = false) final String encoding) throws IOException {
subscriptionResource.checkVisibleSubscription(subscription).getNode().getId();
// Check column's name validity
final String[] sanitizeColumns = ArrayUtils.isEmpty(columns) ? DEFAULT_COLUMNS : columns;
checkHeaders(ACCEPTED_COLUMNS, sanitizeColumns);
// Build CSV header from array
final String csvHeaders = StringUtils.chop(ArrayUtils.toString(sanitizeColumns)).substring(1).replace(',', ';') + "\n";
// Build entries
final String safeEncoding = ObjectUtils.defaultIfNull(encoding, StandardCharsets.UTF_8.name());
csvForBean
.toBean(InstanceUpload.class, new InputStreamReader(
new SequenceInputStream(new ByteArrayInputStream(csvHeaders.getBytes(safeEncoding)), uploadedFile), safeEncoding))
.stream().filter(Objects::nonNull).forEach(i -> persist(i, subscription, term, ramMultiplier));
}
示例15: bubbleDetails
import javax.ws.rs.POST; //导入依赖的package包/类
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("bubble")
@Consumes("*/*")
public Response bubbleDetails(
@Context HttpServletRequest request,
InputStream is
)
throws IOException,
URISyntaxException
{
APIImpl impl = getAPIImpl( request );
if( impl == null )
{
return Response.status( Response.Status.UNAUTHORIZED ).build();
}
String urn = stream2string( is );
Result result = impl.viewableQuery( urn );
return formatReturn( result );
}