use of javax.ws.rs.Produces in project che by eclipse.
the class ProjectService method createBatchProjects.
@POST
@Path("/batch")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates batch of projects according to their configurations", notes = "A project will be created by importing when project configuration contains source object. " + "For creating a project by generator options should be specified.", response = ProjectConfigDto.class)
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Path for new project should be defined"), @ApiResponse(code = 403, message = "Operation is forbidden"), @ApiResponse(code = 409, message = "Project with specified name already exist in workspace"), @ApiResponse(code = 500, message = "Server error") })
@GenerateLink(rel = LINK_REL_CREATE_BATCH_PROJECTS)
public List<ProjectConfigDto> createBatchProjects(@Description("list of descriptors for projects") List<NewProjectConfigDto> projectConfigList, @ApiParam(value = "Force rewrite existing project", allowableValues = "true,false") @QueryParam("force") boolean rewrite) throws ConflictException, ForbiddenException, ServerException, NotFoundException, IOException, UnauthorizedException, BadRequestException {
List<ProjectConfigDto> result = new ArrayList<>(projectConfigList.size());
final ProjectOutputLineConsumerFactory outputOutputConsumerFactory = new ProjectOutputLineConsumerFactory(workspace, 300);
for (RegisteredProject registeredProject : projectManager.createBatchProjects(projectConfigList, rewrite, outputOutputConsumerFactory)) {
ProjectConfigDto projectConfig = injectProjectLinks(asDto(registeredProject));
result.add(projectConfig);
eventService.publish(new ProjectCreatedEvent(workspace, registeredProject.getPath()));
}
return result;
}
use of javax.ws.rs.Produces in project che by eclipse.
the class ProjectService method exportFile.
@GET
@Path("/export/file/{path:.*}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportFile(@ApiParam(value = "Path to resource to be imported") @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException {
final FileEntry file = projectManager.asFile(path);
if (file == null) {
throw new NotFoundException("File not found " + path);
}
final VirtualFile virtualFile = file.getVirtualFile();
return Response.ok(virtualFile.getContent(), TIKA.detect(virtualFile.getName())).lastModified(new Date(virtualFile.getLastModificationDate())).header(HttpHeaders.CONTENT_LENGTH, Long.toString(virtualFile.getLength())).header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + virtualFile.getName() + '"').build();
}
use of javax.ws.rs.Produces in project che by eclipse.
the class ProjectService method createProject.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates new project", response = ProjectConfigDto.class)
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 403, message = "Operation is forbidden"), @ApiResponse(code = 409, message = "Project with specified name already exist in workspace"), @ApiResponse(code = 500, message = "Server error") })
@GenerateLink(rel = LINK_REL_CREATE_PROJECT)
public /**
* NOTE: parentPath is added to make a module
*/
ProjectConfigDto createProject(@ApiParam(value = "Add to this project as module", required = false) @Context UriInfo uriInfo, @Description("descriptor of project") ProjectConfigDto projectConfig) throws ConflictException, ForbiddenException, ServerException, NotFoundException {
Map<String, String> options = new HashMap<>();
MultivaluedMap<String, String> map = uriInfo.getQueryParameters();
for (String key : map.keySet()) {
options.put(key, map.get(key).get(0));
}
String pathToProject = projectConfig.getPath();
String pathToParent = pathToProject.substring(0, pathToProject.lastIndexOf("/"));
if (!pathToParent.equals("/")) {
VirtualFileEntry parentFileEntry = projectManager.getProjectsRoot().getChild(pathToParent);
if (parentFileEntry == null) {
throw new NotFoundException("The parent folder with path " + pathToParent + " does not exist.");
}
}
final RegisteredProject project = projectManager.createProject(projectConfig, options);
final ProjectConfigDto configDto = asDto(project);
eventService.publish(new ProjectCreatedEvent(workspace, project.getPath()));
return injectProjectLinks(configDto);
}
use of javax.ws.rs.Produces in project che by eclipse.
the class TextDocumentService method definition.
@POST
@Path("definition")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<? extends Location> definition(TextDocumentPositionParamsDTO params) throws ExecutionException, InterruptedException, LanguageServerException {
params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri()));
LanguageServer server = getServer(params.getTextDocument().getUri());
if (server == null) {
return emptyList();
}
List<? extends Location> locations = server.getTextDocumentService().definition(params).get();
locations.forEach(o -> {
if (o instanceof LocationImpl) {
((LocationImpl) o).setUri(removePrefixUri(o.getUri()));
}
});
return locations;
}
use of javax.ws.rs.Produces in project che by eclipse.
the class TextDocumentService method onTypeFormatting.
@POST
@Path("onTypeFormatting")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<? extends TextEdit> onTypeFormatting(DocumentOnTypeFormattingParamsDTO params) throws InterruptedException, ExecutionException, LanguageServerException {
params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri()));
LanguageServer server = getServer(params.getTextDocument().getUri());
if (server == null) {
return emptyList();
}
return server.getTextDocumentService().onTypeFormatting(params).get();
}
Aggregations