use of io.dropwizard.jersey.PATCH in project dockstore by dockstore.
the class AbstractHostedEntryResource method editHosted.
@PATCH
@io.swagger.jaxrs.PATCH
@Path("/hostedEntry/{entryId}")
@Timed
@UnitOfWork
@Consumes(MediaType.APPLICATION_JSON)
public T editHosted(@ApiParam(hidden = true) @Parameter(hidden = true, name = "user") @Auth User user, @ApiParam(value = "Entry to modify.", required = true) @Parameter(description = "Entry to modify", name = "entryId", in = ParameterIn.PATH) @PathParam("entryId") Long entryId, @ApiParam(value = "Set of updated sourcefiles, add files by adding new files with unknown paths, delete files by including them with emptied content", required = true) @Parameter(description = "Set of updated sourcefiles, add files by adding new files with unknown paths, delete files by including them with emptied content", name = "sourceFiles", required = true) Set<SourceFile> sourceFiles) {
T entry = getEntryDAO().findById(entryId);
checkEntry(entry);
checkUserCanUpdate(user, entry);
checkHosted(entry);
checkVersionLimit(user, entry);
updateUnsetAbsolutePaths(sourceFiles);
U version = getVersion(entry);
Set<SourceFile> versionSourceFiles = handleSourceFileMerger(entryId, sourceFiles, entry, version);
return saveVersion(user, entryId, entry, version, versionSourceFiles, Optional.empty());
}
use of io.dropwizard.jersey.PATCH in project zucchini-ui by pgentile.
the class TestRunResource method update.
@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());
}
if (!Strings.isNullOrEmpty(request.getEnvironment())) {
testRun.setEnvironment(request.getEnvironment());
}
if (!Strings.isNullOrEmpty(request.getName())) {
testRun.setName(request.getName());
}
testRun.setLabels(convertRequestLabels(request.getLabels()));
testRunRepository.save(testRun);
}
use of io.dropwizard.jersey.PATCH in project velcom by IPDSnelting.
the class RepoEndpoint method patch.
@PATCH
@Path("{repoid}")
@Timed(histogram = true)
public void patch(@Auth Admin admin, @PathParam("repoid") UUID repoUuid, @NotNull PatchRequest request) throws NoSuchRepoException {
RepoId repoId = new RepoId(repoUuid);
// Guards whether the repo exists (that's why it's so high up in the function)
Repo repo = repoAccess.getRepo(repoId);
repoAccess.updateRepo(repoId, request.getName().orElse(null), request.getRemoteUrl().map(RemoteUrl::new).orElse(null));
request.getTrackedBranches().ifPresent(trackedBranches -> {
Set<BranchName> trackedBranchNames = trackedBranches.stream().map(BranchName::fromName).collect(Collectors.toSet());
repoAccess.setTrackedBranches(repoId, trackedBranchNames);
try {
listener.synchronizeCommitsForRepo(repo);
} catch (SynchronizeCommitsException e) {
LOGGER.warn("Failed to update repo {} successfully", repoId);
}
});
request.getGithubToken().ifPresent(token -> {
String stripped = token.strip();
if (stripped.equals("")) {
repoAccess.unsetGithubAuthToken(repoId);
} else {
repoAccess.setGithubAuthToken(repoId, stripped);
}
});
}
use of io.dropwizard.jersey.PATCH in project ldproxy by interactive-instruments.
the class EndpointStyleMetadataManagerCollection method computeDefinition.
@Override
protected ApiEndpointDefinition computeDefinition(OgcApiDataV2 apiData) {
Optional<StylesConfiguration> stylesExtension = apiData.getExtension(StylesConfiguration.class);
ImmutableApiEndpointDefinition.Builder definitionBuilder = new ImmutableApiEndpointDefinition.Builder().apiEntrypoint("collections").sortPriority(ApiEndpointDefinition.SORT_PRIORITY_STYLE_METADATA_MANAGER_COLLECTION);
String subSubPath = "/styles/{styleId}/metadata";
String path = "/collections/{collectionId}" + subSubPath;
List<OgcApiPathParameter> pathParameters = getPathParameters(extensionRegistry, apiData, path);
Optional<OgcApiPathParameter> optCollectionIdParam = pathParameters.stream().filter(param -> param.getName().equals("collectionId")).findAny();
if (!optCollectionIdParam.isPresent()) {
LOGGER.error("Path parameter 'collectionId' missing for resource at path '" + path + "'. The resource will not be available.");
} else {
final OgcApiPathParameter collectionIdParam = optCollectionIdParam.get();
final boolean explode = collectionIdParam.getExplodeInOpenApi(apiData);
final List<String> collectionIds = (explode) ? collectionIdParam.getValues(apiData) : ImmutableList.of("{collectionId}");
for (String collectionId : collectionIds) {
HttpMethods method = HttpMethods.PUT;
List<OgcApiQueryParameter> queryParameters = getQueryParameters(extensionRegistry, apiData, path, collectionId, method);
List<ApiHeader> headers = getHeaders(extensionRegistry, apiData, path, collectionId, method);
String operationSummary = "update the metadata document of a style in the feature collection '" + collectionId + "'";
String description = "Update the style metadata for the style with the id `styleId`";
if (stylesExtension.map(StylesConfiguration::isValidationEnabled).orElse(false)) {
description += " or just validate the style metadata.\n" + "If the header `Prefer` is set to `handling=strict`, the style will be validated before adding " + "the style to the server. If the parameter `dry-run` is set to `true`, the server will " + "not be changed and only any validation errors will be reported";
}
description += ".\n" + "This operation updates the complete metadata document.\n";
// TODO document rules, e.g.wrt links
Optional<String> operationDescription = Optional.of(description);
String resourcePath = "/collections/" + collectionId + subSubPath;
ImmutableOgcApiResourceData.Builder resourceBuilder = new ImmutableOgcApiResourceData.Builder().path(resourcePath).pathParameters(pathParameters);
ApiOperation operation = addOperation(apiData, method, queryParameters, headers, collectionId, subSubPath, operationSummary, operationDescription, TAGS);
if (operation != null)
resourceBuilder.putOperations(method.name(), operation);
method = HttpMethods.PATCH;
queryParameters = getQueryParameters(extensionRegistry, apiData, path, collectionId, method);
headers = getHeaders(extensionRegistry, apiData, path, collectionId, method);
operationSummary = "update parts of the style metadata document of a style in the feature collection '" + collectionId + "'";
description = "Update selected elements of the style metadata for the style with the id `styleId`";
if (stylesExtension.map(StylesConfiguration::isValidationEnabled).orElse(false)) {
description += " or just validate the style metadata.\n" + "If the header `Prefer` is set to `handling=strict`, the style will be validated before adding " + "the style to the server. If the parameter `dry-run` is set to `true`, the server will " + "not be changed and only any validation errors will be reported";
}
description += ".\n" + "The PATCH semantics in this operation are defined by " + "RFC 7396 (JSON Merge Patch). From the specification:\n" + "\n" + "_'A JSON merge patch document describes changes to be " + "made to a target JSON document using a syntax that " + "closely mimics the document being modified. Recipients " + "of a merge patch document determine the exact set of " + "changes being requested by comparing the content of " + "the provided patch against the current content of the " + "target document. If the provided merge patch contains " + "members that do not appear within the target, those " + "members are added. If the target does contain the " + "member, the value is replaced. Null values in the " + "merge patch are given special meaning to indicate " + "the removal of existing values in the target.'_\n" + "\n" + "Some examples:\n" + "\n" + "To add or update the point of contact, the access" + "constraint and the revision date, just send\n" + "\n" + "```\n" + "{\n" + " \"pointOfContact\": \"Jane Doe\",\n" + " \"accessConstraints\": \"restricted\",\n" + " \"dates\": {\n" + " \"revision\": \"2019-05-17T11:46:12Z\"\n" + " }\n" + "}\n" + "```\n" + "\n" + "To remove the point of contact, the access " + "constraint and the revision date, send \n" + "\n" + "```\n" + "{\n" + " \"pointOfContact\": null,\n" + " \"accessConstraints\": null,\n" + " \"dates\": {\n" + " \"revision\": null\n" + " }\n" + "}\n" + "```\n" + "\n" + "For arrays the complete array needs to be sent. " + "To add a keyword to the example style metadata object, send\n" + "\n" + "```\n" + "{\n" + " \"keywords\": [ \"basemap\", \"TDS\", \"TDS 6.1\", \"OGC API\", \"new keyword\" ]\n" + "}\n" + "```\n" + "\n" + "To remove the \"TDS\" keyword, send\n" + "\n" + "```\n" + "{\n" + " \"keywords\": [ \"basemap\", \"TDS 6.1\", \"OGC API\", \"new keyword\" ]\n" + "}\n" + "```\n" + "\n" + "To remove the keywords, send\n" + "\n" + "```\n" + "{\n" + " \"keywords\": null\n" + "}\n" + "```\n" + "\n" + "The same applies to `stylesheets` and `layers`. To update " + "these members, you have to send the complete new array value.";
// TODO document rules, e.g.wrt links
operationDescription = Optional.of(description);
operation = addOperation(apiData, method, queryParameters, headers, collectionId, subSubPath, operationSummary, operationDescription, TAGS);
if (operation != null)
resourceBuilder.putOperations(method.name(), operation);
definitionBuilder.putResources(resourcePath, resourceBuilder.build());
}
}
return definitionBuilder.build();
}
use of io.dropwizard.jersey.PATCH in project zucchini-ui by pgentile.
the class CommentResource method updateComment.
@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);
}
Aggregations