18 package org.turro.elephant.impl.util;
20 import java.io.BufferedReader;
22 import java.io.IOException;
23 import org.turro.elephant.context.ElephantContext;
24 import org.turro.elephant.context.IConstructor;
25 import org.turro.elephant.web.ElContext;
26 import org.turro.elephant.web.ElContextMap;
34 private String context, file, action, lastWiki =
null;
35 private int localeCount = 0;
36 private String[] defaultLocales;
51 return context +
"/_internal/repository";
55 if(defaultLocales ==
null) {
59 return defaultLocales;
63 if(localeCount > defaultLocales.length) localeCount = 0;
64 return file.startsWith(
FileUtil.
crudeName(file) + defaultLocales[localeCount++] +
".")
69 if(file ==
null || file.length() == 0)
return null;
70 if(lastWiki ==
null) {
72 File files[] = folder.listFiles();
75 for(
int i = 0; i < files.length; i++) {
76 fileName = files[i].getName();
77 if(fileName.endsWith(lang +
".wiki") && fileName.startsWith(filePrefix)) {
78 lastWiki = (lastWiki ==
null || fileName.compareTo(lastWiki) > 0) ? fileName : lastWiki;
85 public String
getWiki() throws IOException {
87 if(!folder.exists()) folder.mkdirs();
88 if(
"new".equals(action))
return "";
93 if(lastWiki !=
null) {
99 StringBuilder sb =
new StringBuilder();
102 while((s = br.readLine()) !=
null) {
106 return sb.toString();
112 this.constructor = constructor;
120 this.context = context;
136 this.action = action;
static String getRealPath(String path)
String getRepositoryPath()
IConstructor getConstructor()
void setConstructor(IConstructor constructor)
String[] getAllowedLocales()
String getLastWikiString()
String getSelectedLocale()
void setAction(String action)
void setContext(String context)
void setFile(String file)
static String getLang(String file)
static String getRealContext(String context)
static String crudeName(String file)
static BufferedReader getBufferedFile(String folder, String file)
static ElContext getContext(IConstructor constructor)
Set< String > getDefaultLocales()