BrightSide Workbench Full Report + Source Code
org.turro.elephant.impl.util.FileBean Class Reference

Public Member Functions

 FileBean ()
 
IConstructor getConstructor ()
 
String getRealContext ()
 
String getRepositoryPath ()
 
String[] getAllowedLocales ()
 
String getSelectedLocale ()
 
String getLastWikiString ()
 
String getWiki () throws IOException
 
void setConstructor (IConstructor constructor)
 
String getContext ()
 
void setContext (String context)
 
String getFile ()
 
void setFile (String file)
 
String getAction ()
 
void setAction (String action)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 32 of file FileBean.java.

Constructor & Destructor Documentation

◆ FileBean()

org.turro.elephant.impl.util.FileBean.FileBean ( )

Creates a new instance of FileBean

Definition at line 39 of file FileBean.java.

39  {
40  }

Member Function Documentation

◆ getAction()

String org.turro.elephant.impl.util.FileBean.getAction ( )

Definition at line 131 of file FileBean.java.

131  {
132  return action;
133  }

◆ getAllowedLocales()

String [] org.turro.elephant.impl.util.FileBean.getAllowedLocales ( )

Definition at line 54 of file FileBean.java.

54  {
55  if(defaultLocales == null) {
56  ElContext currContext = ElContextMap.getContext(context);
57  defaultLocales = currContext.getDefaultLocales().toArray(new String[0]);
58  }
59  return defaultLocales;
60  }
Here is the call graph for this function:

◆ getConstructor()

IConstructor org.turro.elephant.impl.util.FileBean.getConstructor ( )

Definition at line 42 of file FileBean.java.

42  {
43  return constructor;
44  }

◆ getContext()

String org.turro.elephant.impl.util.FileBean.getContext ( )

Definition at line 115 of file FileBean.java.

115  {
116  return context;
117  }

◆ getFile()

String org.turro.elephant.impl.util.FileBean.getFile ( )

Definition at line 123 of file FileBean.java.

123  {
124  return file;
125  }

◆ getLastWikiString()

String org.turro.elephant.impl.util.FileBean.getLastWikiString ( )

Definition at line 68 of file FileBean.java.

68  {
69  if(file == null || file.length() == 0) return null;
70  if(lastWiki == null) {
71  File folder = new File(ElephantContext.getRealPath(context));
72  File files[] = folder.listFiles();
73  String filePrefix = FileUtil.crudeName(file),
74  fileName, lang = FileUtil.getLang(file);
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;
79  }
80  }
81  }
82  return lastWiki;
83  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRealContext()

String org.turro.elephant.impl.util.FileBean.getRealContext ( )

Definition at line 46 of file FileBean.java.

46  {
47  return FileUtil.getRealContext(context);
48  }
Here is the call graph for this function:

◆ getRepositoryPath()

String org.turro.elephant.impl.util.FileBean.getRepositoryPath ( )

Definition at line 50 of file FileBean.java.

50  {
51  return context + "/_internal/repository";
52  }

◆ getSelectedLocale()

String org.turro.elephant.impl.util.FileBean.getSelectedLocale ( )

Definition at line 62 of file FileBean.java.

62  {
63  if(localeCount > defaultLocales.length) localeCount = 0;
64  return file.startsWith(FileUtil.crudeName(file) + defaultLocales[localeCount++] + ".")
65  ? "selected" : "";
66  }
Here is the call graph for this function:

◆ getWiki()

String org.turro.elephant.impl.util.FileBean.getWiki ( ) throws IOException

Definition at line 85 of file FileBean.java.

85  {
86  File folder = new File(ElephantContext.getRealPath(context));
87  if(!folder.exists()) folder.mkdirs();
88  if("new".equals(action)) return "";
89  File edit = new File(ElephantContext.getRealPath(context + "/" + file));
90  if(edit.exists()) {
91  String lastWiki = getLastWikiString();
92  File content = null;
93  if(lastWiki != null) {
94  content = new File(ElephantContext.getRealPath(context + "/" + lastWiki));
95  }
96  else {
97  content = edit;
98  }
99  StringBuilder sb = new StringBuilder();
100  try (BufferedReader br = FileUtil.getBufferedFile(content)) {
101  String s;
102  while((s = br.readLine()) != null) {
103  sb.append(s + "\n");
104  }
105  }
106  return sb.toString();
107  }
108  return "";
109  }
Here is the call graph for this function:

◆ setAction()

void org.turro.elephant.impl.util.FileBean.setAction ( String  action)

Definition at line 135 of file FileBean.java.

135  {
136  this.action = action;
137  }

◆ setConstructor()

void org.turro.elephant.impl.util.FileBean.setConstructor ( IConstructor  constructor)

Definition at line 111 of file FileBean.java.

111  {
112  this.constructor = constructor;
113  }

◆ setContext()

void org.turro.elephant.impl.util.FileBean.setContext ( String  context)

Definition at line 119 of file FileBean.java.

119  {
120  this.context = context;
121  }

◆ setFile()

void org.turro.elephant.impl.util.FileBean.setFile ( String  file)

Definition at line 127 of file FileBean.java.

127  {
128  this.file = file;
129  }

The documentation for this class was generated from the following file: