~ubuntu-branches/ubuntu/raring/eucalyptus/raring

« back to all changes in this revision

Viewing changes to clc/modules/www/test-gwt/src/edu/ucsb/eucalyptus/admin/server/EucalyptusWebBackendImpl.java

  • Committer: Package Import Robot
  • Author(s): Brian Thomason
  • Date: 2011-11-29 13:17:52 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 185.
  • Revision ID: package-import@ubuntu.com-20111129131752-rq31al3ntutv2vvl
Tags: upstream-3.0.999beta1
ImportĀ upstreamĀ versionĀ 3.0.999beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 *Copyright (c) 2009  Eucalyptus Systems, Inc.
3
 
 * 
4
 
 *  This program is free software: you can redistribute it and/or modify
5
 
 *  it under the terms of the GNU General Public License as published by
6
 
 *  the Free Software Foundation, only version 3 of the License.
7
 
 * 
8
 
 * 
9
 
 *  This file is distributed in the hope that it will be useful, but WITHOUT
10
 
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 
 *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 
 *  for more details.
13
 
 * 
14
 
 *  You should have received a copy of the GNU General Public License along
15
 
 *  with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
 * 
17
 
 *  Please contact Eucalyptus Systems, Inc., 130 Castilian
18
 
 *  Dr., Goleta, CA 93101 USA or visit <http://www.eucalyptus.com/licenses/>
19
 
 *  if you need additional information or have any questions.
20
 
 * 
21
 
 *  This file may incorporate work covered under the following copyright and
22
 
 *  permission notice:
23
 
 * 
24
 
 *    Software License Agreement (BSD License)
25
 
 * 
26
 
 *    Copyright (c) 2008, Regents of the University of California
27
 
 *    All rights reserved.
28
 
 * 
29
 
 *    Redistribution and use of this software in source and binary forms, with
30
 
 *    or without modification, are permitted provided that the following
31
 
 *    conditions are met:
32
 
 * 
33
 
 *      Redistributions of source code must retain the above copyright notice,
34
 
 *      this list of conditions and the following disclaimer.
35
 
 * 
36
 
 *      Redistributions in binary form must reproduce the above copyright
37
 
 *      notice, this list of conditions and the following disclaimer in the
38
 
 *      documentation and/or other materials provided with the distribution.
39
 
 * 
40
 
 *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
41
 
 *    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
42
 
 *    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
43
 
 *    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
44
 
 *    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45
 
 *    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
46
 
 *    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
47
 
 *    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
48
 
 *    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
49
 
 *    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50
 
 *    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. USERS OF
51
 
 *    THIS SOFTWARE ACKNOWLEDGE THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE
52
 
 *    LICENSED MATERIAL, COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS
53
 
 *    SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
54
 
 *    IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
55
 
 *    BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
56
 
 *    THE REGENTSā€™ DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
57
 
 *    OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
58
 
 *    WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
59
 
 *    ANY SUCH LICENSES OR RIGHTS.
60
 
 *******************************************************************************/
61
 
/*
62
 
 *
63
 
 * Author: Dmitrii Zagorodnov dmitrii@cs.ucsb.edu
64
 
 */
65
 
 
66
 
package edu.ucsb.eucalyptus.admin.server;
67
 
 
68
 
import java.util.ArrayList;
69
 
import java.util.HashMap;
70
 
import java.util.HashSet;
71
 
import java.util.List;
72
 
import java.util.Set;
73
 
 
74
 
import com.google.gwt.user.client.rpc.SerializableException;
75
 
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
76
 
 
77
 
import edu.ucsb.eucalyptus.admin.client.CloudInfoWeb;
78
 
import edu.ucsb.eucalyptus.admin.client.ClusterInfoWeb;
79
 
import edu.ucsb.eucalyptus.admin.client.DownloadsWeb;
80
 
import edu.ucsb.eucalyptus.admin.client.EucalyptusWebBackend;
81
 
import edu.ucsb.eucalyptus.admin.client.StorageInfoWeb;
82
 
import edu.ucsb.eucalyptus.admin.client.SystemConfigWeb;
83
 
import edu.ucsb.eucalyptus.admin.client.UserInfoWeb;
84
 
