Java Code Examples for javax.ws.rs.FormParam
The following examples show how to use
javax.ws.rs.FormParam. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: json-schema-validator-demo Source File: Index.java License: GNU Lesser General Public License v3.0 | 7 votes |
@POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public static Response validate( @FormParam("input") final String schema, @FormParam("input2") final String data ) { if (schema == null || data == null) return BAD; try { final JsonNode ret = buildResult(schema, data); return Response.ok().entity(ret.toString()).build(); } catch (IOException e) { log.error("I/O error while validating data", e); return OOPS; } }
Example 2
Source Project: cassandra-reaper Source File: ClusterResource.java License: Apache License 2.0 | 6 votes |
@PUT @Path("/auth/{cluster_name}") public Response addOrUpdateCluster( @Context UriInfo uriInfo, @PathParam("cluster_name") String clusterName, @FormParam("seedHost") Optional<String> seedHost, @FormParam("jmxPort") Optional<Integer> jmxPort, @FormParam("jmxUsername") Optional<String> jmxUsername, @FormParam("jmxPassword") Optional<String> jmxPassword) { LOG.info( "PUT addOrUpdateCluster called with: cluster_name = {}, seedHost = {}", clusterName, seedHost.orElse(null)); return addOrUpdateCluster(uriInfo, Optional.of(clusterName), seedHost, jmxPort, jmxUsername, jmxPassword); }
Example 3
Source Project: oodt Source File: WorkflowResource.java License: Apache License 2.0 | 6 votes |
/** * Add Packaged Repository Workflow * * @param workflowID * id of the workflow * @param workflowXML * xml representation of the workflow * @return true if addition successful */ @POST @Path("/addPackagedRepositoryWorkflow") public boolean addPackagedRepositoryWorkflow( @FormParam("workflowID") String workflowID, @FormParam("workflowXML") String workflowXML) throws Exception { try { PackagedWorkflowManager pwmanager = new PackagedWorkflowManager(); Workflow workflow = pwmanager.parsePackagedWorkflow(workflowID, workflowXML); if(workflow == null) return false; String workflowDir = this.getContextPkgReposDir().getAbsolutePath(); pwmanager.addWorkflow(workflow, workflowDir); return getContextClient().refreshRepository(); } catch (Exception e) { String message = "Unable to add workflow. "; message += e.getMessage(); LOGGER.log(Level.SEVERE, message); throw e; } }
Example 4
Source Project: datawave Source File: ModelBean.java License: Apache License 2.0 | 6 votes |
/** * <strong>Administrator credentials required.</strong> Copy a model * * @param name * model to copy * @param newName * name of copied model * @param modelTableName * name of the table that contains the model * @return datawave.webservice.result.VoidResponse * @RequestHeader X-ProxiedEntitiesChain use when proxying request for user * * @HTTP 200 success * @HTTP 204 model not found * @HTTP 500 internal server error */ @POST @Produces({"application/xml", "text/xml", "application/json", "text/yaml", "text/x-yaml", "application/x-yaml", "application/x-protobuf", "application/x-protostuff"}) @Path("/clone") @GZIP @RolesAllowed({"Administrator", "JBossAdministrator"}) @Interceptors({RequiredInterceptor.class, ResponseInterceptor.class}) public VoidResponse cloneModel(@Required("name") @FormParam("name") String name, @Required("newName") @FormParam("newName") String newName, @FormParam("modelTableName") String modelTableName) { VoidResponse response = new VoidResponse(); if (modelTableName == null) { modelTableName = defaultModelTableName; } datawave.webservice.model.Model model = getModel(name, modelTableName); // Set the new name model.setName(newName); importModel(model, modelTableName); return response; }
Example 5
Source Project: jaxrs-beanvalidation-javaee7 Source File: Persons.java License: Apache License 2.0 | 6 votes |
@POST @Path("create") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response createPerson( @FormParam("id") @NotNull(message = "{person.id.notnull}") @Pattern(regexp = "[0-9]+", message = "{person.id.pattern}") String id, @FormParam("name") @Size(min = 2, max = 50, message = "{person.name.size}") String name) { Person person = new Person(); person.setId(Integer.valueOf(id)); person.setName(name); persons.put(id, person); return Response.status(Response.Status.CREATED).entity(person).build(); }
Example 6
Source Project: demo-restWS-spring-jersey-jpa2-hibernate Source File: PodcastRestService.java License: MIT License | 6 votes |
/** * Adds a new resource (podcast) from "form" (at least title and feed * elements are required at the DB level) * * @param title * @param linkOnPodcastpedia * @param feed * @param description * @return */ @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({ MediaType.TEXT_HTML }) @Transactional public Response createPodcastFromForm(@FormParam("title") String title, @FormParam("linkOnPodcastpedia") String linkOnPodcastpedia, @FormParam("feed") String feed, @FormParam("description") String description) { Podcast podcast = new Podcast(title, linkOnPodcastpedia, feed, description); podcastDao.createPodcast(podcast); return Response.status(201) .entity("A new podcast/resource has been created").build(); }
Example 7
Source Project: typescript-generator Source File: JaxrsApplicationParser.java License: MIT License | 6 votes |
private MethodParameterModel getEntityParameter(Class<?> resourceClass, Method method, List<Pair<Parameter, Type>> parameters) { for (Pair<Parameter, Type> pair : parameters) { if (!Utils.hasAnyAnnotation(annotationClass -> pair.getValue1().getAnnotation(annotationClass), Arrays.asList( MatrixParam.class, QueryParam.class, PathParam.class, CookieParam.class, HeaderParam.class, Suspended.class, Context.class, FormParam.class, BeanParam.class ))) { final Type resolvedType = GenericsResolver.resolveType(resourceClass, pair.getValue2(), method.getDeclaringClass()); return new MethodParameterModel(pair.getValue1().getName(), resolvedType); } } return null; }
Example 8
Source Project: jaxrs-beanvalidation-javaee7 Source File: Persons.java License: Apache License 2.0 | 6 votes |
@POST @Path("create") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response createPerson( @FormParam("id") @NotNull(message = "{person.id.notnull}") @Pattern(regexp = "[0-9]+", message = "{person.id.pattern}") String id, @FormParam("name") @Size(min = 2, max = 50, message = "{person.name.size}") String name) { Person person = new Person(); person.setId(Integer.valueOf(id)); person.setName(name); persons.put(id, person); return Response.status(Response.Status.CREATED).entity(person).build(); }
Example 9
Source Project: airpal Source File: SessionResource.java License: Apache License 2.0 | 6 votes |
@POST @Path("/login") public void doLogin( @Context HttpServletRequest request, @Context HttpServletResponse response, @FormParam("username") String username, @FormParam("password") String password) throws IOException { Subject currentUser = SecurityUtils.getSubject(); if (!currentUser.isAuthenticated()) { AuthenticationToken token = new UsernamePasswordToken(username, password); currentUser.login(token); } WebUtils.redirectToSavedRequest(request, response, "/app"); }
Example 10
Source Project: commerce-cif-api Source File: CartApi.java License: Apache License 2.0 | 6 votes |
@POST @Path("/{id}/entries") @ApiOperation(value = "Adds a new cart entry to an existing cart.") @ApiResponses(value = { @ApiResponse(code = HTTP_CREATED, message = HTTP_CREATED_MESSAGE, response = Cart.class, responseHeaders = @ResponseHeader(name = "Location", description = "Location of the newly created cart entry.", response = String.class)), @ApiResponse(code = HTTP_BAD_REQUEST, message = HTTP_BAD_REQUEST_MESSAGE, response = ErrorResponse.class), @ApiResponse(code = HTTP_FORBIDDEN, message = HTTP_FORBIDDEN_MESSAGE, response = ErrorResponse.class), @ApiResponse(code = HTTP_NOT_FOUND, message = HTTP_NOT_FOUND_MESSAGE, response = ErrorResponse.class) }) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) Cart postCartEntry( @ApiParam(value = "The ID of the cart for the new entry", required = true) @PathParam("id") String id, @ApiParam(value = "The product variant id to be added to the cart entry. If product variant exists in the" + " cart then the cart entry quantity is increased with the provided quantity.", required = true) @FormParam("productVariantId") String productVariantId, @ApiParam(value = "The quantity for the new entry.", required = true) @FormParam("quantity") @Min(value = 0) int quantity, @ApiParam(value = ACCEPT_LANGUAGE_DESC) @HeaderParam(ACCEPT_LANGUAGE) String acceptLanguage);
Example 11
Source Project: redpipe Source File: WikiResource.java License: Apache License 2.0 | 6 votes |
@Path("/save") @POST public Single<Response> save(@FormParam("id") String id, @FormParam("title") String title, @FormParam("markdown") String markdown, @FormParam("newPage") String newPage){ return fiber(() -> { boolean isNewPage = "yes".equals(newPage); String requiredPermission = isNewPage ? "create" : "update"; if(!await(user.rxIsAuthorised(requiredPermission))) throw new AuthorizationException("Not authorized"); io.reactivex.Single<Integer> query; if(isNewPage) query = dao.insert(new Pages().setName(title).setContent(markdown)); else query = dao.update(new Pages().setId(Integer.valueOf(id)).setContent(markdown).setName(title)); await(query); URI location = Router.getURI(WikiResource::renderPage, title); return Response.seeOther(location).build(); }); }
Example 12
Source Project: java-resource-server Source File: CountryEndpoint.java License: Apache License 2.0 | 6 votes |
@POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response post( @HeaderParam(HttpHeaders.AUTHORIZATION) String authorization, @HeaderParam("DPoP") String dpop, @FormParam("access_token") String accessToken, @PathParam("code") String code, @Context HttpServletRequest request) { // Extract an access token from either the Authorization header or // the request parameters. The Authorization header takes precedence. // See RFC 6750 (Bearer Token Usage) about the standard ways to accept // an access token from a client application. String token = extractAccessToken(authorization, accessToken); return process(request, token, dpop, code); }
Example 13
Source Project: ozark Source File: ConstraintViolationMetadata.java License: Apache License 2.0 | 6 votes |
public Optional<String> getParamName() { for (Annotation annotation : annotations) { if (annotation instanceof QueryParam) { return Optional.of(((QueryParam) annotation).value()); } if (annotation instanceof PathParam) { return Optional.of(((PathParam) annotation).value()); } if (annotation instanceof FormParam) { return Optional.of(((FormParam) annotation).value()); } if (annotation instanceof MatrixParam) { return Optional.of(((MatrixParam) annotation).value()); } if (annotation instanceof CookieParam) { return Optional.of(((CookieParam) annotation).value()); } } return Optional.empty(); }
Example 14
Source Project: proarc Source File: DigitalObjectResource.java License: GNU General Public License v3.0 | 6 votes |
@POST @Path(DigitalObjectResourceApi.CHANGE_PAGE_TO_NDK_PAGE) @Produces(MediaType.APPLICATION_JSON) public SmartGwtResponse<Item> changePageToNdkPage( @FormParam(DigitalObjectResourceApi.DIGITALOBJECT_PID) String pid, @FormParam(DigitalObjectResourceApi.DIGITALOBJECT_MODEL) String modelId ) throws DigitalObjectException { if (pid == null || pid.isEmpty()|| modelId == null || modelId.isEmpty()) { return new SmartGwtResponse<>(); } ChangeModels changeModels = new ChangeModels(appConfig, pid, modelId, NdkPlugin.MODEL_PAGE, NdkPlugin.MODEL_NDK_PAGE); List<String> pids = changeModels.findObjects(); changeModels.changeModels(); RepairMetadata repairMetadata = new RepairMetadata(appConfig, NdkPlugin.MODEL_NDK_PAGE, pids); repairMetadata.repair(); return new SmartGwtResponse<>(); }
Example 15
Source Project: document-management-system Source File: AuthService.java License: GNU General Public License v2.0 | 5 votes |
@PUT @Path("/updateUser") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void updateUser(@FormParam("user") String user, @FormParam("password") String password, @FormParam("email") String email, @FormParam("name") String name, @FormParam("active") boolean active) throws GenericException { try { log.debug("updateUser({}, {}, {}, {}, {})", new Object[]{user, password, email, name, active}); AuthModule am = ModuleManager.getAuthModule(); am.updateUser(null, user, password, email, name, active); log.debug("updateUser: void"); } catch (Exception e) { throw new GenericException(e); } }
Example 16
Source Project: karamel Source File: SetGithubCredentials.java License: Apache License 2.0 | 5 votes |
@POST public Response setGithubCredentials(@FormParam("user") String user, @FormParam("password") String password) { Response response = null; logger.debug(" Received request to set github credentials.... "); try { GithubUser githubUser = karamelApi.registerGithubAccount(user, password); response = Response.status(Response.Status.OK). entity(githubUser).build(); } catch (KaramelException e) { response = buildExceptionResponse(e); } return response; }
Example 17
Source Project: wings Source File: DomainResource.java License: Apache License 2.0 | 5 votes |
@POST @Path("setDomainPermissions") @Produces(MediaType.TEXT_PLAIN) public String setDomainPermissions( @FormParam("domain") String domain, @FormParam("permissions_json") String json) { if(this.dc != null && this.isOwner() && this.dc.setDomainPermissions(domain, json)) return "OK"; return null; }
Example 18
Source Project: smallrye-open-api Source File: ParameterScanTests.java License: Apache License 2.0 | 5 votes |
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) @RequestBody(content = @Content(schema = @Schema(requiredProperties = { "f3" }), encoding = { @Encoding(name = "formField1", contentType = "text/x-custom-type") })) public CompletableFuture<Widget> upd(@MultipartForm Bean form, @FormParam("f3") @DefaultValue("3") int formField3, @org.jboss.resteasy.annotations.jaxrs.FormParam @NotNull String formField4) { return null; }
Example 19
Source Project: wildfly-samples Source File: EmployeeResource.java License: MIT License | 5 votes |
@POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void addToList(@FormParam("name") String name, @FormParam("age") int age) { System.out.println("Creating a new item: " + name); bean.addEmployee(new Employee(name, age)); }
Example 20
Source Project: zheshiyigeniubidexiangmu Source File: BiboxDigest.java License: MIT License | 5 votes |
@Override public String digestParams(RestInvocation restInvocation) { String cmds = (String) restInvocation.getParamValue(FormParam.class, BiboxAuthenticated.FORM_CMDS); try { return DigestUtils.bytesToHex(getMac().doFinal(cmds.getBytes("UTF-8"))).toLowerCase(); } catch (IllegalStateException | UnsupportedEncodingException e1) { throw new RuntimeException(e1.getMessage()); } }
Example 21
Source Project: emissary Source File: AddChildDirectoryAction.java License: Apache License 2.0 | 5 votes |
@POST @Path("/AddChildDirectory.action") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_PLAIN) public Response addChildDirectory(@FormParam(DirectoryAdapter.TARGET_DIRECTORY) String parent, @FormParam(DirectoryAdapter.DIRECTORY_NAME) String child) { try { if (child == null) { throw new IllegalArgumentException("Missing required parameters"); } final IRemoteDirectory localDirectory = new IRemoteDirectory.Lookup().getLocalDirectory(parent); if (localDirectory == null) { throw new IllegalArgumentException("No parent directory found using name " + parent); } MDC.put(MDCConstants.SERVICE_LOCATION, KeyManipulator.getServiceLocation(localDirectory.getKey())); try { localDirectory.irdAddChildDirectory(child); logger.debug("addChildDirectory succeeded"); // old success from AddChildDirectoryWorker // return WORKER_SUCCESS; return Response.ok().entity("addChildDirectory succeeded").build(); } finally { MDC.remove(MDCConstants.SERVICE_LOCATION); } } catch (Exception e) { logger.error("Could not call addChildDirectory", e); // old failure from AddChildDirectoryWorker // return new WorkerStatus(WorkerStatus.FAILURE, "Could not call addChildDirectory", e); return Response.serverError().entity("Could not call addChildDirectory:\n" + e.getMessage()).build(); } }
Example 22
Source Project: datacollector Source File: HttpProcessorIT.java License: Apache License 2.0 | 5 votes |
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) @POST public Response post( @FormParam(OAuth2ConfigBean.GRANT_TYPE_KEY) String type, @FormParam(OAuth2ConfigBean.CLIENT_ID_KEY) String clientId, @FormParam(OAuth2ConfigBean.CLIENT_SECRET_KEY) String clientSecret, @FormParam(OAuth2ConfigBean.RESOURCE_OWNER_KEY) String username, @FormParam(OAuth2ConfigBean.PASSWORD_KEY) String password ) { token = RandomStringUtils.randomAlphanumeric(16); String tokenResponse = "{\n" + " \"token_type\": \"Bearer\",\n" + " \"expires_in\": \"3600\",\n" + " \"ext_expires_in\": \"0\",\n" + " \"expires_on\": \"1484788319\",\n" + " \"not_before\": \"1484784419\",\n" + " \"access_token\": \"" + token + "\"\n" + "}"; if ((OAuth2ConfigBean.RESOURCE_OWNER_GRANT.equals(type) && USERNAME.equals(username) && PASSWORD.equals(password) && CLIENT_ID.equals(clientId) && CLIENT_SECRET.equals(clientSecret) )) { tokenGetCount++; return Response.ok().entity(tokenResponse).build(); } return Response.status(Response.Status.FORBIDDEN).build(); }
Example 23
Source Project: peer-os Source File: RestService.java License: Apache License 2.0 | 5 votes |
@POST @Produces( { MediaType.APPLICATION_JSON } ) @Path( "{environmentId}/modify/advanced" ) Response modifyAdvanced( @PathParam( "environmentId" ) String environmentId, @FormParam( "topology" ) String topologyJson, @FormParam( "removedContainers" ) String removedContainers, @FormParam( "quotaContainers" ) String quotaContainers );
Example 24
Source Project: cxf Source File: BookStore.java License: Apache License 2.0 | 5 votes |
@POST @Path("/books") @Valid public BookWithValidation addBook(@NotNull @FormParam("id") String id, @FormParam("name") String name) { return new BookWithValidation(name, id); }
Example 25
Source Project: opencps-v2 Source File: UserManagement.java License: GNU Affero General Public License v3.0 | 5 votes |
@POST @Path("/{id}/changepass/application") @Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response addChangepassApplication(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext, @PathParam("id") long id, @FormParam("oldPassword") String oldPassword, @FormParam("newPassword") String newPassword);
Example 26
Source Project: emissary Source File: HeartbeatAction.java License: Apache License 2.0 | 5 votes |
@POST @Path("/Heartbeat.action") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_PLAIN) public Response heartbeatPost(@FormParam(HeartbeatAdapter.FROM_PLACE_NAME) String fromPlace, @FormParam(HeartbeatAdapter.TO_PLACE_NAME) String toPlace) { return processHeartbeat(fromPlace, toPlace); }
Example 27
Source Project: jumbune Source File: ClusterAnalysisService.java License: GNU Lesser General Public License v3.0 | 5 votes |
@POST @Path(WebConstants.DATA_CENTER_HEAT_MAP) @Produces(MediaType.APPLICATION_JSON) public Response getDataCenterHeatMap(@FormParam(CLUSTER_NAME) String clusterName, @FormParam("colorConfigJSON") String colorConfigJSON) { try { Cluster cluster = cache.getCluster(clusterName); ClusterInfo dataCenterHeatMap = getHeatMap(cluster, colorConfigJSON, "CLUSTER_VIEW"); return Response.ok(Constants.gson.toJson(dataCenterHeatMap)).build(); } catch (Exception e) { LOGGER.error("Unable to get data center heat map", e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } }
Example 28
Source Project: document-management-software Source File: RestDocumentService.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override @POST @Path("/unsetPassword") @Consumes({ MediaType.APPLICATION_FORM_URLENCODED }) @ApiOperation( value = "Removes password protection", notes = "Removes the password protection from the document") public void unsetPassword( @FormParam("docId") @ApiParam(value = "Document ID", required = true) long docId, @FormParam("currentPassword") @ApiParam(value = "A password", required = true) String currentPassword) throws Exception { String sid = validateSession(); super.unsetPassword(sid, docId, currentPassword); }
Example 29
Source Project: gitlab-plugin Source File: V3GitLabApiProxy.java License: GNU General Public License v2.0 | 5 votes |
@POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("/projects/{projectId}/hooks") @Override void addProjectHook(@PathParam("projectId") String projectId, @FormParam("url") String url, @FormParam("push_events") Boolean pushEvents, @FormParam("merge_requests_events") Boolean mergeRequestEvents, @FormParam("note_events") Boolean noteEvents);
Example 30
Source Project: tutorials Source File: FruitResource.java License: MIT License | 5 votes |
@PUT @Path("/update") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void updateFruit(@SerialNumber @FormParam("serial") String serial) { Fruit fruit = new Fruit(); fruit.setSerial(serial); SimpleStorageService.storeFruit(fruit); }