Search in sources :

Example 31 with POST

use of javax.ws.rs.POST 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);
}
Also used : HashMap(java.util.HashMap) NewProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.NewProjectConfigDto) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) NotFoundException(org.eclipse.che.api.core.NotFoundException) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) ApiResponses(io.swagger.annotations.ApiResponses)

Example 32 with POST

use of javax.ws.rs.POST 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;
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) LocationImpl(io.typefox.lsapi.impl.LocationImpl) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 33 with POST

use of javax.ws.rs.POST 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();
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 34 with POST

use of javax.ws.rs.POST in project che by eclipse.

the class TextDocumentService method didOpen.

@POST
@Path("didOpen")
@Consumes(MediaType.APPLICATION_JSON)
public void didOpen(DidOpenTextDocumentParamsDTO openEvent) throws LanguageServerException {
    openEvent.getTextDocument().setUri(prefixURI(openEvent.getTextDocument().getUri()));
    openEvent.setUri(prefixURI(openEvent.getUri()));
    LanguageServer server = getServer(openEvent.getTextDocument().getUri());
    if (server != null) {
        server.getTextDocumentService().didOpen(openEvent);
    }
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 35 with POST

use of javax.ws.rs.POST in project che by eclipse.

the class TextDocumentService method didChange.

@POST
@Path("didChange")
@Consumes(MediaType.APPLICATION_JSON)
public void didChange(DidChangeTextDocumentParamsDTO change) throws LanguageServerException {
    change.getTextDocument().setUri(prefixURI(change.getTextDocument().getUri()));
    change.setUri(prefixURI(change.getUri()));
    LanguageServer server = getServer(change.getTextDocument().getUri());
    if (server != null) {
        server.getTextDocumentService().didChange(change);
    }
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

POST (javax.ws.rs.POST)513 Path (javax.ws.rs.Path)360 Consumes (javax.ws.rs.Consumes)242 Produces (javax.ws.rs.Produces)222 ApiOperation (io.swagger.annotations.ApiOperation)133 ApiResponses (io.swagger.annotations.ApiResponses)107 IOException (java.io.IOException)74 URI (java.net.URI)63 WebApplicationException (javax.ws.rs.WebApplicationException)62 Timed (com.codahale.metrics.annotation.Timed)55 Response (javax.ws.rs.core.Response)50 TimedResource (org.killbill.commons.metrics.TimedResource)36 CallContext (org.killbill.billing.util.callcontext.CallContext)35 AuditEvent (org.graylog2.audit.jersey.AuditEvent)33 HashMap (java.util.HashMap)32 BadRequestException (co.cask.cdap.common.BadRequestException)24 AuditPolicy (co.cask.cdap.common.security.AuditPolicy)24 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)23 Account (org.killbill.billing.account.api.Account)22 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)20