BrightSide Workbench Full Report + Source Code
org.turro.elephant.impl.repository.RepositoryBean Class Reference

Public Member Functions

 RepositoryBean ()
 
void setRoleUpload (String value)
 
void setRoleList (String value)
 
void setRoleDelete (String value)
 
void setRoleCreateDir (String value)
 
void setRootPath (String value)
 
void setValidUploads (String value)
 
void deleteFile (String file)
 
void createFolder (String folder)
 
String[] getFiles ()
 
String getRealFolder ()
 
String convertToValidName (String fileName)
 
String getContext ()
 
void setContext (String context)
 
IConstructor getConstructor ()
 
void setConstructor (IConstructor constructor) throws Exception
 
String getImageUrl (String file)
 
boolean isSelectable ()
 
void setSelectable (boolean selectable)
 
String getSubFolder ()
 
void setSubFolder (String subFolder)
 

Static Public Attributes

static final String REPOSITORY_JSP = "/WEB-INF/elephant/admin/repository.jsp"
 

Detailed Description

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

Definition at line 35 of file RepositoryBean.java.

Constructor & Destructor Documentation

◆ RepositoryBean()

org.turro.elephant.impl.repository.RepositoryBean.RepositoryBean ( )

Creates a new instance of RepositoryBean

Definition at line 56 of file RepositoryBean.java.

56  {
57  }

Member Function Documentation

◆ convertToValidName()

String org.turro.elephant.impl.repository.RepositoryBean.convertToValidName ( String  fileName)

Definition at line 148 of file RepositoryBean.java.

148  {
149  return fileName.replaceAll("[^a-zA-Z0-9\\-\\_\\.]", "_");
150  }
Here is the caller graph for this function:

◆ createFolder()

void org.turro.elephant.impl.repository.RepositoryBean.createFolder ( String  folder)

Definition at line 106 of file RepositoryBean.java.

106  {
107  File f = new File(getRealPath(folder));
108  f.mkdir();
109  }
Here is the caller graph for this function:

◆ deleteFile()

void org.turro.elephant.impl.repository.RepositoryBean.deleteFile ( String  file)

Definition at line 99 of file RepositoryBean.java.

99  {
100  File f = new File(getRealPath(file));
101  if(f.exists()) {
102  org.amic.util.file.FileUtil.deleteFile(f);
103  }
104  }
Here is the caller graph for this function:

◆ getConstructor()

IConstructor org.turro.elephant.impl.repository.RepositoryBean.getConstructor ( )

Definition at line 160 of file RepositoryBean.java.

160  {
161  return constructor;
162  }

◆ getContext()

String org.turro.elephant.impl.repository.RepositoryBean.getContext ( )

Definition at line 152 of file RepositoryBean.java.

152  {
153  return context;
154  }

◆ getFiles()

String [] org.turro.elephant.impl.repository.RepositoryBean.getFiles ( )

Definition at line 111 of file RepositoryBean.java.

111  {
112  if(!constructor.isInRole(roleList)) {
113  htmlFiles = new String[0];
114  }
115  if(htmlFiles == null) {
116  File f = new File(getRealPath(null));
117  File[] children = f.listFiles();
118  TreeSet set = new TreeSet();
119  String folderLink;
120  if(subFolder != null && subFolder.length() > 0) {
121  folderLink = ElephantContext.getRootWebPath() + "/xprepository?context=" + context;
122  set.add(
123  "<li>" +
124  "<a class='folder' href='" + folderLink + "'>..</a>" +
125  "</li>");
126  }
127  for(int i = 0; children != null && i < children.length; i++) {
128  folderLink = ElephantContext.getRootWebPath() + "/xprepository?context=" + context + "&subfolder=" + children[i].getName();
129  set.add(
130  "<li>" +
131  (isSelectable() ? "<input type='checkbox' name='check' value ='" + children[i].getName() + "'/>" : "") +
132  (children[i].isDirectory() ?
133  "<a class='folder' href='" + folderLink + "'>" :
134  "<a repository=\"" + getImageUrl(children[i].getName()) + "\" class='file'>") +
135  children[i].getName() +
136  "</a>" +
137  "</li>");
138  }
139  htmlFiles = (String[])set.toArray(new String[0]);
140  }
141  return htmlFiles;
142  }
Here is the call graph for this function:

◆ getImageUrl()

String org.turro.elephant.impl.repository.RepositoryBean.getImageUrl ( String  file)

Definition at line 200 of file RepositoryBean.java.

200  {
201  String folderPath = "repository(" +
202  (subFolder == null || subFolder.length() == 0 ? "" : "/" + subFolder);
203  return folderPath + "/" + file + ")";
204  }
Here is the caller graph for this function:

◆ getRealFolder()

String org.turro.elephant.impl.repository.RepositoryBean.getRealFolder ( )

Definition at line 144 of file RepositoryBean.java.

144  {
145  return getRealPath(null);
146  }

◆ getSubFolder()

String org.turro.elephant.impl.repository.RepositoryBean.getSubFolder ( )

