BrightSide Workbench Full Report + Source Code
org.turro.wd.files.Directory Class Reference
Inheritance diagram for org.turro.wd.files.Directory:
Collaboration diagram for org.turro.wd.files.Directory:

Public Member Functions

DirectorySet getDirs ()
 
void setDirs (DirectorySet dirs)
 
WorkFileSet getFiles ()
 
void setFiles (WorkFileSet files)
 
String getName ()
 
void setName (String name)
 
Directory getParent ()
 
void setParent (Directory parent)
 
String getAbsolutePath ()
 
String getPath ()
 
String getServerPath ()
 
void setServerPath (String serverPath)
 
String getSystemName ()
 
String getSystemPath ()
 
File getSystemFile ()
 
String getHost ()
 
Integer getPort ()
 
String getContext ()
 
String getUser ()
 
boolean isRoot ()
 
boolean isWorkingDirectory ()
 
boolean isExistsOnServer ()
 
boolean isUpdatable ()
 
Directory addDirectory (String name)
 
WorkFile addFile (String name)
 
int getnCommits ()
 
int getnFiles ()
 
int getnUpdates ()
 
int compareTo (Directory o)
 
Collection< String > doQueryFolders ()
 
Collection< ServerFiledoQueryFiles ()
 

Protected Member Functions

void countFiles () throws ParseException
 
void readXML (Element root) throws ParseException
 
void writeXML (Element root)
 
boolean checkExisting ()
 
void loadSystemFiles ()
 
void loadServerFiles ()
 

Detailed Description

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

Definition at line 39 of file Directory.java.

Member Function Documentation

◆ addDirectory()

Directory org.turro.wd.files.Directory.addDirectory ( String  name)

Definition at line 193 of file Directory.java.

