Source Code Cross Referenced for ServerData.java in  » Net » SkunkDAV » org » skunk » dav » client » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » SkunkDAV » org.skunk.dav.client.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:/*  $Id: ServerData.java,v 1.19 2001/07/29 22:37:36 smulloni Exp $
002: *  Time-stamp: <01/07/27 15:21:32 smulloni>
003: *
004: *  Copyright (c) 2000-2001, Jacob Smullyan.
005: *
006: *  This is part of SkunkDAV, a WebDAV client.  See http://skunkdav.sourceforge.net/ 
007: *  for the latest version.
008: * 
009: *  SkunkDAV is free software; you can redistribute it and/or
010: *  modify it under the terms of the GNU General Public License as published
011: *  by the Free Software Foundation; either version 2, or (at your option)
012: *  any later version.
013: * 
014: *  SkunkDAV  is distributed in the hope that it will be useful,
015: *  but WITHOUT ANY WARRANTY; without even the implied warranty of
016: *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017: *  General Public License for more details.
018: * 
019: *  You should have received a copy of the GNU General Public License
020: *  along with SkunkDAV; see the file COPYING.  If not, write to the Free
021: *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
022: *  02111-1307, USA.
023:*/
024:
025:package org.skunk.dav.client.gui;
026:
027:import java.io.IOException;
028:import java.io.Serializable;
029:import java.util.Enumeration;
030:import java.util.Vector;
031:import org.skunk.assert.Assertion;
032:import org.skunk.config.LocalConfigStore;
033:import org.skunk.config.Configurator;
034:import org.skunk.dav.client.DAVConstants;
035:import org.skunk.trace.Debug;
036:
037:/**
038: *  encapsulates data about a DAV server.
039: */
040:public class ServerData implements  Cloneable, Serializable
041:{
042:    static final long serialVersionUID = -6873822752692653196L;
043:    protected static ServerDataContainer container=new ServerDataContainer();
044: 
045:    public static void init()
046:    {
047:	try
048:	{
049:	    loadServerList();
050:	}
051:	catch (Exception e)
052:	{
053:	    Debug.trace(ServerData.class, Debug.DP2, e);
054:	    container.setServerDataVector(new Vector());
055:	}
056:    }
057:    
058:    private String host, initialPath, username, password;
059:    private int port;
060:    private boolean permitsLockStealing=true;
061:    private boolean https=false;
062:    private boolean rememberPassword=false;
063:    private String owner=null;
064:    private boolean touched=false;
065:
066:    public ServerData(boolean https,
067:		      String host,
068:		      int port,
069:		      String initialPath,
070:		      String username,
071:		      String password)
072:    {
073:	this (https, 
074:	     host, 
075:	     port, 
076:	     initialPath, 
077:	     username, 
078:	     password, 
079:	     false);
080:    }
081:
082:    public ServerData(boolean https,
083:		      String host,
084:		      int port,
085:		      String initialPath,
086:		      String username,
087:		      String password,
088:		      boolean rememberPassword)
089:    {
090:	this (https, host, port, initialPath, username, password, rememberPassword, true);
091:    }
092:    
093:    public ServerData(boolean https, 
094:		      String host, 
095:		      int port, 
096:		      String initialPath, 
097:		      String username, 
098:		      String password,
099:		      boolean rememberPassword,
100:		      boolean autotouch)
101:    {
102:	this .https=https;
103:	this .host=host;
104:	this .port=port;
105:	this .initialPath=correctPath(initialPath);
106:	this .username=username;
107:	this .password=password;
108:	this .rememberPassword=rememberPassword;
109:	if (autotouch)
110:	try
111:	{
112:	    touch(this );	
113:	}
114:	catch (IOException oyVeh)
115:	{
116:	    Debug.trace(this , Debug.DP2, oyVeh);
117:	}
118:    }
119:
120:    public ServerData(String host, 
121:		      int port, 
122:		      String initialPath, 
123:		      String username, 
124:		      String password)
125:    {
126:	this (false, 
127:	     host, 
128:	     port, 
129:	     initialPath, 
130:	     username, 
131:	     password,
132:	     false);
133:    }
134:
135:    public boolean usesSSL() 
136:    { 
137:	return https; 
138:    }
139:
140:    public void setUsesSSL(boolean https) 
141:    { 
142:	this .https=https; 
143:    }
144:    
145:    public String getHost() 
146:    { 
147:	return host; 
148:    }
149:
150:    public void setHost(String host) 
151:    { 
152:	this .host=host; 
153:    }
154:
155:    public int getPort() 
156:    { 
157:	return port; 
158:    }
159:
160:    public void setPort(int port) 
161:    { 
162:	this .port=port; 
163:    }
164:
165:    public String getInitialPath() 
166:    { 
167:	return initialPath; 
168:    }
169:
170:    public void setInitialPath(String initialPath) 
171:    { 
172:	this .initialPath=correctPath(initialPath); 
173:    }
174:
175:    public String getUsername() { return username; }
176:
177:    public void setUsername(String username)
178:    {
179:	this .username=username;
180:    }
181:
182:    public String getPassword() { return password; }
183:
184:    public void setPassword(String password)
185:    {
186:	this .password=password;
187:    }
188:
189:    /**
190:     * whether or not password information for the server should be
191:     * saved.
192:     * @return whether or not to remember the password.
193:     */
194:    public boolean getRememberPassword() 
195:    { 
196:	return rememberPassword; 
197:    }
198:
199:    public void setRememberPassword(boolean rememberPassword) 
200:    { 
201:	this .rememberPassword=rememberPassword; 
202:    }
203:
204:    public boolean getPermitsLockStealing() 
205:    { 
206:	return this .permitsLockStealing; 
207:    }
208:    
209:    public void setPermitsLockStealing(boolean permitsLockStealing) 
210:    { 
211:	this .permitsLockStealing=permitsLockStealing; 
212:	Debug.trace(this , Debug.DP3, 
213:		    "permitsLockStealing set to " 
214:		    + permitsLockStealing 
215:		    + " for {0}",
216:		    this );
217:	try
218:	{
219:	    saveServers();
220:	}
221:	catch (IOException oyVeh)
222:	{
223:	    Debug.trace(this , Debug.DP2, oyVeh);
224:	}
225:    }
226:
227:    public String getOwner() { return this .owner; }
228:
229:    public void setOwner(String owner)
230:    {
231:	this .owner=owner;
232:    }
233:	       
234:    public String toString() 
235:    { 
236:	return makeString(https, host, port, initialPath);
237:    }
238:
239:    private static String makeString(String host, 
240:				     int port, 
241:				     String initialPath)
242:    {
243:	return new StringBuffer(host)
244:	    .append(':')
245:	    .append(port)
246:	    .append(initialPath)
247:	    .toString();
248:    }
249:
250:    private static String makeString(boolean https, 
251:				     String host, 
252:				     int port, 
253:				     String initialPath)
254:    {
255:	return new StringBuffer((https)
256:				? DAVConstants.HTTPS
257:				: DAVConstants.HTTP)
258:	    .append("://")
259:	    .append(host)
260:	    .append(':')
261:	    .append(port)
262:	    .append(initialPath)
263:	    .toString();
264:    }
265:
266:    private static String correctPath(String path)
267:    {
268:	if (path==null) 
269:	    return DAVConstants.DAV_FILE_SEPARATOR;
270:	else if (path.endsWith(DAVConstants.DAV_FILE_SEPARATOR))
271:	    return path;
272:	else return path+DAVConstants.DAV_FILE_SEPARATOR;
273:    }
274:			
275:    /**
276:     * makes this serverData the last selected one.
277:     */
278:    protected static void touch(ServerData sd) throws IOException
279:    {
280:	Vector servers=getServers();
281:	servers.remove(sd);
282:	addNewServer(sd);
283:	saveServers();
284:	sd.touched=true;
285:    }
286:    
287:    public static Vector getServers()
288:    {
289:	return container.getServerDataVector(); 
290:    }
291:    
292:    public static ServerData getLastSelectedServer()
293:    {
294:	Vector servers=getServers();
295:	int size=servers.size();
296:	return (size>0) 
297:	    ?  (ServerData) servers.elementAt(size-1)
298:	    : null;
299:    }
300:    
301:    private static void addNewServer(ServerData sd)
302:    {
303:	Vector servers=getServers();
304:	for (Enumeration enum=servers.elements();enum.hasMoreElements();)
305:	{
306:	    ServerData next=(ServerData)enum.nextElement();
307:	    if (next.getHost().equals(sd.getHost()) 
308:		&& next.getPort() ==sd.getPort()
309:		&& next.getInitialPath().equals(sd.getInitialPath()))
310:	    {
311:		servers.remove(next);
312:		break;
313:	    }
314:	}
315:	servers.addElement(sd);
316:    }
317:
318:    protected static void saveServers() throws IOException
319:    {
320:	Configurator.getConfigurator().getStore()
321:	    .setConfigValue(ServerDataContainer.class, 
322:			    ServerDataContainer.SERVER_DATA_VECTOR_PROPERTY, 
323:			    getServers());
324:    }
325:
326:    
327:    public static void removeServer(ServerData sd) throws IOException
328:    {
329:	Vector servers=getServers();
330:	if (servers.contains(sd)) 
331:	{
332:	    servers.remove(sd);
333:	    saveServers();
334:	}
335:    }
336:    
337:    private static void loadServerList()
338:            throws IOException, ClassNotFoundException
339:    {
340:	Configurator.getConfigurator().configure(container);
341:	Debug.trace(ServerData.class, 
342:		    Debug.DP3, 
343:		    "ServerDataContainer loaded; serverdata is {0}",
344:		    getServers());
345:    }
346:
347:    public Object clone() 
348:    {
349:	try
350:	{
351:	    return super .clone();
352:	}
353:	catch (CloneNotSupportedException inconceivable)
354:	{
355:	    return null;
356:	}
357:    }
358:
359:    public static ServerData getServer(String serverString)
360:    {
361:	if (!serverString.startsWith(DAVConstants.HTTP) 
362:	    && !serverString.startsWith(DAVConstants.HTTPS))
363:	{
364:	    serverString=new StringBuffer(DAVConstants.HTTP)
365:		.append("://")
366:		.append(serverString)
367:		.toString();
368:	}
369:	for (Enumeration enum=getServers().elements();
370:	     enum.hasMoreElements();)
371:	{
372:	    Object nextObj=enum.nextElement();
373:	    if (serverString.equals(nextObj.toString()))
374:		return (ServerData) nextObj;
375:	}
376:	Debug.trace(ServerData.class, Debug.DP3, 
377:		    "server {0} not found", 
378:		    new Object[] {serverString});
379:	return null;
380:    }
381:
382:    public static ServerData getServer(String host, 
383:				       int port, 
384:				       String initialPath)
385:    {
386:	return getServer(makeString(false, 
387:				    host, 
388:				    port, 
389:				    initialPath));
390:    }  
391:
392:    public static ServerData getServer(boolean https, 
393:				       String host, 
394:				       int port, 
395:				       String initialPath)
396:    {
397:	return getServer(makeString(https, 
398:				    host, 
399:				    port, 
400:				    initialPath));
401:    }  
402:}
403:
404:/* $Log: ServerData.java,v $
405:/* Revision 1.19  2001/07/29 22:37:36  smulloni
406:/* fix to NetworkCustomizer; workaround to bad design of ServerData
407:/*
408:/* Revision 1.18  2001/06/09 03:09:09  smulloni
409:/* added server customization to the NetworkCustomizer.  Buggy.
410:/*
411:/* Revision 1.17  2001/05/30 03:49:35  smulloni
412:/* Some bug fixes and improvements to authentication handling.  Users are now
413:/* prompted for a password the first time they connect to a given server
414:/* in a session; if the password is rejected, they are asked again.
415:/* Users also now have the option of whether a given password will be remembered
416:/* or not.
417:/*
418:/* Revision 1.16  2001/01/05 08:01:12  smulloni
419:/* changes to the connection gui for the Explorer; added depth configurability to
420:/* propfind in the jpython test script; added an experimental "allprop" system
421:/* property which affects the propfind query type
422:/*
423:/* Revision 1.15  2000/12/19 22:36:05  smulloni
424:/* adjustments to preamble.
425:/*
426:/* Revision 1.14  2000/12/18 23:22:47  smulloni
427:/* added optional SSL capability to the gui application.  Separate make targets
428:/* exist for building it will SSL support.
429:/*
430:/* Revision 1.13  2000/12/03 23:53:26  smulloni
431:/* added license and copyright preamble to java files.
432:/*
433:/* Revision 1.12  2000/11/09 23:34:59  smullyan
434:/* log added to every Java file, with the help of python.  Lock stealing
435:/* implemented, and treatment of locks made more robust.
436:/* */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.