javax.ws.rs.PathParam Java Examples

The following examples show how to use javax.ws.rs.PathParam. 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 File: TaskAction.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@JaxrsMethodDescribe(value = "删除待办.", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
	ActionResult<ActionDelete.Wo> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	try {
		result = new ActionDelete().execute(effectivePerson, id);
	} catch (Exception e) {
		logger.error(e, effectivePerson, request, null);
		result.error(e);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
Example #2
Source File: SchemaRegistryResource.java    From registry with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/schemas/{name}/branches")
@ApiOperation(value = "Get list of registered schema branches",
        response = SchemaBranch.class, responseContainer = "List",
        tags = OPERATION_GROUP_OTHER)
@Timed
@UnitOfWork
public Response getAllBranches(@ApiParam(value = "Details about schema name",required = true) @PathParam("name") String schemaName,
                               @Context UriInfo uriInfo,
                               @Context SecurityContext securityContext) {
    try {
        Collection<SchemaBranch> schemaBranches = authorizationAgent.authorizeGetAllBranches(AuthorizationUtils.getUserAndGroups(securityContext),
                schemaRegistry, schemaName, schemaRegistry.getSchemaBranches(schemaName));
        return WSUtils.respondEntities(schemaBranches, Response.Status.OK);
    }  catch(SchemaNotFoundException e) {
        return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaName);
    } catch (Exception ex) {
        LOG.error("Encountered error while listing schema branches", ex);
        return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage());
    }
}
 
Example #3
Source File: VulnerabilityResource.java    From dependency-track with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/source/{source}/vuln/{vuln}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Returns a specific vulnerability",
        response = Vulnerability.class
)
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 404, message = "The vulnerability could not be found")
})
@PermissionRequired(Permissions.Constants.VIEW_PORTFOLIO)
public Response getVulnerabilityByVulnId(@PathParam("source") String source,
                                         @PathParam("vuln") String vuln) {
    try (QueryManager qm = new QueryManager()) {
        final Vulnerability vulnerability = qm.getVulnerabilityByVulnId(source, vuln);
        if (vulnerability != null) {
            return Response.ok(vulnerability).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).entity("The vulnerability could not be found.").build();
        }
    }
}
 
Example #4
Source File: DataAction.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@JaxrsMethodDescribe(value = "更新指定Work的Data数据.", action = ActionUpdateWithWorkPath0.class)
@PUT
@Path("work/{id}/{path0}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void updateWithWorkPath0(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("工作标识") @PathParam("id") String id, @JaxrsParameterDescribe("0级路径") @PathParam("path0") String path0,
		JsonElement jsonElement) {
	ActionResult<ActionUpdateWithWorkPath0.Wo> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	try {
		result = new ActionUpdateWithWorkPath0().execute(effectivePerson, id, path0, jsonElement);
	} catch (Exception e) {
		logger.error(e, effectivePerson, request, jsonElement);
		result.error(e);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
Example #5
Source File: OidcResource.java    From dependency-track with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/mapping/{uuid}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Deletes a mapping",
        code = 204
)
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 404, message = "The UUID of the mapping could not be found"),
})
@PermissionRequired(Permissions.Constants.ACCESS_MANAGEMENT)
public Response deleteMappingByUuid(@ApiParam(value = "The UUID of the mapping to delete", required = true)
                                    @PathParam("uuid") final String uuid) {
    try (QueryManager qm = new QueryManager()) {
        final MappedOidcGroup mapping = qm.getObjectByUuid(MappedOidcGroup.class, uuid);
        if (mapping != null) {
            super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "Mapping for group " + mapping.getGroup().getName() + " and team " + mapping.getTeam().getName() + " deleted");
            qm.delete(mapping);
            return Response.status(Response.Status.NO_CONTENT).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).entity("The UUID of the mapping could not be found.").build();
        }
    }
}
 
Example #6
Source File: MachineResource.java    From difido-reports with Apache License 2.0 6 votes vote down vote up
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public int addNewMachine(@Context HttpServletRequest request, @PathParam("execution") int executionId,
		MachineNode machine) {
	log.debug("POST (" + request.getRemoteAddr() + ") - Add new machine to execution " + executionId);
	if (null == machine) {
		throw new WebApplicationException("Machine can't be null");
	}
	final Execution execution = executionRepository.findById(executionId);

	StopWatch stopWatch = newStopWatch(log).start("Adding machine to execution");
	execution.addMachine(machine);
	stopWatch.stopAndLog();

	stopWatch = newStopWatch(log).start("Publishing machine create event");
	publisher.publishEvent(new MachineCreatedEvent(executionId, machine));
	stopWatch.stopAndLog();
	return execution.getMachines().indexOf(machine);
}
 
