Java Code Examples for javax.ws.rs.QueryParam

The following are top voted examples for showing how to use javax.ws.rs.QueryParam. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: hadoop-oss   File: KMS.java   View source code 10 votes vote down vote up
@GET
@Path(KMSRESTConstants.KEYS_METADATA_RESOURCE)
@Produces(MediaType.APPLICATION_JSON)
public Response getKeysMetadata(@QueryParam(KMSRESTConstants.KEY)
    List<String> keyNamesList) throws Exception {
  KMSWebApp.getAdminCallsMeter().mark();
  UserGroupInformation user = HttpUserGroupInformation.get();
  final String[] keyNames = keyNamesList.toArray(
      new String[keyNamesList.size()]);
  assertAccess(KMSACLs.Type.GET_METADATA, user, KMSOp.GET_KEYS_METADATA);

  KeyProvider.Metadata[] keysMeta = user.doAs(
      new PrivilegedExceptionAction<KeyProvider.Metadata[]>() {
        @Override
        public KeyProvider.Metadata[] run() throws Exception {
          return provider.getKeysMetadata(keyNames);
        }
      }
  );

  Object json = KMSServerJSONUtils.toJSON(keyNames, keysMeta);
  kmsAudit.ok(user, KMSOp.GET_KEYS_METADATA, "");
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(json).build();
}
 
