Search in sources :

Example 66 with ApiOperation

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

the class MavenServerService method reimportDependencies.

@POST
@Path("reimport")
@ApiOperation(value = "Re-import maven model")
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Internal Server Error") })
public Response reimportDependencies(@ApiParam(value = "The paths to projects which need to be reimported") @QueryParam("projectPath") List<String> paths) throws ServerException {
    IWorkspace workspace = eclipseWorkspaceProvider.get();
    List<IProject> projectsList = paths.stream().map(projectPath -> workspace.getRoot().getProject(projectPath)).collect(Collectors.toList());
    mavenWorkspace.update(projectsList);
    return Response.ok().build();
}
Also used : MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) Inject(com.google.inject.Inject) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) XMLTreeException(org.eclipse.che.commons.xml.XMLTreeException) MavenProjectProblem(org.eclipse.che.maven.data.MavenProjectProblem) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) ApiResponses(io.swagger.annotations.ApiResponses) ArrayList(java.util.ArrayList) ApiOperation(io.swagger.annotations.ApiOperation) Document(org.eclipse.jface.text.Document) MavenProgressNotifier(org.eclipse.che.plugin.maven.server.core.MavenProgressNotifier) QueryParam(javax.ws.rs.QueryParam) IProject(org.eclipse.core.resources.IProject) IWorkspace(org.eclipse.core.resources.IWorkspace) Model(org.eclipse.che.ide.maven.tools.Model) BadLocationException(org.eclipse.jface.text.BadLocationException) DtoFactory(org.eclipse.che.dto.server.DtoFactory) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) TEXT_XML(javax.ws.rs.core.MediaType.TEXT_XML) MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) NotFoundException(org.eclipse.che.api.core.NotFoundException) SAXParseException(org.xml.sax.SAXParseException) List(java.util.List) ServerException(org.eclipse.che.api.core.ServerException) Response(javax.ws.rs.core.Response) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) ApiResponse(io.swagger.annotations.ApiResponse) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) ProjectManager(org.eclipse.che.api.project.server.ProjectManager) Collections(java.util.Collections) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) IWorkspace(org.eclipse.core.resources.IWorkspace) IProject(org.eclipse.core.resources.IProject) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 67 with ApiOperation

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

the class ProjectService method createFile.

@POST
@Path("/file/{parent:.*}")
@Consumes({ MediaType.MEDIA_TYPE_WILDCARD })
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Create file", notes = "Create a new file in a project. If file type isn't specified the server will resolve its type.")
@ApiResponses({ @ApiResponse(code = 201, message = ""), @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "File already exists"), @ApiResponse(code = 500, message = "Internal Server Error") })
public Response createFile(@ApiParam(value = "Path to a target directory", required = true) @PathParam("parent") String parentPath, @ApiParam(value = "New file name", required = true) @QueryParam("name") String fileName, InputStream content) throws NotFoundException, ConflictException, ForbiddenException, ServerException {
    final FolderEntry parent = projectManager.asFolder(parentPath);
    if (parent == null) {
        throw new NotFoundException("Parent not found for " + parentPath);
    }
    final FileEntry newFile = parent.createFile(fileName, content);
    eventService.publish(new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.CREATED, workspace, newFile.getProject(), newFile.getPath().toString(), false));
    final URI location = getServiceContext().getServiceUriBuilder().clone().path(getClass(), "getFile").build(new String[] { newFile.getPath().toString().substring(1) }, false);
    return Response.created(location).entity(injectFileLinks(asDto(newFile))).build();
}
Also used : ProjectItemModifiedEvent(org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent) NotFoundException(org.eclipse.che.api.core.NotFoundException) URI(java.net.URI) 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) ApiResponses(io.swagger.annotations.ApiResponses)

Example 68 with ApiOperation

use of io.swagger.annotations.ApiOperation 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 69 with ApiOperation

use of io.swagger.annotations.ApiOperation 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 70 with ApiOperation

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

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1144 ApiResponses (io.swagger.annotations.ApiResponses)611 Path (javax.ws.rs.Path)410 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)305 Produces (javax.ws.rs.Produces)284 Timed (com.codahale.metrics.annotation.Timed)255 GET (javax.ws.rs.GET)240 Counted (com.codahale.metrics.annotation.Counted)210 POST (javax.ws.rs.POST)153 Consumes (javax.ws.rs.Consumes)138 TimedResource (org.killbill.commons.metrics.TimedResource)112 AuditEvent (org.graylog2.audit.jersey.AuditEvent)99 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)94 ApiResponse (io.swagger.annotations.ApiResponse)87 Authorisation (nikita.webapp.security.Authorisation)87 PUT (javax.ws.rs.PUT)85 Response (javax.ws.rs.core.Response)84 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)80 DELETE (javax.ws.rs.DELETE)77 DBObject (com.mongodb.DBObject)72