Java Code Examples for javax.ws.rs.DefaultValue

The following examples show how to use javax.ws.rs.DefaultValue. 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: datacollector   Source File: AdminResource.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("/bundle/generate")
@ApiOperation(
    value = "Generates a new support bundle.",
    response = Object.class,
    authorizations = @Authorization(value = "basic")
)
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/octet-stream")
@RolesAllowed({
    AuthzRole.ADMIN,
    AuthzRole.ADMIN_REMOTE
})
public Response createSupportBundlesContentGenerators(
  @QueryParam("generators") @DefaultValue("") String generators
) throws IOException {
  SupportBundle bundle = supportBundleManager.generateNewBundle(getGeneratorList(generators), BundleType.SUPPORT);

  return Response
    .ok()
    .header("content-disposition", "attachment; filename=\"" + bundle.getBundleName() + "\"")
    .entity(bundle.getInputStream())
    .build();
}
 
Example 2
Source Project: pnc   Source File: ArtifactEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
@GET
public Response getAll(
        @QueryParam(PAGE_INDEX_QUERY_PARAM) @DefaultValue(PAGE_INDEX_DEFAULT_VALUE) int pageIndex,
        @QueryParam(PAGE_SIZE_QUERY_PARAM) @DefaultValue(PAGE_SIZE_DEFAULT_VALUE) int pageSize,
        @QueryParam(SORTING_QUERY_PARAM) String sort,
        @QueryParam(QUERY_QUERY_PARAM) String q,
        @QueryParam("sha256") String sha256,
        @QueryParam("md5") String md5,
        @QueryParam("sha1") String sha1) {
    return fromCollection(
            artifactProvider.getAll(
                    pageIndex,
                    pageSize,
                    sort,
                    q,
                    Optional.ofNullable(sha256),
                    Optional.ofNullable(md5),
                    Optional.ofNullable(sha1)));
}
 
Example 3
Source Project: usergrid   Source File: UserResource.java    License: Apache License 2.0 6 votes vote down vote up
@CheckPermissionsForPath
@POST
@Path("deactivate")
@JSONP
@Produces({MediaType.APPLICATION_JSON, "application/javascript"})
public ApiResponse deactivate( @Context UriInfo ui, Map<String, Object> json,
                                   @QueryParam("callback") @DefaultValue("") String callback ) throws Exception {

    ApiResponse response = createApiResponse();
    response.setAction( "Deactivate user" );

    User user = management.deactivateUser( getApplicationId(), getUserUuid() );

    response.withEntity( user );

    return response;
}
 
Example 4
@GET
@Path("/cd")
@Produces(MediaType.APPLICATION_JSON)
public Response listConceptualDomains(
		@CookieParam(AuthenticationService.SID) String sessionID,
		@QueryParam("limit") @DefaultValue("10") Integer limit,
		@QueryParam("offset") @DefaultValue("0") Integer offset) {
	WebUtil.checkUserSession(sessionID);
	Repository repository = RepositoryManager.getInstance().getRepository();
	List<ConceptualDomain> cdList = repository.getConceptualDomains(limit,
			offset);

	List<ConceptualDomainModel> cdModelList = new ArrayList<ConceptualDomainModel>();
	for (ConceptualDomain cd : cdList) {
		if (cd instanceof EnumeratedConceptualDomain) {
			cdModelList.add(new ConceptualDomainModel(cd, true));
		} else {
			cdModelList.add(new ConceptualDomainModel(cd, false));
		}
	}

	return Response.ok(cdModelList).build();
}
 
Example 5
Source Project: brooklyn-server   Source File: EntityConfigApi.java    License: Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{config}")
@ApiOperation(value = "Manually set a config value")
@ApiResponses(value = {
        @ApiResponse(code = 404, message = "Could not find application, entity or config key")
})
public void set(
        @ApiParam(value = "Application ID or name", required = true)
        @PathParam("application") final String application,
        @ApiParam(value = "Entity ID or name", required = true)
        @PathParam("entity") final String entityToken,
        @ApiParam(value = "Config key name", required = true)
        @PathParam("config") String configName,
        @ApiParam(value = "Apply the config to all pre-existing descendants", required = false)
        @QueryParam("recurse") @DefaultValue("false") final Boolean recurse,
        @ApiParam(value = "Value to set")
        Object newValue);
 
