BrightSide Workbench Full Report + Source Code
org.turro.file.FileWrapper Class Reference
Inheritance diagram for org.turro.file.FileWrapper:
Collaboration diagram for org.turro.file.FileWrapper:

Public Member Functions

 FileWrapper (File file)
 
File getFile ()
 
String getBaseName ()
 
String getExtension ()
 
List< FileActiongetActions ()
 
FileAction getAction (String label)
 
Properties getProperties () throws FileNotFoundException, IOException
 
FileItem getFileItem ()
 
void setFileItem (FileItem fileItem)
 
void delete ()
 
void copyTo (File destination) throws IOException
 
void download ()
 
void upload (final Command command)
 
void uploadContent (final Command command)
 

Static Public Member Functions

static FileWrapper getFileByType (File file)
 

Protected Attributes

File file
 
FileItem fileItem
 
PropertiesFile propertiesFile
 
List< FileActionactions
 

Detailed Description

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

Definition at line 45 of file FileWrapper.java.

Constructor & Destructor Documentation

◆ FileWrapper()

org.turro.file.FileWrapper.FileWrapper ( File  file)

Definition at line 52 of file FileWrapper.java.

52  {
53  this.file = file;
54  actions = new ArrayList<>();
55  actions.add(new DeleteAction(this));
56  actions.add(new RenameAction(this));
57  if(file.isDirectory()) {
58  actions.add(new UploadAction(this));
59  } else if(file.isFile()) {
60  actions.add(new DownloadAction(this));
61  if(EditAction.fits(file)) {
62  actions.add(new EditAction(this));
63  }
64  }
65  }
List< FileAction > actions
static boolean fits(File file)
Definition: EditAction.java:68
Here is the call graph for this function:

Member Function Documentation

◆ copyTo()

void org.turro.file.FileWrapper.copyTo ( File  destination) throws IOException

Definition at line 111 of file FileWrapper.java.

111  {
112  if(destination.isDirectory()) {
113  if(file.isDirectory()) {
114  FileUtil.copyFolder(file, destination.getAbsolutePath());
115  } else if(file.isFile()) {
116  FileUtil.copyFile(file, destination.getAbsolutePath());
117  }
118  }
119  }

◆ delete()

void org.turro.file.FileWrapper.delete ( )

Definition at line 107 of file FileWrapper.java.

107  {
108  FileUtil.deleteFile(file);
109  }
Here is the caller graph for this function:

◆ download()

void org.turro.file.FileWrapper.download ( )

Definition at line 121 of file FileWrapper.java.

