*/
private IProject createIProject(String name, final java.net.URI hdfsURI) {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject project = workspace.getRoot().getProject(name);
final IProjectDescription pd = workspace.newProjectDescription(name);
WorkspaceJob operation = new WorkspaceJob("Adding HDFS Location") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Creating Project", 100);
try {
pd.setLocationURI(hdfsURI);
project.create(pd, new SubProgressMonitor(monitor, 70));
project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 30));
RepositoryProvider.map(project, HDFSTeamRepositoryProvider.ID);
return Status.OK_STATUS;
} catch (final CoreException e) {
logger.error("error found in creating HDFS site", e);
Display.getDefault().syncExec(new Runnable(){
public void run(){
MessageDialog.openError(Display.getDefault().getActiveShell(),
"HDFS Error", "Unable to create HDFS site :"+e.getMessage());
}
});
deleteServer(getServer(hdfsURI.toString()));
return e.getStatus();
} finally {
monitor.done();
}
}
};
operation.setPriority(Job.LONG);
operation.setUser(true);
operation.setRule(project);
operation.schedule();
return project;
}