Author: adietish
Date: 2012-05-16 06:44:57 -0400 (Wed, 16 May 2012)
New Revision: 41052
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgeStrategy.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategyAdapter.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/EmbedCartridgeStrategyTest.java
Log:
[JBIDE-11880] fixed NPE when trying to get the domain from the application when there was
no application yet (was the case in the "new application wizard").
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgeStrategy.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgeStrategy.java 2012-05-16
10:43:54 UTC (rev 41051)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/EmbedCartridgeStrategy.java 2012-05-16
10:44:57 UTC (rev 41052)
@@ -20,6 +20,7 @@
import com.openshift.client.IApplication;
import com.openshift.client.ICartridge;
+import com.openshift.client.IDomain;
import com.openshift.client.IEmbeddableCartridge;
import com.openshift.client.OpenShiftException;
@@ -54,10 +55,10 @@
private Map<IEmbeddableCartridge, EmbeddableCartridgeRelations>
dependenciesByCartridge;
private HashMap<IEmbeddableCartridge, Set<IEmbeddableCartridge>>
dependantsByCartridge;
- private IApplication application;
+ private IDomain domain;
- public EmbedCartridgeStrategy(IApplication application) {
- this.application = application;
+ public EmbedCartridgeStrategy(IDomain domain) {
+ this.domain = domain;
initDependencyMaps(dependencies);
}
@@ -115,7 +116,7 @@
private void addRequiredApplication(EmbeddableCartridgeDiff diff,
EmbeddableCartridgeRelations relation) throws OpenShiftException {
if (relation.getRequiredApplication() != null
- &&
!application.getDomain().hasApplicationByCartridge(relation.getRequiredApplication())) {
+ && !domain.hasApplicationByCartridge(relation.getRequiredApplication())) {
diff.addApplicationAddition(relation.getRequiredApplication());
}
}
@@ -155,9 +156,9 @@
private static class EmbeddableCartridgeRelations {
+ private IEmbeddableCartridge subject;
private IEmbeddableCartridge conflicting;
private IEmbeddableCartridge required;
- private IEmbeddableCartridge subject;
private ICartridge requiredApplication;
protected EmbeddableCartridgeRelations(IEmbeddableCartridge cartridge,
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-05-16
10:43:54 UTC (rev 41051)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-05-16
10:44:57 UTC (rev 41052)
@@ -27,6 +27,7 @@
import com.openshift.client.ApplicationScale;
import com.openshift.client.IApplication;
import com.openshift.client.ICartridge;
+import com.openshift.client.IDomain;
import com.openshift.client.IEmbeddableCartridge;
import com.openshift.client.IGearProfile;
import com.openshift.client.OpenShiftException;
@@ -415,8 +416,9 @@
return getUser().hasApplication(applicationName);
}
- public IApplication getApplication() {
- return wizardModel.getApplication();
+ @Override
+ public IDomain getDomain() throws SocketTimeoutException, OpenShiftException {
+ return wizardModel.getUser().getDefaultDomain();
}
public IApplication createJenkinsApplication(String name, IProgressMonitor monitor)
throws OpenShiftException {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategyAdapter.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategyAdapter.java 2012-05-16
10:43:54 UTC (rev 41051)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeStrategyAdapter.java 2012-05-16
10:44:57 UTC (rev 41052)
@@ -64,7 +64,7 @@
try {
IEmbeddableCartridge cartridge = (IEmbeddableCartridge) event.getElement();
EmbeddableCartridgeDiff diff = null;
- EmbedCartridgeStrategy embedCartridgeStrategy = new
EmbedCartridgeStrategy(pageModel.getApplication());
+ EmbedCartridgeStrategy embedCartridgeStrategy = new
EmbedCartridgeStrategy(pageModel.getDomain());
diff = createEmbeddableCartridgeDiff(event.getChecked(), cartridge,
embedCartridgeStrategy);
if (diff.hasChanges()) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java 2012-05-16
10:43:54 UTC (rev 41051)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/EmbedCartridgeWizardPageModel.java 2012-05-16
10:44:57 UTC (rev 41052)
@@ -24,6 +24,7 @@
import com.openshift.client.ApplicationScale;
import com.openshift.client.IApplication;
import com.openshift.client.ICartridge;
+import com.openshift.client.IDomain;
import com.openshift.client.IEmbeddableCartridge;
import com.openshift.client.IEmbeddedCartridge;
import com.openshift.client.IGearProfile;
@@ -100,12 +101,16 @@
return wizardModel.getUser().hasApplicationOfType(cartridge);
}
- @Override
public IApplication getApplication() {
return wizardModel.getApplication();
}
@Override
+ public IDomain getDomain() throws SocketTimeoutException, OpenShiftException {
+ return wizardModel.getUser().getDefaultDomain();
+ }
+
+ @Override
public void selectEmbeddedCartridges(IEmbeddableCartridge cartridge)
throws OpenShiftException,SocketTimeoutException {
getSelectedEmbeddableCartridges().add(cartridge);
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java 2012-05-16
10:43:54 UTC (rev 41051)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/IEmbedCartridgesWizardPageModel.java 2012-05-16
10:44:57 UTC (rev 41052)
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import com.openshift.client.IApplication;
+import com.openshift.client.IDomain;
import com.openshift.client.IEmbeddableCartridge;
import com.openshift.client.OpenShiftException;
@@ -36,7 +37,7 @@
public boolean isSelected(IEmbeddableCartridge cartridge) throws OpenShiftException,
SocketTimeoutException;
- public IApplication getApplication();
+ public IDomain getDomain() throws SocketTimeoutException, OpenShiftException;
public IApplication createJenkinsApplication(String name, IProgressMonitor monitor)
throws OpenShiftException;
Modified:
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/EmbedCartridgeStrategyTest.java
===================================================================
---
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/EmbedCartridgeStrategyTest.java 2012-05-16
10:43:54 UTC (rev 41051)
+++
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/EmbedCartridgeStrategyTest.java 2012-05-16
10:44:57 UTC (rev 41052)
@@ -10,8 +10,8 @@
******************************************************************************/
package org.jboss.tools.openshift.express.test;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -52,8 +52,7 @@
@Before
public void setUp() throws SocketTimeoutException, OpenShiftException {
this.domainFake = new DomainFake();
- IApplication applicationFake = domainFake.createApplication("adietish",
ICartridge.JBOSSAS_7);
- this.embedStrategy = new EmbedCartridgeStrategy(applicationFake);
+ this.embedStrategy = new EmbedCartridgeStrategy(domainFake);
}
@Test