121  {
122  try {
123  Filedownload.save(file, ContentTypes.getContentType(FileUtil.getExtension(file)));
124  SystemLogger.info()
125  .entityPath("/file" + ElephantContext.getRelativePath(file.getAbsolutePath()))
126  .entityName(file.getName()).comment("downloaded")
127  .log();
128  } catch (Exception ex) {
129  Logger.getLogger(FileWrapper.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
130  }
131  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAction()

FileAction org.turro.file.FileWrapper.getAction ( String  label)

Definition at line 83 of file FileWrapper.java.

83  {
84  for(FileAction fa : getActions()) {
85  if(fa.getLabel().equals(label)) {
86  return fa;
87  }
88  }
89  return null;
90  }
List< FileAction > getActions()
Here is the call graph for this function:

◆ getActions()

List<FileAction> org.turro.file.FileWrapper.getActions ( )

Definition at line 79 of file FileWrapper.java.

79  {
80  return actions;
81  }
Here is the caller graph for this function:

◆ getBaseName()

String org.turro.file.FileWrapper.getBaseName ( )

Definition at line 71 of file FileWrapper.java.

71  {
72  return FileUtil.getBaseName(file);
73  }

◆ getExtension()

String org.turro.file.FileWrapper.getExtension ( )

Definition at line 75 of file FileWrapper.java.

75  {
76  return FileUtil.getExtension(file);
77  }

◆ getFile()

File org.turro.file.FileWrapper.getFile ( )

Definition at line 67 of file FileWrapper.java.

67  {
68  return file;
69  }
Here is the caller graph for this function:

◆ getFileByType()

static FileWrapper org.turro.file.FileWrapper.getFileByType ( File  file)
static

Definition at line 186 of file FileWrapper.java.

186  {
187  if(FolderFile.isMyType(file)) {
188  return new FolderFile(file);
189  } else if(ZipFile.isMyType(file)) {
190  return new ZipFile(file);
191  } else if(VideoFile.isMyType(file)) {
192  return new VideoFile(file);
193  } else if(ImageFile.isMyType(file)) {
194  return new ImageFile(file);
195  } else if(JasperFile.isMyType(file)) {
196  return new JasperFile(file);
197  } else if(DefaultFile.isMyType(file)) {
198  return new DefaultFile(file);
199  }
200  return null;
201  }
static boolean isMyType(File file)
Definition: FolderFile.java:50
static boolean isMyType(File file)
Definition: JasperFile.java:52
static boolean isMyType(File file)
Definition: ZipFile.java:40
Here is the call graph for this function:

◆ getFileItem()

FileItem org.turro.file.FileWrapper.getFileItem ( )

Definition at line 99 of file FileWrapper.java.

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

◆ getProperties()

Properties org.turro.file.FileWrapper.getProperties ( ) throws FileNotFoundException, IOException

Definition at line 92 of file FileWrapper.java.

92  {
93  if(propertiesFile == null) {
94  propertiesFile = new PropertiesFile(file);
95  }
97  }
PropertiesFile propertiesFile
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFileItem()

void org.turro.file.FileWrapper.setFileItem ( FileItem  fileItem)

Definition at line 103 of file FileWrapper.java.

103  {
104  this.fileItem = fileItem;
105  }

◆ upload()

void org.turro.file.FileWrapper.upload ( final Command  command)

Definition at line 133 of file FileWrapper.java.

133  {
134  if(!file.exists()) {
135  file.mkdirs();
136  }
137  Fileupload.get(100, new EventListener<UploadEvent>() {
138  @Override
139  public void onEvent(UploadEvent event) {
140  ArrayList<File> list = new ArrayList<>();
141  Media[] medias = event.getMedias();
142  if(medias == null || medias.length == 0) return;
143  for(Media media : medias) {
144  File newFile = new File(file.getAbsolutePath() + "/" + Document.correctName(media.getName()));
145  Medias.toFile(media, newFile);
146  list.add(newFile);
147  }
148  if(command != null) {
149  try {
150  Context context = new Context();
151  context.put("files", list);
152  command.execute(context);
153  } catch (Exception ex) {
154  Logger.getLogger(FileWrapper.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
155  }
156  }
157  }
158  });
159  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uploadContent()

void org.turro.file.FileWrapper.uploadContent ( final Command  command)

Definition at line 161 of file FileWrapper.java.

161  {
162  if(!file.getParentFile().exists()) {
163  file.getParentFile().mkdirs();
164  }
165  Fileupload.get(1, new EventListener<UploadEvent>() {
166  @Override
167  public void onEvent(UploadEvent event) throws Exception {
168  Media[] medias = event.getMedias();
169  if(medias == null || medias.length == 0) return;
170  for(Media media : medias) {
171  Medias.toFile(media, file);
172  }
173  if(command != null) {
174  try {
175  Context context = new Context();
176  context.put("file", file);
177  command.execute(context);
178  } catch (Exception ex) {
179  Logger.getLogger(FileWrapper.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
180  }
181  }
182  }
183  });
184  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ actions

List<FileAction> org.turro.file.FileWrapper.actions
protected

Definition at line 50 of file FileWrapper.java.

◆ file

File org.turro.file.FileWrapper.file
protected

Definition at line 47 of file FileWrapper.java.

◆ fileItem

FileItem org.turro.file.FileWrapper.fileItem
protected

Definition at line 48 of file FileWrapper.java.

◆ propertiesFile

PropertiesFile org.turro.file.FileWrapper.propertiesFile
protected

Definition at line 49 of file FileWrapper.java.


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