18 package org.turro.attach.zul;
20 import java.io.IOException;
21 import java.util.Collection;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import org.turro.string.Strings;
25 import org.turro.attach.db.AttachPU;
26 import org.turro.attach.entity.AttachContent;
27 import org.turro.attach.entity.Attachment;
28 import org.turro.attach.version.AttachVersionSet;
29 import org.turro.elephant.util.Messages;
30 import org.turro.http.Respond;
31 import org.turro.jpa.Dao;
32 import org.turro.jpa.DaoTransaction;
33 import org.turro.log.SystemLogger;
34 import org.turro.log.WebLoggers;
35 import org.turro.zul.frame.Framework;
36 import org.zkoss.zul.Filedownload;
50 attachment = transaction.saveObject(attachment);
64 attachment = transaction.saveObject(attachment);
90 }
catch (IOException ex) {
96 public static void paste(String toPath) {
97 pasteAttachment(toPath);
102 public static Collection<Attachment>
delete(String path) {
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});
125 private static void pasteAttachment(String toPath) {
133 Dao dao =
new AttachPU();
134 for (Attachment a : avs) {
136 a.setPath(Strings.isEmpty(toPath) ?
"/" : toPath);
139 Attachment na = a.cloneEntity();
140 na.setPath(Strings.isEmpty(toPath) ?
"/" : toPath);
152 public static void cutFolder(String name,
final Object value) {
159 private static void pasteFolder(String toPath) {
162 if(Strings.isBlank(path)) {
166 if(!Strings.isBlank(path)) {
167 Dao dao =
new AttachPU();
168 for(Attachment a : (Collection<Attachment>) dao.getResultList(
"select a from Attachment a where a.path like ? or a.path = ?",
169 new Object[] {path +
"/%", path})) {
171 a.setPath(convertPath(path, a.getPath(), toPath));
174 Attachment na = a.cloneEntity();
175 na.setPath(convertPath(path, a.getPath(), toPath));
196 private static String convertPath(String root, String path, String toPath) {
197 String reminder = path.substring(root.length());
198 return (Strings.isEmpty(toPath) ?
"/" : toPath) + reminder;
201 private AttachmentUtil() {
AttachContent getAttachContent()
String getFileContentType()
static boolean respond(Respond respond, Long id)
static void clearClipboard()
static void copyAttachment(Object value)
static void copyFolder(Object value)
static boolean hasClipboard()
static Attachment withContent(Long id)
static boolean download(Attachment attachment)
static void cutFolder(String name, final Object value)
static void cutAttachment(String name, final Object value)
static Attachment withContent(Attachment attachment)
static void paste(String toPath)
static Messages confirmCutting()
Messages add(String word)
static ILogWrapper info()
static WebLoggers severe(Object entity)
WebLoggers exception(Throwable throwable)
static FrameClipboard getClipboard()
ILogWrapper comment(String comment)
ILogWrapper entity(Object entity)