Example 2
Project: microprofile-jwt-auth   File: JsonValuejectionEndpoint.java   View source code 8 votes vote down vote up
@GET
@Path("/verifyInjectedIssuer")
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("Tester")
public JsonObject verifyInjectedIssuer(@QueryParam("iss") String iss) {
    boolean pass = false;
    String msg;
    String issValue = issuer.getString();
    if(issValue == null || issValue.length() == 0) {
        msg = Claims.iss.name()+"value is null or empty, FAIL";
    }
    else if(issValue.equals(iss)) {
        msg = Claims.iss.name()+" PASS";
        pass = true;
    }
    else {
        msg = String.format("%s: %s != %s", Claims.iss.name(), issValue, iss);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 
Example 3
Project: presto-manager   File: ControllerPackageAPI.java   View source code 7 votes vote down vote up
@PUT
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Install Presto using rpm or tarball")
@ApiResponses(value = {
        @ApiResponse(code = 207, message = "Multiple responses available"),
        @ApiResponse(code = 400, message = "Request contains invalid parameters")})
public Response install(String urlToFetchPackage,
        @QueryParam("checkDependencies") @DefaultValue("true") boolean checkDependencies,
        @QueryParam("scope") String scope,
        @QueryParam("nodeId") List<String> nodeId)
{
    ApiRequester.Builder apiRequester = requesterBuilder(ControllerPackageAPI.class)
            .httpMethod(PUT)
            .accept(MediaType.TEXT_PLAIN)
            .entity(Entity.entity(urlToFetchPackage, MediaType.TEXT_PLAIN));

    optionalQueryParam(apiRequester, "checkDependencies", checkDependencies);

    return forwardRequest(scope, apiRequester.build(), nodeId);
}
 
Example 4
Project: CommonInformationSpace   File: CISAdaptorConnectorRestController.java   View source code 7 votes vote down vote up
@ApiOperation(value = "getParticipantFromCGOR", nickname = "getParticipantFromCGOR")
@RequestMapping(value = "/CISConnector/getParticipantFromCGOR/{cgorName}", method = RequestMethod.GET)
@ApiImplicitParams({
       @ApiImplicitParam(name = "cgorName", value = "the CGOR name", required = true, dataType = "String", paramType = "path"),
       @ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "query")
     })
@ApiResponses(value = { 
           @ApiResponse(code = 200, message = "Success", response = Participant.class),
           @ApiResponse(code = 400, message = "Bad Request", response = Participant.class),
           @ApiResponse(code = 500, message = "Failure", response = Participant.class)})
public ResponseEntity<Participant> getParticipantFromCGOR(@PathVariable String cgorName, @QueryParam("organisation") String organisation) {
	log.info("--> getParticipantFromCGOR: " + cgorName);
	
	Participant participant;
	
	try {
		participant = connector.getParticipantFromCGOR(cgorName, organisation);
	} catch (CISCommunicationException e) {
		log.error("Error executing the request: Communication Error" , e);
		participant = null;
	}
	
	HttpHeaders responseHeaders = new HttpHeaders();
	
	log.info("getParticipantFromCGOR -->");
	return new ResponseEntity<Participant>(participant, responseHeaders, HttpStatus.OK);
}
 
Example 5
Project: Equella   File: EquellaItemResource.java   View source code 7 votes vote down vote up
@DELETE
@Path("/{uuid}/{version}/comment")
@ApiOperation(value = "Delete a comment")
Response deleteComment(
	@Context 
		UriInfo info,
	@ApiParam(APIDOC_ITEMUUID) 
	@PathParam("uuid") 
		String uuid,
	@ApiParam(APIDOC_ITEMVERSION) 
	@PathParam("version") 
		int version,
	@ApiParam(APIDOC_ITEMVERSION) 
	@QueryParam("commentuuid") 
		String commentUuid
	);
 
Example 6
Project: presto-manager   File: ControllerConfigAPI.java   View source code 6 votes vote down vote up
@GET
@Path("/{file}")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Get contents of a configuration file")
@ApiResponses(value = {
        @ApiResponse(code = 207, message = "Multiple responses available"),
        @ApiResponse(code = 400, message = "Request contains invalid parameters")})
public Response getConfigFile(
        @PathParam("file") String file,
        @QueryParam("scope") String scope,
        @QueryParam("nodeId") List<String> nodeId)
{
    ApiRequester apiRequester = requesterBuilder(ControllerConfigAPI.class)
            .pathMethod("getConfigFile")
            .httpMethod(GET)
            .resolveTemplate("file", file)
            .accept(MediaType.TEXT_PLAIN)
            .build();

    return forwardRequest(scope, apiRequester, nodeId);
}
 
Example 7
Project: traccar-service   File: UserResource.java   View source code 6 votes vote down vote up
@GET
public Collection<User> get(@QueryParam("userId") long userId) throws SQLException {
    UsersManager usersManager = Context.getUsersManager();
    Set<Long> result = null;
    if (Context.getPermissionsManager().getUserAdmin(getUserId())) {
        if (userId != 0) {
            result = usersManager.getUserItems(userId);
        } else {
            result = usersManager.getAllItems();
        }
    } else if (Context.getPermissionsManager().getUserManager(getUserId())) {
        result = usersManager.getManagedItems(getUserId());
    } else {
        throw new SecurityException("Admin or manager access required");
    }
    return usersManager.getItems(result);
}
 
Example 8
Project: neo4j-sparql-extension-yars   File: GraphStore.java   View source code 6 votes vote down vote up
/**
 * Indirect HTTP PUT
 *
 * @see <a href="http://www.w3.org/TR/sparql11-http-rdf-update/#http-put">
 * Section 5.3 "HTTP PUT"
 * </a>
 * @param uriInfo JAX-RS {@link UriInfo} object
 * @param type Content-Type HTTP header field
 * @param graphString the "graph" query parameter
 * @param def the "default" query parameter
 * @param chunked the "chunked" query parameter
 * @param in HTTP body as {@link InputStream}
 * @return "204 No Content", if operation was successful
 */
@PUT
@Consumes({
	RDFMediaType.RDF_TURTLE,
	RDFMediaType.RDF_YARS,
	RDFMediaType.RDF_XML,
	RDFMediaType.RDF_NTRIPLES,
	RDFMediaType.RDF_XML
})
public Response graphIndirectPut(
		@Context UriInfo uriInfo,
		@HeaderParam("Content-Type") MediaType type,
		@QueryParam("graph") String graphString,
		@QueryParam("default") String def,
		@QueryParam("chunked") String chunked,
		InputStream in) {
	return handleAdd(uriInfo, type, graphString, def, in, chunked, true);
}
 
Example 9
Project: ctsms   File: ProbandListEntryResource.java   View source code 6 votes vote down vote up
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("{id}/tagvalues")
public JsValuesOutVOPage<ProbandListEntryTagValueOutVO, ProbandListEntryTagValueJsonVO> getProbandListEntryTagValues(@PathParam("id") Long id,
		@QueryParam("sort") Boolean sort, @QueryParam("load_all_js_values") Boolean loadAllJsValues, @Context UriInfo uriInfo)
				throws AuthenticationException, AuthorisationException, ServiceException {
	PSFUriPart psf = new PSFUriPart(uriInfo, "sort", "load_all_js_values");
	ProbandListEntryTagValuesOutVO values = WebUtil.getServiceLocator().getTrialService()
			.getProbandListEntryTagValues(auth, id, sort, loadAllJsValues, psf);
	return new JsValuesOutVOPage<ProbandListEntryTagValueOutVO, ProbandListEntryTagValueJsonVO>(values.getPageValues(), values.getJsValues(), psf);
	// PSFUriPart psf;
	// return new ProbandListEntryTagValuesOutVOPage(WebUtil.getServiceLocator().getTrialService()
	// .getProbandListEntryTagValues(auth, id, false, false, psf = new PSFUriPart(uriInfo)),
	// psf);
	// return WebUtil.getServiceLocator().getTrialService().getProbandListEntryTagValues(auth, id, false, false, new PSFUriPart(uriInfo));
}
 
Example 10
Project: presto-manager   File: ControllerConnectorAPI.java   View source code 6 votes vote down vote up
@DELETE
@Path("/{file}/{property}")
@ApiOperation(value = "Delete a certain property of connector file")
@ApiResponses(value = {
        @ApiResponse(code = 207, message = "Multiple responses available"),
        @ApiResponse(code = 400, message = "Request contains invalid parameters")})
public Response deleteConnectorProperty(
        @PathParam("file") String file,
        @PathParam("property") String property,
        @QueryParam("scope") String scope,
        @QueryParam("nodeId") List<String> nodeId)
{
    ApiRequester apiRequester = requesterBuilder(ControllerConnectorAPI.class)
            .pathMethod("deleteConnectorProperty")
            .httpMethod(DELETE)
            .resolveTemplate("file", file)
            .resolveTemplate("property", property)
            .accept(MediaType.TEXT_PLAIN)
            .build();

    return forwardRequest(scope, apiRequester, nodeId);
}
 
Example 11
Project: https-github.com-apache-zookeeper   File: ZNodeResource.java   View source code 6 votes vote down vote up
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
 
Example 12
Project: Equella   File: TaskResource.java   View source code 6 votes vote down vote up
@GET
@Path("/")
@ApiOperation(value = "Search tasks")
public Response tasksSearch(
	// @formatter:off
	@Context UriInfo uriInfo,
	@ApiParam(value="The filtering to apply to the task list", allowableValues = "all,assignedme,assignedothers,assignednone,mustmoderate", required = false, defaultValue=DEFAULT_FILTER) @QueryParam("filter")
		String filtering,
	@ApiParam(value="Query string", required = false) @QueryParam("q")
		String q,
	@ApiParam(value="The first record of the search results to return", required = false, defaultValue="0") @QueryParam("start")
		int start,
	@ApiParam(value="The number of results to return", required = false, defaultValue = "10", allowableValues = "range[1,100]") @QueryParam("length")
		int length,
	@ApiParam(value="List of collections", required = false) @QueryParam("collections")
		CsvList collections,
	@ApiParam(value="The order of the search results", allowableValues="priority,duedate,waiting, name", required = false) @QueryParam("order")
		String order,
	@ApiParam(value="Reverse the order of the search results", allowableValues = ",true,false", defaultValue = "false", required = false)
	@QueryParam("reverse")
		String reverse
	);
 
Example 13
Project: microprofile-jwt-auth   File: PrimitiveInjectionEndpoint.java   View source code 6 votes vote down vote up
@GET
@Path("/verifyInjectedCustomString")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedCustomString(@QueryParam("value") String value) {
    boolean pass = false;
    String msg;
    // iat
    String customValue = this.customString;
    if (customValue == null || customValue.length() == 0) {
        msg = "customString value is null or empty, FAIL";
    }
    else if (customValue.equals(value)) {
        msg = "customString PASS";
        pass = true;
    }
    else {
        msg = String.format("customString: %s != %s", customValue, value);
    }
    JsonObject result = Json.createObjectBuilder()
            .add("pass", pass)
            .add("msg", msg)
            .build();
    return result;
}
 
Example 14
Project: hadoop   File: HsWebServices.java   View source code 6 votes vote down vote up
@GET
@Path("/mapreduce/jobs/{jobid}/tasks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public TasksInfo getJobTasks(@Context HttpServletRequest hsr,
    @PathParam("jobid") String jid, @QueryParam("type") String type) {

  init();
  Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
  checkAccess(job, hsr);
  TasksInfo allTasks = new TasksInfo();
  for (Task task : job.getTasks().values()) {
    TaskType ttype = null;
    if (type != null && !type.isEmpty()) {
      try {
        ttype = MRApps.taskType(type);
      } catch (YarnRuntimeException e) {
        throw new BadRequestException("tasktype must be either m or r");
      }
    }
    if (ttype != null && task.getType() != ttype) {
      continue;
    }
    allTasks.add(new TaskInfo(task));
  }
  return allTasks;
}
 
Example 15
Project: presto-manager   File: ControllerConfigAPI.java   View source code 6 votes vote down vote up
@GET
@Path("/{file}/{property}")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Get specific configuration property")
@ApiResponses(value = {
        @ApiResponse(code = 207, message = "Multiple responses available"),
        @ApiResponse(code = 400, message = "Request contains invalid parameters")})
public Response getConfigProperty(
        @PathParam("file") String file,
        @PathParam("property") String property,
        @QueryParam("scope") String scope,
        @QueryParam("nodeId") List<String> nodeId)
{
    ApiRequester apiRequester = requesterBuilder(ControllerConfigAPI.class)
            .pathMethod("getConfigProperty")
            .httpMethod(GET)
            .resolveTemplate("file", file)
            .resolveTemplate("property", property)
            .accept(MediaType.TEXT_PLAIN)
            .build();

    return forwardRequest(scope, apiRequester, nodeId);
}
 
Example 16
Project: message-broker   File: QueuesApi.java   View source code 6 votes vote down vote up
@DELETE
@Path("/{queueName}")
@Produces({"application/json"})
@ApiOperation(value = "Delete the specified queue.", notes = "Delete the specified queue if the queue exists in "
        + "the broker and the query param properties ifUnused and ifEmpty are satisfied.",
              response = Void.class, tags = {})
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Queue deleted", response = Void.class),
        @ApiResponse(code = 400, message = "Bad request. Invalid request or validation error.",
                     response = Error.class),
        @ApiResponse(code = 404, message = "Queue not found", response = Error.class)})