import edu.ucsb.eucalyptus.admin.client.VmTypeWeb;
85
 
import edu.ucsb.eucalyptus.admin.client.WalrusInfoWeb;
86
 
 
87
 
/**
88
 
 * Created by IntelliJ IDEA.
89
 
 * User: dmitriizagorodnov
90
 
 * Date: May 3, 2008
91
 
 * Time: 2:57:31 PM
92
 
 * To change this template use File | Settings | File Templates.
93
 
 */
94
 
public class EucalyptusWebBackendImpl extends RemoteServiceServlet implements EucalyptusWebBackend {
95
 
 
96
 
        static UserInfoWeb adminUser = new UserInfoWeb();
97
 
        static Set<UserInfoWeb> users = new HashSet<UserInfoWeb>();
98
 
        
99
 
        static {
100
 
                adminUser.setUserName("admin");
101
 
                adminUser.setIsAdministrator(true); // so we see all tabs
102
 
                adminUser.setIsApproved(true);
103
 
                adminUser.setIsConfirmed(true);
104
 
                adminUser.setIsEnabled(true);
105
 
                adminUser.setEmail("foo@bar"); // so we skip first-time login screen
106
 
                users.add(adminUser);
107
 
                
108
 
                for (int i=0; i<9; i++) {
109
 
                        UserInfoWeb newUser = new UserInfoWeb();
110
 
                        newUser.setUserName("user" + i);
111
 
                        newUser.setEmail("foo" + i + "@bar");
112
 
                        newUser.setIsAdministrator(false);
113
 
                        newUser.setIsApproved((i%2==0)?false:true);
114
 
                        newUser.setIsConfirmed((i%3==0)?false:true);
115
 
                        newUser.setIsEnabled((i%4==0)?false:true);
116
 
                        users.add(newUser);
117
 
                }
118
 
        }
119
 
        
120
 
        public String addUserRecord ( UserInfoWeb user )
121
 
        throws SerializableException
122
 
        {
123
 
                return addUserRecord(null, user);
124
 
        }
125
 
 
126
 
        public String addUserRecord(String sessionId, UserInfoWeb user)
127
 
        throws SerializableException
128
 
        {
129
 
                users.add(user);
130
 
                return "OK";
131
 
        }
132
 
 
133
 
        public String recoverPassword ( UserInfoWeb web_user )
134
 
        throws SerializableException
135
 
        {
136
 
                return "OK";
137
 
        }
138
 
 
139
 
        public String getNewSessionID (String userId, String md5Password)
140
 
        throws SerializableException
141
 
        {
142
 
                return "session-id";
143
 
        }
144
 
 
145
 
        public String performAction (String sessionId, String action, String param)
146
 
        throws SerializableException
147
 
        {
148
 
                return "OK";
149
 
        }
150
 
 
151
 
        public void logoutSession(String sessionId)
152
 
        throws SerializableException
153
 
        {
154
 
 
155
 
        }
156
 
 
157
 
        public List getUserRecord (String sessionId, String userId)
158
 
        throws SerializableException
159
 
        {
160
 
                if (userId==null) {
161
 
                        List l = new ArrayList();
162
 
                        l.add(adminUser);
163
 
                        return l;
164
 
                } else {
165
 
                        return new ArrayList(users);
166
 
                }
167
 
        }
168
 
 
169
 
        public static UserInfoWeb getUserRecord (String sessionId) // a *static* getUserRecord, for ImageStoreService
170
 
        throws SerializableException
171
 
        {
172
 
                return adminUser;
173
 
        }
174
 
 
175
 
        public List getImageInfo (String sessionId, String userId)
176
 
        throws SerializableException
177
 
        {
178
 
                return new ArrayList();
179
 
        }
180
 
 
181
 
        /* from here on down, all requests require users to be enabled, approved, and confirmed */
182
 
 
183
 
        public String getNewCert(String sessionId)
184
 
        throws SerializableException
185
 
        {
186
 
                return "cert";
187
 
        }
188
 
 
189
 
        public HashMap getProperties()
190
 
        throws SerializableException
191
 
