Java 类io.dropwizard.jersey.PATCH 实例源码

项目:robe    文件:SystemParameterResource.java   
/**
 * Update {@link SystemParameter) resource.
 *
 * @param credentials Injected by {@link RobeAuth} annotation for authentication.
 * @param id          This is  the oid of {@link SystemParameter}
 * @param model       This is the one model of {@link SystemParameter}
 * @return Update {@link SystemParameter) resource and matches with the given id.
 */
@RobeService(group = "SystemParameter", description = "Update SystemParameter resource.")
@Path("{id}")
@PATCH
@UnitOfWork
public SystemParameter merge(@RobeAuth Credentials credentials, @PathParam("id") String id, SystemParameter model) {

    if (!id.equals(model.getOid()))
        throw new WebApplicationException(Response.status(412).build());
    SystemParameter dest = systemParameterDao.findById(id);
    if (dest == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    Fields.mergeRight(model, dest);
    return systemParameterDao.update(dest);
}
项目:robe    文件:ServiceResource.java   
private String ifServiceGetHttpMethod(Method method) {
    if (method.getAnnotation(GET.class) != null)
        return "GET";
    if (method.getAnnotation(PUT.class) != null)
        return "PUT";
    if (method.getAnnotation(POST.class) != null)
        return "POST";
    if (method.getAnnotation(DELETE.class) != null)
        return "DELETE";
    if (method.getAnnotation(PATCH.class) != null)
        return "PATCH";
    if (method.getAnnotation(OPTIONS.class) != null)
        return "OPTIONS";

    return null;
}
项目:robe    文件:RoleResource.java   
/**
 * Update a Role resource with the matches given id.
 * <p>
 * Status Code:
 * Not Found  404
 * Not Matches 412
 *
 * @param credentials auto fill by @{@link RobeAuth} annotation for authentication.
 * @param id          This is  the oid of {@link Role}
 * @param model       This is the one model of {@link Role}
 * @return Updates a  {@link Role} resource with the matches given id.
 */
@RobeService(group = "Role", description = "Update a Role resource with the matches given id.")
@Path("{id}")
@PATCH
@UnitOfWork
public Role merge(@RobeAuth Credentials credentials, @PathParam("id") String id, Role model) {

    if (!id.equals(model.getOid()))
        throw new WebApplicationException(Response.status(412).build());
    Role dest = roleDao.findById(id);
    if (dest == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    Fields.mergeRight(model, dest);
    return roleDao.update(dest);
}
项目:oacc-example-securetodo    文件:TodoItemResource.java   
@Path("/{id}")
@PATCH
// @Consumes(MediaType.APPLICATION_MERGE_PATCH_JSON)
public TodoItem updateItem(@Auth OaccPrincipal oaccPrincipal,
                           @PathParam("id") LongParam todoItemId,
                           TodoItem patchItem) {

   return todoItemService.updateItem(oaccPrincipal.getAccessControlContext(), todoItemId.get(), patchItem);
}
项目:pay-adminusers    文件:ServiceResource.java   
@Path("/{serviceExternalId}")
@PATCH
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public Response updateServiceAttribute(@PathParam("serviceExternalId") String serviceExternalId, JsonNode payload) {
    LOGGER.info("Service PATCH request - [ {} ]", serviceExternalId);
    return serviceRequestValidator.validateUpdateAttributeRequest(payload)
            .map(errors -> Response.status(BAD_REQUEST).entity(errors).build())
            .orElseGet(() -> serviceServicesFactory.serviceUpdater().doUpdate(serviceExternalId, ServiceUpdateRequest.from(payload))
                    .map(service -> Response.status(OK).entity(service).build())
                    .orElseGet(() -> Response.status(NOT_FOUND).build()));

}
项目:pay-adminusers    文件:UserResource.java   
@PATCH
@Path(USER_RESOURCE)
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public Response updateUserAttribute(@PathParam("externalId") String externalId, JsonNode node) {
    logger.info("User update attribute attempt request");
    return validator.validatePatchRequest(node)
            .map(errors -> Response.status(BAD_REQUEST).entity(errors).build())
            .orElseGet(() -> userServices.patchUser(externalId, PatchRequest.from(node))
                    .map(user -> Response.status(OK).entity(user).build())
                    .orElseGet(() -> Response.status(NOT_FOUND).build()));
}
项目:sam    文件:ApplicationResource.java   
@PATCH
@RolesAllowed(Roles.EDIT)
@Path("services/application/{id}")
@ApiOperation(value = "Update application")
@ApiResponses({
  @ApiResponse(code = 200, message = "The application was successfully updated.", response = ApplicationLink.class),
  @ApiResponse(code = 404, message = "No application exists with the supplied id.", response = ErrorMessage.class),
  @ApiResponse(code = 412, message = "No application exists with the supplied id and hash.", response = ErrorMessage.class),
  @ApiResponse(code = 422, message = "The supplied application is not valid.", response = ErrorMessage.class),
})
public Response updateApplication(
  @ApiParam("Application id") @PathParam("id") String id,
  @ApiParam("Application") Application application,
  @ApiParam("The number of levels to merge this update") @QueryParam("mergedepth") @DefaultValue(RestHelper.INTEGER_MAX) int mergeDepth,
  @Context UriInfo uriInfo,
  @Context Request request,
  @Context SecurityContext securityContext
) throws IOException {
  logger.info("Update application: {}", application);

  RestHelper.validate(application, Application.Update.class);

  final Document existing = getApplicationForUpdate(id);
  final MongoCollection<Document> collection = database.getCollection(Collections.APPLICATIONS);
  final Document updated = RestHelper.mergeAndUpdateMeta(existing, application, mergeDepth, collection, objectMapper, securityContext, request);
  return linkResponse(Status.OK, updated, uriInfo);
}
项目:sam    文件:GroupResource.java   
@PATCH
@RolesAllowed(Roles.EDIT)
@Path("services/group/{id}")
@ApiOperation(value = "Update group")
@ApiResponses({
  @ApiResponse(code = 200, message = "The group was successfully updated.", response = GroupLink.class),
  @ApiResponse(code = 404, message = "No group exists with the supplied id.", response = ErrorMessage.class),
  @ApiResponse(code = 412, message = "No group exists with the supplied id and hash.", response = ErrorMessage.class),
  @ApiResponse(code = 422, message = "The supplied group is not valid.", response = ErrorMessage.class),
})
public Response updateGroup(
  @ApiParam("Group id") @PathParam("id") String id,
  @ApiParam("Group") Group group,
  @ApiParam("The number of levels to merge this update") @QueryParam("mergedepth") @DefaultValue(RestHelper.INTEGER_MAX) int mergeDepth,
  @Context UriInfo uriInfo,
  @Context Request request,
  @Context SecurityContext securityContext
) throws IOException {
  logger.info("Update group: {}", group);

  RestHelper.validate(group, Group.Update.class);

  final Document existing = getGroupForUpdate(id);
  final MongoCollection<Document> collection = database.getCollection(Collections.GROUPS);
  final Document updated = RestHelper.mergeAndUpdateMeta(existing, group, mergeDepth, collection, objectMapper, securityContext, request);
  return linkResponse(Status.OK, updated, uriInfo);
}
项目:sam    文件:ServerResource.java   
@PATCH
@RolesAllowed(Roles.EDIT)
@Path("services/server/{environment}/{hostname}")
@ApiOperation(value = "Update server")
@ApiResponses({
  @ApiResponse(code = 200, message = "The server was successfully updated.", response = ServerLink.class),
  @ApiResponse(code = 404, message = "No server exists with the supplied environment and hostname.", response = ErrorMessage.class),
  @ApiResponse(code = 412, message = "No server exists with the supplied environment, hostname and hash.", response = ErrorMessage.class),
  @ApiResponse(code = 422, message = "The supplied server is not valid.", response = ErrorMessage.class),
})
public Response updateServer(
  @ApiParam("Server hostname") @PathParam("hostname") String hostname,
  @ApiParam("Environment") @PathParam("environment") String environment,
  @ApiParam("Server") Server server,
  @ApiParam("The number of levels to merge this update") @QueryParam("mergedepth") @DefaultValue(RestHelper.INTEGER_MAX) int mergeDepth,
  @Context UriInfo uriInfo,
  @Context Request request,
  @Context SecurityContext securityContext
) throws IOException {
  logger.info("Update server {}@{}, {}", hostname, environment, server);

  RestHelper.validate(server, Server.Update.class);

  final Document existing = getServerForUpdate(hostname, environment);
  final MongoCollection<Document> collection = database.getCollection(Collections.SERVERS);
  final Document updated = RestHelper.mergeAndUpdateMeta(existing, server, mergeDepth, collection, objectMapper, securityContext, request);
  return linkResponse(Status.OK, updated, uriInfo);
}
项目:sam    文件:AssetResource.java   
@PATCH
@RolesAllowed(Roles.EDIT)
@Path("services/asset/{id}")
@ApiOperation(value = "Update asset")
@ApiResponses({
  @ApiResponse(code = 200, message = "The asset was successfully updated.", response = AssetLink.class),
  @ApiResponse(code = 404, message = "No asset exists with the supplied id.", response = ErrorMessage.class),
  @ApiResponse(code = 412, message = "No asset exists with the supplied id and hash.", response = ErrorMessage.class),
  @ApiResponse(code = 422, message = "The supplied asset is not valid.", response = ErrorMessage.class),
})
public Response updateAsset(
  @ApiParam("Asset id") @PathParam("id") String id,
  @ApiParam("Asset") Asset asset,
  @ApiParam("The number of levels to merge this update") @QueryParam("mergedepth") @DefaultValue(RestHelper.INTEGER_MAX) int mergeDepth,
  @Context UriInfo uriInfo,
  @Context Request request,
  @Context SecurityContext securityContext
) throws IOException {
  logger.info("Update asset: {}", asset);

  RestHelper.validate(asset, Asset.Update.class);

  final Document existing = getAssetForUpdate(id);
  final MongoCollection<Document> collection = database.getCollection(Collections.ASSETS);
  final Document updated = RestHelper.mergeAndUpdateMeta(existing, asset, mergeDepth, collection, objectMapper, securityContext, request);
  return linkResponse(Status.OK, updated, uriInfo);
}
项目:irontest    文件:TestcaseResource.java   
@PATCH @Path("testcases/{testcaseId}/moveStep")
@PermitAll
public Testcase moveStep(Testcase testcase) throws JsonProcessingException {
    List<Teststep> teststeps = testcase.getTeststeps();
    teststepDAO.moveInTestcase(testcase.getId(), teststeps.get(0).getSequence(), teststeps.get(1).getSequence());
    return testcaseDAO.findById_TestcaseEditView(testcase.getId());
}
项目:zucchini-ui    文件:TestRunResource.java   
@PATCH
@Path("{testRunId}")
public void update(@PathParam("testRunId") final String testRunId, @Valid @NotNull final UpdateTestRunRequest request) {
    final TestRun testRun = testRunRepository.getById(testRunId);

    if (!Strings.isNullOrEmpty(request.getType())) {
        testRun.setType(request.getType());
    }
    testRun.setLabels(convertRequestLabels(request.getLabels()));

    testRunRepository.save(testRun);
}
项目:zucchini-ui    文件:CommentResource.java   
@PATCH
@Path("{commentId}")
public void updateComment(@PathParam("commentId") final String commentId, @Valid @NotNull final UpdateCommentRequest request) {
    final Comment comment = loadCommentById(commentId);
    comment.setContent(request.getContent());
    commentRepository.save(comment);
}
项目:zucchini-ui    文件:ScenarioResource.java   
@PATCH
@Path("{scenarioId}")
public void update(@PathParam("scenarioId") final String scenarioId, @Valid @NotNull final UpdateScenarioRequest request) {
    final UpdateScenarioParams updateScenarioParams = new UpdateScenarioParams(
        Optional.ofNullable(request.getStatus()),
        Optional.ofNullable(request.isReviewed())
    );
    scenarioService.updateScenario(scenarioId, updateScenarioParams);
}
项目:robe    文件:PermissionResource.java   
/**
 * Updates a {@link Permission} resource matches with the given id.
 * <p>
 * Status Code:
 * Not Found  404
 * Not Matches 412
 *
 * @param credentials Injected by @{@link RobeAuth} annotation for authentication.
 * @param id          This is  the oid of {@link Permission}
 * @param model       Data of {@link Permission}
 * @return Updates a @{@link Permission} resource matches with the given id.
 */
@RobeService(group = "Permission", description = "Updates a permission resource matches with the given id.")
@PATCH
@UnitOfWork
@Path("{id}")
public Permission merge(@RobeAuth Credentials credentials, @PathParam("id") String id, Permission model) {
    if (!id.equals(model.getOid()))
        throw new WebApplicationException(Response.status(412).build());
    Permission dest = permissionDao.findById(id);
    if (dest == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    Fields.mergeRight(model, dest);
    return permissionDao.update(dest);
}
项目:robe    文件:ServiceResource.java   
/**
 * Update {@link Service) resource and matches with the given id.
 * <p>
 * Status Code:
 * Not Found  404
 * Not Matches 412
 *
 * @param credentials Injected by {@link RobeAuth} annotation for authentication.
 * @param id          This is  the oid of {@link Service}
 * @param model       This is the one model of {@link Service}
 * @return Update {@link Service) resource and matches with the given id.
 */
@RobeService(group = "Service", description = "Update Service resource.")
@PATCH
@UnitOfWork
@Path("{id}")
public Service merge(@RobeAuth Credentials credentials, @PathParam("id") String id, Service model) {
    if (!id.equals(model.getOid()))
        throw new WebApplicationException(Response.status(412).build());
    Service dest = serviceDao.findById(id);
    if (dest == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    Fields.mergeRight(model, dest);
    return serviceDao.update(dest);
}
项目:robe    文件:UserResource.java   
/**
 * Updates a single {@link User} matches with the given id.
 * <p>
 * Status Code:
 * Not Found  404
 * Not Matches 412
 *
 * @param credentials injected by {@link RobeAuth} annotation for authentication.
 * @param id          This is the oid of {@link User}
 * @param model       data of {@link User}
 * @return Updates a single {@link User} matches with the given id.
 */
@RobeService(group = "User", description = "Updates a single User matches with the given id.")
@PATCH
@UnitOfWork
@Path("{id}")
public User merge(@RobeAuth Credentials credentials, @PathParam("id") String id, User model) {
    if (!id.equals(model.getOid()))
        throw new WebApplicationException(Response.status(412).build());
    User dest = userDao.findById(id);
    if (dest == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    Fields.mergeRight(model, dest);
    return userDao.update(dest);
}
项目:robe    文件:MenuResource.java   
/**
 * Updates a single {@link Menu} matches with the given id.
 * <p>
 * Status Code:
 * Not Found  404
 * Not Matches 412
 *
 * @param credentials injected by {@link RobeAuth} annotation for authentication.
 * @param id          This is the oid of {@link Menu}
 * @param model       data of {@link Menu}
 * @return Updates a single {@link Menu} matches with the given id.
 */
@RobeService(group = "Menu", description = "Updates a single Menu matches with the given id.")
@PATCH
@UnitOfWork
@Path("{id}")
public Menu merge(@RobeAuth Credentials credentials, @PathParam("id") String id, Menu model) {
    if (!id.equals(model.getOid()))
        throw new WebApplicationException(Response.status(412).build());
    Menu dest = menuDao.findById(id);
    if (dest == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    Fields.mergeRight(model, dest);
    return menuDao.update(dest);
}
项目:robe    文件:InitializeCommand.java   
protected boolean isItService(Method method) {
    return method.getAnnotation(GET.class) != null ||
            method.getAnnotation(PUT.class) != null ||
            method.getAnnotation(POST.class) != null ||
            method.getAnnotation(DELETE.class) != null ||
            method.getAnnotation(OPTIONS.class) != null ||
            method.getAnnotation(PATCH.class) != null;
}
项目:robe    文件:InitializeCommand.java   
protected String getHttpMethodType(Method method) {
    return method.getAnnotation(GET.class) != null ? "GET" :
            method.getAnnotation(POST.class) != null ? "POST" :
                    method.getAnnotation(PATCH.class) != null ? "PATCH" :
                            method.getAnnotation(PUT.class) != null ? "PUT" :
                                    method.getAnnotation(DELETE.class) != null ? "DELETE" :
                                            method.getAnnotation(OPTIONS.class) != null ? "OPTIONS" : "";
}
项目:dropwizard-patch    文件:UserResource.java   
@PATCH
@Path("/default/{id}")
public void updateUserDefault(@PathParam("id") int id, DefaultJsonPatch<User> request) {
    User user = dao.getUsers().get(id);
    User patchedUser = request.apply(user);

    dao.getUsers().set(id, patchedUser);
}
项目:dropwizard-patch    文件:UserResource.java   
@PATCH
@Path("/contextual/no-operations/{id}")
public void noOpContextual(@PathParam("id") int id, ContextualJsonPatch<User> request) {
    dao.getUsers().set(0, request.apply(dao.getUsers().get(0)));
}
项目:dropwizard-patch    文件:UserResource.java   
@PATCH
@Path("/no-operations/{id}")
public void noOp(@PathParam("id") int id, BasicJsonPatch request) {
    request.apply();
}