Develop and Download Open Source Software

Browse CVS Repository

Diff of /pal/wiki/src/main/java/jp/sf/pal/wiki/service/WikiContentService.java

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by shinsuke, Sat Jan 27 15:38:33 2007 UTC revision 1.3 by shinsuke, Thu Feb 1 22:30:24 2007 UTC
# Line 24  import java.io.IOException; Line 24  import java.io.IOException;
24  import java.io.InputStreamReader;  import java.io.InputStreamReader;
25  import java.io.UnsupportedEncodingException;  import java.io.UnsupportedEncodingException;
26  import java.io.Writer;  import java.io.Writer;
27    import java.util.ArrayList;
28    import java.util.Date;
29    import java.util.List;
30    
31  import javax.faces.context.FacesContext;  import javax.faces.context.FacesContext;
32    
33  import jp.sf.pal.wiki.WikiConstants;  import jp.sf.pal.wiki.WikiConstants;
34  import jp.sf.pal.wiki.callback.WikiLinkGeneratorCallback;  import jp.sf.pal.wiki.callback.WikiLinkGeneratorCallback;
35    import jp.sf.pal.wiki.entity.WikiPage;
36  import jp.sf.pal.wiki.util.WikiUtil;  import jp.sf.pal.wiki.util.WikiUtil;
37  import jp.sf.stconv.pipeline.PipelineException;  import jp.sf.stconv.pipeline.PipelineException;
38  import jp.sf.stconv.pipeline.StreamConverterPipeline;  import jp.sf.stconv.pipeline.StreamConverterPipeline;
# Line 41  import org.apache.commons.logging.Log; Line 45  import org.apache.commons.logging.Log;
45  import org.apache.commons.logging.LogFactory;  import org.apache.commons.logging.LogFactory;
46  import org.seasar.framework.container.S2Container;  import org.seasar.framework.container.S2Container;
47    
48  import com.marevol.utils.faces.application.FacesMessageUtil;  import jp.sf.pal.common.faces.application.FacesMessageUtil;
49    
50  /**  /**
51   * @author shinsuke   * @author shinsuke
# Line 242  public class WikiContentService { Line 246  public class WikiContentService {
246      }      }
247    
248      protected File getPageFile(String pageName) {      protected File getPageFile(String pageName) {
249            File dataDir = getDataDir();
250            return new File(dataDir, pageName + WikiConstants.DATA_SUFFIX);
251        }
252    
253        public List getPages() {
254            ArrayList list = new ArrayList();
255            File dataDir = getDataDir();
256    
257            File[] files = dataDir.listFiles();
258            for (int i = 0; i < files.length; i++) {
259                String filename = files[i].getName();
260                if (log.isDebugEnabled()) {
261                    log.debug("getPages() - filename=" + filename);
262                }
263    
264                if (filename != null
265                        && filename.lastIndexOf(WikiConstants.DATA_SUFFIX) >= 0) {
266                    WikiPage page = new WikiPage();
267                    page.setFile(files[i]);
268                    page.setPageName(filename.substring(0, filename.length()
269                            - WikiConstants.DATA_SUFFIX.length()));
270                    page.setUpdated(new Date(files[i].lastModified()));
271                    list.add(page);
272                }
273    
274            }
275            //TODO sort?
276    
277            return list;
278        }
279    
280        protected File getDataDir() {
281          String dataDirName = WikiUtil.getWikiDataDir();          String dataDirName = WikiUtil.getWikiDataDir();
282          File dataDir = new File(dataDirName);          File dataDir = new File(dataDirName);
283          if (!dataDir.exists()) {          if (!dataDir.exists()) {
# Line 253  public class WikiContentService { Line 289  public class WikiContentService {
289                  log.debug("Created directory: " + dataDirName);                  log.debug("Created directory: " + dataDirName);
290              }              }
291          }          }
292          return new File(dataDir, pageName + WikiConstants.DATA_SUFFIX);          return dataDir;
293      }      }
294    
295      protected void setCurrentPageNameToSession(String pageName) {      protected void setCurrentPageNameToSession(String pageName) {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26