Author: adietish
Date: 2011-09-27 11:40:34 -0400 (Tue, 27 Sep 2011)
New Revision: 35066
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/InternalUser.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/User.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Application.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Domain.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/IOpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/UserInfoAware.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/ApplicationResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/DomainResponseUnmarshaller.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestUser.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationUtils.java
Log:
[JBIDE-9773] hiding User implementation from user programmer
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/ApplicationLogReader.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -18,7 +18,7 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.Application;
import org.jboss.ide.eclipse.as.openshift.core.internal.IOpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
/**
* @author André Dietisheim
@@ -32,12 +32,12 @@
private IOpenshiftService service;
private StringReader logReader;
private Application application;
- private User user;
+ private InternalUser internalUser;
private String currentStatus;
- public ApplicationLogReader(Application application, User user, IOpenshiftService
service) {
+ public ApplicationLogReader(Application application, InternalUser internalUser,
IOpenshiftService service) {
this.application = application;
- this.user = user;
+ this.internalUser = internalUser;
this.service = service;
}
@@ -91,7 +91,7 @@
protected String requestStatus() throws IOException {
try {
- String status = service.getStatus(application.getName(), application.getCartridge(),
user);
+ String status = service.getStatus(application.getName(), application.getCartridge(),
internalUser);
if (isSameStatus(status, currentStatus)) {
status = null;
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -0,0 +1,10 @@
+package org.jboss.ide.eclipse.as.openshift.core;
+
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
+
+public class User extends InternalUser {
+
+ public User(String rhlogin, String password) {
+ super(rhlogin, password);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserFactory.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserFactory.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserFactory.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -1,11 +0,0 @@
-package org.jboss.ide.eclipse.as.openshift.core;
-
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
-
-public class UserFactory {
-
- public static IUser create(String rhlogin, String password) {
- return new User(rhlogin, password);
- }
-
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Application.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Application.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Application.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -32,13 +32,13 @@
private ApplicationLogReader logReader;
private ApplicationInfo applicationInfo;
- public Application(String name, ICartridge cartridge, User user, IOpenshiftService
service) {
- this(name, cartridge, null, user, service);
+ public Application(String name, ICartridge cartridge, InternalUser internalUser,
IOpenshiftService service) {
+ this(name, cartridge, null, internalUser, service);
}
- public Application(String name, ICartridge cartridge, ApplicationInfo applicationInfo,
User user,
+ public Application(String name, ICartridge cartridge, ApplicationInfo applicationInfo,
InternalUser internalUser,
IOpenshiftService service) {
- super(user);
+ super(internalUser);
this.name = name;
this.cartridge = cartridge;
this.service = service;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Domain.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Domain.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/Domain.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -20,12 +20,12 @@
private String namespace;
- public Domain(String namespace, User user) {
- this(namespace, null, user);
+ public Domain(String namespace, InternalUser internalUser) {
+ this(namespace, null, internalUser);
}
- public Domain(String namespace, String rhcDomain, User user) {
- super(user);
+ public Domain(String namespace, String rhcDomain, InternalUser internalUser) {
+ super(internalUser);
this.namespace = namespace;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/IOpenshiftService.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/IOpenshiftService.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/IOpenshiftService.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -22,23 +22,23 @@
*/
public interface IOpenshiftService {
- public List<ICartridge> getCartridges(User user) throws OpenshiftException;
+ public List<ICartridge> getCartridges(InternalUser internalUser) throws
OpenshiftException;
- public Application createApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException;
+ public Application createApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException;
- public void destroyApplication(String name, ICartridge cartridge, User user) throws
OpenshiftException;
+ public void destroyApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException;
- public IApplication startApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException;
+ public IApplication startApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException;
- public IApplication restartApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException;
+ public IApplication restartApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException;
- public IApplication stopApplication(String name, ICartridge cartridge, User user) throws
OpenshiftException;
+ public IApplication stopApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException;
- public String getStatus(String name, ICartridge cartridge, User user) throws
OpenshiftException;
+ public String getStatus(String name, ICartridge cartridge, InternalUser internalUser)
throws OpenshiftException;
- public IDomain changeDomain(String name, ISSHPublicKey sshKey, User user) throws
OpenshiftException;
+ public IDomain changeDomain(String name, ISSHPublicKey sshKey, InternalUser
internalUser) throws OpenshiftException;
- public IDomain createDomain(String name, ISSHPublicKey sshKey, User user) throws
OpenshiftException;
+ public IDomain createDomain(String name, ISSHPublicKey sshKey, InternalUser
internalUser) throws OpenshiftException;
- public UserInfo getUserInfo(User user) throws OpenshiftException;
+ public UserInfo getUserInfo(InternalUser internalUser) throws OpenshiftException;
}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/InternalUser.java
(from rev 35062,
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/User.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/InternalUser.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/InternalUser.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.openshift.core.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.IApplication;
+import org.jboss.ide.eclipse.as.openshift.core.ICartridge;
+import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
+import org.jboss.ide.eclipse.as.openshift.core.IUser;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+
+/**
+ * @author André Dietisheim
+ */
+public class InternalUser implements IUser {
+
+ private String rhlogin;
+ private String password;
+ private ISSHPublicKey sshKey;
+ private Domain domain;
+ private UserInfo userInfo;
+ private List<ICartridge> cartridges;
+ private List<IApplication> applications = new ArrayList<IApplication>();
+
+ private IOpenshiftService service;
+
+ public InternalUser(String rhlogin, String password) {
+ this(rhlogin, password, (ISSHPublicKey) null, new OpenshiftService());
+ }
+
+ public InternalUser(String rhlogin, String password, IOpenshiftService service) {
+ this(rhlogin, password, (ISSHPublicKey) null, service);
+ }
+
+ public InternalUser(String rhlogin, String password, ISSHPublicKey sshKey,
IOpenshiftService service) {
+ this.rhlogin = rhlogin;
+ this.password = password;
+ this.sshKey = sshKey;
+ this.service = service;
+ }
+
+ public IDomain getDomain() throws OpenshiftException {
+ if (domain == null) {
+ this.domain = new Domain(
+ getUserInfo().getNamespace()
+ , getUserInfo().getRhcDomain(), this);
+ }
+ return domain;
+ }
+
+ public ISSHPublicKey getSshKey() throws OpenshiftException {
+ if (sshKey == null) {
+ sshKey = getUserInfo().getSshPublicKey();
+ }
+ return sshKey;
+ }
+
+ public String getRhlogin() {
+ return rhlogin;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getUUID() throws OpenshiftException {
+ return getUserInfo().getUuid();
+ }
+
+ public List<ICartridge> getCartridges() throws OpenshiftException {
+ if (cartridges == null) {
+ this.cartridges = service.getCartridges(this);
+ }
+ return Collections.unmodifiableList(cartridges);
+ }
+
+ public IApplication createApplication(String name, ICartridge cartridge) throws
OpenshiftException {
+ Application application = service.createApplication(name, cartridge, this);
+ add(application);
+ return application;
+ }
+
+ public Collection<IApplication> getApplications() throws OpenshiftException {
+ if (getUserInfo().getApplicationInfos().size() > applications.size()) {
+ update(getUserInfo().getApplicationInfos());
+ }
+ return Collections.unmodifiableList(applications);
+ }
+
+ public IApplication getApplicationByName(String name) throws OpenshiftException {
+ return getApplicationByName(name, getApplications());
+ }
+
+ private IApplication getApplicationByName(String name, Collection<IApplication>
applications) {
+ IApplication matchingApplication = null;
+ for (IApplication application : applications) {
+ if (name.equals(application.getName())) {
+ matchingApplication = application;
+ }
+ }
+ return matchingApplication;
+ }
+
+ public void add(Application application) {
+ applications.add(application);
+ }
+
+ public void remove(IApplication application) {
+ applications.remove(application);
+ }
+
+ public void setSshPublicKey(ISSHPublicKey key) {
+ this.sshKey = key;
+ }
+
+ protected UserInfo getUserInfo() throws OpenshiftException {
+ if (userInfo == null) {
+ this.userInfo = service.getUserInfo(this);
+ }
+ return userInfo;
+ }
+
+ public void refresh() throws OpenshiftException {
+ this.domain = null;
+ this.sshKey = null;
+ getUserInfo();
+ }
+
+ private void update(List<ApplicationInfo> applicationInfos) {
+ for (ApplicationInfo applicationInfo : applicationInfos) {
+ IApplication application = getApplicationByName(applicationInfo.getName(),
applications);
+ if (application == null) {
+ applications.add(createApplication(applicationInfo));
+ }
+ }
+ }
+
+ private Application createApplication(ApplicationInfo applicationInfo) {
+ return new Application(applicationInfo.getName()
+ , applicationInfo.getCartridge()
+ , applicationInfo
+ , this, service);
+ }
+
+ protected IOpenshiftService getService() {
+ return service;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/InternalUser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/OpenshiftService.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -52,12 +52,12 @@
private static final String BASE_URL = "https://openshift.redhat.com/broker";
@Override
- public UserInfo getUserInfo(User user) throws OpenshiftException {
- UserInfoRequest request = new UserInfoRequest(user.getRhlogin(), true);
+ public UserInfo getUserInfo(InternalUser internalUser) throws OpenshiftException {
+ UserInfoRequest request = new UserInfoRequest(internalUser.getRhlogin(), true);
String url = request.getUrlString(BASE_URL);
try {
String requestString = new UserInfoRequestJsonMarshaller().marshall(request);
- String openShiftRequestString = new OpenshiftEnvelopeFactory(user.getPassword(),
requestString)
+ String openShiftRequestString = new
OpenshiftEnvelopeFactory(internalUser.getPassword(), requestString)
.createString();
String responseString = createHttpClient(url).post(openShiftRequestString);
responseString = JsonSanitizer.sanitize(responseString);
@@ -66,21 +66,21 @@
return response.getOpenshiftObject();
} catch (MalformedURLException e) {
throw new OpenshiftEndpointException(
- url, e, "Could not get user info for user \"{0}\" at
\"{1}\"", user.getRhlogin(), url, e);
+ url, e, "Could not get user info for user \"{0}\" at
\"{1}\"", internalUser.getRhlogin(), url, e);
} catch (HttpClientException e) {
throw new OpenshiftEndpointException(
- url, e, "Could not get user info for user \"{0}\" at
\"{1}\"", user.getRhlogin(), url, e);
+ url, e, "Could not get user info for user \"{0}\" at
\"{1}\"", internalUser.getRhlogin(), url, e);
}
}
@Override
- public List<ICartridge> getCartridges(User user) throws OpenshiftException {
- ListCartridgesRequest listCartridgesRequest = new
ListCartridgesRequest(user.getRhlogin(), true);
+ public List<ICartridge> getCartridges(InternalUser internalUser) throws
OpenshiftException {
+ ListCartridgesRequest listCartridgesRequest = new
ListCartridgesRequest(internalUser.getRhlogin(), true);
String url = listCartridgesRequest.getUrlString(BASE_URL);
try {
String listCartridgesRequestString =
new ListCartridgesRequestJsonMarshaller().marshall(listCartridgesRequest);
- String request = new OpenshiftEnvelopeFactory(user.getPassword(),
listCartridgesRequestString)
+ String request = new OpenshiftEnvelopeFactory(internalUser.getPassword(),
listCartridgesRequestString)
.createString();
String listCatridgesReponse = createHttpClient(url).post(request);
listCatridgesReponse = JsonSanitizer.sanitize(listCatridgesReponse);
@@ -95,27 +95,27 @@
}
@Override
- public IDomain createDomain(String name, ISSHPublicKey sshKey, User user) throws
OpenshiftException {
- return requestDomainAction(new CreateDomainRequest(name, sshKey, user.getRhlogin(),
true), user);
+ public IDomain createDomain(String name, ISSHPublicKey sshKey, InternalUser
internalUser) throws OpenshiftException {
+ return requestDomainAction(new CreateDomainRequest(name, sshKey,
internalUser.getRhlogin(), true), internalUser);
}
@Override
- public IDomain changeDomain(String newName, ISSHPublicKey sshKey, User user) throws
OpenshiftException {
- return requestDomainAction(new ChangeDomainRequest(newName, sshKey, user.getRhlogin(),
true), user);
+ public IDomain changeDomain(String newName, ISSHPublicKey sshKey, InternalUser
internalUser) throws OpenshiftException {
+ return requestDomainAction(new ChangeDomainRequest(newName, sshKey,
internalUser.getRhlogin(), true), internalUser);
}
- protected IDomain requestDomainAction(AbstractDomainRequest request, User user) throws
OpenshiftException {
+ protected IDomain requestDomainAction(AbstractDomainRequest request, InternalUser
internalUser) throws OpenshiftException {
String url = request.getUrlString(BASE_URL);
try {
String requestString =
new OpenshiftEnvelopeFactory(
- user.getPassword(),
+ internalUser.getPassword(),
new DomainRequestJsonMarshaller().marshall(request))
.createString();
String responseString = createHttpClient(url).post(requestString);
responseString = JsonSanitizer.sanitize(responseString);
OpenshiftResponse<IDomain> response =
- new DomainResponseUnmarshaller(request.getName(), user).unmarshall(responseString);
+ new DomainResponseUnmarshaller(request.getName(),
internalUser).unmarshall(responseString);
return response.getOpenshiftObject();
} catch (MalformedURLException e) {
throw new OpenshiftEndpointException(url, e, "Could not list available cartridges
at \"{0}\"", url);
@@ -125,35 +125,35 @@
}
@Override
- public Application createApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException {
+ public Application createApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
Application application = requestApplicationAction(new ApplicationRequest(name,
cartridge, ApplicationAction.CONFIGURE,
- user.getRhlogin(), true), user);
+ internalUser.getRhlogin(), true), internalUser);
return application;
}
@Override
- public void destroyApplication(String name, ICartridge cartridge, User user) throws
OpenshiftException {
+ public void destroyApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
IApplication application = requestApplicationAction(new ApplicationRequest(name,
cartridge, ApplicationAction.DECONFIGURE,
- user.getRhlogin(), true), user);
- user.remove(application);
+ internalUser.getRhlogin(), true), internalUser);
+ internalUser.remove(application);
}
@Override
- public IApplication startApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException {
+ public IApplication startApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
return requestApplicationAction(new ApplicationRequest(name, cartridge,
ApplicationAction.START,
- user.getRhlogin(), true), user);
+ internalUser.getRhlogin(), true), internalUser);
}
@Override
- public IApplication restartApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException {
+ public IApplication restartApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
return requestApplicationAction(new ApplicationRequest(name, cartridge,
ApplicationAction.RESTART,
- user.getRhlogin(), true), user);
+ internalUser.getRhlogin(), true), internalUser);
}
@Override
- public IApplication stopApplication(String name, ICartridge cartridge, User user) throws
OpenshiftException {
+ public IApplication stopApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
return requestApplicationAction(new ApplicationRequest(name, cartridge,
ApplicationAction.STOP,
- user.getRhlogin(), true), user);
+ internalUser.getRhlogin(), true), internalUser);
}
/**
@@ -168,14 +168,14 @@
* ,"app_name","api"],"exit_code":0}
*/
@Override
- public String getStatus(String applicationName, ICartridge cartridge, User user) throws
OpenshiftException {
+ public String getStatus(String applicationName, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
ApplicationRequest applicationRequest =
- new ApplicationRequest(applicationName, cartridge, ApplicationAction.STATUS,
user.getRhlogin(), true);
+ new ApplicationRequest(applicationName, cartridge, ApplicationAction.STATUS,
internalUser.getRhlogin(), true);
String url = applicationRequest.getUrlString(BASE_URL);
try {
String applicationRequestString =
new ApplicationRequestJsonMarshaller().marshall(applicationRequest);
- String request = new OpenshiftEnvelopeFactory(user.getPassword(),
applicationRequestString).createString();
+ String request = new OpenshiftEnvelopeFactory(internalUser.getPassword(),
applicationRequestString).createString();
String response = createHttpClient(url).post(request);
response = JsonSanitizer.sanitize(response);
@@ -191,7 +191,7 @@
url, e,
"Could not {0} application \"{1}\" at \"{2}\": Invalid
credentials user \"{3}\", password \"{4}\"",
applicationRequest.getAction().toHumanReadable(), applicationRequest.getName(),
url,
- user.getRhlogin(), user.getPassword());
+ internalUser.getRhlogin(), internalUser.getPassword());
} catch (HttpClientException e) {
throw new OpenshiftEndpointException(
url, e, "Could not {0} application \"{1}\" at
\"{2}\"",
@@ -199,19 +199,19 @@
}
}
- protected Application requestApplicationAction(ApplicationRequest applicationRequest,
User user)
+ protected Application requestApplicationAction(ApplicationRequest applicationRequest,
InternalUser internalUser)
throws OpenshiftException {
String url = applicationRequest.getUrlString(BASE_URL);
try {
String applicationRequestString =
new ApplicationRequestJsonMarshaller().marshall(applicationRequest);
- String request = new OpenshiftEnvelopeFactory(user.getPassword(),
applicationRequestString).createString();
+ String request = new OpenshiftEnvelopeFactory(internalUser.getPassword(),
applicationRequestString).createString();
String response = createHttpClient(url).post(request);
response = JsonSanitizer.sanitize(response);
OpenshiftResponse<Application> openshiftResponse =
new ApplicationResponseUnmarshaller(applicationRequest.getName(),
- applicationRequest.getCartridge(), user, this).unmarshall(response);
+ applicationRequest.getCartridge(), internalUser, this).unmarshall(response);
return openshiftResponse.getOpenshiftObject();
} catch (MalformedURLException e) {
throw new OpenshiftException(
@@ -222,8 +222,8 @@
url, e,
"Could not {0} application \"{1}\" at \"{2}\": Invalid
credentials user \"{3}\", password \"{4}\"",
applicationRequest.getAction().toHumanReadable(), applicationRequest.getName(),
url,
- user.getRhlogin(),
- user.getPassword());
+ internalUser.getRhlogin(),
+ internalUser.getPassword());
} catch (HttpClientException e) {
throw new OpenshiftEndpointException(
url, e, "Could not {0} application \"{1}\" at
\"{2}\"",
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/User.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/User.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/User.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.ide.eclipse.as.openshift.core.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.ide.eclipse.as.openshift.core.IApplication;
-import org.jboss.ide.eclipse.as.openshift.core.ICartridge;
-import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
-import org.jboss.ide.eclipse.as.openshift.core.IUser;
-import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-
-/**
- * @author André Dietisheim
- */
-public class User implements IUser {
-
- private String rhlogin;
- private String password;
- private ISSHPublicKey sshKey;
- private Domain domain;
- private UserInfo userInfo;
- private List<ICartridge> cartridges;
- private List<IApplication> applications = new ArrayList<IApplication>();
-
- private IOpenshiftService service;
-
- public User(String rhlogin, String password) {
- this(rhlogin, password, (ISSHPublicKey) null, new OpenshiftService());
- }
-
- public User(String rhlogin, String password, IOpenshiftService service) {
- this(rhlogin, password, (ISSHPublicKey) null, service);
- }
-
- public User(String rhlogin, String password, ISSHPublicKey sshKey, IOpenshiftService
service) {
- this.rhlogin = rhlogin;
- this.password = password;
- this.sshKey = sshKey;
- this.service = service;
- }
-
- @Override
- public IDomain getDomain() throws OpenshiftException {
- if (domain == null) {
- this.domain = new Domain(
- getUserInfo().getNamespace()
- , getUserInfo().getRhcDomain(), this);
- }
- return domain;
- }
-
- @Override
- public ISSHPublicKey getSshKey() throws OpenshiftException {
- if (sshKey == null) {
- sshKey = getUserInfo().getSshPublicKey();
- }
- return sshKey;
- }
-
- @Override
- public String getRhlogin() {
- return rhlogin;
- }
-
- @Override
- public String getPassword() {
- return password;
- }
-
- public String getUUID() throws OpenshiftException {
- return getUserInfo().getUuid();
- }
-
- @Override
- public List<ICartridge> getCartridges() throws OpenshiftException {
- if (cartridges == null) {
- this.cartridges = service.getCartridges(this);
- }
- return Collections.unmodifiableList(cartridges);
- }
-
- @Override
- public IApplication createApplication(String name, ICartridge cartridge) throws
OpenshiftException {
- Application application = service.createApplication(name, cartridge, this);
- add(application);
- return application;
- }
-
- @Override
- public Collection<IApplication> getApplications() throws OpenshiftException {
- if (getUserInfo().getApplicationInfos().size() > applications.size()) {
- update(getUserInfo().getApplicationInfos());
- }
- return Collections.unmodifiableList(applications);
- }
-
- @Override
- public IApplication getApplicationByName(String name) throws OpenshiftException {
- return getApplicationByName(name, getApplications());
- }
-
- private IApplication getApplicationByName(String name, Collection<IApplication>
applications) {
- IApplication matchingApplication = null;
- for (IApplication application : applications) {
- if (name.equals(application.getName())) {
- matchingApplication = application;
- }
- }
- return matchingApplication;
- }
-
- public void add(Application application) {
- applications.add(application);
- }
-
- public void remove(IApplication application) {
- applications.remove(application);
- }
-
- public void setSshPublicKey(ISSHPublicKey key) {
- this.sshKey = key;
- }
-
- public UserInfo getUserInfo() throws OpenshiftException {
- if (userInfo == null) {
- this.userInfo = service.getUserInfo(this);
- }
- return userInfo;
- }
-
- public void refresh() throws OpenshiftException {
- this.domain = null;
- this.sshKey = null;
- getUserInfo();
- }
-
- private void update(List<ApplicationInfo> applicationInfos) {
- for (ApplicationInfo applicationInfo : applicationInfos) {
- IApplication application = getApplicationByName(applicationInfo.getName(),
applications);
- if (application == null) {
- applications.add(createApplication(applicationInfo));
- }
- }
- }
-
- private Application createApplication(ApplicationInfo applicationInfo) {
- return new Application(applicationInfo.getName()
- , applicationInfo.getCartridge()
- , applicationInfo
- , this, service);
- }
-
- protected IOpenshiftService getService() {
- return service;
- }
-
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/UserInfoAware.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/UserInfoAware.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/UserInfoAware.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -15,21 +15,21 @@
public class UserInfoAware {
private UserInfo userInfo;
- private User user;
+ private InternalUser internalUser;
- protected UserInfoAware(User user) {
- this.user = user;
+ protected UserInfoAware(InternalUser internalUser) {
+ this.internalUser = internalUser;
}
protected UserInfo getUserInfo() throws OpenshiftException {
if (userInfo == null) {
- this.userInfo = user.getUserInfo();
+ this.userInfo = internalUser.getUserInfo();
}
return userInfo;
}
- protected User getUser() {
- return user;
+ protected InternalUser getUser() {
+ return internalUser;
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/ApplicationResponseUnmarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/ApplicationResponseUnmarshaller.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/ApplicationResponseUnmarshaller.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -14,27 +14,27 @@
import org.jboss.ide.eclipse.as.openshift.core.ICartridge;
import org.jboss.ide.eclipse.as.openshift.core.internal.Application;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
/**
* @author André Dietisheim
*/
public class ApplicationResponseUnmarshaller extends
AbstractOpenshiftJsonResponseUnmarshaller<Application> {
- private User user;
+ private InternalUser internalUser;
private String applicationName;
private ICartridge cartridge;
private OpenshiftService service;
- public ApplicationResponseUnmarshaller(String applicationName, ICartridge cartridge,
User user, OpenshiftService service) {
+ public ApplicationResponseUnmarshaller(String applicationName, ICartridge cartridge,
InternalUser internalUser, OpenshiftService service) {
this.applicationName = applicationName;
this.cartridge = cartridge;
- this.user = user;
+ this.internalUser = internalUser;
this.service = service;
}
@Override
protected Application createOpenshiftObject(ModelNode node) {
- return new Application(applicationName, cartridge, user, service);
+ return new Application(applicationName, cartridge, internalUser, service);
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/DomainResponseUnmarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/DomainResponseUnmarshaller.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/response/unmarshalling/DomainResponseUnmarshaller.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -13,7 +13,7 @@
import org.jboss.dmr.ModelNode;
import org.jboss.ide.eclipse.as.openshift.core.internal.Domain;
import org.jboss.ide.eclipse.as.openshift.core.internal.IDomain;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
/**
* @author André Dietisheim
@@ -21,15 +21,15 @@
public class DomainResponseUnmarshaller extends
AbstractOpenshiftJsonResponseUnmarshaller<IDomain> {
private String domainName;
- private User user;
+ private InternalUser internalUser;
- public DomainResponseUnmarshaller(String domainName, User user) {
+ public DomainResponseUnmarshaller(String domainName, InternalUser internalUser) {
this.domainName = domainName;
- this.user = user;
+ this.internalUser = internalUser;
}
@Override
protected IDomain createOpenshiftObject(ModelNode node) {
- return new Domain(domainName, user);
+ return new Domain(domainName, internalUser);
}
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -22,7 +22,7 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.Application;
import org.jboss.ide.eclipse.as.openshift.core.internal.IOpenshiftService;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestUser;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationUtils;
import org.junit.Before;
@@ -35,13 +35,13 @@
private IOpenshiftService service;
- private User user;
- private User invalidUser;
+ private InternalUser internalUser;
+ private InternalUser invalidUser;
@Before
public void setUp() {
this.service = new OpenshiftService();
- this.user = new TestUser();
+ this.internalUser = new TestUser();
this.invalidUser = new TestUser("bogusPassword");
}
@@ -55,30 +55,30 @@
String applicationName = ApplicationUtils.createRandomApplicationName();
try {
ICartridge cartridge = ICartridge.JBOSSAS_7;
- Application application = service.createApplication(applicationName, cartridge,
user);
+ Application application = service.createApplication(applicationName, cartridge,
internalUser);
assertNotNull(application);
assertEquals(applicationName, application.getName());
assertEquals(cartridge, application.getCartridge());
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@Test
public void canDestroyApplication() throws Exception {
String applicationName = ApplicationUtils.createRandomApplicationName();
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.destroyApplication(applicationName, ICartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.destroyApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
}
@Test(expected = OpenshiftException.class)
public void createDuplicateApplicationThrowsException() throws Exception {
String applicationName = ApplicationUtils.createRandomApplicationName();
try {
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -86,10 +86,10 @@
public void canStopApplication() throws Exception {
String applicationName = ApplicationUtils.createRandomApplicationName();
try {
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.stopApplication(applicationName, ICartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.stopApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -97,11 +97,11 @@
public void canStartStoppedApplication() throws Exception {
String applicationName = ApplicationUtils.createRandomApplicationName();
try {
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.stopApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.startApplication(applicationName, ICartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.stopApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.startApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -116,10 +116,10 @@
*
https://github.com/openshift/os-client-tools/blob/master/express
* /doc/API
*/
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.startApplication(applicationName, ICartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.startApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -134,11 +134,11 @@
*
https://github.com/openshift/os-client-tools/blob/master/express
* /doc/API
*/
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.stopApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.stopApplication(applicationName, ICartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.stopApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.stopApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -153,10 +153,10 @@
*
https://github.com/openshift/os-client-tools/blob/master/express
* /doc/API
*/
- service.createApplication(applicationName, ICartridge.JBOSSAS_7, user);
- service.restartApplication(applicationName, ICartridge.JBOSSAS_7, user);
+ service.createApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
+ service.restartApplication(applicationName, ICartridge.JBOSSAS_7, internalUser);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -164,11 +164,11 @@
public void canGetStatus() throws Exception {
String applicationName = ApplicationUtils.createRandomApplicationName();
try {
- Application application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, user);
- String applicationStatus = service.getStatus(application.getName(),
application.getCartridge(), user);
+ Application application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, internalUser);
+ String applicationStatus = service.getStatus(application.getName(),
application.getCartridge(), internalUser);
assertNotNull(applicationStatus);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -176,12 +176,12 @@
public void returnsValidGitUri() throws Exception {
String applicationName = ApplicationUtils.createRandomApplicationName();
try {
- IApplication application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, user);
+ IApplication application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, internalUser);
String gitUri = application.getGitUri();
assertNotNull(gitUri);
assertGitUri(applicationName, gitUri);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
@@ -189,12 +189,12 @@
public void returnsValidApplicationUrl() throws Exception {
String applicationName = ApplicationUtils.createRandomApplicationName();
try {
- IApplication application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, user);
+ IApplication application = service.createApplication(applicationName,
ICartridge.JBOSSAS_7, internalUser);
String applicationUrl = application.getApplicationUrl();
assertNotNull(applicationUrl);
assertAppliactionUrl(applicationName, applicationUrl);
} finally {
- ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, service);
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, internalUser,
service);
}
}
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -27,7 +27,7 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.Application;
import org.jboss.ide.eclipse.as.openshift.core.internal.ApplicationInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
import org.jboss.ide.eclipse.as.openshift.core.internal.UserInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.ApplicationAction;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.ApplicationRequest;
@@ -46,7 +46,7 @@
*/
public class ApplicationTest {
- private User user = new User(ApplicationResponseFake.RHLOGIN,
ApplicationResponseFake.PASSWORD,
+ private InternalUser internalUser = new InternalUser(ApplicationResponseFake.RHLOGIN,
ApplicationResponseFake.PASSWORD,
new NoopOpenshiftServiceFake());
@Test
@@ -106,7 +106,7 @@
OpenshiftResponse<Application> openshiftResponse =
new ApplicationResponseUnmarshaller(
ApplicationResponseFake.APPLICATION_NAME,
ApplicationResponseFake.APPLICATION_CARTRIDGE,
- user, new NoopOpenshiftServiceFake())
+ internalUser, new NoopOpenshiftServiceFake())
.unmarshall(response);
Application application = openshiftResponse.getOpenshiftObject();
assertNotNull(application);
@@ -117,8 +117,8 @@
@Test
public void returnsValidGitUri() throws OpenshiftException {
OpenshiftService userInfoService = createUserInfoService();
- User user = createUser(userInfoService);
- IApplication application = createApplication(userInfoService, user);
+ InternalUser internalUser = createUser(userInfoService);
+ IApplication application = createApplication(userInfoService, internalUser);
String gitUri = application.getGitUri();
assertNotNull(gitUri);
@@ -133,8 +133,8 @@
@Test
public void returnsValidApplicationUrl() throws OpenshiftException {
OpenshiftService userInfoService = createUserInfoService();
- User user = createUser(userInfoService);
- IApplication application = createApplication(userInfoService, user);
+ InternalUser internalUser = createUser(userInfoService);
+ IApplication application = createApplication(userInfoService, internalUser);
String applicationUrl = application.getApplicationUrl();
assertNotNull(applicationUrl);
@@ -160,15 +160,15 @@
OpenshiftService service = new NoopOpenshiftServiceFake() {
@Override
- public String getStatus(String applicationName, ICartridge cartridge, User user)
throws OpenshiftException {
+ public String getStatus(String applicationName, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
return ApplicationResponseFake.tail;
}
};
Application application =
new Application(ApplicationResponseFake.APPLICATION_NAME,
- ApplicationResponseFake.APPLICATION_CARTRIDGE, user, service);
- ApplicationLogReader reader = new ApplicationLogReader(application, user, service);
+ ApplicationResponseFake.APPLICATION_CARTRIDGE, internalUser, service);
+ ApplicationLogReader reader = new ApplicationLogReader(application, internalUser,
service);
int charactersRead = 0;
int character = -1;
@@ -183,7 +183,7 @@
}
}
- private IApplication createApplication(OpenshiftService userInfoService, User user) {
+ private IApplication createApplication(OpenshiftService userInfoService, InternalUser
internalUser) {
Application application = new Application(
ApplicationResponseFake.APPLICATION_NAME
, ApplicationResponseFake.APPLICATION_CARTRIDGE
@@ -193,27 +193,27 @@
, ApplicationResponseFake.APPLICATION_EMBEDDED
, ApplicationResponseFake.APPLICATION_CARTRIDGE
, ApplicationResponseFake.APPLICATION_CREATIONTIME)
- , user
+ , internalUser
, userInfoService);
/**
* we have to add it manually since we dont create the application with
- * the user class
+ * the internalUser class
*
- * @see User#createApplication
+ * @see InternalUser#createApplication
*/
- user.add(application);
+ internalUser.add(application);
return application;
}
- private User createUser(OpenshiftService userInfoService) {
- User user = new User(ApplicationResponseFake.RHLOGIN, ApplicationResponseFake.PASSWORD,
userInfoService);
- return user;
+ private InternalUser createUser(OpenshiftService userInfoService) {
+ InternalUser internalUser = new InternalUser(ApplicationResponseFake.RHLOGIN,
ApplicationResponseFake.PASSWORD, userInfoService);
+ return internalUser;
}
private OpenshiftService createUserInfoService() {
OpenshiftService userInfoService = new NoopOpenshiftServiceFake() {
@Override
- public UserInfo getUserInfo(User user) throws OpenshiftException {
+ public UserInfo getUserInfo(InternalUser internalUser) throws OpenshiftException {
ApplicationInfo applicationInfo = new ApplicationInfo(
ApplicationResponseFake.APPLICATION_NAME,
ApplicationResponseFake.APPLICATION_UUID,
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -17,7 +17,7 @@
import org.jboss.ide.eclipse.as.openshift.core.ICartridge;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestUser;
import org.junit.Before;
import org.junit.Ignore;
@@ -30,18 +30,18 @@
private OpenshiftService openshiftService;
- private User user;
+ private InternalUser internalUser;
@Before
public void setUp() {
this.openshiftService = new OpenshiftService();
- this.user = new TestUser();
+ this.internalUser = new TestUser();
}
@Ignore
@Test
public void canRequestListCartridges() throws Exception {
- List<ICartridge> cartridges = openshiftService.getCartridges(user);
+ List<ICartridge> cartridges = openshiftService.getCartridges(internalUser);
assertNotNull(cartridges);
assertTrue(cartridges.size() > 0);
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -20,7 +20,7 @@
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.SSHKeyPair;
import org.jboss.ide.eclipse.as.openshift.core.internal.IDomain;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.ChangeDomainRequest;
import org.jboss.ide.eclipse.as.openshift.core.internal.request.CreateDomainRequest;
import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftEnvelopeFactory;
@@ -62,8 +62,8 @@
String responseString = createDomainResponseString(RHLOGIN, UUID);
responseString = JsonSanitizer.sanitize(responseString);
- User user = new User(RHLOGIN, PASSWORD, new NoopOpenshiftServiceFake());
- OpenshiftResponse<IDomain> response = new DomainResponseUnmarshaller(domainName,
user).unmarshall(responseString);
+ InternalUser internalUser = new InternalUser(RHLOGIN, PASSWORD, new
NoopOpenshiftServiceFake());
+ OpenshiftResponse<IDomain> response = new DomainResponseUnmarshaller(domainName,
internalUser).unmarshall(responseString);
assertNotNull(response);
IDomain domain = response.getOpenshiftObject();
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserTest.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -30,7 +30,7 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.ApplicationInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.IDomain;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
import org.jboss.ide.eclipse.as.openshift.core.internal.UserInfo;
import org.jboss.ide.eclipse.as.openshift.core.internal.utils.RFC822DateUtils;
import
org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.CartridgeResponseFake;
@@ -45,30 +45,30 @@
public class UserTest {
private OpenshiftService userInfoservice;
- private User user;
+ private InternalUser internalUser;
@Before
public void setUp() throws OpenshiftException, DatatypeConfigurationException {
UserInfo userInfo = createUserInfo();
this.userInfoservice = createUserInfoService(userInfo);
- this.user = new User(UserInfoResponseFake.RHLOGIN, UserInfoResponseFake.PASSWORD,
userInfoservice);
+ this.internalUser = new InternalUser(UserInfoResponseFake.RHLOGIN,
UserInfoResponseFake.PASSWORD, userInfoservice);
}
@Test
public void canGetUserUUID() throws OpenshiftException {
- assertEquals(UserInfoResponseFake.UUID, user.getUUID());
+ assertEquals(UserInfoResponseFake.UUID, internalUser.getUUID());
}
@Test
public void canGetPublicKey() throws OpenshiftException {
- ISSHPublicKey key = user.getSshKey();
+ ISSHPublicKey key = internalUser.getSshKey();
assertNotNull(key);
assertEquals(UserInfoResponseFake.SSH_KEY, key.getPublicKey());
}
@Test
public void canGetDomain() throws OpenshiftException {
- IDomain domain = user.getDomain();
+ IDomain domain = internalUser.getDomain();
assertNotNull(domain);
assertEquals(UserInfoResponseFake.RHC_DOMAIN, domain.getRhcDomain());
assertEquals(UserInfoResponseFake.NAMESPACE, domain.getNamespace());
@@ -79,7 +79,7 @@
OpenshiftService cartridgeListService = new NoopOpenshiftServiceFake() {
@Override
- public List<ICartridge> getCartridges(User user) throws OpenshiftException {
+ public List<ICartridge> getCartridges(InternalUser internalUser) throws
OpenshiftException {
ArrayList<ICartridge> cartridges = new ArrayList<ICartridge>();
cartridges.add(new Cartridge(CartridgeResponseFake.CARTRIDGE_JBOSSAS70));
cartridges.add(new Cartridge(CartridgeResponseFake.CARTRIDGE_PERL5));
@@ -89,8 +89,8 @@
return cartridges;
}
};
- User user = new User(UserInfoResponseFake.RHLOGIN, UserInfoResponseFake.PASSWORD,
cartridgeListService);
- Collection<ICartridge> cartridges = user.getCartridges();
+ InternalUser internalUser = new InternalUser(UserInfoResponseFake.RHLOGIN,
UserInfoResponseFake.PASSWORD, cartridgeListService);
+ Collection<ICartridge> cartridges = internalUser.getCartridges();
assertNotNull(cartridges);
assertEquals(5, cartridges.size());
assertThatContainsCartridge(CartridgeResponseFake.CARTRIDGE_JBOSSAS70, cartridges);
@@ -103,14 +103,14 @@
@Test
public void canGetApplications() throws OpenshiftException {
/** response is UserInfoResponseFake */
- Collection<IApplication> applications = user.getApplications();
+ Collection<IApplication> applications = internalUser.getApplications();
assertNotNull(applications);
assertEquals(2, applications.size());
}
@Test
public void canGetApplicationByName() throws OpenshiftException,
DatatypeConfigurationException {
- IApplication application = user.getApplicationByName(UserInfoResponseFake.APP2_NAME);
+ IApplication application =
internalUser.getApplicationByName(UserInfoResponseFake.APP2_NAME);
assertApplication(
UserInfoResponseFake.APP2_NAME
, UserInfoResponseFake.APP2_UUID
@@ -146,7 +146,7 @@
return new NoopOpenshiftServiceFake() {
@Override
- public UserInfo getUserInfo(User user) throws OpenshiftException {
+ public UserInfo getUserInfo(InternalUser internalUser) throws OpenshiftException {
return userInfo;
}
};
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/NoopOpenshiftServiceFake.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -19,7 +19,7 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.Application;
import org.jboss.ide.eclipse.as.openshift.core.internal.IDomain;
import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
import org.jboss.ide.eclipse.as.openshift.core.internal.UserInfo;
/**
@@ -28,52 +28,52 @@
public class NoopOpenshiftServiceFake extends OpenshiftService {
@Override
- public UserInfo getUserInfo(User user) throws OpenshiftException {
+ public UserInfo getUserInfo(InternalUser internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public List<ICartridge> getCartridges(User user) throws OpenshiftException {
+ public List<ICartridge> getCartridges(InternalUser internalUser) throws
OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public Application createApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException {
+ public Application createApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public void destroyApplication(String name, ICartridge cartridge, User user) throws
OpenshiftException {
+ public void destroyApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public IApplication startApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException {
+ public IApplication startApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public IApplication restartApplication(String name, ICartridge cartridge, User user)
throws OpenshiftException {
+ public IApplication restartApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public IApplication stopApplication(String name, ICartridge cartridge, User user) throws
OpenshiftException {
+ public IApplication stopApplication(String name, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public String getStatus(String applicationName, ICartridge cartridge, User user) throws
OpenshiftException {
+ public String getStatus(String applicationName, ICartridge cartridge, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public IDomain changeDomain(String domainName, ISSHPublicKey sshKey, User user) throws
OpenshiftException {
+ public IDomain changeDomain(String domainName, ISSHPublicKey sshKey, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
@Override
- public IDomain createDomain(String name, ISSHPublicKey keyPair, User user) throws
OpenshiftException {
+ public IDomain createDomain(String name, ISSHPublicKey keyPair, InternalUser
internalUser) throws OpenshiftException {
throw new UnsupportedOperationException();
}
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestUser.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestUser.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestUser.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -13,13 +13,13 @@
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
import org.jboss.ide.eclipse.as.openshift.core.IApplication;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
import org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationUtils;
/**
* @author André Dietisheim
*/
-public class TestUser extends User {
+public class TestUser extends InternalUser {
private static final String RHLOGIN = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationUtils.java 2011-09-27
15:39:43 UTC (rev 35065)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationUtils.java 2011-09-27
15:40:34 UTC (rev 35066)
@@ -15,7 +15,7 @@
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.internal.Application;
import org.jboss.ide.eclipse.as.openshift.core.internal.IOpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.internal.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
/**
* @author André Dietisheim
@@ -26,13 +26,13 @@
return String.valueOf(System.currentTimeMillis());
}
- public static Application createApplication(User user, IOpenshiftService service) throws
OpenshiftException {
- return service.createApplication(createRandomApplicationName(), Cartridge.JBOSSAS_7,
user);
+ public static Application createApplication(InternalUser internalUser, IOpenshiftService
service) throws OpenshiftException {
+ return service.createApplication(createRandomApplicationName(), Cartridge.JBOSSAS_7,
internalUser);
}
- public static void silentlyDestroyAS7Application(String name, User user,
IOpenshiftService service) {
+ public static void silentlyDestroyAS7Application(String name, InternalUser internalUser,
IOpenshiftService service) {
try {
- service.destroyApplication(name, ICartridge.JBOSSAS_7, user);
+ service.destroyApplication(name, ICartridge.JBOSSAS_7, internalUser);
} catch (OpenshiftException e) {
e.printStackTrace();
}