        {
192
 
                HashMap h = new HashMap();
193
 
                h.put("ready", true);
194
 
                h.put("cloud-name", "Back-end stub");
195
 
                h.put("version", "1.6.2");
196
 
                h.put("signup-greeting", "<signup greeting>");
197
 
                h.put("certificate-download-text", "<certificate-download-text>");
198
 
                h.put("rest-credentials-text", "<rest-credentials-text>");
199
 
                h.put("user-account-text", "user-account-text");
200
 
                h.put("admin-first-time-config-text", "admin-first-time-config-text");
201
 
                h.put("admin-email-change-text", "admin-email-change-text");
202
 
                h.put("admin-cloud-ip-setup-text", "admin-cloud-ip-setup-text");
203
 
                return h;
204
 
        }
205
 
 
206
 
        public String changePassword (String sessionId, String oldPassword, String newPassword )
207
 
        throws SerializableException
208
 
        {
209
 
                return "OK";
210
 
        }
211
 
 
212
 
        public String updateUserRecord (String sessionId, UserInfoWeb newRecord )
213
 
        throws SerializableException
214
 
        {
215
 
                return "OK";
216
 
        }
217
 
 
218
 
        public List<ClusterInfoWeb> getClusterList(String sessionId) throws SerializableException
219
 
        {
220
 
                ArrayList<ClusterInfoWeb> a = new ArrayList<ClusterInfoWeb>();
221
 
                ClusterInfoWeb c = new ClusterInfoWeb("CLUSTER", "hostname", 43210, 44, 55);
222
 
                a.add(c);
223
 
                return a;
224
 
        }
225
 
 
226
 
        public void setClusterList(String sessionId, List<ClusterInfoWeb> clusterList ) throws SerializableException
227
 
        {
228
 
 
229
 
        }
230
 
 
231
 
        public List<StorageInfoWeb> getStorageList(String sessionId) throws SerializableException
232
 
        {
233
 
                ArrayList<StorageInfoWeb> a = new ArrayList<StorageInfoWeb>();
234
 
                StorageInfoWeb s = new StorageInfoWeb("CLUSTER", "hostname", 54321, 55, 555, new ArrayList<String>());
235
 
                a.add(s);
236
 
                return a;
237
 
        }
238
 
 
239
 
        public void setStorageList(String sessionId, List<StorageInfoWeb> storageList ) throws SerializableException
240
 
        {
241
 
 
242
 
        }
243
 
 
244
 
        public List<WalrusInfoWeb> getWalrusList(String sessionId) throws SerializableException
245
 
        {
246
 
                return new ArrayList<WalrusInfoWeb>();
247
 
        }
248
 
 
249
 
        public void setWalrusList(String sessionId, List<WalrusInfoWeb> walrusList ) throws SerializableException
250
 
        {
251
 
 
252
 
        }
253
 
 
254
 
        public SystemConfigWeb getSystemConfig( final String sessionId ) throws SerializableException
255
 
        {
256
 
                SystemConfigWeb c = new SystemConfigWeb();
257
 
                c.setDoDynamicPublicAddresses(false);
258
 
                return c;
259
 
        }
260
 
 
261
 
        public void setSystemConfig( final String sessionId, final SystemConfigWeb systemConfig ) throws SerializableException
262
 
        {
263
 
 
264
 
        }
265
 
 
266
 
        public List<VmTypeWeb> getVmTypes( final String sessionId ) throws SerializableException
267
 
        {
268
 
                return new ArrayList<VmTypeWeb>();
269
 
        }
270
 
 
271
 
        public void setVmTypes( final String sessionId, final List<VmTypeWeb> vmTypes ) throws SerializableException
272
 
        {
273
 
 
274
 
        }
275
 
 
276
 
        public CloudInfoWeb getCloudInfo(final String sessionId, final boolean setExternalHostPort) throws SerializableException
277
 
        {
278
 
                return new CloudInfoWeb();
279
 
        }
280
 
 
281
 
        private static List<DownloadsWeb> getDownloadsFromUrl(final String downloadsUrl) {
282
 
                return new ArrayList<DownloadsWeb>();
283
 
        }
284
 
 
285
 
        public List<DownloadsWeb> getDownloads(final String sessionId, final String downloadsUrl) throws SerializableException {
286
 
                return new ArrayList<DownloadsWeb>();
287
 
        }
288
 
}