Example #7
Source File: GenericFacade.java    From icure-backend with GNU General Public License v2.0 6 votes vote down vote up
@ApiOperation(
		value = "List enum values",
		response = String.class,
		responseContainer = "Array",
		httpMethod = "GET"
)
@GET
@Path("/enum/{className}")
public Response listEnum(@PathParam("className") String className) {
	if (!className.startsWith("org.taktik.icure.services.external.rest.v1.dto")) {
		throw new IllegalArgumentException("Invalid package");
	}
	if (!className.matches("[a-zA-Z0-9.]+")) {
		throw new IllegalArgumentException("Invalid class name");
	}

	try {
		return Response.ok().entity(Arrays.asList((Enum[]) Class.forName(className).getMethod("values").invoke(null))
				.stream().map(Enum::name).collect(Collectors.toList())).build();
	} catch (IllegalAccessException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) {
		throw new IllegalArgumentException("Invalid class name");
	}
}
 
Example #8
Source File: ProductVersionEndpoint.java    From pnc with Apache License 2.0 6 votes vote down vote up
/**
 * {@value GET_RELEASES}
 * 
 * @param id {@value PV_ID}
 * @param pageParameters
 * @return
 */
@Operation(
        summary = GET_RELEASES,
        responses = {
                @ApiResponse(
                        responseCode = SUCCESS_CODE,
                        description = SUCCESS_DESCRIPTION,
                        content = @Content(schema = @Schema(implementation = ProductReleasePage.class))),
                @ApiResponse(
                        responseCode = INVALID_CODE,
                        description = INVALID_DESCRIPTION,
                        content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
                @ApiResponse(
                        responseCode = SERVER_ERROR_CODE,
                        description = SERVER_ERROR_DESCRIPTION,
                        content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@GET
@Path("/{id}/releases")
Page<ProductRelease> getReleases(
        @Parameter(description = PV_ID) @PathParam("id") String id,
        @Valid @BeanParam PageParameters pageParameters);
 
Example #9
Source File: ProductVersionEndpoint.java    From pnc with Apache License 2.0 6 votes vote down vote up
/**
 * {@value GET_BUILD_CONFIGS_DESC}
 * 
 * @param id {@value PV_ID}
 * @param pageParams
 * @return
 */
@Operation(
        summary = GET_BUILD_CONFIGS_DESC,
        responses = {
                @ApiResponse(
                        responseCode = SUCCESS_CODE,
                        description = SUCCESS_DESCRIPTION,
                        content = @Content(schema = @Schema(implementation = BuildConfigPage.class))),
                @ApiResponse(
                        responseCode = INVALID_CODE,
                        description = INVALID_DESCRIPTION,
                        content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
                @ApiResponse(
                        responseCode = SERVER_ERROR_CODE,
                        description = SERVER_ERROR_DESCRIPTION,
                        content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@GET
@Path("/{id}/build-configs")
Page<BuildConfiguration> getBuildConfigs(
        @Parameter(description = PV_ID) @PathParam("id") String id,
        @Valid @BeanParam PageParameters pageParams);
 
Example #10
Source File: QueryMetricsBean.java    From datawave with Apache License 2.0 6 votes vote down vote up
@GET
@POST
@Path("/id/{id}/map")
@Interceptors({RequiredInterceptor.class, ResponseInterceptor.class})
public QueryGeometryResponse map(@PathParam("id") @Required("id") String id) {
    
    // Find out who/what called this method
    DatawavePrincipal dp = null;
    Principal p = ctx.getCallerPrincipal();
    String user = p.getName();
    if (p instanceof DatawavePrincipal) {
        dp = (DatawavePrincipal) p;
        user = dp.getShortName();
    }
    
    return queryGeometryHandler.getQueryGeometryResponse(id, queryHandler.query(user, id, dp).getResult());
}
 
Example #11
Source File: OpenstackNetworkWebResource.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the service network.
 *
 * @param id network identifier
 * @return 204 NO_CONTENT, 400 BAD_REQUEST if the network does not exist
 */
@DELETE
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteNetwork(@PathParam("id") String id) {
    log.trace(String.format(MESSAGE, "DELETE " + id));

    if (!haService.isActive()
            && !DEFAULT_ACTIVE_IP_ADDRESS.equals(haService.getActiveIp())) {
        return syncDelete(haService, NETWORKS, id);
    }

    adminService.removeNetwork(id);
    return noContent().build();
}
 
Example #12
Source File: TagREST.java    From ranger with Apache License 2.0 6 votes vote down vote up
@PUT
@Path(TagRESTConstants.RESOURCE_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerServiceResource updateServiceResource(@PathParam("id") Long id, RangerServiceResource resource) {
    if(LOG.isDebugEnabled()) {
        LOG.debug("==> TagREST.updateServiceResource(" + id + ")");
    }
    RangerServiceResource ret;

    try {
        validator.preUpdateServiceResource(id, resource);
        ret = tagStore.updateServiceResource(resource);
    } catch(Exception excp) {
        LOG.error("updateServiceResource(" + resource + ") failed", excp);

        throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
    }

    if(LOG.isDebugEnabled()) {
        LOG.debug("<== TagREST.updateServiceResource(" + id + "): " + ret);
    }
    return ret;
}
 
Example #13
Source File: AttachmentAction.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@JaxrsMethodDescribe(value = "获取指定人员共享给我编辑的文件.", action = ActionListWithEditor.class)
@GET
@Path("list/editor/{owner}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithEditor(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("文件所有人") @PathParam("owner") String owner) {
	ActionResult<List<ActionListWithEditor.Wo>> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		result = new ActionListWithEditor().execute(effectivePerson, owner);
	} catch (Exception e) {
		logger.error(e, effectivePerson, request, null);
		result.error(e);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
Example #14
Source File: DraftAction.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@JaxrsMethodDescribe(value = "列示当前用户的草稿对象,上一页.", action = ActionListPrev.class)
@GET
@Path("list/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("草稿标识") @PathParam("id") String id,
		@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
	ActionResult<List<ActionListPrev.Wo>> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	try {
		result = new ActionListPrev().execute(effectivePerson, id, count);
	} catch (Exception e) {
		logger.error(e, effectivePerson, request, null);
		result.error(e);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
Example #15
Source File: AttendanceImportFileInfoAction.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@JaxrsMethodDescribe(value = "根据ID删除已经上传成功的文件以及文件信息", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("导入文件信息ID") @PathParam("id") String id) {
	ActionResult<ActionDelete.Wo> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	Boolean check = true;

	if (check) {
		try {
			result = new ActionDelete().execute(request, effectivePerson, id);
		} catch (Exception e) {
			result = new ActionResult<>();
			Exception exception = new ExceptionAttendanceImportFileProcess(e, "根据ID删除已经上传成功的文件以及文件信息时发生异常!");
			result.error(exception);
			logger.error(e, effectivePerson, request, null);
		}
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
Example #16
Source File: EntityREST.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch complete definition of an entity given its GUID.
 * @param guid GUID for the entity
 * @return AtlasEntity
 * @throws AtlasBaseException
 */
@GET
@Path("/guid/{guid}")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasEntityWithExtInfo getById(@PathParam("guid") String guid) throws AtlasBaseException {
    AtlasPerfTracer perf = null;

    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getById(" + guid + ")");
        }

        return entitiesStore.getById(guid);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
 
Example #17
Source File: BusinessModelVisualDependenciesResource.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@POST
@Consumes("application/json")
@Produces("application/json")
public MetaModelParview addVisualDependeciesForBusinessModelDriver(@PathParam("id") Integer id, MetaModelParview parameterViewObject) {
	logger.debug("IN");
	IMetaModelParviewDAO parameterViewDAO;
	Integer newId = null;
	Assert.assertNotNull(parameterViewObject, "Visual Dependencies can not be null");
	try {
		parameterViewDAO = DAOFactory.getMetaModelParviewDao();
		newId = parameterViewDAO.insertMetaModelParview(parameterViewObject);
		parameterViewObject.setId(newId);
	} catch (HibernateException e) {
		logger.error("Visual Dependencies can not be created", e);
		throw new SpagoBIRestServiceException(e.getCause().getLocalizedMessage() + "in Visual Dependencsies", buildLocaleFromSession(), e);
	}
	logger.debug("OUT");
	return parameterViewObject;

}
 
Example #18
Source File: UserFacade.java    From icure-backend with GNU General Public License v2.0 6 votes vote down vote up
@ApiOperation(
		value = "Get a user by his Email/Login",
		response = UserDto.class,
		httpMethod = "GET",
		notes = "General information about the user"
)
@GET
@Path("/byEmail/{email}")
public Response getUserByEmail(@PathParam("email") String email) {
	if (email == null) {
		return Response.status(400).type("text/plain").entity("A required query parameter was not specified for this request.").build();
	}

	User user = userLogic.getUserByEmail(email);

	boolean succeed = (user != null);
	if (succeed) {
		return Response.ok().entity(mapper.map(user, UserDto.class)).build();
	} else {
		return Response.status(404).type("text/plain").entity("Getting User failed. Possible reasons: no such user exists, or server error. Please try again or read the server log.").build();
	}
}
 
Example #19
Source File: ContactFacade.java    From icure-backend with GNU General Public License v2.0 6 votes vote down vote up
@ApiOperation(
        value = "Delete contacts.",
        response = String.class,
        responseContainer = "Array",
        httpMethod = "DELETE",
        notes = "Response is a set containing the ID's of deleted contacts."
)
@DELETE
@Path("/{contactIds}")
public Response deleteContacts(@PathParam("contactIds") String ids) {
    if (ids == null || ids.length() == 0) {
        return Response.status(400).type("text/plain").entity("A required query parameter was not specified for this request.").build();
    }

    // TODO versioning?

    Set<String> deletedIds = contactLogic.deleteContacts(new HashSet<>(Arrays.asList(ids.split(","))));

    boolean succeed = (deletedIds != null);
    if (succeed) {
        return Response.ok().entity(deletedIds).build();
    } else {
        return Response.status(500).type("text/plain").entity("Contacts deletion failed.").build();
    }
}
 
Example #20
Source File: CartApi.java    From commerce-cif-api with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{id}/entries/{cartEntryId}")
@ApiOperation(value = "Removes a cart entry from the cart.")
@ApiResponses(value = {
    @ApiResponse(code = HTTP_OK, message = HTTP_OK_MESSAGE, response = Cart.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)
})
Cart deleteCartEntry(
    @ApiParam(value = "The ID of the cart.", required = true)
    @PathParam("id") String id,

    @ApiParam(value = "The cart entry id to be removed.", required = true)
    @PathParam("cartEntryId") String cartEntryId,

    @ApiParam(value = ACCEPT_LANGUAGE_DESC)
    @HeaderParam(ACCEPT_LANGUAGE) String acceptLanguage);
 
Example #21
Source File: Image.java    From rapid with MIT License 6 votes vote down vote up
@POST
@Path("{id}/tag")
public ResponseFrame tagImage(@PathParam("id") String id,
                              @QueryParam("repo") String repo,
                              @QueryParam("tag") String tag) {

    WebTarget target = resource().path(IMAGES)
            .path(id).path("tag")
            .queryParam("tag", tag).queryParam("repo", repo);

    Response response = postResponse(target);
    String entity = response.readEntity(String.class);
    response.close();
    ResponseFrame frame = new ResponseFrame();
    frame.setId(id);

    if (entity.isEmpty())
        frame.setMessage("tagged as " + tag);
    else {
        JsonReader reader = Json.createReader(new StringReader(entity));
        JsonObject o = reader.readObject();
        frame.setMessage(o.getJsonString("message").getString());
    }
    return frame;
}
 
Example #22
Source File: CommandsResource.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
@POST
@Path("/command/validate/{name}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response validateCommand(@PathParam("name") final String name, final ExecutionRequest executionRequest) throws Exception {
    try {
        final UserDetails userDetails;
        if (commandCompletePostProcessor != null) {
            userDetails = commandCompletePostProcessor.preprocessRequest(name, executionRequest, request);
        } else {
            userDetails = null;
        }
        final String namespace = executionRequest.getNamespace();
        final String projectName = executionRequest.getProjectName();
        final String resourcePath = executionRequest.getResource();
        GitContext gitContext = new GitContext();
        gitContext.setRequirePull(false);
        return withUIContext(namespace, projectName, resourcePath, false, new RestUIFunction<Response>() {
            @Override
            public Response apply(RestUIContext uiContext) throws Exception {
                return doValidate(name, executionRequest, userDetails, uiContext);
            }
        }, gitContext);

    } catch (Throwable e) {
        LOG.warn("Failed to invoke command " + name + " on " + executionRequest + ". " + e, e);
        throw e;
    }
}
 
Example #23
Source File: CustomerService.java    From servicemix with Apache License 2.0 5 votes vote down vote up
@Path("/orders/{orderId}/")
public Order getOrder(@PathParam("orderId") String orderId) {
    System.out.println("----invoking getOrder, Order id is: " + orderId);
    long idNumber = Long.parseLong(orderId);
    Order c = orders.get(idNumber);
    return c;
}
 
Example #24
Source File: ServerPolicyRestApi.java    From open-Autoscaler with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a policy
 * 
 * @param policyId
 * @return
 */
@GET
@Path("/policies/{policyId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getPolicy(@Context final HttpServletRequest httpServletRequest,
		@PathParam("policyId") String policyId) {
	String jsonStr = "{\"new\":false,\"scheduledPolicies\":{\"59c1793e-5188-443d-bc08-100bfa7e20a8\":{\"minInstCount\":1,\"repeatCycle\":\"[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\"]\",\"maxInstCount\":2,\"timezone\":\"(GMT +08:00) Antarctica\\/Casey\",\"instanceMaxCount\":2,\"startTime\":\"00:00\",\"instanceMinCount\":1,\"endTime\":\"23:59\",\"type\":\"RECURRING\",\"repeatOn\":\"[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\"]\"},\"f06030e0-36a3-4d7a-b013-9e6a750d87cf\":{\"minInstCount\":1,\"repeatCycle\":\"\",\"maxInstCount\":2,\"endDate\":\"2016-04-01\",\"timezone\":\"(GMT +08:00) Antarctica\\/Casey\",\"instanceMaxCount\":2,\"startTime\":\"00:00\",\"instanceMinCount\":1,\"endTime\":\"23:59\",\"type\":\"SPECIALDATE\",\"startDate\":\"2016-04-01\"}},\"attachments\":null,\"specificDate\":[{\"minInstCount\":1,\"repeatCycle\":\"\",\"maxInstCount\":2,\"endDate\":\"2016-04-01\",\"timezone\":\"(GMT +08:00) Antarctica\\/Casey\",\"instanceMaxCount\":2,\"startTime\":\"00:00\",\"instanceMinCount\":1,\"endTime\":\"23:59\",\"type\":\"SPECIALDATE\",\"startDate\":\"2016-04-01\"}],\"policyName\":null,\"policyTriggers\":[{\"upperThreshold\":80,\"instanceStepCountUp\":1,\"statType\":\"average\",\"scaleInAdjustmentType\":\"changeCapacity\",\"scaleInAdjustment\":\"changeCapacity\",\"scaleOutAdjustment\":\"changeCapacity\",\"stepDownCoolDownSecs\":600,\"scaleOutAdjustmentType\":\"changeCapacity\",\"metricType\":\"Memory\",\"statWindow\":300,\"unit\":\"percent\",\"instanceStepCountDown\":-1,\"breachDuration\":600,\"startTime\":0,\"endTime\":0,\"lowerThreshold\":30,\"endSetNumInstances\":10,\"stepUpCoolDownSecs\":600,\"startSetNumInstances\":10}],\"timezone\":\"(GMT +08:00) Antarctica\\/Casey\",\"instanceMinCount\":1,\"type\":\"AutoScalerPolicy\",\"orgId\":\"800faf6a-8413-45a4-b7c7-b9760061bf31\",\"revision\":\"2-e6c41cf81021c692b3170afbc530acac\",\"spaceId\":\"b33cd8c3-455a-4da9-985c-01c2d3f44bd4\",\"policyId\":\"cb032b44-a2e9-454c-87fb-a3fabedcefca\",\"recurringSchedule\":[{\"minInstCount\":1,\"repeatCycle\":\"[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\"]\",\"maxInstCount\":2,\"timezone\":\"(GMT +08:00) Antarctica\\/Casey\",\"instanceMaxCount\":2,\"startTime\":\"00:00\",\"instanceMinCount\":1,\"endTime\":\"23:59\",\"type\":\"RECURRING\",\"repeatOn\":\"[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\"]\"}],\"instanceMaxCount\":5,\"conflicts\":null,\"revisions\":null,\"_id\":\"cb032b44-a2e9-454c-87fb-a3fabedcefca\",\"id\":\"cb032b44-a2e9-454c-87fb-a3fabedcefca\",\"currentScheduledPolicyId\":\"f06030e0-36a3-4d7a-b013-9e6a750d87cf\"}";
	return RestApiResponseHandler.getResponseOk(jsonStr);

}
 
Example #25
Source File: NominalLabelResource.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
public Response getNominalLabelByID(@PathParam("id") Long labelID) {
    NominalLabelDTO label = labelLocal.getNominalLabelByID(labelID);
    if (label == null)
        return Response.noContent().build();
    
    return Response.ok(label).build();
}
 
Example #26
Source File: SecurityCatalogResource.java    From streamline with Apache License 2.0 5 votes vote down vote up
@PUT
@Path("/acls/{id}")
@Timed
public Response addOrUpdateAcl(@PathParam("id") Long aclId, AclEntry aclEntry, @Context SecurityContext securityContext) {
    mayBeFillSidId(aclEntry);
    checkAclOp(aclEntry, securityContext, this::shouldAllowAclAddOrUpdate);
    AclEntry newAclEntry = catalogService.addOrUpdateAcl(aclId, aclEntry);
    return WSUtils.respondEntity(newAclEntry, OK);
}
 
Example #27
Source File: VulnerabilityResource.java    From dependency-track with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/component/{ident}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Returns a list of all vulnerabilities for a specific component",
        notes = "A valid UUID of the component may be specified, or the MD5 or SHA1 hash of the component",
        response = Vulnerability.class,
        responseContainer = "List",
        responseHeaders = @ResponseHeader(name = TOTAL_COUNT_HEADER, response = Long.class, description = "The total number of vulnerabilities")
)
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 404, message = "The component could not be found")
})
@PermissionRequired(Permissions.Constants.VIEW_PORTFOLIO)
public Response getVulnerabilitiesByComponent(@PathParam("ident") String ident,
                                              @ApiParam(value = "Optionally includes suppressed vulnerabilities")
                                              @QueryParam("suppressed") boolean suppressed) {
    try (QueryManager qm = new QueryManager(getAlpineRequest())) {
        final Component component;
        if (UuidUtil.isValidUUID(ident)) {
            component = qm.getObjectByUuid(Component.class, ident);
        } else {
            component = qm.getComponentByHash(ident);
        }
        if (component != null) {
            final PaginatedResult result = qm.getVulnerabilities(component, suppressed);
            return Response.ok(result.getObjects()).header(TOTAL_COUNT_HEADER, result.getTotal()).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).entity("The component could not be found.").build();
        }
    }
}
 
Example #28
Source File: BuildStatusApi.java    From bitbucket-rest with Apache License 2.0 5 votes vote down vote up
@Named("build-status:status")
@Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/4.14.4/bitbucket-build-rest.html#idm44911111531152"})
@Consumes(MediaType.APPLICATION_JSON)
@Path("/commits/{commitId}")
@Fallback(BitbucketFallbacks.StatusPageOnError.class)
@GET
StatusPage status(@PathParam("commitId") String commitId,
                  @Nullable @QueryParam("start") Integer start,
                  @Nullable @QueryParam("limit") Integer limit);
 
Example #29
Source File: OtherEntityTestResource.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/{id}")
@Produces(MediaType.TEXT_PLAIN)
public String getName(@PathParam("id") long id) {
    OtherEntity entity = em.find(OtherEntity.class, id);
    if (entity != null) {
        return entity.toString();
    }

    return "no entity";
}
 
Example #30
Source File: TodoAction.java    From appstart with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/{id}")
public Todo delete(@PathParam("id") Long id) {
	
	Todo todo = null;
	try {
		todo = service.delete(id);
		
	} catch(Exception e) {
		log.log(Level.SEVERE, "Something went wrong", e);
		RestUtils.throwRestException(e.getMessage(), Response.Status.BAD_REQUEST);
	}
	return todo;
}