use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class SubversionProjectImporterTest method testInvalidImportSources.
/**
* Test for {@link SubversionProjectImporter#importSources(org.eclipse.che.api.project.server.FolderEntry, org.eclipse.che.api.core.model.project.SourceStorage, org.eclipse.che.api.core.util.LineConsumerFactory)}
* invalid url.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testInvalidImportSources() throws Exception {
final String projectName = NameGenerator.generate("project-", 3);
//root.getChild(org.eclipse.che.api.vfs.Path.of(projectName));
final VirtualFile virtualFile = root.createFolder(projectName);
FolderEntry projectFolder = new FolderEntry(virtualFile);
try {
String fakeUrl = Paths.get(repoRoot.getAbsolutePath()).toUri() + "fake";
when(sourceStorage.getLocation()).thenReturn(fakeUrl);
projectImporter.importSources(projectFolder, sourceStorage, new TestUtils.SystemOutLineConsumerFactory());
fail("The code above should had failed");
} catch (SubversionException e) {
final String message = e.getMessage();
boolean assertBoolean = Pattern.matches("svn: (E[0-9]{6}: )?URL 'file://.*/fake' doesn't exist\n?", message.trim());
assertTrue(message, assertBoolean);
}
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class SubversionValueProviderFactory method isSvn.
private boolean isSvn(final FolderEntry project) throws ForbiddenException, ServerException {
LOG.debug("Searching for '.svn' in {}.", project.getPath());
final VirtualFileEntry svn = project.getChild(".svn");
if (svn != null && svn instanceof FolderEntry) {
LOG.debug("Found it.");
return true;
} else {
LOG.debug("Didn't find it.");
return false;
}
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class Workspace method createResource.
public void createResource(IResource resource, int updateFlags) throws CoreException {
try {
IPath path = resource.getFullPath();
switch(resource.getType()) {
case IResource.FILE:
String newName = path.lastSegment();
VirtualFileEntry child = getProjectsRoot().getChild(path.removeLastSegments(1).toOSString());
if (child == null) {
throw new NotFoundException("Can't find parent folder: " + path.removeLastSegments(1).toOSString());
}
FolderEntry entry = (FolderEntry) child;
entry.createFile(newName, new byte[0]);
break;
case IResource.FOLDER:
getProjectsRoot().createFolder(path.toOSString());
break;
case IResource.PROJECT:
ProjectConfigImpl projectConfig = new ProjectConfigImpl();
projectConfig.setPath(resource.getName());
projectConfig.setName(resource.getName());
projectConfig.setType(BaseProjectType.ID);
projectManager.get().createProject(projectConfig, new HashMap<>());
break;
default:
throw new UnsupportedOperationException();
}
} catch (ForbiddenException | ConflictException | ServerException | NotFoundException e) {
throw new CoreException(new Status(0, ResourcesPlugin.getPluginId(), e.getMessage(), e));
}
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class JsonExampleCreateProjectHandler method onCreateProject.
@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
try (InputStream packageJson = getClass().getClassLoader().getResourceAsStream("files/default_package");
InputStream personJson = getClass().getClassLoader().getResourceAsStream("files/default_person")) {
FolderEntry myJsonFiles = baseFolder.createFolder("myJsonFiles");
baseFolder.createFile(FILE_NAME, packageJson);
myJsonFiles.createFile("person.json", personJson);
} catch (IOException ioEx) {
throw new ServerException(ioEx.getLocalizedMessage(), ioEx);
}
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class GitService method deleteRepository.
@DELETE
@Path("repository")
public void deleteRepository(@Context UriInfo uriInfo) throws ApiException {
final RegisteredProject project = projectRegistry.getProject(projectPath);
final FolderEntry gitFolder = project.getBaseFolder().getChildFolder(".git");
gitFolder.getVirtualFile().delete();
projectRegistry.removeProjectType(projectPath, GitProjectType.TYPE_ID);
}
Aggregations