Definition at line 225 of file RepositoryBean.java.

225  {
226  return subFolder;
227  }

◆ isSelectable()

boolean org.turro.elephant.impl.repository.RepositoryBean.isSelectable ( )

Definition at line 217 of file RepositoryBean.java.

217  {
218  return selectable;
219  }
Here is the caller graph for this function:

◆ setConstructor()

void org.turro.elephant.impl.repository.RepositoryBean.setConstructor ( IConstructor  constructor) throws Exception

Definition at line 164 of file RepositoryBean.java.

164  {
165  this.constructor = constructor;
166  if(ServletFileUpload.isMultipartContent(constructor.getRequest()) && constructor.isInRole(roleUpload)) {
167  FileItemFactory factory = new DiskFileItemFactory();
168  ServletFileUpload upload = new ServletFileUpload(factory);
169  List items = upload.parseRequest(constructor.getRequest());
170  Iterator iter = items.iterator();
171  while (iter.hasNext()) {
172  FileItem item = (FileItem) iter.next();
173  if(!item.isFormField()) {
174  String onlyName = item.getName();
175  if(onlyName != null && onlyName.length() > 0) {
176  int p = onlyName.lastIndexOf('/');
177  if(p == -1) p = onlyName.lastIndexOf('\\');
178  String realName = getRealPath(convertToValidName(onlyName.substring(p + 1)));
179  if(realName.matches(validUploads)) {
180  File uploadedFile = new File(realName);
181  item.write(uploadedFile);
182  }
183  }
184  }
185  }
186  }
187  else if(constructor.getParameter("removesel") != null && constructor.isInRole(roleDelete)) {
188  String[] check = constructor.getRequest().getParameterValues("check");
189  if(check != null) {
190  for(int i = 0; i < check.length; i++) {
191  deleteFile(check[i]);
192  }
193  }
194  }
195  else if(constructor.getParameter("createdir") != null && constructor.isInRole(roleCreateDir)) {
196  createFolder(convertToValidName(constructor.getParameter("newdir")));
197  }
198  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setContext()

void org.turro.elephant.impl.repository.RepositoryBean.setContext ( String  context)

Definition at line 156 of file RepositoryBean.java.

156  {
157  this.context = context;
158  }
Here is the caller graph for this function:

◆ setRoleCreateDir()

void org.turro.elephant.impl.repository.RepositoryBean.setRoleCreateDir ( String  value)

Definition at line 71 of file RepositoryBean.java.

71  {
72  roleCreateDir = value;
73  }

◆ setRoleDelete()

void org.turro.elephant.impl.repository.RepositoryBean.setRoleDelete ( String  value)

Definition at line 67 of file RepositoryBean.java.

67  {
68  roleDelete = value;
69  }

◆ setRoleList()

void org.turro.elephant.impl.repository.RepositoryBean.setRoleList ( String  value)

Definition at line 63 of file RepositoryBean.java.

63  {
64  roleList = value;
65  }

◆ setRoleUpload()

void org.turro.elephant.impl.repository.RepositoryBean.setRoleUpload ( String  value)

Definition at line 59 of file RepositoryBean.java.

59  {
60  roleUpload = value;
61  }

◆ setRootPath()

void org.turro.elephant.impl.repository.RepositoryBean.setRootPath ( String  value)

Definition at line 75 of file RepositoryBean.java.

75  {
76  rootPath = value;
77  }

◆ setSelectable()

void org.turro.elephant.impl.repository.RepositoryBean.setSelectable ( boolean  selectable)

Definition at line 221 of file RepositoryBean.java.

221  {
222  this.selectable = selectable;
223  }

◆ setSubFolder()

void org.turro.elephant.impl.repository.RepositoryBean.setSubFolder ( String  subFolder)

Definition at line 229 of file RepositoryBean.java.

229  {
230  this.subFolder = subFolder;
231  }
Here is the caller graph for this function:

◆ setValidUploads()

void org.turro.elephant.impl.repository.RepositoryBean.setValidUploads ( String  value)

Definition at line 79 of file RepositoryBean.java.

79  {
80  String sep ="", values[] = value.split(" *, *");
81  validUploads = "";
82  for(int i = 0; i < values.length; i++) {
83  if(values[i].equals("images")) {
84  validUploads += sep + VALID_IMAGES;
85  sep ="|";
86  }
87  else if(values[i].equals("html")) {
88  validUploads += sep + VALID_HTML;
89  sep ="|";
90  }
91  if(values[i].equals("documents")) {
92  validUploads += sep + VALID_DOCUMENTS;
93  sep ="|";
94  }
95  }
96  validUploads = VALID_PATTERN.replaceAll("#", validUploads);
97  }

Member Data Documentation

◆ REPOSITORY_JSP

final String org.turro.elephant.impl.repository.RepositoryBean.REPOSITORY_JSP = "/WEB-INF/elephant/admin/repository.jsp"
static

Definition at line 37 of file RepositoryBean.java.


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