Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JBIDe-14669] corrected error message, corrected separation of concerns #147

Merged
merged 1 commit into from
May 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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