KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > jwi > jgallery > WebFolder


1 package de.jwi.jgallery;
2
3 /*
4  * jGallery - Java web application to display image galleries
5  *
6  * Copyright (C) 2004 Juergen Weber
7  *
8  * This file is part of jGallery.
9  *
10  * jGallery is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * jGallery is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with jGallery; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston
23  */

24
25
26 import java.io.BufferedReader JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.io.InputStream JavaDoc;
29 import java.io.InputStreamReader JavaDoc;
30 import java.util.ArrayList JavaDoc;
31 import java.util.List JavaDoc;
32
33 import javax.servlet.ServletContext JavaDoc;
34
35
36
37 /**
38  * @author Jürgen Weber
39  * Source file created on 07.03.2004
40  *
41  */

42 public class WebFolder extends Folder
43 {
44     private String JavaDoc baseURL;
45     private String JavaDoc remoteKey;
46     
47     public WebFolder(String JavaDoc baseURL, ServletContext JavaDoc appContext, Configuration configuration, ConfigData configData, String JavaDoc remoteKey, String JavaDoc jgalleryContextPath,
48             String JavaDoc folderPath, InputStream JavaDoc fileList) throws GalleryException
49     {
50         super(null, appContext, configuration,configData, jgalleryContextPath,folderPath,folderPath,null);
51         this.baseURL = baseURL;
52         this.remoteKey = remoteKey;
53         
54         List JavaDoc images = new ArrayList JavaDoc();
55         
56         BufferedReader JavaDoc in
57         = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(fileList));
58         
59         String JavaDoc s;
60         
61         try
62         {
63             while ((s=in.readLine())!=null)
64             {
65                 images.add(s);
66             }
67         }
68         catch (IOException JavaDoc e)
69         {
70             throw new GalleryException(e.getMessage());
71         }
72         
73         imageFiles = (String JavaDoc[])images.toArray(new String JavaDoc[0]);
74         
75         endLoad();
76     }
77     
78     protected IImageAccessor makeImageAccessor(String JavaDoc name)
79     {
80         return new WebImageAccessor(name, this);
81     }
82
83     public void loadFolder()
84     {
85         // NOP
86

87     }
88     
89     protected String JavaDoc[] getSubDirectories()
90     {
91         return new String JavaDoc[0];
92     }
93     
94     public String JavaDoc getBaseURL()
95     {
96         return baseURL;
97     }
98     
99     public String JavaDoc getFolderPath()
100     {
101         return baseURL + folderPath;
102     }
103
104     public String JavaDoc getThumbsPath()
105     {
106         return baseURL + super.getThumbsPath();
107     }
108     
109     public String JavaDoc getHTMLBase()
110     {
111         return jgalleryContextPath + "/" + remoteKey + folderPath;
112     }
113     
114     
115 }
116
Popular Tags