Search in sources :

Example 96 with Produces

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

the class RefactoringService method createRenameRefactoring.

/**
     * Create rename refactoring session.
     *
     * @param settings
     *         rename settings
     * @return the rename refactoring session
     * @throws CoreException
     *         when RenameSupport can't be created
     * @throws RefactoringException
     *         when Java element was not found
     */
@POST
@Path("rename/create")
@Produces("application/json")
@Consumes("application/json")
public RenameRefactoringSession createRenameRefactoring(CreateRenameRefactoring settings) throws CoreException, RefactoringException {
    IJavaProject javaProject = model.getJavaProject(settings.getProjectPath());
    IJavaElement elementToRename;
    ICompilationUnit cu = null;
    switch(settings.getType()) {
        case COMPILATION_UNIT:
            elementToRename = javaProject.findType(settings.getPath()).getCompilationUnit();
            break;
        case PACKAGE:
            elementToRename = javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(settings.getPath()));
            break;
        case JAVA_ELEMENT:
            cu = javaProject.findType(settings.getPath()).getCompilationUnit();
            elementToRename = getSelectionElement(cu, settings.getOffset());
            break;
        default:
            elementToRename = null;
    }
    if (elementToRename == null) {
        throw new RefactoringException("Can't find java element to rename.");
    }
    return manager.createRenameRefactoring(elementToRename, cu, settings.getOffset(), settings.isRefactorLightweight());
}
Also used : Path(javax.ws.rs.Path) IJavaElement(org.eclipse.jdt.core.IJavaElement) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IJavaProject(org.eclipse.jdt.core.IJavaProject) RefactoringException(org.eclipse.che.plugin.java.server.refactoring.RefactoringException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Example 97 with Produces

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

the class RefactoringService method createMoveRefactoring.

/**
     * Create move refactoring session.
     *
     * @param cmr
     *         move settings, contains resource paths to move.
     * @return refactoring session id.
     * @throws JavaModelException
     *         when JavaModel has a failure
     * @throws RefactoringException
     *         when impossible to create move refactoring session
     */
@POST
@Path("move/create")
@Consumes("application/json")
@Produces("text/plain")
public String createMoveRefactoring(CreateMoveRefactoring cmr) throws JavaModelException, RefactoringException {
    IJavaProject javaProject = model.getJavaProject(cmr.getProjectPath());
    IJavaElement[] javaElements;
    try {
        Function<ElementToMove, IJavaElement> map = javaElement -> {
            try {
                if (javaElement.isPack()) {
                    return javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(javaElement.getPath()));
                } else {
                    return javaProject.findType(javaElement.getPath()).getCompilationUnit();
                }
            } catch (JavaModelException e) {
                throw new IllegalArgumentException(e);
            }
        };
        javaElements = cmr.getElements().stream().map(map).toArray(IJavaElement[]::new);
    } catch (IllegalArgumentException e) {
        if (e.getCause() instanceof JavaModelException) {
            throw (JavaModelException) e.getCause();
        } else {
            throw e;
        }
    }
    if (RefactoringAvailabilityTester.isMoveAvailable(new IResource[0], javaElements)) {
        return manager.createMoveRefactoringSession(javaElements);
    }
    throw new RefactoringException("Can't create move refactoring.");
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) Produces(javax.ws.rs.Produces) JavaModelException(org.eclipse.jdt.core.JavaModelException) GET(javax.ws.rs.GET) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) Inject(com.google.inject.Inject) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) Path(javax.ws.rs.Path) CoreException(org.eclipse.core.runtime.CoreException) Function(java.util.function.Function) LinkedRenameRefactoringApply(org.eclipse.che.ide.ext.java.shared.dto.refactoring.LinkedRenameRefactoringApply) RefactoringChange(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange) JavaModelManager(org.eclipse.jdt.internal.core.JavaModelManager) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview) JavaModel(org.eclipse.jdt.internal.core.JavaModel) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) RefactoringException(org.eclipse.che.plugin.java.server.refactoring.RefactoringException) RenameSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameSettings) ChangeEnabledState(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeEnabledState) RefactoringManager(org.eclipse.che.plugin.java.server.refactoring.RefactoringManager) ValidateNewName(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ValidateNewName) ChangePreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview) POST(javax.ws.rs.POST) IJavaProject(org.eclipse.jdt.core.IJavaProject) RefactoringAvailabilityTester(org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester) ChangeCreationResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult) CreateRenameRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring) RefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringSession) ElementToMove(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ElementToMove) CreateMoveRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateMoveRefactoring) RefactoringResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult) IJavaElement(org.eclipse.jdt.core.IJavaElement) Response(javax.ws.rs.core.Response) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) IResource(org.eclipse.core.resources.IResource) Path(javax.ws.rs.Path) IJavaElement(org.eclipse.jdt.core.IJavaElement) JavaModelException(org.eclipse.jdt.core.JavaModelException) IJavaProject(org.eclipse.jdt.core.IJavaProject) ElementToMove(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ElementToMove) RefactoringException(org.eclipse.che.plugin.java.server.refactoring.RefactoringException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 98 with Produces

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

the class SearchService method findUsages.

@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("find/usages")
public FindUsagesResponse findUsages(FindUsagesRequest request) throws SearchException {
    JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
    IJavaProject javaProject = javaModel.getJavaProject(request.getProjectPath());
    return manager.findUsage(javaProject, request.getFQN(), request.getOffset());
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaModel(org.eclipse.jdt.internal.core.JavaModel) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 99 with Produces

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

the class DebuggerService method getDebugSession.

@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public DebugSessionDto getDebugSession(@PathParam("id") String sessionId) throws DebuggerException {
    DebuggerInfo debuggerInfo = debuggerManager.getDebugger(sessionId).getInfo();
    DebugSessionDto debugSessionDto = newDto(DebugSessionDto.class);
    debugSessionDto.setDebuggerInfo(asDto(debuggerInfo));
    debugSessionDto.setId(sessionId);
    debugSessionDto.setType(debuggerManager.getDebuggerType(sessionId));
    return debugSessionDto;
}
Also used : DebuggerInfo(org.eclipse.che.api.debug.shared.model.DebuggerInfo) DebugSessionDto(org.eclipse.che.api.debug.shared.dto.DebugSessionDto) Path(javax.ws.rs.Path) VariablePath(org.eclipse.che.api.debug.shared.model.VariablePath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 100 with Produces

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

the class TestingService method run.

/**
     * Execute the Java test cases and return the test result.
     *
     * <pre>
     *     Required request parameters.
     *     <em>projectPath</em> : Relative path to the project directory.
     *     <em>testFramework</em> : Name of the test framework where the tests should be run on. This should match with
     *                     the name returned by {@link TestRunner#getName()} implementation.
     * </pre>
     *
     * @param uriInfo
     *            JAX-RS implementation of UrlInfo with set of query parameters.
     * @return the test result of test case
     * @throws Exception
     *             when the test runner failed to execute test cases.
     */
@GET
@Path("run")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Execute Java tests and return results", notes = "The GET parameters are passed to the test framework implementation.")
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public TestResult run(@Context UriInfo uriInfo) throws Exception {
    Map<String, String> queryParameters = getMap(uriInfo.getQueryParameters());
    String projectPath = queryParameters.get("projectPath");
    String absoluteProjectPath = ResourcesPlugin.getPathToWorkspace() + projectPath;
    queryParameters.put("absoluteProjectPath", absoluteProjectPath);
    String testFramework = queryParameters.get("testFramework");
    TestRunner runner = frameworkRegistry.getTestRunner(testFramework);
    if (runner == null) {
        throw new Exception("No test frameworks found: " + testFramework);
    }
    TestResult result = frameworkRegistry.getTestRunner(testFramework).execute(queryParameters);
    return result;
}
Also used : TestRunner(org.eclipse.che.api.testing.server.framework.TestRunner) TestResult(org.eclipse.che.api.testing.shared.TestResult) 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

Produces (javax.ws.rs.Produces)937 Path (javax.ws.rs.Path)686 GET (javax.ws.rs.GET)600 ApiOperation (io.swagger.annotations.ApiOperation)271 Consumes (javax.ws.rs.Consumes)241 POST (javax.ws.rs.POST)233 ApiResponses (io.swagger.annotations.ApiResponses)216 Response (javax.ws.rs.core.Response)110 TimedResource (org.killbill.commons.metrics.TimedResource)109 IOException (java.io.IOException)105 WebApplicationException (javax.ws.rs.WebApplicationException)95 Timed (com.codahale.metrics.annotation.Timed)92 URI (java.net.URI)88 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)81 PUT (javax.ws.rs.PUT)79 ArrayList (java.util.ArrayList)71 UUID (java.util.UUID)62 Map (java.util.Map)58 TenantContext (org.killbill.billing.util.callcontext.TenantContext)58 DELETE (javax.ws.rs.DELETE)56