Skip to content

Commit

Permalink
[JBIDe-14669] corrected error message, corrected separation of concerns
Browse files Browse the repository at this point in the history
Corrected error message and moved throwing the maven import error from
import job to maven import operation
  • Loading branch information
adietish committed May 28, 2013
1 parent f7b45f7 commit 06a166d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
return Status.CANCEL_STATUS;
} catch (final ImportFailedException e) {
return OpenShiftUIActivator.createErrorStatus(
"Could not import maven project from application {0}.", e, model.getApplicationName());
"Could not import project from application {0}.", e, model.getApplicationName());
} catch (IOException e) {
return OpenShiftUIActivator.createErrorStatus(
"Could not copy openshift configuration files to project {0}", e, model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.openshift.egit.core.EGitUtils;
import org.jboss.tools.openshift.express.internal.core.connection.Connection;
import org.jboss.tools.openshift.express.internal.ui.ImportFailedException;
import org.jboss.tools.openshift.express.internal.ui.WontOverwriteException;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.wizard.application.importoperation.project.GeneralProjectImportOperation;
import org.jboss.tools.openshift.express.internal.ui.wizard.application.importoperation.project.MavenProjectImportOperation;

Expand Down Expand Up @@ -77,26 +75,12 @@ public IProject execute(IProgressMonitor monitor)
File repositoryFolder =
cloneRepository(getApplication(), getRemoteName(), cloneDestination, true, monitor);
List<IProject> importedProjects = importProjectsFrom(repositoryFolder, monitor);
if (importedProjects.size() == 0) {
String projectName = getProjectName();
if (StringUtils.isEmpty(projectName)) {
projectName = getApplication().getName();
}
throw new ImportFailedException(
NLS.bind("Could not import project {0}. One of the possible reasons is that there's already a " +
"project in your workspace that matches the openshift application/maven name of the " +
"OpenShift application. " +
"Please rename your workspace project in that case and start over again."
, projectName));
}

connectToGitRepo(importedProjects, repositoryFolder, monitor);
// TODO: handle multiple projects (is this really possible?)
IProject project = getSettingsProject(importedProjects);
addToModified(setupGitIgnore(project, monitor));
addSettingsFile(project, monitor);
addAndCommitModifiedResource(project, monitor);

return getSettingsProject(importedProjects);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
import org.eclipse.m2e.core.project.LocalProjectScanner;
import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.openshift.express.internal.ui.ImportFailedException;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;

import com.openshift.client.IApplication;

/**
* @author Andre Dietisheim <adietish@redhat.com>
Expand All @@ -49,7 +54,7 @@ public List<IProject> importToWorkspace(IProgressMonitor monitor)
ProjectImportConfiguration projectImportConfiguration = new ProjectImportConfiguration();
List<IMavenProjectImportResult> importResults =
configurationManager.importProjects(projectInfos, projectImportConfiguration, monitor);
return toProjects(importResults);
return validate(toProjects(importResults));
}

private List<IProject> toProjects(List<IMavenProjectImportResult> importResults) {
Expand All @@ -60,6 +65,20 @@ private List<IProject> toProjects(List<IMavenProjectImportResult> importResults)
projects.add(importResult.getProject());
}
}

return projects;
}

private List<IProject> validate(List<IProject> projects) {
if (projects.size() == 0) {
throw new ImportFailedException(
NLS.bind("There was a maven related error that prevented us from importing the project. "
+ "We encourage you to look into the pom in the cloned repository at {0}.\n "
+ "One of the possible reasons is that there is already a project in your workspace "
+ "that matches the maven name of the OpenShift application. "
+ "You can then rename your workspace project and start over again.\n"
, getProjectDirectory()));
}
return projects;
}

Expand Down

0 comments on commit 06a166d

Please sign in to comment.