Example 6
Source Project: atlas   Source File: GlossaryREST.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get all terms associated with the specific category
 * @param categoryGuid unique identifier for glossary category
 * @param limit page size - by default there is no paging
 * @param offset offset for pagination purpose
 * @param sort ASC (default) or DESC
 * @return List of associated terms
 * @throws AtlasBaseException
 * @HTTP 200 List of terms for the given category or an empty list
 * @HTTP 404 If glossary category guid in invalid
 */
@GET
@Path("/category/{categoryGuid}/terms")
public List<AtlasRelatedTermHeader> getCategoryTerms(@PathParam("categoryGuid") String categoryGuid,
                                                     @DefaultValue("-1") @QueryParam("limit") String limit,
                                                     @DefaultValue("0") @QueryParam("offset") String offset,
                                                     @DefaultValue("ASC") @QueryParam("sort") final String sort) throws AtlasBaseException {
    Servlets.validateQueryParamLength("categoryGuid", categoryGuid);

    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getCategoryTerms(" + categoryGuid + ")");
        }

        return glossaryService.getCategoryTerms(categoryGuid, Integer.parseInt(offset), Integer.parseInt(limit), toSortOrder(sort));

    } finally {
        AtlasPerfTracer.log(perf);
    }
}
 
Example 7
@RequestMapping(value = "/generateJsonTweetIdsLink.action", method = RequestMethod.GET)
@ResponseBody
public Map<String,Object> generateJsonTweetIdsLink(@RequestParam String code,
		@DefaultValue(DownloadType.TEXT_JSON) @QueryParam("jsonType") String jsonType) throws Exception {
	Map<String, Object> result = null;
	try {
		result = collectionLogService.generateJsonTweetIdsLink(code, jsonType);
		if (result != null && result.get("url") != null) {
			return getUIWrapper(result.get("url"),true, null, (String)result.get("message"));
		} else {
			return getUIWrapper(false, "Something wrong - no file generated!");
		}
	} catch (Exception e) {
		logger.error("Error while generating JSON Tweet Ids Link for collection: "+code +"and jsonType: "+jsonType, e);
		return getUIWrapper(false, "System is down or under maintenance. For further inquiries please contact admin.");
	}
}
 
Example 8
Source Project: qcon-microservices   Source File: OrderService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Perform a "Long-Poll" styled get. This method will attempt to get the value for the passed key
 * blocking until the key is available or passed timeout is reached. Non-blocking IO is used to
 * implement this, but the API will block the calling thread if no data is available
 *
 * @param id - the key of the value to retrieve
 * @param timeout - the timeout for the long-poll
 * @param asyncResponse - async response used to trigger the poll early should the appropriate
 * value become available
 */
@GET
@ManagedAsync
@Path("/orders/{id}")
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
public void getWithTimeout(@PathParam("id") final String id,
                           @QueryParam("timeout") @DefaultValue(CALL_TIMEOUT) Long timeout,
                           @Suspended final AsyncResponse asyncResponse) {
    setTimeout(timeout, asyncResponse);

    log.info("running GET on this node");
    try {
        Order order = ordersStore().get(id);
        if (order == null) {
            log.info("Delaying get as order not present for id " + id);
            outstandingRequests.put(id, new FilteredResponse<>(asyncResponse, (k, v) -> true));
        } else {
            asyncResponse.resume(order);
        }
    } catch (InvalidStateStoreException e) {
        //Store not ready so delay
        log.info("Delaying request for " + id + " because state store is not ready.");
        outstandingRequests.put(id, new FilteredResponse<>(asyncResponse, (k, v) -> true));
    }
}
 
Example 9
Source Project: olingo-odata4   Source File: Services.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Replace property.
 *
 * @param accept
 * @param entitySetName
 * @param entityId
 * @param path
 * @param format
 * @param changes
 * @return response
 */
@PUT
@Path("/{entitySetName}({entityId})/{path:.*}")
public Response replaceProperty(
    @Context final UriInfo uriInfo,
    @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
    @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
    @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
    @PathParam("entitySetName") final String entitySetName,
    @PathParam("entityId") final String entityId,
    @PathParam("path") final String path,
    @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
    final String changes) {

  if (xml.isMediaContent(entitySetName + "/" + path)) {
    return replaceMediaProperty(prefer, entitySetName, entityId, path, changes);
  } else {
    return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
        accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
  }
}
 
