Search in sources :

Example 61 with ConflictException

use of org.eclipse.che.api.core.ConflictException in project che by eclipse.

the class CommandExistsAgentChecker method isLaunched.

@Override
public boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException {
    Command command = new CommandImpl(format("Wait for %s, try %d", agent.getId(), ++counter), checkingCommand, "test");
    try (ListLineConsumer lineConsumer = new ListLineConsumer()) {
        InstanceProcess waitProcess = machine.createProcess(command, null);
        waitProcess.start(lineConsumer);
        return lineConsumer.getText().endsWith("[STDOUT] 0");
    } catch (ConflictException e) {
        throw new MachineException(e.getServiceError());
    }
}
Also used : CommandImpl(org.eclipse.che.api.machine.server.model.impl.CommandImpl) ListLineConsumer(org.eclipse.che.api.core.util.ListLineConsumer) Command(org.eclipse.che.api.core.model.machine.Command) ConflictException(org.eclipse.che.api.core.ConflictException) MachineException(org.eclipse.che.api.machine.server.exception.MachineException) InstanceProcess(org.eclipse.che.api.machine.server.spi.InstanceProcess)

Example 62 with ConflictException

use of org.eclipse.che.api.core.ConflictException in project che by eclipse.

the class ProcessIsLaunchedChecker method isLaunched.

@Override
public boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException {
    Command command = new CommandImpl(format("Wait for %s, try %d", agent.getId(), ++counter), format(CHECK_COMMAND, processNameToWait), "test");
    try (ListLineConsumer lineConsumer = new ListLineConsumer()) {
        InstanceProcess waitProcess = machine.createProcess(command, null);
        waitProcess.start(lineConsumer);
        return lineConsumer.getText().endsWith("[STDOUT] 0");
    } catch (ConflictException e) {
        throw new MachineException(e.getServiceError());
    }
}
Also used : CommandImpl(org.eclipse.che.api.machine.server.model.impl.CommandImpl) ListLineConsumer(org.eclipse.che.api.core.util.ListLineConsumer) Command(org.eclipse.che.api.core.model.machine.Command) ConflictException(org.eclipse.che.api.core.ConflictException) MachineException(org.eclipse.che.api.machine.server.exception.MachineException) InstanceProcess(org.eclipse.che.api.machine.server.spi.InstanceProcess)

Example 63 with ConflictException

use of org.eclipse.che.api.core.ConflictException in project che by eclipse.

the class Workspace method standardMoveFolder.

public void standardMoveFolder(IFolder folder, IFolder destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
    VirtualFileEntry child = null;
    try {
        child = getProjectsRoot().getChild(folder.getFullPath().toOSString());
        projectManager.get().moveTo(child.getPath().toString(), destination.getFullPath().removeLastSegments(1).toOSString(), destination.getName(), true);
    } catch (ForbiddenException | NotFoundException | ServerException | ConflictException e) {
        throw new CoreException(new Status(IStatus.ERROR, "", "Can't move folder: " + folder.getFullPath() + " to: " + destination.getFullPath(), e));
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) ServerException(org.eclipse.che.api.core.ServerException) CoreException(org.eclipse.core.runtime.CoreException) ConflictException(org.eclipse.che.api.core.ConflictException) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) NotFoundException(org.eclipse.che.api.core.NotFoundException)

Example 64 with ConflictException

use of org.eclipse.che.api.core.ConflictException in project che by eclipse.

the class Workspace method standardMoveFile.

public void standardMoveFile(IFile file, IFile destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
    VirtualFileEntry child = null;
    try {
        child = getProjectsRoot().getChild(file.getFullPath().toOSString());
        projectManager.get().moveTo(child.getPath().toString(), destination.getFullPath().removeLastSegments(1).toOSString(), destination.getName(), true);
    } catch (ForbiddenException | ServerException | NotFoundException | ConflictException e) {
        throw new CoreException(new Status(IStatus.ERROR, "", "Can't move file: " + file.getFullPath() + " to: " + destination.getFullPath(), e));
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) ServerException(org.eclipse.che.api.core.ServerException) CoreException(org.eclipse.core.runtime.CoreException) ConflictException(org.eclipse.che.api.core.ConflictException) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) NotFoundException(org.eclipse.che.api.core.NotFoundException)

Example 65 with ConflictException

use of org.eclipse.che.api.core.ConflictException in project che by eclipse.

the class Workspace method write.

void write(File file, InputStream content, int updateFlags, boolean append, IProgressMonitor monitor) throws CoreException {
    try {
        FolderEntry projectsRoot = getProjectsRoot();
        VirtualFileEntry child = projectsRoot.getChild(file.getFullPath().toOSString());
        if (child == null) {
            projectsRoot.createFile(file.getFullPath().toOSString(), content);
        } else {
            FileEntry fileEntry = (FileEntry) child;
            fileEntry.updateContent(content);
        }
    } catch (ForbiddenException | ConflictException | ServerException e) {
        throw new CoreException(new Status(0, "", e.getMessage(), e));
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) ServerException(org.eclipse.che.api.core.ServerException) CoreException(org.eclipse.core.runtime.CoreException) ConflictException(org.eclipse.che.api.core.ConflictException) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) FileEntry(org.eclipse.che.api.project.server.FileEntry)

Aggregations

ConflictException (org.eclipse.che.api.core.ConflictException)81 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)28 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)25 ServerException (org.eclipse.che.api.core.ServerException)24 Test (org.junit.Test)24 NotFoundException (org.eclipse.che.api.core.NotFoundException)17 Path (org.eclipse.che.api.vfs.Path)12 IOException (java.io.IOException)10 NewProjectConfig (org.eclipse.che.api.core.model.project.NewProjectConfig)8 Unlocker (org.eclipse.che.commons.lang.concurrent.Unlocker)8 ArrayList (java.util.ArrayList)7 BadRequestException (org.eclipse.che.api.core.BadRequestException)7 MachineException (org.eclipse.che.api.machine.server.exception.MachineException)7 File (java.io.File)6 ProjectConfig (org.eclipse.che.api.core.model.project.ProjectConfig)6 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)6 List (java.util.List)5 Map (java.util.Map)5 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)5 String.format (java.lang.String.format)4