Source Code Cross Referenced for AutoLookupDirectory.java in  » Web-Server » Jigsaw » org » w3c » jigedit » resources » 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 » Web Server » Jigsaw » org.w3c.jigedit.resources 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // AutoLookupDirectory.java
002:        // $Id: AutoLookupDirectory.java,v 1.11 2000/08/16 21:37:33 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigedit.resources;
007:
008:        import java.io.File;
009:
010:        import org.w3c.cvs.CVS;
011:        import org.w3c.cvs.CvsDirectory;
012:        import org.w3c.cvs.CvsException;
013:
014:        import org.w3c.tools.resources.Attribute;
015:        import org.w3c.tools.resources.AttributeHolder;
016:        import org.w3c.tools.resources.AttributeRegistry;
017:        import org.w3c.tools.resources.BooleanAttribute;
018:        import org.w3c.tools.resources.LookupResult;
019:        import org.w3c.tools.resources.LookupState;
020:        import org.w3c.tools.resources.ProtocolException;
021:        import org.w3c.tools.resources.Resource;
022:        import org.w3c.tools.resources.ResourceReference;
023:        import org.w3c.tools.resources.ServerInterface;
024:
025:        import org.w3c.www.http.HttpRequestMessage;
026:
027:        import org.w3c.jigsaw.http.Request;
028:
029:        import org.w3c.jigedit.cvs.CvsModule;
030:        import org.w3c.jigedit.cvs.CvsRootDirectory;
031:
032:        /**
033:         * A special version of DirectoryResource that can fetch a file
034:         * from CVS directly if it is not already here.
035:         * It can alos do an automatic update, depending on a flag
036:         */
037:
038:        public class AutoLookupDirectory extends CvsRootDirectory {
039:
040:            private CvsDirectory cvs = null;
041:
042:            /**
043:             * Attribute index, tell if we must update the resource everytime it is
044:             * acceded (not recommended as it generates many cvs commands)
045:             */
046:
047:            private static int ATTR_AUTOUPDATE = -1;
048:
049:            /**
050:             * Attribute index, tell if we must add into cvs new puted directories.
051:             */
052:            private static int ATTR_EXTENSIBLE = -1;
053:
054:            static {
055:                Attribute a = null;
056:                Class cls = null;
057:
058:                try {
059:                    cls = Class
060:                            .forName("org.w3c.jigedit.resources.AutoLookupDirectory");
061:                } catch (Exception ex) {
062:                    ex.printStackTrace();
063:                    System.exit(1);
064:                }
065:                // The browsable flag:
066:                a = new BooleanAttribute("autoupdate", Boolean.FALSE,
067:                        Attribute.EDITABLE);
068:                ATTR_AUTOUPDATE = AttributeRegistry.registerAttribute(cls, a);
069:                // The browsable flag:
070:                a = new BooleanAttribute("cvs-extensible", Boolean.FALSE,
071:                        Attribute.EDITABLE);
072:                ATTR_EXTENSIBLE = AttributeRegistry.registerAttribute(cls, a);
073:            }
074:
075:            /**
076:             * Get the appropriate CVS manager for the directory we handle.
077:             * @return A CvsDirectory instance.
078:             * @exception CvsException If we couldn't get the manager.
079:             */
080:
081:            protected synchronized CvsDirectory getCvsManager()
082:                    throws CvsException {
083:                if (cvs == null) {
084:                    cvs = CvsModule.getCvsManager(getDirectory(), getContext(),
085:                            getServer().getProperties());
086:                }
087:                return cvs;
088:            }
089:
090:            /**
091:             * tell if we must always do an update.
092:             */
093:
094:            public boolean isAutoUpdatable() {
095:                return getBoolean(ATTR_AUTOUPDATE, false);
096:            }
097:
098:            /**
099:             * tell if we must add in cvs the new puted documents.
100:             */
101:            public boolean isCvsExtensible() {
102:                return getBoolean(ATTR_EXTENSIBLE, false);
103:            }
104:
105:            /**
106:             * Create a DirectoryResource and the physical directory too.
107:             * Add the new directory in the CVS repository.
108:             * @param name the name of the resource.
109:             * @return A ResourceReference instance.
110:             */
111:            public ResourceReference createDirectoryResource(String name) {
112:                ResourceReference newdir = super .createDirectoryResource(name);
113:                if ((newdir != null) && isCvsExtensible()) {
114:                    String names[] = new String[1];
115:                    names[0] = name;
116:                    try {
117:                        getCvsManager().add(names);
118:                    } catch (CvsException ex) {
119:                        getServer().errlog(this , ex.getMessage());
120:                    }
121:                }
122:                return newdir;
123:            }
124:
125:            /**
126:             * Lookup the next component of this lookup state in here.
127:             * @param ls The current lookup state.
128:             * @param lr The lookup result under construction.
129:             * @exception ProtocolException If an error occurs.
130:             * @return A boolean, <strong>true</strong> if lookup has completed, 
131:             * <strong>false</strong> if it should be continued by the caller.
132:             */
133:            public boolean lookup(LookupState ls, LookupResult lr)
134:                    throws ProtocolException {
135:                Request request = (Request) ls.getRequest();
136:                if ((request != null) && (request.getMethod().equals("PUT"))) {
137:                    if (ls.hasMoreComponents()) {
138:                        String name = null;
139:                        try {
140:                            name = ls.peekNextComponent();
141:                            File dir = new File(getDirectory(), name);
142:                            if (dir.isDirectory()) {
143:                                CvsDirectory cvs = getCvsManager();
144:                                if (cvs.getDirectoryStatus(name, false) == CVS.DIR_Q) {
145:                                    String names[] = { name };
146:                                    cvs.add(names);
147:                                }
148:                            }
149:                        } catch (CvsException ex) {
150:                            String msg = "cvs add \"" + name + "\" failed.";
151:                            getServer().errlog(this , msg);
152:                        }
153:                    }
154:                }
155:                return super .lookup(ls, lr);
156:            }
157:
158:            /**
159:             * Lookup the resource having the given name in this directory.
160:             * if the resource is not present, it will try to fetch it from
161:             * the Cvs repository.
162:             * @param name The name of the resource.
163:             * @return A ResourceReference instance, or <strong>null</strong>.
164:             */
165:
166:            public ResourceReference lookup(String name) {
167:                ResourceReference rr = super .lookup(name);
168:                if (rr == null) {
169:                    // This may be an unchecked out directory:
170:                    try {
171:                        CvsDirectory cvs = getCvsManager();
172:                        if (cvs.getDirectoryStatus(name) == CVS.DIR_NCO)
173:                            cvs.updateDirectory(name);
174:                    } catch (CvsException ex) {
175:                        String msg = "cvs update -d \"" + name + "\" failed.";
176:                        getServer().errlog(this , msg);
177:                        return null;
178:                    }
179:                    // Checking out the directory succeeded, retry lookup:
180:                    return super.lookup(name);
181:                } else {
182:                    return rr;
183:                }
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.