|
static Attachment | saveFromFile (File file, String fileName, String fileDate, String path, String user, String comment, boolean lock, boolean validated) |
|
static File | convertToFile (String path, String fileName, String user, boolean forEditing) |
|
static void | writeToFile (Attachment attachment, File file) |
|
static List< String > | queryFolders (String path, String user) |
|
static List< ServerFile > | queryAttachments (String path, String user) |
|
static List< ServerFile > | queryVersionedAttachments (String path, String user) |
|
static Attachment | queryVersionedAttachment (String path, String fileName, String user) |
|
static Object | unlockFile (String path, String fileName, String user) |
|
- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 41 of file AttachWd.java.
◆ convertToFile()
static File org.turro.wd.entities.AttachWd.convertToFile |
( |
String |
path, |
|
|
String |
fileName, |
|
|
String |
user, |
|
|
boolean |
forEditing |
|
) |
| |
|
static |
Definition at line 88 of file AttachWd.java.
92 if(attachment.isLocked())
return null;
93 attachment.setLocked(
true);
94 attachment.setLocker(user);
95 attachment =
new AttachPU().saveObject(attachment);
97 attachment = AttachmentUtil.withContent(attachment);
98 File tempFile = File.createTempFile(AttachWd.class.getName(),
null);
99 FileOutputStream outputStream =
new FileOutputStream(tempFile);
101 ByteArrayInputStream inputStream =
new ByteArrayInputStream(attachment.getAttachContent().getFileContent());
102 for(
int data = inputStream.read(); data != -1; data = inputStream.read()) {
103 outputStream.write((
byte)data);
106 outputStream.close();
108 tempFile.setLastModified(attachment.getModification().getTime());
110 }
catch (IOException ex) {
111 Logger.getLogger(AttachWd.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
static Attachment queryVersionedAttachment(String path, String fileName, String user)
◆ queryAttachments()
static List<ServerFile> org.turro.wd.entities.AttachWd.queryAttachments |
( |
String |
path, |
|
|
String |
user |
|
) |
| |
|
static |
Definition at line 143 of file AttachWd.java.
144 AttachHeadlessResults results =
new AttachHeadlessResults();
145 results.setAttachValue(
"*");
146 results.setAttachPath(Strings.isEmpty(path) ?
"/" : path);
147 results.setCkExactPath(
true);
148 return new ServerFileAdapter(results.getAttachmentList());
◆ queryFolders()
static List<String> org.turro.wd.entities.AttachWd.queryFolders |
( |
String |
path, |
|
|
String |
user |
|
) |
| |
|
static |
Definition at line 135 of file AttachWd.java.
136 AttachHeadlessResults results =
new AttachHeadlessResults();
137 results.setAttachValue(
"*");
138 results.setAttachPath(path +
"/_%");
139 results.setCkExactPath(
false);
140 return new ArrayList<String>(results.getPathList(path));
◆ queryVersionedAttachment()
static Attachment org.turro.wd.entities.AttachWd.queryVersionedAttachment |
( |
String |
path, |
|
|
String |
fileName, |
|
|
String |
user |
|
) |
| |
|
static |
Definition at line 163 of file AttachWd.java.
164 AttachHeadlessResults results =
new AttachHeadlessResults();
165 results.setAttachValue(fileName);
166 results.setAttachPath(Strings.isEmpty(path) ?
"/" : path);
167 results.setCkExactPath(
true);
168 AttachVersionMap avm =
new AttachVersionMap();
169 for(Attachment a : results.getAttachmentList()) {
170 avm.addAttachment(a);
172 return avm.isEmpty() ? null : avm.get(fileName).first();
◆ queryVersionedAttachments()
static List<ServerFile> org.turro.wd.entities.AttachWd.queryVersionedAttachments |
( |
String |
path, |
|
|
String |
user |
|
) |
| |
|
static |
Definition at line 151 of file AttachWd.java.
152 AttachHeadlessResults results =
new AttachHeadlessResults();
153 results.setAttachValue(
"*");
154 results.setAttachPath(Strings.isEmpty(path) ?
"/" : path);
155 results.setCkExactPath(
true);
156 AttachVersionMap avm =
new AttachVersionMap();
157 for(Attachment a : results.getAttachmentList()) {
158 avm.addAttachment(a);
160 return new ServerFileAdapter(avm.getVersionedAttachments());
◆ saveFromFile()
static Attachment org.turro.wd.entities.AttachWd.saveFromFile |
( |
File |
file, |
|
|
String |
fileName, |
|
|
String |
fileDate, |
|
|
String |
path, |
|
|
String |
user, |
|
|
String |
comment, |
|
|
boolean |
lock, |
|
|
boolean |
validated |
|
) |
| |
|
static |
Definition at line 43 of file AttachWd.java.
45 InputStream is =
null;
47 Attachment attachment =
new Attachment();
48 attachment.setFileName(fileName);
49 attachment.setModification(WdFormats.parse(fileDate));
50 attachment.setPath(path);
51 attachment.setOwner(user);
52 attachment.setOnlyOwner(
false);
53 attachment.setComment(comment);
54 attachment.setShowKey(
null);
56 attachment.setLocked(
true);
57 attachment.setLocker(user);
59 AttachContent ac =
new AttachContent();
60 byte[] buffer =
new byte[102400];
61 is =
new FileInputStream(file);
62 ByteArrayOutputStream baos =
new ByteArrayOutputStream();
64 while ((r = is.read(buffer)) != -1) {
65 baos.write(buffer, 0, r);
68 ac.setFileContent(baos.toByteArray());
69 attachment.setAttachContent(ac);
70 attachment.setFileContentType(WdFormats.getContentType(file));
71 attachment.setFileSize(ac.getFileContent().length);
72 attachment.setValidated(validated);
73 return new AttachPU().saveObject(attachment);
74 }
catch (ParseException ex) {
75 Logger.getLogger(AttachWd.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
76 }
catch (IOException ex) {
77 Logger.getLogger(AttachWd.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
80 if(is !=
null) is.close();
81 }
catch (IOException ex) {
82 Logger.getLogger(AttachWd.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
◆ unlockFile()
static Object org.turro.wd.entities.AttachWd.unlockFile |
( |
String |
path, |
|
|
String |
fileName, |
|
|
String |
user |
|
) |
| |
|
static |
Definition at line 175 of file AttachWd.java.
177 if(attachment !=
null && attachment.isLocked()) {
178 attachment.setLocked(
false);
179 attachment.setLocker(
null);
180 attachment.setLockComment(
null);
181 attachment.setLockDate(
null);
182 attachment.setLockCommit(
null);
183 attachment =
new AttachPU().saveObject(attachment);
185 ServerFile sf =
new ServerFile();
186 if(attachment !=
null) {
187 sf.setFileContentType(attachment.getFileContentType());
188 sf.setFileName(attachment.getFileName());
189 sf.setFileSize(attachment.getFileSize());
190 sf.setLocked(attachment.isLocked());
191 sf.setLocker(attachment.getLocker());
192 sf.setModification(attachment.getModification());
193 sf.setOwner(attachment.getOwner());
194 sf.setPath(attachment.getPath());
◆ writeToFile()
static void org.turro.wd.entities.AttachWd.writeToFile |
( |
Attachment |
attachment, |
|
|
File |
file |
|
) |
| |
|
static |
Definition at line 116 of file AttachWd.java.
118 attachment = AttachmentUtil.withContent(attachment);
119 FileOutputStream outputStream =
new FileOutputStream(file);
121 ByteArrayInputStream inputStream =
new ByteArrayInputStream(attachment.getAttachContent().getFileContent());
122 for(
int data = inputStream.read(); data != -1; data = inputStream.read()) {
123 outputStream.write((
byte)data);
126 outputStream.flush();
127 outputStream.close();
129 file.setLastModified(attachment.getModification().getTime());
130 }
catch (IOException ex) {
131 Logger.getLogger(AttachWd.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
The documentation for this class was generated from the following file: