Source Code Cross Referenced for FileSystemWorkArea.java in  » Groupware » hipergate » com » knowgate » workareas » 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 » Groupware » hipergate » com.knowgate.workareas 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.knowgate.workareas;
002:
003:        import java.lang.Exception;
004:        import java.util.Properties;
005:        import java.io.IOException;
006:
007:        import com.enterprisedt.net.ftp.FTPException;
008:
009:        import com.knowgate.debug.DebugFile;
010:        import com.knowgate.dfs.FileSystem;
011:
012:        public class FileSystemWorkArea extends FileSystem {
013:            private Properties oPropsCNF;
014:
015:            private FileSystemWorkArea() {
016:                oPropsCNF = null;
017:            }
018:
019:            private FileSystemWorkArea(String sUser, String sPwd) {
020:                oPropsCNF = null;
021:            }
022:
023:            public FileSystemWorkArea(Properties oEnvProps) {
024:                super (oEnvProps);
025:                oPropsCNF = oEnvProps;
026:            }
027:
028:            // ---------------------------------------------------------------------------
029:
030:            /**
031:             * <p>Create a complete directory branch under workarea root directory at /web branch</p>
032:             * The given path is appended to "file://" + <i>workareasput</i> + <i>sWorkArea<</i>
033:             * and the full resulting path is created if it does not exist.
034:             * @param oProps Properties collection containing <i>workareasput</i> property
035:             * (typically readed from file hipergate.cnf)
036:             * @param sWorkArea WorkArea GUID
037:             * @param sPath Relative path to be created under workarea root directory
038:             * @throws IOException
039:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
040:             */
041:
042:            private boolean mkworkpath(Properties oProps, String sWorkArea,
043:                    String sPath) throws IOException, IllegalArgumentException {
044:                boolean bRetVal = false;
045:
046:                if (DebugFile.trace) {
047:                    DebugFile.writeln("Begin FileSystemWorkArea.mkworkpath("
048:                            + sPath + ")");
049:                    DebugFile.incIdent();
050:                }
051:
052:                if (sWorkArea == null)
053:                    throw new IllegalArgumentException(
054:                            "WorkArea GUID may not be null");
055:
056:                String sWorkAreaPath = oProps.getProperty("workareasput");
057:                if (!sWorkAreaPath.endsWith(SLASH))
058:                    sWorkAreaPath += SLASH;
059:
060:                try {
061:                    if (null == sPath)
062:                        bRetVal = mkdirs("file://" + sWorkAreaPath + sWorkArea);
063:                    else
064:                        bRetVal = mkdirs("file://" + sWorkAreaPath + sWorkArea
065:                                + SLASH + sPath);
066:                } catch (IOException ioe) {
067:                    throw new IOException(ioe.getMessage());
068:                } catch (Exception e) { /* never thrown */
069:                }
070:
071:                if (DebugFile.trace) {
072:                    DebugFile.decIdent();
073:                    DebugFile.writeln("End FileSystemWorkArea.mkworkpath() : "
074:                            + String.valueOf(bRetVal));
075:                }
076:
077:                return bRetVal;
078:            } // mkworkpath
079:
080:            // ---------------------------------------------------------------------------
081:
082:            /**
083:             * <p>Create workarea root directory at /web branch</p>
084:             * @param oProps Properties collection containing <i>workareasput</i> property
085:             * @param sWorkArea WorkArea GUID
086:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
087:             */
088:            private boolean mkworkpath(Properties oProps, String sWorkArea)
089:                    throws IOException, IllegalArgumentException {
090:
091:                return mkworkpath(oProps, sWorkArea, null);
092:            }
093:
094:            // ---------------------------------------------------------------------------
095:
096:            /**
097:             * <p>Create a complete directory branch under workarea root directory.</p>
098:             * The given path is appended to "file://" + workareasput + <i>sWorkArea</i>
099:             * and the full resulting path is created if it does not exist.
100:             * @param sWorkArea WorkArea GUID
101:             * @param sPath Relative path to be created under workareas root directory
102:             * @throws IOException
103:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
104:             */
105:            public boolean mkworkpath(String sWorkArea, String sPath)
106:                    throws Exception, IOException {
107:                return mkworkpath(oPropsCNF, sWorkArea, sPath);
108:            }
109:
110:            // ---------------------------------------------------------------------------
111:
112:            /**
113:             * <p>Create workarea root directory at /web branch</p>
114:             * @param oProps Properties collection containing <i>workareasput</i> property
115:             * @param sWorkArea WorkArea GUID
116:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
117:             */
118:            public boolean mkworkpath(String sWorkArea) throws IOException,
119:                    IllegalArgumentException {
120:
121:                return mkworkpath(oPropsCNF, sWorkArea, null);
122:            }
123:
124:            // ---------------------------------------------------------------------------
125:
126:            /**
127:             * <p>Delete a directory and all its subdirectories and files
128:             * under workarea root directory at /web branch.</p>
129:             * The given path is appended to "file://" + <i>workareasput</i> + <i>sWorkArea</i>,
130:             * the resulting directory and all its childs are deleted.
131:             * @param oProps Properties collection containing workareasput property
132:             * @param sWorkArea WorkArea GUID
133:             * @param sPath Relative path to be created under workareas root directory
134:             * @throws IOException
135:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
136:             * @throws NullPointerException if "workareasput" property is not found at oProps Properties
137:             */
138:
139:            private boolean rmworkpath(Properties oProps, String sWorkArea,
140:                    String sPath) throws IOException, IllegalArgumentException,
141:                    NullPointerException {
142:                boolean bRetVal = false;
143:
144:                if (DebugFile.trace) {
145:                    DebugFile.writeln("Begin FileSystemWorkArea.rmworkpath("
146:                            + sPath + ")");
147:                    DebugFile.incIdent();
148:                }
149:
150:                String sWorkAreaPath = oProps.getProperty("workareasput");
151:
152:                if (sWorkAreaPath == null) {
153:                    throw new NullPointerException(
154:                            "Cannot find property workareasput at configuration file");
155:                } else {
156:                    if (sPath == null) {
157:                        bRetVal = rmdir("file://" + sWorkAreaPath);
158:                    } else {
159:                        if (!sWorkAreaPath.endsWith(SLASH)
160:                                && !sPath.startsWith(SLASH))
161:                            sWorkAreaPath += SLASH;
162:                        bRetVal = rmdir("file://" + sWorkAreaPath + sPath);
163:                    }
164:                }
165:
166:                if (DebugFile.trace) {
167:                    DebugFile.decIdent();
168:                    DebugFile.writeln("End FileSystemWorkArea.rmworkpath() : "
169:                            + String.valueOf(bRetVal));
170:                }
171:
172:                return bRetVal;
173:            } // rmworkpath
174:
175:            // ---------------------------------------------------------------------------
176:
177:            /**
178:             * <p>Delete a directory and all its subdirectories and files
179:             * under workarea root directory at /web branch.</p>
180:             * The given path is appended to "file://" + <i>workareasput</i> + <i>sWorkArea</i>,
181:             * the resulting directory and all its childs are deleted.
182:             * @param sWorkArea WorkArea GUID
183:             * @param sPath Relative path to be created under workareas root directory
184:             * @throws IOException
185:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
186:             */
187:
188:            public boolean rmworkpath(String sWorkArea, String sPath)
189:                    throws IOException, IllegalArgumentException {
190:                return rmworkpath(oPropsCNF, sWorkArea, sPath);
191:            }
192:
193:            // ---------------------------------------------------------------------------
194:
195:            /**
196:             * <p>Delete workarea root directory at /web branch.</p>
197:             * The given path is appended to "file://" + <i>workareasput</i> + ,
198:             * the resulting directory and all its childs are deleted.
199:             * @param sWorkArea WorkArea GUID
200:             * @throws IOException
201:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
202:             */
203:
204:            public boolean rmworkpath(String sWorkArea) throws IOException,
205:                    IllegalArgumentException {
206:                return rmworkpath(oPropsCNF, sWorkArea, null);
207:            }
208:
209:            // ---------------------------------------------------------------------------
210:
211:            /**
212:             * <p>Create a complete directory branch under storage root directory</p>
213:             * The given path is appended to storage/domains/<i>iDomain</i>/workareas/<i>sWorkArea</i>/
214:             * and the full resulting path is created if it does not exist.
215:             * @param oProps Properties collection containing storage property
216:             * (typically readed from file hipergate.cnf)
217:             * @param iDomain Domain Numeric Identifier
218:             * @param sWorkArea WorkArea GUID
219:             * @param sPath Relative path to be created under workarea directory. For example:
220:             * "ROOT/DOMAINS/TEST1/TEST1_USERS/TEST1_administrator/TEST1_administrator_temp"
221:             * If sPath is <b>null</b> hen the workarea root directory itself will be created.
222:             * @throws IOException
223:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
224:             */
225:
226:            private boolean mkstorpath(Properties oProps, int iDomain,
227:                    String sWorkArea, String sPath) throws Exception,
228:                    IOException, IllegalArgumentException {
229:                boolean bRetVal = false;
230:
231:                if (DebugFile.trace) {
232:                    DebugFile
233:                            .writeln("Begin FileSystemWorkArea.mkstorpath([Properties],"
234:                                    + String.valueOf(iDomain)
235:                                    + ","
236:                                    + sWorkArea
237:                                    + "," + sPath + ")");
238:                    DebugFile.incIdent();
239:                }
240:
241:                if (sWorkArea == null)
242:                    throw new IllegalArgumentException(
243:                            "WorkArea GUID may not be null");
244:
245:                String sProtocol = oProps.getProperty("protocol", "file://");
246:                String sWorkAreaPath = oProps.getProperty("storage");
247:
248:                if (sProtocol.equalsIgnoreCase("ftp://")) {
249:                    if (!sWorkAreaPath.endsWith("/"))
250:                        sWorkAreaPath += "/";
251:                    sWorkAreaPath += "domains/" + String.valueOf(iDomain)
252:                            + "/workareas/" + sWorkArea;
253:
254:                    if (null == sPath)
255:                        bRetVal = mkdirs(sProtocol
256:                                + oProps.getProperty("protocol", "localhost")
257:                                + "/" + sWorkAreaPath);
258:                    else
259:                        bRetVal = mkdirs(sProtocol
260:                                + oProps.getProperty("protocol", "localhost")
261:                                + "/" + sWorkAreaPath
262:                                + (sPath.startsWith("/") ? sPath : "/" + sPath));
263:                } else {
264:                    if (!sWorkAreaPath.endsWith(SLASH))
265:                        sWorkAreaPath += SLASH;
266:
267:                    sWorkAreaPath += "domains" + SLASH
268:                            + String.valueOf(iDomain) + SLASH + "workareas"
269:                            + SLASH + sWorkArea;
270:
271:                    if (null == sPath)
272:                        bRetVal = mkdirs(sProtocol + sWorkAreaPath);
273:                    else
274:                        bRetVal = mkdirs(sProtocol
275:                                + sWorkAreaPath
276:                                + (sPath.startsWith(SLASH) ? sPath : SLASH
277:                                        + sPath));
278:                } // fi (sProtocol)
279:
280:                if (DebugFile.trace) {
281:                    DebugFile.decIdent();
282:                    DebugFile.writeln("End FileSystemWorkArea.mkstorpath() : "
283:                            + String.valueOf(bRetVal));
284:                }
285:
286:                return bRetVal;
287:            } // mkworkpath
288:
289:            // ---------------------------------------------------------------------------
290:
291:            /**
292:             * <p>Create a complete directory branch under storage root directory</p>
293:             * The given path is appended to storage/domains/<i>iDomain</i>/workareas/<i>sWorkArea</i>/
294:             * and the full resulting path is created if it does not exist.
295:             * @param iDomain Domain Numeric Identifier
296:             * @param sWorkArea WorkArea GUID
297:             * @param sPath Relative path to be created under workarea directory. For example:
298:             * "ROOT/DOMAINS/TEST1/TEST1_USERS/TEST1_administrator/TEST1_administrator_temp"
299:             * If sPath is <b>null</b> hen the workarea root directory itself will be created.
300:             * @throws IOException
301:             * @throws IllegalArgumentException If sWorkArea is <b>null</b>
302:             */
303:            public boolean mkstorpath(int iDomain, String sWorkArea,
304:                    String sPath) throws Exception, IOException {
305:                return mkstorpath(oPropsCNF, iDomain, sWorkArea, sPath);
306:            }
307:
308:            /**
309:             * <p>Remove workarea files under /storage branch</p>
310:             * @param oProps Properties collection containing storage property
311:             * @param iDomain WorkArea Domain Numeric Identifier
312:             * @param sWorkArea WorkArea GUID
313:             * @param sPath Relative path from workarea subdirectory to delete.
314:             * @throws Exception
315:             * @throws IOException
316:             */
317:            private boolean rmstorpath(Properties oProps, int iDomain,
318:                    String sWorkArea, String sPath) throws Exception,
319:                    IOException {
320:                boolean bRetVal = false;
321:
322:                if (DebugFile.trace) {
323:                    DebugFile.writeln("Begin FileSystemWorkArea.rmstorpath ("
324:                            + String.valueOf(iDomain) + "," + sWorkArea + ","
325:                            + (sPath == null ? "null" : sPath) + ")");
326:                    DebugFile.incIdent();
327:                }
328:
329:                String sProtocol = oProps.getProperty("protocol", "file://");
330:                String sWorkAreaPath = oProps.getProperty("storage");
331:
332:                if (sProtocol.equalsIgnoreCase("ftp://")) {
333:                    if (!sWorkAreaPath.endsWith("/"))
334:                        sWorkAreaPath += "/";
335:                    sWorkAreaPath += "domains/" + String.valueOf(iDomain)
336:                            + "/workareas/" + sWorkArea;
337:
338:                    if (null == sPath)
339:                        bRetVal = rmdir(sProtocol
340:                                + oProps.getProperty("protocol", "localhost")
341:                                + "/" + sWorkAreaPath);
342:                    else
343:                        bRetVal = rmdir(sProtocol
344:                                + oProps.getProperty("protocol", "localhost")
345:                                + "/" + sWorkAreaPath
346:                                + (sPath.startsWith("/") ? sPath : "/" + sPath));
347:                } else {
348:                    if (!sWorkAreaPath.endsWith(SLASH))
349:                        sWorkAreaPath += SLASH;
350:
351:                    sWorkAreaPath += "domains" + SLASH
352:                            + String.valueOf(iDomain) + SLASH + "workareas"
353:                            + SLASH + sWorkArea;
354:
355:                    if (null == sPath)
356:                        bRetVal = rmdir(sProtocol + sWorkAreaPath);
357:                    else
358:                        bRetVal = rmdir(sProtocol
359:                                + sWorkAreaPath
360:                                + (sPath.startsWith(SLASH) ? sPath : SLASH
361:                                        + sPath));
362:                }
363:
364:                if (DebugFile.trace) {
365:                    DebugFile.decIdent();
366:                    DebugFile.writeln("End FileSystemWorkArea.rmworkpath() : "
367:                            + String.valueOf(bRetVal));
368:                }
369:
370:                return bRetVal;
371:            } // rmstorpath
372:
373:            // ---------------------------------------------------------------------------
374:
375:            /**
376:             * <p>Remove workarea files under /storage branch</p>
377:             * @param iDomain WorkArea Domain Numeric Identifier
378:             * @param sWorkArea WorkArea GUID
379:             * @param sPath Relative path from workarea subdirectory to delete.
380:             * @throws Exception
381:             * @throws IOException
382:             */
383:
384:            public boolean rmstorpath(int iDomain, String sWorkArea,
385:                    String sPath) throws Exception, IOException {
386:                return rmstorpath(oPropsCNF, iDomain, sWorkArea, sPath);
387:            }
388:
389:            /**
390:             * <p>Remove workarea files under /storage branch</p>
391:             * @param iDomain WorkArea Domain Numeric Identifier
392:             * @param sWorkArea WorkArea GUID
393:             * @throws Exception
394:             * @throws IOException
395:             */
396:
397:            public boolean rmstorpath(int iDomain, String sWorkArea)
398:                    throws Exception, IOException {
399:                return rmstorpath(oPropsCNF, iDomain, sWorkArea, null);
400:            }
401:
402:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.