use of javax.ws.rs.PathParam in project syndesis by syndesisio.
the class IntegrationHandler method putDeployment.
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/deployments")
public IntegrationDeployment putDeployment(@Context SecurityContext sec, @NotNull @PathParam("id") @ApiParam(required = true) String id) {
Integration integration = getIntegration(id);
int nextDeploymentVersion = 1;
// Update previous deployments targetState=Undeployed and make sure nextDeploymentVersion is larger than all previous ones.
Set<String> deploymentIds = getDataManager().fetchIdsByPropertyValue(IntegrationDeployment.class, "integrationId", id);
if (deploymentIds != null && !deploymentIds.isEmpty()) {
Stream<IntegrationDeployment> deployments = deploymentIds.stream().map(i -> getDataManager().fetch(IntegrationDeployment.class, i)).filter(r -> r != null);
for (IntegrationDeployment d : deployments.toArray(IntegrationDeployment[]::new)) {
nextDeploymentVersion = Math.max(nextDeploymentVersion, d.getVersion() + 1);
getDataManager().update(d.withTargetState(IntegrationDeploymentState.Unpublished));
}
}
IntegrationDeployment deployment = new IntegrationDeployment.Builder().id(IntegrationDeployment.compositeId(id, nextDeploymentVersion)).spec(integration).version(nextDeploymentVersion).userId(sec.getUserPrincipal().getName()).build();
deployment = getDataManager().create(deployment);
return deployment;
}
use of javax.ws.rs.PathParam in project syndesis by syndesisio.
the class JsonDBResource method get.
@Produces({ APPLICATION_JSON, APPLICATION_JAVASCRIPT })
@Path("/{path: .*}.json")
@GET
public Response get(@PathParam("path") String path, @QueryParam("print") String print, @QueryParam("shallow") Boolean shallow, @QueryParam("callback") String callback) {
GetOptions options = new GetOptions();
if ("pretty".equals(print)) {
options.prettyPrint(true);
} else if ("silent".equals(print)) {
if (jsondb.exists(path)) {
return Response.noContent().build();
}
return Response.status(Response.Status.NOT_FOUND).build();
}
if (shallow != null) {
options.depth(1);
}
String contentType = APPLICATION_JSON;
if (callback != null) {
contentType = APPLICATION_JAVASCRIPT;
options.callback(callback);
}
Consumer<OutputStream> stream = jsondb.getAsStreamingOutput(path, options);
if (stream == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
StreamingOutput streamingOutput = x -> stream.accept(x);
return Response.ok(streamingOutput).header(CONTENT_TYPE, contentType).build();
}
use of javax.ws.rs.PathParam in project timbuctoo by HuygensING.
the class TabularUpload method upload.
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@POST
public Response upload(@FormDataParam("file") final InputStream rdfInputStream, @FormDataParam("file") final FormDataBodyPart body, @FormDataParam("file") final FormDataContentDisposition fileInfo, @FormDataParam("fileMimeTypeOverride") final MediaType mimeTypeOverride, FormDataMultiPart formData, @HeaderParam("authorization") final String authHeader, @PathParam("userId") final String ownerId, @PathParam("dataSetId") final String dataSetId, @QueryParam("forceCreation") boolean forceCreation) throws DataStoreCreationException, FileStorageFailedException, ExecutionException, InterruptedException, LogStorageFailedException {
final Either<Response, Response> result = authCheck.getOrCreate(authHeader, ownerId, dataSetId, forceCreation).flatMap(userAndDs -> authCheck.hasAdminAccess(userAndDs.getLeft(), userAndDs.getRight())).map(userAndDs -> {
final MediaType mediaType = mimeTypeOverride == null ? body.getMediaType() : mimeTypeOverride;
Optional<Loader> loader = LoaderFactory.createFor(mediaType.toString(), formData.getFields().entrySet().stream().filter(entry -> entry.getValue().size() > 0).filter(entry -> entry.getValue().get(0) != null).filter(entry -> MediaTypes.typeEqual(MediaType.TEXT_PLAIN_TYPE, entry.getValue().get(0).getMediaType())).collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get(0).getValue())));
if (!loader.isPresent()) {
return errorResponseHelper.error(400, "We do not support the mediatype '" + mediaType + "'. Make sure to add the correct mediatype to the file " + "parameter. In curl you'd use `-F \"file=@<filename>;type=<mediatype>\"`. In a webbrowser you probably " + "have no way of setting the correct mimetype. So you can use a special parameter to override it: " + "`formData.append(\"fileMimeTypeOverride\", \"<mimetype>\");`");
}
final DataSet dataSet = userAndDs.getRight();
ImportManager importManager = dataSet.getImportManager();
if (StringUtils.isBlank(fileInfo.getName())) {
return Response.status(400).entity("filename cannot be empty.").build();
}
try {
String fileToken = importManager.addFile(rdfInputStream, fileInfo.getFileName(), mediaType);
Future<ImportStatus> promise = importManager.generateLog(dataSet.getMetadata().getBaseUri(), dataSet.getMetadata().getBaseUri(), new TabularRdfCreator(loader.get(), fileToken, fileInfo.getFileName()));
return handleImportManagerResult(promise);
} catch (FileStorageFailedException | LogStorageFailedException e) {
LOG.error("Tabular upload failed", e);
return Response.serverError().build();
}
});
if (result.isLeft()) {
return result.getLeft();
} else {
return result.get();
}
}
use of javax.ws.rs.PathParam in project onebusaway-application-modules by camsys.
the class RESTEndpointsDocumenter method discoverParameters.
/**
* Get the parameters for the specified endpoint from the provided java method.
*/
@SuppressWarnings("rawtypes")
private void discoverParameters(Method method, Endpoint endpoint) {
Annotation[][] annotations = method.getParameterAnnotations();
Class[] parameterTypes = method.getParameterTypes();
for (int i = 0; i < parameterTypes.length; i++) {
Class parameter = parameterTypes[i];
// ignore parameters used to access context
if ((parameter == Request.class) || (parameter == javax.servlet.http.HttpServletResponse.class) || (parameter == javax.servlet.http.HttpServletRequest.class)) {
continue;
}
EndpointParameter nextParameter = new EndpointParameter();
nextParameter.javaType = parameter.getName();
Annotation[] parameterAnnotations = annotations[i];
for (Annotation annotation : parameterAnnotations) {
if (annotation instanceof PathParam) {
nextParameter.parameterType = ParameterType.PATH;
PathParam pathparam = (PathParam) annotation;
nextParameter.name = pathparam.value();
} else if (annotation instanceof QueryParam) {
nextParameter.parameterType = ParameterType.QUERY;
QueryParam queryparam = (QueryParam) annotation;
nextParameter.name = queryparam.value();
} else if (annotation instanceof DefaultValue) {
DefaultValue defaultvalue = (DefaultValue) annotation;
nextParameter.defaultValue = defaultvalue.value();
}
}
switch(nextParameter.parameterType) {
case PATH:
endpoint.pathParameters.add(nextParameter);
break;
case QUERY:
endpoint.queryParameters.add(nextParameter);
break;
case PAYLOAD:
endpoint.payloadParameters.add(nextParameter);
break;
}
}
}
use of javax.ws.rs.PathParam in project ovirt-engine by oVirt.
the class V3CapabilitiesServer method get.
@GET
@Path("/{id}")
public V3VersionCaps get(@PathParam("id") String id) {
V3Capabilities capabilities = list();
Optional<V3VersionCaps> caps = capabilities.getVersions().stream().filter(x -> x.getId().equals(id)).findFirst();
if (caps.isPresent()) {
return caps.get();
}
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
Aggregations