193  {
194  Directory wdir = new Directory();
195  wdir.setParent(this);
196  wdir.setName(name == null ? "wdtmp" : name);
197  dirs.add(wdir);
198  return wdir;
199  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addFile()

WorkFile org.turro.wd.files.Directory.addFile ( String  name)

Definition at line 201 of file Directory.java.

201  {
202  WorkFile wfile = new WorkFile();
203  wfile.setParent(this);
204  wfile.setName(name == null ? "wdtmp" : name);
205  files.add(wfile);
206  return wfile;
207  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkExisting()

boolean org.turro.wd.files.Directory.checkExisting ( )
protected

Definition at line 278 of file Directory.java.

278  {
279  if(!(isRoot() || isWorkingDirectory())) return false;
280  File dir = getSystemFile();
281  ProgressSheet.nextProgress(dir.getName());
282  if (dir != null && dir.exists()) {
283  Iterator<Directory> itd = getDirs().iterator();
284  while (itd.hasNext()) {
285  if (!itd.next().checkExisting()) {
286  itd.remove();
287  }
288  }
289 // Iterator<WorkFile> itwf = getFiles().iterator();
290 // while (itwf.hasNext()) {
291 // if (!itwf.next().checkExisting()) {
292 // itwf.remove();
293 // }
294 // }
295  return true;
296  } else {
297  return false;
298  }
299  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compareTo()

int org.turro.wd.files.Directory.compareTo ( Directory  o)

Definition at line 351 of file Directory.java.

351  {
352  if (getName() == null || o.getName() == null) {
353  return 0;
354  }
355  return getName().compareTo(o.getName());
356  }
Here is the call graph for this function:

◆ countFiles()

void org.turro.wd.files.Directory.countFiles ( ) throws ParseException
protected

Definition at line 221 of file Directory.java.

221  {
222  nUpdates = nCommits = nFiles = 0;
223  for(Directory d : getDirs()) {
224  d.countFiles();
225  nUpdates += d.nUpdates;
226  nCommits += d.nCommits;
227  nFiles += d.nFiles;
228  }
229  for(WorkFile wf : getFiles()) {
230  nFiles++;
231  if(wf.isDownloadable()) {
232  nUpdates++;
233  } else if(wf.isUploadable()) {
234  nCommits++;
235  }
236  }
237  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doQueryFiles()

Collection<ServerFile> org.turro.wd.files.Directory.doQueryFiles ( )

Definition at line 375 of file Directory.java.

375  {
376  if (isUpdatable()) {
377  try {
378  GetQuery getQuery = new GetQuery(
379  getHost(), getPort(),
380  getContext() + "/pservice/queryFiles", false);
381  getQuery.getParameters().put("user", getUser());
382  getQuery.getParameters().put("path", getAbsolutePath());
383  getQuery.setSerializer(new BinarySerializer());
384  return (Collection<ServerFile>) getQuery.execute();
385  } catch (QueryException ex) {
386  Logger.getLogger(Directory.class.getName()).log(Level.SEVERE, null, ex);
387  }
388  }
389  return new ArrayList<ServerFile>();
390  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doQueryFolders()

Collection<String> org.turro.wd.files.Directory.doQueryFolders ( )

Definition at line 358 of file Directory.java.

358  {
359  if (isUpdatable()) {
360  try {
361  GetQuery getQuery = new GetQuery(
362  getHost(), getPort(),
363  getContext() + "/pservice/queryFolders", false);
364  getQuery.getParameters().put("user", getUser());
365  getQuery.getParameters().put("path", getAbsolutePath());
366  getQuery.setSerializer(new BinarySerializer());
367  return (Collection<String>) getQuery.execute();
368  } catch (QueryException ex) {
369  Logger.getLogger(Directory.class.getName()).log(Level.SEVERE, null, ex);
370  }
371  }
372  return new ArrayList<String>();
373  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAbsolutePath()

String org.turro.wd.files.Directory.getAbsolutePath ( )

Definition at line 79 of file Directory.java.

79  {
80  String ap = null;
81  Directory current = this;
82  while (current != null) {
83  if (current.getPath() != null) {
84  ap = current.getPath() + (ap == null ? "" : "/" + ap);
85  }
86  current = current.getParent();
87  }
88  return ap;
89  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContext()

String org.turro.wd.files.Directory.getContext ( )

Definition at line 159 of file Directory.java.

159  {
160  Directory current = this;
161  while (!(current instanceof WorkingDirectory)) {
162  current = current.getParent();
163  }
164  return ((WorkingDirectory) current).getBbContext();
165  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDirs()

DirectorySet org.turro.wd.files.Directory.getDirs ( )

Definition at line 47 of file Directory.java.

47  {
48  return dirs;
49  }
Here is the caller graph for this function:

◆ getFiles()

WorkFileSet org.turro.wd.files.Directory.getFiles ( )

Definition at line 55 of file Directory.java.

55  {
56  return files;
57  }
Here is the caller graph for this function:

◆ getHost()

String org.turro.wd.files.Directory.getHost ( )

Definition at line 142 of file Directory.java.

142  {
143  Directory current = this;
144  while (!(current instanceof WorkingDirectory)) {
145  current = current.getParent();
146  }
147  return ((WorkingDirectory) current).getBbHost();
148  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getName()

String org.turro.wd.files.Directory.getName ( )

Definition at line 63 of file Directory.java.

63  {
64  return name;
65  }
Here is the caller graph for this function:

◆ getnCommits()

int org.turro.wd.files.Directory.getnCommits ( )

Definition at line 209 of file Directory.java.

209  {
210  return nCommits;
211  }
Here is the caller graph for this function:

◆ getnFiles()

int org.turro.wd.files.Directory.getnFiles ( )

Definition at line 213 of file Directory.java.

213  {
214  return nFiles;
215  }

◆ getnUpdates()

int org.turro.wd.files.Directory.getnUpdates ( )

Definition at line 217 of file Directory.java.

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

◆ getParent()

Directory org.turro.wd.files.Directory.getParent ( )

Definition at line 71 of file Directory.java.

71  {
72  return parent;
73  }
Here is the caller graph for this function:

◆ getPath()

String org.turro.wd.files.Directory.getPath ( )

Definition at line 91 of file Directory.java.

91  {
92  if (getServerPath() != null) {
93  return getServerPath();
94  } else {
95  return getName();
96  }
97  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPort()

Integer org.turro.wd.files.Directory.getPort ( )

Definition at line 150 of file Directory.java.

150  {
151  Directory current = this;
152  while (!(current instanceof WorkingDirectory)) {
153  current = current.getParent();
154  }
155  String port = ((WorkingDirectory) current).getBbPort();
156  return port == null ? 80 : new Integer(port);
157  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getServerPath()

String org.turro.wd.files.Directory.getServerPath ( )

Definition at line 99 of file Directory.java.

99  {
100  return serverPath;
101  }
Here is the caller graph for this function:

◆ getSystemFile()

File org.turro.wd.files.Directory.getSystemFile ( )

Definition at line 134 of file Directory.java.

134  {
135  String sp = getSystemPath();
136  if (sp != null) {
137  return new File(sp);
138  }
139  return null;
140  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSystemName()

String org.turro.wd.files.Directory.getSystemName ( )

Reimplemented in org.turro.wd.files.WorkingDirectory.

Definition at line 107 of file Directory.java.

107  {
108  return getName()
109  .replaceAll("\\|", "-")
110  .replaceAll("\\<", "-")
111  .replaceAll("\\>", "-")
112  .replaceAll("\\:", "-")
113  .replaceAll("\"", "'")
114  .replaceAll("\\\\", "-")
115  .replaceAll("\\/", "-")
116  .replaceAll("\\*", "-")
117  .replaceAll("\\&", "i")
118  .replaceAll("\\%", "-")
119  .replaceAll("\\?", "-");
120  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSystemPath()

String org.turro.wd.files.Directory.getSystemPath ( )

Definition at line 122 of file Directory.java.

122  {
123  String sp = null;
124  Directory current = this;
125  while (current != null) {
126  if (current.getSystemName() != null) {
127  sp = current.getSystemName() + (sp == null ? "" : "/" + sp);
128  current = current.getParent();
129  }
130  }
131  return sp;
132  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUser()

String org.turro.wd.files.Directory.getUser ( )

Definition at line 167 of file Directory.java.

167  {
168  Directory current = this;
169  while (!(current instanceof WorkingDirectory)) {
170  current = current.getParent();
171  }
172  return ((WorkingDirectory) current).getBbUser();
173  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isExistsOnServer()

boolean org.turro.wd.files.Directory.isExistsOnServer ( )

Definition at line 183 of file Directory.java.

183  {
184  return !isWorkingDirectory() && getServerPath() != null;
185  }
Here is the call graph for this function:

◆ isRoot()

boolean org.turro.wd.files.Directory.isRoot ( )

Definition at line 175 of file Directory.java.

175  {
176  return parent instanceof WorkingDirectory;
177  }
Here is the caller graph for this function:

◆ isUpdatable()

boolean org.turro.wd.files.Directory.isUpdatable ( )

Definition at line 187 of file Directory.java.

187  {
188  return !isWorkingDirectory()
189  && ((isRoot() && getServerPath() != null)
190  || !isRoot() && parent.isUpdatable());
191  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isWorkingDirectory()

boolean org.turro.wd.files.Directory.isWorkingDirectory ( )

Definition at line 179 of file Directory.java.

179  {
180  return this instanceof WorkingDirectory;
181  }
Here is the caller graph for this function:

◆ loadServerFiles()

void org.turro.wd.files.Directory.loadServerFiles ( )
protected

Definition at line 326 of file Directory.java.

326  {
327  for (Directory d : getDirs()) {
328  d.loadServerFiles();
329  }
330  for (String folder : doQueryFolders()) {
331  ProgressSheet.nextProgress(folder);
332  if (!getDirs().containsDir(folder)) {
333  Directory nd = addDirectory(folder);
334  nd.loadServerFiles();
335  }
336  }
337  for (ServerFile sf : doQueryFiles()) {
338  WorkFile wf = getFiles().getFile(sf.getFileName());
339  if (wf == null) {
340  wf = addFile(sf.getFileName());
341  }
342  ProgressSheet.nextProgress(sf.getFileName());
343  wf.setDownModification(sf.getModification());
344  wf.setServerOwner(sf.getOwner());
345  wf.setServerSize(sf.getFileSize());
346  wf.setServerLocked(sf.isLocked());
347  wf.setServerLocker(sf.getLocker());
348  }
349  }
Collection< String > doQueryFolders()
Definition: Directory.java:358
Directory addDirectory(String name)
Definition: Directory.java:193
WorkFile addFile(String name)
Definition: Directory.java:201
Collection< ServerFile > doQueryFiles()
Definition: Directory.java:375
WorkFile getFile(String file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadSystemFiles()

void org.turro.wd.files.Directory.loadSystemFiles ( )
protected

Definition at line 301 of file Directory.java.

301  {
302  File dir = getSystemFile();
303  for (File file : dir.listFiles()) {
304  if(file.getName().startsWith(".") ||
305  file.getName().endsWith("~") ||
306  file.isHidden()) {
307  continue;
308  }
309  ProgressSheet.nextProgress(file.getName());
310  if (file.isDirectory()) {
311  Directory d = getDirs().getDir(file.getName());
312  if (d == null) {
313  d = addDirectory(file.getName());
314  }
315  d.loadSystemFiles();
316  } else if (file.isFile()) {
317  WorkFile wf = getFiles().getFile(file.getName());
318  if (wf == null) {
319  wf = addFile(file.getName());
320  }
321  wf.setFile(file);
322  }
323  }
324  }
Directory getDir(String dir)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readXML()

void org.turro.wd.files.Directory.readXML ( Element  root) throws ParseException
protected

Definition at line 239 of file Directory.java.

239  {
240  if (root.getAttributeValue("name") != null) {
241  setName(root.getAttributeValue("name"));
242  }
243  if (root.getAttributeValue("serverPath") != null) {
244  setServerPath(decryptString(root.getAttributeValue("serverPath")));
245  return;
246  }
247  for (Element el : (List<Element>) root.getChildren("wdir")) {
248  Directory wdir = addDirectory(null);
249  wdir.readXML(el);
250  }
251  for (Element el : (List<Element>) root.getChildren("wfile")) {
252  WorkFile wfile = addFile(null);
253  wfile.readXML(el);
254  }
255  }
void setName(String name)
Definition: Directory.java:67
void setServerPath(String serverPath)
Definition: Directory.java:103
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDirs()

void org.turro.wd.files.Directory.setDirs ( DirectorySet  dirs)

Definition at line 51 of file Directory.java.

51  {
52  this.dirs = dirs;
53  }

◆ setFiles()

void org.turro.wd.files.Directory.setFiles ( WorkFileSet  files)

Definition at line 59 of file Directory.java.

59  {
60  this.files = files;
61  }

◆ setName()

void org.turro.wd.files.Directory.setName ( String  name)

Definition at line 67 of file Directory.java.

67  {
68  this.name = name;
69  }
Here is the caller graph for this function:

◆ setParent()

void org.turro.wd.files.Directory.setParent ( Directory  parent)

Definition at line 75 of file Directory.java.

75  {
76  this.parent = parent;
77  }
Here is the caller graph for this function:

◆ setServerPath()

void org.turro.wd.files.Directory.setServerPath ( String  serverPath)

Definition at line 103 of file Directory.java.

103  {
104  this.serverPath = serverPath;
105  }
Here is the caller graph for this function:

◆ writeXML()

void org.turro.wd.files.Directory.writeXML ( Element  root)
protected

Definition at line 257 of file Directory.java.

257  {
258  Element el;
259  if (!isWorkingDirectory()) {
260  el = new Element("wdir");
261  el.setAttribute("name", getName());
262  if (getServerPath() != null) {
263  el.setAttribute("serverPath", encryptString(getServerPath()));
264  }
265  root.addContent(el);
266  if (getServerPath() != null) return;
267  } else {
268  el = root;
269  }
270  for (Directory d : dirs) {
271  d.writeXML(el);
272  }
273  for (WorkFile f : files) {
274  f.writeXML(el);
275  }
276  }
Here is the call graph for this function:
Here is the caller graph for this function:

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