public Response deleteQueue(
        @PathParam("queueName") @ApiParam("Name of the queue") String queueName, @QueryParam("ifUnused")
@ApiParam("If set to true, queue will be deleted only if the queue has no active consumers.") Boolean ifUnused,
         @QueryParam("ifEmpty") @ApiParam("If set to true, queue will be deleted only if the queue is empty.")
                Boolean ifEmpty) {
    return delegate.deleteQueue(queueName, ifUnused, ifEmpty);
}
 
Example 17
Project: rebase-server   File: AuthorizationResource.java   View source code 6 votes vote down vote up
@GET @Path("{username}")
@Produces(MediaType.APPLICATION_JSON)
public Response authorize(
    @Username @PathParam("username") String username,
    @NotEmpty @QueryParam("password") String password) {

    Bson filter = and(eq(User.USERNAME, username), eq(User.PASSWORD, Hashes.sha1(password)));
    Document newAuth = Authorizations.newInstance(username);
    Document user = MongoDBs.users().findOneAndUpdate(filter, set(User.AUTHORIZATION, newAuth));
    if (user == null) {
        return Response.status(FORBIDDEN)
            .entity(new Failure("The username or password is incorrect"))
            .build();
    } else {
        return Response.ok(newAuth).build();
    }
}
 
Example 18
Project: presto-manager   File: ControllerPackageAPI.java   View source code 6 votes vote down vote up
@DELETE
@ApiOperation(value = "Uninstall Presto")
@ApiResponses(value = {
        @ApiResponse(code = 207, message = "Multiple responses available"),
        @ApiResponse(code = 400, message = "Request contains invalid parameters")})
