use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class ProjectManager method initWatcher.
void initWatcher() throws IOException {
FileWatcherNotificationListener defaultListener = new FileWatcherNotificationListener(file -> !(file.getPath().toString().contains(".che") || file.getPath().toString().contains(".#"))) {
@Override
public void onFileWatcherEvent(VirtualFile virtualFile, FileWatcherEventType eventType) {
LOG.debug("FS event detected: " + eventType + " " + virtualFile.getPath().toString() + " " + virtualFile.isFile());
}
};
fileWatchNotifier.addNotificationListener(defaultListener);
try {
fileWatcher.startup();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
fileWatchNotifier.removeNotificationListener(defaultListener);
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class ProjectManager method delete.
/**
* deletes item including project
*
* @param path
*
* @throws ServerException
* @throws ForbiddenException
* @throws NotFoundException
* @throws ConflictException
*/
public void delete(String path) throws ServerException, ForbiddenException, NotFoundException, ConflictException {
final String apath = ProjectRegistry.absolutizePath(path);
// delete item
final VirtualFile item = vfs.getRoot().getChild(Path.of(apath));
if (item != null) {
item.delete();
}
// delete child projects
projectRegistry.removeProjects(apath);
workspaceProjectsHolder.sync(projectRegistry);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class ProjectRegistry method initProjects.
@PostConstruct
public void initProjects() throws ConflictException, NotFoundException, ServerException, ForbiddenException {
List<? extends ProjectConfig> projectConfigs = workspaceHolder.getProjects();
// take all the projects from ws's config
for (ProjectConfig projectConfig : projectConfigs) {
final String path = projectConfig.getPath();
final VirtualFile vf = vfs.getRoot().getChild(Path.of(path));
final FolderEntry projectFolder = ((vf == null) ? null : new FolderEntry(vf, this));
putProject(projectConfig, projectFolder, false, false);
}
initUnconfiguredFolders();
initialized = true;
for (RegisteredProject project : projects.values()) {
// only for projects with sources
if (project.getBaseFolder() != null) {
fireInitHandlers(project);
}
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class ProjectService method exportFile.
@GET
@Path("/export/file/{path:.*}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportFile(@ApiParam(value = "Path to resource to be imported") @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException {
final FileEntry file = projectManager.asFile(path);
if (file == null) {
throw new NotFoundException("File not found " + path);
}
final VirtualFile virtualFile = file.getVirtualFile();
return Response.ok(virtualFile.getContent(), TIKA.detect(virtualFile.getName())).lastModified(new Date(virtualFile.getLastModificationDate())).header(HttpHeaders.CONTENT_LENGTH, Long.toString(virtualFile.getLength())).header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + virtualFile.getName() + '"').build();
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class SubversionProjectImporterTest method testValidImportSources.
/**
* 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)}
* with a valid url.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testValidImportSources() throws Exception {
final String projectName = NameGenerator.generate("project-", 3);
final VirtualFile virtualFile = root.createFolder(projectName);
FolderEntry projectFolder = new FolderEntry(virtualFile);
String repoUrl = Paths.get(repoRoot.getAbsolutePath()).toUri().toString();
when(sourceStorage.getLocation()).thenReturn(repoUrl);
projectImporter.importSources(projectFolder, sourceStorage, new TestUtils.SystemOutLineConsumerFactory());
assertTrue(projectFolder.getChild(".svn").isFolder());
assertTrue(projectFolder.getChild("trunk").isFolder());
assertTrue(projectFolder.getChildFolder("trunk").getChild("A").isFolder());
assertTrue(projectFolder.getChildFolder("trunk").getChildFolder("A").getChild("mu").isFile());
}
Aggregations