use of io.swagger.annotations.ApiOperation in project che by eclipse.
the class MavenServerService method reconcilePom.
@GET
@Path("pom/reconcile")
@ApiOperation(value = "Reconcile pom.xml file")
@ApiResponses({ @ApiResponse(code = 200, message = "OK") })
@Produces("application/json")
public List<Problem> reconcilePom(@ApiParam(value = "The paths to pom.xml file which need to be reconciled") @QueryParam("pompath") String pomPath) {
VirtualFileEntry entry = null;
List<Problem> result = new ArrayList<>();
try {
entry = cheProjectManager.getProjectsRoot().getChild(pomPath);
if (entry == null) {
return result;
}
Model.readFrom(entry.getVirtualFile());
org.eclipse.che.api.vfs.Path path = entry.getPath();
String pomContent = entry.getVirtualFile().getContentAsString();
MavenProject mavenProject = mavenProjectManager.findMavenProject(ResourcesPlugin.getWorkspace().getRoot().getProject(path.getParent().toString()));
if (mavenProject == null) {
return result;
}
List<MavenProjectProblem> problems = mavenProject.getProblems();
int start = pomContent.indexOf("<project ") + 1;
int end = start + "<project ".length();
List<Problem> problemList = problems.stream().map(mavenProjectProblem -> DtoFactory.newDto(Problem.class).withError(true).withSourceStart(start).withSourceEnd(end).withMessage(mavenProjectProblem.getDescription())).collect(Collectors.toList());
result.addAll(problemList);
} catch (ServerException | ForbiddenException | IOException e) {
LOG.error(e.getMessage(), e);
} catch (XMLTreeException exception) {
Throwable cause = exception.getCause();
if (cause != null && cause instanceof SAXParseException) {
result.add(createProblem(entry, (SAXParseException) cause));
}
}
return result;
}
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();
}
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();
}
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);
}
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();
}
Aggregations