public Response uninstall(
        @QueryParam("checkDependencies") @DefaultValue("true") boolean checkDependencies,
        @QueryParam("forceUninstall") @DefaultValue("false") boolean forceUninstall,
        @QueryParam("scope") String scope,
        @QueryParam("nodeId") List<String> nodeId)
{
    ApiRequester.Builder apiRequester = requesterBuilder(ControllerPackageAPI.class)
            .httpMethod(DELETE);

    optionalQueryParam(apiRequester, "forceUninstall", forceUninstall);
    optionalQueryParam(apiRequester, "checkDependencies", checkDependencies);

    return forwardRequest(scope, apiRequester.build(), nodeId);
}
 
Example 19
Project: microprofile-jwt-auth   File: ClaimValueInjectionEndpoint.java   View source code 6 votes vote down vote up
@GET
@Path("/verifyInjectedAudience")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedAudience(@QueryParam("aud") String audience) {
    boolean pass = false;
    String msg;
    // aud
    Set<String> audValue = aud.getValue();
    if(audValue == null || audValue.size() == 0) {
        msg = Claims.aud.name()+"value is null or empty, FAIL";
    }
    else if(audValue.contains(audience)) {
        msg = Claims.aud.name()+" PASS";
        pass = true;
    }
    else {
        msg = String.format("%s: %s != %s", Claims.aud.name(), audValue, audience);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 
Example 20
Project: neo4j-sparql-extension-yars   File: SPARQLQuery.java   View source code 6 votes vote down vote up
/**
 * Query via GET (with inference).
 *
 * @see <a href="http://www.w3.org/TR/sparql11-protocol/#query-operation">
 * SPARQL 1.1 Protocol
 * </a>
 * @param req JAX-RS {@link Request} object
 * @param uriInfo JAX-RS {@link UriInfo} object
 * @param queryString the "query" query parameter
 * @param defgraphs the "default-graph-uri" query parameter
 * @param namedgraphs the "named-graph-uri" query parameter
 * @return the result of the SPARQL query
 */
@GET
@Path("/inference")
@Produces({
	RDFMediaType.SPARQL_RESULTS_JSON,
	RDFMediaType.SPARQL_RESULTS_XML,
	RDFMediaType.SPARQL_RESULTS_CSV,
	RDFMediaType.SPARQL_RESULTS_TSV,
	RDFMediaType.RDF_TURTLE,
	RDFMediaType.RDF_YARS,
	RDFMediaType.RDF_NTRIPLES,
	RDFMediaType.RDF_XML,
	RDFMediaType.RDF_JSON
})
public Response queryInference(
		@Context Request req,
		@Context UriInfo uriInfo,
		@QueryParam("query") String queryString,
		@QueryParam("default-graph-uri") List<String> defgraphs,
		@QueryParam("named-graph-uri") List<String> namedgraphs) {
	return handleQuery(
			req, uriInfo, queryString, defgraphs, namedgraphs, "true");
}
 
Example 21
Project: hadoop   File: KMS.java   View source code 6 votes vote down vote up
@GET
@Path(KMSRESTConstants.KEYS_METADATA_RESOURCE)
@Produces(MediaType.APPLICATION_JSON)
public Response getKeysMetadata(@QueryParam(KMSRESTConstants.KEY)
    List<String> keyNamesList) throws Exception {
  KMSWebApp.getAdminCallsMeter().mark();
  UserGroupInformation user = HttpUserGroupInformation.get();
  final String[] keyNames = keyNamesList.toArray(
      new String[keyNamesList.size()]);
  assertAccess(KMSACLs.Type.GET_METADATA, user, KMSOp.GET_KEYS_METADATA);

  KeyProvider.Metadata[] keysMeta = user.doAs(
      new PrivilegedExceptionAction<KeyProvider.Metadata[]>() {
        @Override
        public KeyProvider.Metadata[] run() throws Exception {
          return provider.getKeysMetadata(keyNames);
        }
      }
  );

  Object json = KMSServerJSONUtils.toJSON(keyNames, keysMeta);
  kmsAudit.ok(user, KMSOp.GET_KEYS_METADATA, "");
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(json).build();
}
 
Example 22
Project: microprofile-jwt-auth   File: ClaimValueInjectionEndpoint.java   View source code 6 votes vote down vote up
@GET
@Path("/verifyInjectedAudienceStandard")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedAudienceStandard(@QueryParam("aud") String audience) {
    boolean pass = false;
    String msg;
    // aud
    Set<String> audValue = audStandard.getValue();
    if(audValue == null || audValue.size() == 0) {
        msg = Claims.aud.name()+"value is null or empty, FAIL";
    }
    else if(audValue.contains(audience)) {
        msg = Claims.aud.name()+" PASS";
        pass = true;
    }
    else {
        msg = String.format("%s: %s != %s", Claims.aud.name(), audValue, audience);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 
Example 23
Project: agilion   File: OffsetDateTimeProvider.java   View source code 6 votes vote down vote up
@Override
public Injectable<OffsetDateTime> getInjectable(final ComponentContext cc, final QueryParam a) {
    return new Injectable<OffsetDateTime>() {
        @Override
        public OffsetDateTime getValue() {
            final List<String> values = uriInfo.getQueryParameters().get(a.value());

            if (values == null || values.isEmpty())
                return null;
            if (values.size() > 1) {
                throw new WebApplicationException(Response.status(Status.BAD_REQUEST).
                        entity(a.value() + " cannot contain multiple values").build());
            }

            return OffsetDateTime.parse(values.get(0));
        }
    };
}
 
Example 24
Project: neo4j-sparql-extension-yars   File: GraphStore.java   View source code 6 votes vote down vote up
/**
 * Direct HTTP POST
 *
 * @see <a href="http://www.w3.org/TR/sparql11-http-rdf-update/#http-post">
 * Section 5.5 "HTTP POST"
 * </a>
 * @param uriInfo JAX-RS {@link UriInfo} object
 * @param type Content-Type HTTP header field
 * @param chunked the "chunked" query parameter
 * @param in HTTP body as {@link InputStream}
 * @return "204 No Content", if operation was successful
 */
@POST
@Consumes({
	RDFMediaType.RDF_TURTLE,
	RDFMediaType.RDF_YARS,
	RDFMediaType.RDF_XML,
	RDFMediaType.RDF_NTRIPLES,
	RDFMediaType.RDF_XML
})
@Path("/{graph}")
public Response graphDirectPost(
		@Context UriInfo uriInfo,
		@HeaderParam("Content-Type") MediaType type,
		@QueryParam("chunked") String chunked,
		InputStream in) {
	String graphuri = uriInfo.getAbsolutePath().toASCIIString();
	return handleAdd(uriInfo, type, graphuri, null, in, chunked, false);
}
 
Example 25
Project: emr-nlp-server   File: WSInterface.java   View source code 6 votes vote down vote up
@GET
	@Path("getVarGridObj/{fn_modelFnList}/{fn_reportIDList}")
//	@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
	@Produces(MediaType.APPLICATION_JSON)	
	public Map<String, Object> getReportFromList(
			@PathParam("fn_reportIDList") String fn_reportIDList,
			@PathParam("fn_modelFnList") String fn_modelFnList,
			@QueryParam("callback") String callback) throws Exception {
		int topKwords = 5;
		boolean biasFeature = true;
		Map<String, Object> gridVarObj = 
//				GridVar_Controller.instance.getPrediction(fn_reportIDList,
//						fn_modelFnList, topKwords, biasFeature);
				new GridVar_Controller().getPrediction(fn_reportIDList,
						fn_modelFnList, topKwords, biasFeature);
		return gridVarObj;
	}
 
Example 26
Project: MaximoForgeViewerPlugin   File: ForgeRS.java   View source code 6 votes vote down vote up
@GET
   @Produces(MediaType.APPLICATION_JSON)
   @Path("bucket")
   public Response bucketList(
    	@Context HttpServletRequest request,
    	@QueryParam("region") String region
) 
	throws IOException, 
	       URISyntaxException 
   {
   	APIImpl impl = getAPIImpl( request );
   	if( impl == null )
   	{
           return Response.status( Response.Status.UNAUTHORIZED ).build();     
   	}

   	ResultBucketList result = impl.bucketList( region );
   	
   	return formatReturn( result );
   }
 
Example 27
Project: microprofile-jwt-auth   File: ProviderInjectionEndpoint.java   View source code 6 votes vote down vote up
@GET
@Path("/verifyInjectedJTI")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedJTI(@QueryParam("jti") String jwtID) {
    boolean pass = false;
    String msg;
    // jti
    String jtiValue = jti.get();
    if(jtiValue == null || jtiValue.length() == 0) {
        msg = Claims.jti.name()+"value is null or empty, FAIL";
    }
    else if(jtiValue.equals(jwtID)) {
        msg = Claims.jti.name()+" PASS";
        pass = true;
    }
    else {
        msg = String.format("%s: %s != %s", Claims.jti.name(), jtiValue, jwtID);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 
Example 28
Project: MaximoForgeViewerPlugin   File: ForgeRS.java   View source code 6 votes vote down vote up
@PUT
   @Produces(MediaType.APPLICATION_JSON)
   @Path("bucket/{bucketKey}/rights/{serviceId}")
   public Response bucketGrant(
    	@Context HttpServletRequest request,
   	@PathParam("bucketKey") String bucketKey,
   	@PathParam("serviceId") String serviceId,
   	@QueryParam("access")   String access
) 
	throws IOException, 
	       URISyntaxException 
   {
   	APIImpl impl = getAPIImpl( request );
   	if( impl == null )
   	{
           return Response.status( Response.Status.UNAUTHORIZED ).build();     
   	}
   	Result result = impl.bucketGrantRightsV2( bucketKey, serviceId, access );
   	return formatReturn( result );
   }
 
Example 29
Project: MaximoForgeViewerPlugin   File: ForgeRS.java   View source code 6 votes vote down vote up
@GET
   @Produces(MediaType.APPLICATION_JSON)
   @Path("model/{bucketKey}")
   public Response modelList(
    	@Context HttpServletRequest request,
   	@PathParam("bucketKey") String bucketKey,
   	@QueryParam("name") String name,
   	@QueryParam("start") String start,
   	@QueryParam("pagesize") String pagesize
) 
	throws IOException, 
	       URISyntaxException 
   {
   	APIImpl impl = getAPIImpl( request );
   	if( impl == null )
   	{
           return Response.status( Response.Status.UNAUTHORIZED ).build();     
   	}
   	Result result = impl.objectListPaged( bucketKey, name, start, pagesize );
   	return formatReturn( result );
   }
 
Example 30
Project: neo4j-sparql-extension-yars   File: GraphStore.java   View source code 6 votes vote down vote up
/**
 * Indirect HTTP POST
 *
 * @see <a href="http://www.w3.org/TR/sparql11-http-rdf-update/#http-post">
 * Section 5.5 "HTTP POST"
 * </a>
 * @param uriInfo JAX-RS {@link UriInfo} object
 * @param type Content-Type HTTP header field
 * @param graphString the "graph" query parameter
 * @param def the "default" query parameter
 * @param chunked the "chunked" query parameter
 * @param in HTTP body as {@link InputStream}
 * @return "204 No Content", if operation was successful
 */
@POST
@Consumes({
	RDFMediaType.RDF_TURTLE,
	RDFMediaType.RDF_YARS,
	RDFMediaType.RDF_XML,
	RDFMediaType.RDF_NTRIPLES,
	RDFMediaType.RDF_XML
})
public Response graphIndirectPost(
		@Context UriInfo uriInfo,
		@HeaderParam("Content-Type") MediaType type,
		@QueryParam("graph") String graphString,
		@QueryParam("default") String def,
		@QueryParam("chunked") String chunked,
		InputStream in) {
	return handleAdd(uriInfo, type, graphString, def, in, chunked, false);
}
 
Example 31
Project: microprofile-jwt-auth   File: ClaimValueInjectionEndpoint.java   View source code 6 votes vote down vote up
@GET
@Path("/verifyInjectedIssuer")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedIssuer(@QueryParam("iss") String iss) {
    boolean pass = false;
    String msg;
    String issValue = issuer.getValue();
    if(issValue == null || issValue.length() == 0) {
        msg = Claims.iss.name()+"value is null or empty, FAIL";
    }
    else if(issValue.equals(iss)) {
        msg = Claims.iss.name()+" PASS";
        pass = true;
    }
    else {
        msg = String.format("%s: %s != %s", Claims.iss.name(), issValue, iss);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 
Example 32
Project: soapbox-race-core   File: Powerups.java   View source code 6 votes vote down vote up
@POST
@Secured
@Path("/activated/{powerupHash}")
@Produces(MediaType.APPLICATION_XML)
public String activated(@HeaderParam("securityToken") String securityToken, @PathParam(value = "powerupHash") Integer powerupHash, @QueryParam("targetId") Long targetId,
		@QueryParam("receivers") String receivers, @QueryParam("eventSessionId") Long eventSessionId) {
	XMPP_ResponseTypePowerupActivated powerupActivatedResponse = new XMPP_ResponseTypePowerupActivated();
	XMPP_PowerupActivatedType powerupActivated = new XMPP_PowerupActivatedType();
	powerupActivated.setId(Long.valueOf(powerupHash));
	powerupActivated.setTargetPersonaId(targetId);
	Long activePersonaId = tokenBO.getActivePersonaId(securityToken);
	powerupActivated.setPersonaId(activePersonaId);
	powerupActivatedResponse.setPowerupActivated(powerupActivated);
	for (String receiver : receivers.split("-")) {
		Long receiverPersonaId = Long.valueOf(receiver);
		if (receiverPersonaId > 10) {
			openFireSoapBoxCli.send(powerupActivatedResponse, receiverPersonaId);
		}
	}
	return "";
}
 
Example 33
Project: athena   File: ApplicationResource.java   View source code 5 votes vote down vote up
@Path("upload")
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response upload(@QueryParam("activate") @DefaultValue("false") String activate,
                       @FormDataParam("file") InputStream stream) throws IOException {
    ApplicationAdminService service = get(ApplicationAdminService.class);
    Application app = service.install(stream);
    lastInstalledAppName = app.id().name();
    if (Objects.equals(activate, "true")) {
        service.activate(app.id());
    }
    return Response.ok().build();
}
 
Example 34
Project: alvisnlp   File: RunResource.java   View source code 5 votes vote down vote up
@GET
@Path("/{id}/output/{path:.*}")
public Response output(
		@PathParam("id") String id,
		@PathParam("path") String path,
		@DefaultValue("false") @QueryParam("recdir") boolean recdir
		) throws IOException, SAXException, ClassNotFoundException, InstantiationException, IllegalAccessException {
	return output(id, path, recdir ? Integer.MAX_VALUE : 1);
}
 
Example 35
Project: task-app   File: TaskDaoResource.java   View source code 5 votes vote down vote up
@POST
@RolesAllowed(value = "TASK_APP_CLIENT")
@Path("/getTaskProperties")
@Produces(MediaType.APPLICATION_JSON)
public List<TaskProperty> getTaskProperties(
        @QueryParam("taskId") Long taskId) {
    List<TaskProperty> result = new ArrayList<>();
    List<JmdTaskProperty> list = taskDao.getProperties(taskId);
    list.forEach((jmdTaskProperty) -> {
        TaskProperty taskProperty = new TaskProperty();
        new Dto().objToObj(jmdTaskProperty, taskProperty);
        result.add(taskProperty);
    });
    return result;
}
 
Example 36
Project: dremio-oss   File: DataGraphResource.java   View source code 5 votes vote down vote up
@GET
@Produces(APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{version}")
public DataGraph getDataGraph(@PathParam("version") DatasetVersion version,
                              @QueryParam("currentView") DatasetPath currentView,
                              @QueryParam("searchParents") String parentFilter,
                              @QueryParam("searchChildren") String childrenFilter) throws NamespaceException {
  return datasetService.getDataGraph(datasetPath, version, currentView, parentFilter, childrenFilter);
}
 
Example 37
Project: crnk-framework   File: QueryParamProvider.java   View source code 5 votes vote down vote up
@Override
public Object provideValue(Parameter parameter, ContainerRequestContext requestContext, ObjectMapper objectMapper) {
	Object returnValue;
	List<String> value =
			requestContext.getUriInfo().getQueryParameters().get(parameter.getAnnotation(QueryParam.class).value());
	if (value == null || value.isEmpty()) {
		return null;
	}
	else {
		if (String.class.isAssignableFrom(parameter.getType())) {
			// Given a query string: ?x=y&x=z, JAX-RS will return a value of y.
			returnValue = value.get(0);
		}
		else if (Iterable.class.isAssignableFrom(parameter.getType())) {
			returnValue = value;
		}
		else {
			try {
				returnValue = objectMapper.readValue(value.get(0), parameter.getType());
			}
			catch (IOException e) {
				throw new IllegalStateException(e);
			}
		}
	}
	return returnValue;
}
 
Example 38
Project: message-broker   File: QueuesApi.java   View source code 5 votes vote down vote up
@GET
@Produces({"application/json"})
@ApiOperation(value = "Get all queues", notes = "Gets metadata of all the queues in the broker. This includes "
        + "durable  and non durable queues.  ", response = QueueMetadata.class, responseContainer = "List", tags
        = {})
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "List of queues", response = QueueMetadata.class, responseContainer =
                "List")})
public Response getAllQueues(@QueryParam("durable") @ApiParam("filter queues by durability") Boolean durable) {
    return delegate.getAllQueues(durable);
}
 
Example 39
Project: jboot   File: UserServiceImpl.java   View source code 5 votes vote down vote up
@Override
@GET
@Path("hello")
@Consumes({MediaType.APPLICATION_JSON})
public String test(@QueryParam("name") String name) {

    System.out.println("UserServiceImpl test() invoked!!!");
    return Ret.ok().set("name",name).toJson();
}
 
Example 40
Project: fuck_zookeeper   File: ZNodeResource.java   View source code 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_XML)
public Response getZNodeList(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("data") @QueryParam("view") String view,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    return getZNodeList(false, path, callback, view, dataformat, ui);
}