Example 10
Source Project: datacollector   Source File: ManagerResource.java    License: Apache License 2.0 6 votes vote down vote up
@Path("/pipeline/{pipelineId}/alerts")
@DELETE
@ApiOperation(value = "Delete alert by Pipeline name, revision and Alert ID", response = Boolean.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response deleteAlert(
  @PathParam("pipelineId") String pipelineId,
  @QueryParam("rev") @DefaultValue("0") String rev,
  @QueryParam("alertId") String alertId
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(
    manager.getRunner(pipelineId, rev).deleteAlert(alertId)).build();
}
 
Example 11
Source Project: cxf   Source File: BookStoreOpenApi.java    License: Apache License 2.0 6 votes vote down vote up
@Produces({ MediaType.APPLICATION_JSON })
@GET
@Operation(
    description = "Get books",
    responses = @ApiResponse(
        responseCode = "200", 
        content = @Content(
            mediaType = MediaType.APPLICATION_JSON,
            array = @ArraySchema(schema = @Schema(implementation = Book.class))
        )
    )
)
public Response getBooks(
    @Parameter(description = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) {
    return Response.ok(
        Arrays.asList(
            new Book("Book 1", 1),
            new Book("Book 2", 2)
        )
    ).build();
}
 
Example 12
Source Project: proarc   Source File: ImportResource.java    License: GNU General Public License v3.0 6 votes vote down vote up
@POST
@Path(ImportResourceApi.BATCH_PATH)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public SmartGwtResponse<BatchView> newBatch(
        @FormParam(ImportResourceApi.IMPORT_BATCH_FOLDER) @DefaultValue("") String path,
        @FormParam(ImportResourceApi.NEWBATCH_DEVICE_PARAM) String device,
        @FormParam(ImportResourceApi.NEWBATCH_INDICES_PARAM) @DefaultValue("true") boolean indices,
        @FormParam(ImportResourceApi.IMPORT_BATCH_PROFILE) String profileId
        ) throws URISyntaxException, IOException {
    
    LOG.log(Level.FINE, "import path: {0}, indices: {1}, device: {2}",
            new Object[] {path, indices, device});
    String folderPath = validateParentPath(path);
    URI userRoot = user.getImportFolder();
    URI folderUri = (folderPath != null)
            // URI multi param constructor escapes input unlike single param constructor or URI.create!
            ? userRoot.resolve(new URI(null, null, folderPath, null))
            : userRoot;
    File folder = new File(folderUri);
    ConfigurationProfile profile = findImportProfile(null, profileId);
    ImportProcess process = ImportProcess.prepare(folder, folderPath, user,
            importManager, device, indices, appConfig.getImportConfiguration(profile));
    ImportDispatcher.getDefault().addImport(process);
    Batch batch = process.getBatch();
    return new SmartGwtResponse<BatchView>(importManager.viewBatch(batch.getId()));
}
 
Example 13
Source Project: pulsar   Source File: PersistentTopics.java    License: Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{property}/{cluster}/{namespace}/{topic}/subscription/{subName}/resetcursor/{timestamp}")
@ApiOperation(hidden = true, value = "Reset subscription to message position closest to absolute timestamp (in ms).", notes = "It fence cursor and disconnects all active consumers before reseting cursor.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic/Subscription does not exist") })
public void resetCursor(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String encodedTopic, @PathParam("subName") String encodedSubName,
        @PathParam("timestamp") long timestamp,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalResetCursor(asyncResponse, decode(encodedSubName), timestamp, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example 14
Source Project: keycloak   Source File: GroupsResource.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get group hierarchy.  Only name and ids are returned.
 *
 * @return
 */
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public List<GroupRepresentation> getGroups(@QueryParam("search") String search,
                                           @QueryParam("first") Integer firstResult,
                                           @QueryParam("max") Integer maxResults,
                                           @QueryParam("briefRepresentation") @DefaultValue("true") boolean briefRepresentation) {
    auth.groups().requireList();

    List<GroupRepresentation> results;

    if (Objects.nonNull(search)) {
        results = ModelToRepresentation.searchForGroupByName(realm, !briefRepresentation, search.trim(), firstResult, maxResults);
    } else if(Objects.nonNull(firstResult) && Objects.nonNull(maxResults)) {
        results = ModelToRepresentation.toGroupHierarchy(realm, !briefRepresentation, firstResult, maxResults);
    } else {
        results = ModelToRepresentation.toGroupHierarchy(realm, !briefRepresentation);
    }

    return results;
}
 
Example 15
Source Project: olingo-odata4   Source File: Services.java    License: Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/People(1)/Parent")
public Response changeSingleValuedNavigationPropertyReference(
    @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
    @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
    final String content) {

  try {
    final Accept contentTypeValue = Accept.parse(contentType);
    assert contentTypeValue == Accept.JSON;

    jsonDeserializer.toEntity(IOUtils.toInputStream(content, Constants.ENCODING));

    return Response.noContent().type(MediaType.APPLICATION_JSON).build();
  } catch (Exception e) {
    LOG.error("While update single property reference", e);
    return xml.createFaultResponse(accept, e);
  }
}
 
Example 16
Source Project: pulsar   Source File: Namespaces.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{tenant}/{namespace}/topics")
@ApiOperation(value = "Get the list of all the topics under a certain namespace.", response = String.class, responseContainer = "Set")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Tenant or cluster or namespace doesn't exist") })
public void getTopics(@PathParam("tenant") String tenant,
                              @PathParam("namespace") String namespace,
                              @QueryParam("mode") @DefaultValue("PERSISTENT") Mode mode,
                              @Suspended AsyncResponse asyncResponse) {
    validateNamespaceName(tenant, namespace);
    validateNamespaceOperation(NamespaceName.get(tenant, namespace), NamespaceOperation.GET_TOPICS);

    // Validate that namespace exists, throws 404 if it doesn't exist
    getNamespacePolicies(namespaceName);

    pulsar().getNamespaceService().getListOfTopics(namespaceName, mode)
            .thenAccept(asyncResponse::resume)
            .exceptionally(ex -> {
                log.error("Failed to get topics list for namespace {}", namespaceName, ex);
                asyncResponse.resume(ex);
                return null;
            });
}
 
Example 17
Source Project: quarkus   Source File: MultiDataSourcesDevModeEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Produces("text/plain")
public String locations(@QueryParam("name") @DefaultValue("default") String name) {
    Configuration configuration;
    if ("default".equals(name)) {
        configuration = flywayDefault.getConfiguration();
    } else if ("users".equals(name)) {
        configuration = flywayUsers.getConfiguration();
    } else if ("inventory".equals(name)) {
        configuration = flywayInventory.getConfiguration();
    } else {
        throw new RuntimeException("Flyway " + name + " not found");
    }

    return Arrays.stream(configuration.getLocations()).map(Location::getPath).collect(Collectors.joining(","));
}
 
Example 18
Source Project: pulsar   Source File: PersistentTopics.java    License: Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{property}/{cluster}/{namespace}/{topic}/subscriptions")
@ApiOperation(hidden = true, value = "Get the list of persistent subscriptions for a given topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist") })
public void getSubscriptions(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String encodedTopic,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalGetSubscriptions(asyncResponse, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example 19
Source Project: brooklyn-server   Source File: CatalogApi.java    License: Apache License 2.0 6 votes vote down vote up
/** @deprecated since 0.11.0 use {@link #createFromYaml(String)} instead */
@Deprecated
@Consumes("application/json-deprecated")  // prevent this from taking things
@POST
@ApiOperation(
        value = "Add a catalog items (e.g. new type of entity, policy or location) by uploading YAML descriptor (deprecated, use POST of yaml or ZIP/JAR instead)",
        notes = "Return value is map of ID to CatalogItemSummary.",
        response = String.class,
        hidden = true
)
@ApiResponses(value = {
        @ApiResponse(code = 400, message = "Error processing the given YAML"),
        @ApiResponse(code = 201, message = "Catalog items added successfully")
})
public Response create(String yaml,
        @ApiParam(name="forceUpdate", value="Force update of catalog item (overwriting existing catalog items with same name and version)")
        @QueryParam("forceUpdate") @DefaultValue("false") boolean forceUpdate);
 
Example 20
Source Project: timbuctoo   Source File: Search.java    License: GNU General Public License v3.0 6 votes vote down vote up
@GET
@Path("{id}")
/*
 * Use UUIDParam instead of UUID, because we want to be explicit to the user of this API the request is not
 * supported. When UUID is used Jersery returns a '404 Not Found' if the request contains a malformed one. The
 * UUIDParam will return a '400 Bad Request' for malformed UUID's.
 * See: http://www.dropwizard.io/0.9.1/dropwizard-jersey/apidocs/io/dropwizard/jersey/params/AbstractParam.html
 * Or: http://codahale.com/what-makes-jersey-interesting-parameter-classes/
 */
public Response get(@PathParam("id") UUIDParam id,
                    @QueryParam("rows") @DefaultValue("10") int rows,
                    @QueryParam("start") @DefaultValue("0") int start) {
  Optional<SearchResult> searchResult = searchStore.getSearchResult(id.get());
  if (searchResult.isPresent()) {
    return Response.ok(searchResponseFactory.createResponse(searchResult.get(), rows, start)).build();
  }

  return Response
    .status(Response.Status.NOT_FOUND)
    .entity(new NotFoundMessage(id))
    .build();
}
 
Example 21
@PUT
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response update(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@DefaultValue("0") @PathParam("id") long id, @BeanParam EmployeeInputModel input);
 
Example 22
Source Project: dexter   Source File: JSONPService.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/relatedness")
@ApiOperation(value = "Return the semantic relatedness between two entities", response = Relatedness.class)
@Produces({ MediaType.APPLICATION_JSON })
public String relatedness(@Context UriInfo ui,
		@QueryParam("callback") @DefaultValue("callback") String callback,
		@QueryParam("e1") String e1, @QueryParam("e2") String e2,
		@QueryParam("rel") @DefaultValue("milnewitten") String rel,
		@QueryParam("wn") @DefaultValue("false") String wikiNames,
		@QueryParam("debug") @DefaultValue("false") String dbg) {

	return addCallback(callback,
			r.relatedness(ui, e1, e2, rel, wikiNames, dbg));

}
 
Example 23
Source Project: cxf   Source File: BookStore.java    License: Apache License 2.0 5 votes vote down vote up
@Descriptions({
    @Description(value = "Update the books collection", target = DocTarget.METHOD),
    @Description(value = "Requested Book", target = DocTarget.RETURN),
    @Description(value = "Request", target = DocTarget.REQUEST),
    @Description(value = "Response", target = DocTarget.RESPONSE),
    @Description(value = "Resource books/{bookid}", target = DocTarget.RESOURCE)
})
@ResponseStatus({Status.CREATED, Status.OK })
//CHECKSTYLE:OFF
@POST
@Path("books/{bookid}")
public Book addBook(@Description("book id") //NOPMD
                    @PathParam("id") int id,
                    @PathParam("bookid") int bookId,
                    @MatrixParam("mid") @DefaultValue("mid > 5") String matrixId,
                    @Description("header param")
                    @HeaderParam("hid") int headerId,
                    @CookieParam("cid") int cookieId,
                    @QueryParam("provider.bar") int queryParam,
                    @QueryParam("bookstate") BookEnum state,
                    @QueryParam("orderstatus") BookOrderEnum status,
                    @QueryParam("a") List<String> queryList,
                    @Context HttpHeaders headers,
                    @Description("InputBook")
                    @XMLName(value = "{http://books}thesuperbook2")
                    Book2 b) {
    return new Book(1);
}
 
Example 24
Source Project: emodb   Source File: RawDatabusResource1.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("{subscription}/peek")
public List<Event> peek(@PathParam("subscription") String subscription,
                        @QueryParam("limit") @DefaultValue("10") IntParam limit) {
    checkLegalSubscriptionName(subscription);
    return fromInternal(_eventStore.peek(subscription, limit.get()));
}
 
Example 25
Source Project: emodb   Source File: ReportResource1.java    License: Apache License 2.0 5 votes vote down vote up
@Path ("tables/{reportId}/entries")
@GET
public Iterable<TableReportEntry> getTableReportEntries(@PathParam  ("reportId") String reportId,
                                          @QueryParam ("table") List<String> tables,
                                          @QueryParam ("placement") List<String> placements,
                                          @QueryParam ("includeDropped") @DefaultValue ("true") boolean includeDropped,
                                          @QueryParam ("includeFacades") @DefaultValue ("true") boolean includeFacades,
                                          @QueryParam ("from") String fromTable,
                                          @QueryParam ("limit") @DefaultValue ("10") int limit) {

    AllTablesReportQuery query = new AllTablesReportQuery();
    if (tables != null && !tables.isEmpty()) {
        query.setTableNames(tables);
    }
    if (placements != null && !placements.isEmpty()) {
        query.setPlacements(placements);
    }
    if (fromTable != null) {
        query.setFromTable(fromTable);
    }
    query.setIncludeDropped(includeDropped);
    query.setIncludeFacades(includeFacades);
    query.setLimit(limit);

    try {
        return _reportLoader.getTableReportEntries(reportId, query);
    } catch (ReportNotFoundException e) {
        throw handleException(reportId, e);
    }
}
 
Example 26
Source Project: rapid   Source File: Container.java    License: MIT License 5 votes vote down vote up
@DELETE
@Path("{id}")
public Response deleteContainer(@PathParam("id") String containerId,
                                @DefaultValue("false") @QueryParam("v") String v,
                                @DefaultValue("false") @QueryParam("force") String force) {

    WebTarget target = resource().path(CONTAINERS)
            .path(containerId)
            .queryParam("v", v)
            .queryParam("force", force);

    Response response = deleteResponse(target);
    String entity = response.readEntity(String.class);

    try {
        if (entity.isEmpty()) {
            return Response.ok(Json.createObjectBuilder().add(MESSAGE, containerId + " deleted.").build())
                    .build();
        } else {
            return Response.status(response.getStatus())
                    .entity(Json.createReader(new StringReader(entity)).read())
                    .build();
        }
    } finally {
        response.close();
    }
}
 
Example 27
Source Project: olingo-odata4   Source File: Services.java    License: Apache License 2.0 5 votes vote down vote up
@POST
@Path("/$batch")
@Consumes(MULTIPART_MIXED)
@Produces(APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY)
public Response batch(
    @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
    final @Multipart MultipartBody attachment) {
  try {
    final boolean continueOnError = prefer.contains("odata.continue-on-error");
    return xml.createBatchResponse(
        exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError));
  } catch (IOException e) {
    return xml.createFaultResponse(Accept.XML.toString(), e);
  }
}
 
Example 28
Source Project: metacat   Source File: MetadataV1.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Delete the definition metadata for the given name.
 *
 * @param name  Name of definition metadata to be deleted
 * @param force If true, deletes the metadata without checking if the database/table/partition exists
 */
@DELETE
@Path("definition")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
void deleteDefinitionMetadata(
    @QueryParam("name")
        String name,
    @DefaultValue("false")
    @QueryParam("force")
        Boolean force
);
 
Example 29
Source Project: brooklyn-server   Source File: CatalogResource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public List<CatalogEnricherSummary> listEnrichers(@ApiParam(name = "regex", value = "Regular expression to search for") @DefaultValue("") String regex, @ApiParam(name = "fragment", value = "Substring case-insensitive to search for") @DefaultValue("") String fragment, @ApiParam(name = "allVersions", value = "Include all versions (defaults false, only returning the best version)") @DefaultValue("false") boolean includeAllVersions) {
    Predicate<RegisteredType> filter =
            Predicates.and(
                    RegisteredTypePredicates.IS_ENRICHER,
                    RegisteredTypePredicates.disabled(false));
    List<CatalogItemSummary> result = getCatalogItemSummariesMatchingRegexFragment(filter, regex, fragment, includeAllVersions);
    return castList(result, CatalogEnricherSummary.class);
}
 
Example 30
Source Project: che   Source File: RemoteServiceDescriptorTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@GET
@Path("my_method")
@GenerateLink(rel = "echo")
@Produces(MediaType.TEXT_PLAIN)
public String echo(
    @Description("some text")
        @Required
        @Valid({"a", "b"})
        @DefaultValue("a")
        @QueryParam("text")
        String test) {
  return test;
}