Search in sources :

Example 61 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class ProjectService method estimateProject.

@GET
@Path("/estimate/{path:.*}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Estimates if the folder supposed to be project of certain type", response = Map.class)
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "Project with specified path doesn't exist in workspace"), @ApiResponse(code = 403, message = "Access to requested project is forbidden"), @ApiResponse(code = 500, message = "Server error") })
public SourceEstimation estimateProject(@ApiParam(value = "Path to requested project", required = true) @PathParam("path") String path, @ApiParam(value = "Project Type ID to estimate against", required = true) @QueryParam("type") String projectType) throws NotFoundException, ForbiddenException, ServerException, ConflictException {
    final ProjectTypeResolution resolution = projectManager.estimateProject(path, projectType);
    final HashMap<String, List<String>> attributes = new HashMap<>();
    for (Map.Entry<String, Value> attr : resolution.getProvidedAttributes().entrySet()) {
        attributes.put(attr.getKey(), attr.getValue().getList());
    }
    return DtoFactory.newDto(SourceEstimation.class).withType(projectType).withMatched(resolution.matched()).withResolution(resolution.getResolution()).withAttributes(attributes);
}
Also used : ProjectTypeResolution(org.eclipse.che.api.project.server.type.ProjectTypeResolution) HashMap(java.util.HashMap) DefaultValue(javax.ws.rs.DefaultValue) Value(org.eclipse.che.api.core.model.project.type.Value) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 62 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class ProjectService method updateFile.

@PUT
@Path("/file/{path:.*}")
@Consumes({ MediaType.MEDIA_TYPE_WILDCARD })
@ApiOperation(value = "Update file", notes = "Update an existing file with new content")
@ApiResponses({ @ApiResponse(code = 200, message = ""), @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 500, message = "Internal Server Error") })
public Response updateFile(@ApiParam(value = "Full path to a file", required = true) @PathParam("path") String path, InputStream content) throws NotFoundException, ForbiddenException, ServerException {
    final FileEntry file = projectManager.asFile(path);
    if (file == null) {
        throw new NotFoundException("File not found for " + path);
    }
    file.updateContent(content);
    eventService.publish(new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.UPDATED, workspace, file.getProject(), file.getPath().toString(), false));
    return Response.ok().build();
}
Also used : ProjectItemModifiedEvent(org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent) NotFoundException(org.eclipse.che.api.core.NotFoundException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 63 with ApiResponses

use of io.swagger.annotations.ApiResponses in project che by eclipse.

the class ProjectService method search.

@GET
@Path("/search/{path:.*}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Search for resources", notes = "Search for resources applying a number of search filters as query parameters", response = ItemReference.class, responseContainer = "List")
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "Conflict error"), @ApiResponse(code = 500, message = "Internal Server Error") })
public List<ItemReference> search(@ApiParam(value = "Path to resource, i.e. where to search?", required = true) @PathParam("path") String path, @ApiParam(value = "Resource name") @QueryParam("name") String name, @ApiParam(value = "Search keywords") @QueryParam("text") String text, @ApiParam(value = "Maximum items to display. If this parameter is dropped, there are no limits") @QueryParam("maxItems") @DefaultValue("-1") int maxItems, @ApiParam(value = "Skip count") @QueryParam("skipCount") int skipCount) throws NotFoundException, ForbiddenException, ConflictException, ServerException {
    final Searcher searcher;
    try {
        searcher = projectManager.getSearcher();
    } catch (NotFoundException e) {
        LOG.warn(e.getLocalizedMessage());
        return Collections.emptyList();
    }
    if (skipCount < 0) {
        throw new ConflictException(String.format("Invalid 'skipCount' parameter: %d.", skipCount));
    }
    final QueryExpression expr = new QueryExpression().setPath(path.startsWith("/") ? path : ('/' + path)).setName(name).setText(text).setMaxItems(maxItems).setSkipCount(skipCount);
    final SearchResult result = searcher.search(expr);
    final List<SearchResultEntry> searchResultEntries = result.getResults();
    final List<ItemReference> items = new ArrayList<>(searchResultEntries.size());
    final FolderEntry root = projectManager.getProjectsRoot();
    for (SearchResultEntry searchResultEntry : searchResultEntries) {
        final VirtualFileEntry child = root.getChild(searchResultEntry.getFilePath());
        if (child != null && child.isFile()) {
            items.add(injectFileLinks(asDto((FileEntry) child)));
        }
    }
    return items;
}
Also used : ItemReference(org.eclipse.che.api.project.shared.dto.ItemReference) ConflictException(org.eclipse.che.api.core.ConflictException) Searcher(org.eclipse.che.api.vfs.search.Searcher) ArrayList(java.util.ArrayList) NotFoundException(org.eclipse.che.api.core.NotFoundException) SearchResult(org.eclipse.che.api.vfs.search.SearchResult) QueryExpression(org.eclipse.che.api.vfs.search.QueryExpression) SearchResultEntry(org.eclipse.che.api.vfs.search.SearchResultEntry) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 64 with ApiResponses

use of io.swagger.annotations.ApiResponses 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;
}
Also used : NewProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.NewProjectConfigDto) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) ArrayList(java.util.ArrayList) Path(javax.ws.rs.Path) 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 65 with ApiResponses

use of io.swagger.annotations.ApiResponses 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)

Aggregations

ApiResponses (io.swagger.annotations.ApiResponses)612 ApiOperation (io.swagger.annotations.ApiOperation)607 Path (javax.ws.rs.Path)319 Produces (javax.ws.rs.Produces)223 Counted (com.codahale.metrics.annotation.Counted)210 Timed (com.codahale.metrics.annotation.Timed)193 GET (javax.ws.rs.GET)169 POST (javax.ws.rs.POST)119 TimedResource (org.killbill.commons.metrics.TimedResource)111 Consumes (javax.ws.rs.Consumes)109 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)94 Authorisation (nikita.webapp.security.Authorisation)87 PUT (javax.ws.rs.PUT)66 UUID (java.util.UUID)62 DELETE (javax.ws.rs.DELETE)62 AuditEvent (org.graylog2.audit.jersey.AuditEvent)59 TenantContext (org.killbill.billing.util.callcontext.TenantContext)58 RestException (com.yahoo.pulsar.broker.web.RestException)54 ApiResponse (io.swagger.annotations.ApiResponse)53 CallContext (org.killbill.billing.util.callcontext.CallContext)51