BrightSide Workbench Full Report + Source Code
org.turro.attach.zul.AttachmentUtil Class Reference

Static Public Member Functions

static boolean download (Attachment attachment)
 
static Attachment withContent (Attachment attachment)
 
static Attachment withContent (Long id)
 
static boolean respond (Respond respond, Long id)
 
static void paste (String toPath)
 
static Collection< Attachmentdelete (String path)
 
static void copyAttachment (Object value)
 
static void cutAttachment (String name, final Object value)
 
static void copyFolder (Object value)
 
static void cutFolder (String name, final Object value)
 
static boolean hasClipboard ()
 
static void clearClipboard ()
 

Detailed Description

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

Definition at line 42 of file AttachmentUtil.java.

Member Function Documentation

◆ clearClipboard()

static void org.turro.attach.zul.AttachmentUtil.clearClipboard ( )
static

Definition at line 189 of file AttachmentUtil.java.

189  {
190  Framework.getClipboard().remove("bba_clip_attach_folder_copy");
191  Framework.getClipboard().remove("bba_clip_attach_folder_cut");
192  Framework.getClipboard().remove("bba_clip_attach_copy");
193  Framework.getClipboard().remove("bba_clip_attach_cut");
194  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyAttachment()

static void org.turro.attach.zul.AttachmentUtil.copyAttachment ( Object  value)
static

Definition at line 113 of file AttachmentUtil.java.

113  {
114  clearClipboard();
115  Framework.getClipboard().put("bba_clip_attach_copy", value);
116  }
Here is the call graph for this function:

◆ copyFolder()

static void org.turro.attach.zul.AttachmentUtil.copyFolder ( Object  value)
static

Definition at line 147 of file AttachmentUtil.java.

147  {
148  clearClipboard();
149  Framework.getClipboard().put("bba_clip_attach_folder_copy", value);
150  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cutAttachment()

static void org.turro.attach.zul.AttachmentUtil.cutAttachment ( String  name,
final Object  value 
)
static

Definition at line 118 of file AttachmentUtil.java.

118  {
119  Messages.confirmCutting().add(name).show(() -> {
120  clearClipboard();
121  Framework.getClipboard().put("bba_clip_attach_cut", value);
122  });
123  }
Here is the call graph for this function:

◆ cutFolder()

static void org.turro.attach.zul.AttachmentUtil.cutFolder ( String  name,
final Object  value 
)
static

Definition at line 152 of file AttachmentUtil.java.

152  {
153  Messages.confirmCutting().add(name).show(() -> {
154  clearClipboard();
155  Framework.getClipboard().put("bba_clip_attach_folder_cut", value);
156  });
157  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete()

static Collection<Attachment> org.turro.attach.zul.AttachmentUtil.delete ( String  path)
static

Definition at line 102 of file AttachmentUtil.java.

102  {
103  Dao dao = new AttachPU();
104  Collection<Attachment> list = (Collection<Attachment>) dao.getResultList(
105  "select a from Attachment a where a.path like ? or a.path = ?",
106  new Object[] {path + "/%", path});
107  for(Attachment a : list) {
108  dao.deleteObject(a);
109  }
110  return list;
111  }
Here is the caller graph for this function:

◆ download()

static boolean org.turro.attach.zul.AttachmentUtil.download ( Attachment  attachment)
static

Definition at line 44 of file AttachmentUtil.java.

44  {
45  boolean done = false;
46 // Dao dao = new AttachPU();
47 // dao.startTrans();
48  try(DaoTransaction transaction = new DaoTransaction(new AttachPU())) {
49 // attachment = dao.saveObjectWithTrans(attachment);
50  attachment = transaction.saveObject(attachment);
51  Filedownload.save(attachment.getAttachContent().getFileContent(), attachment.getFileContentType(), attachment.getFileName());
52  done = true;
53 // } finally {
54 // dao.endTrans();
55  SystemLogger.info().entity(attachment).comment("downloaded").log();
56  }
57  return done;
58  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasClipboard()

static boolean org.turro.attach.zul.AttachmentUtil.hasClipboard ( )
static

Definition at line 182 of file AttachmentUtil.java.

182  {
183  return Framework.getClipboard().get("bba_clip_attach_folder_copy") != null ||
184  Framework.getClipboard().get("bba_clip_attach_folder_cut") != null ||
185  Framework.getClipboard().get("bba_clip_attach_copy") != null ||
186  Framework.getClipboard().get("bba_clip_attach_cut") != null;
187  }
Here is the call graph for this function:

◆ paste()

static void org.turro.attach.zul.AttachmentUtil.paste ( String  toPath)
static

Definition at line 96 of file AttachmentUtil.java.

96  {
97  pasteAttachment(toPath);
98  pasteFolder(toPath);
100  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ respond()

static boolean org.turro.attach.zul.AttachmentUtil.respond ( Respond  respond,
Long  id 
)
static

Definition at line 82 of file AttachmentUtil.java.

82  {
83  try {
84  Attachment attachment = withContent(id);
85  respond.name(attachment.getFileName())
86  .type(attachment.getFileContentType())
87  .lenght(attachment.getFileSize())
88  .flush(attachment.getAttachContent().getFileContent());
89  return true;
90  } catch (IOException ex) {
91  WebLoggers.severe(AttachmentUtil.class).exception(ex).log();
92  return false;
93  }
94  }
static boolean respond(Respond respond, Long id)
static Attachment withContent(Attachment attachment)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ withContent() [1/2]

static Attachment org.turro.attach.zul.AttachmentUtil.withContent ( Attachment  attachment)
static

Definition at line 60 of file AttachmentUtil.java.

60  {
61 // Dao dao = new AttachPU();
62 // dao.startTrans();
63  try(DaoTransaction transaction = new DaoTransaction(new AttachPU())) {
64  attachment = transaction.saveObject(attachment);
65  AttachContent content = attachment.getAttachContent();
66  content.getFileContent();
67 // } finally {
68 // dao.endTrans();
69  }
70  return attachment;
71  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ withContent() [2/2]

static Attachment org.turro.attach.zul.AttachmentUtil.withContent ( Long  id)
static

Definition at line 73 of file AttachmentUtil.java.

73  {
74  try(DaoTransaction transaction = new DaoTransaction(new AttachPU())) {
75  Attachment attachment = transaction.find(Attachment.class, id);
76  AttachContent content = attachment.getAttachContent();
77  content.getFileContent();
78  return attachment;
79  }
80  }
Here is the call graph for this function:

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