+ public void upload(Attachment attachment, Resource resource) {
+ try {
+ storeAttachment(attachment, resource.getInputStream());
+ } catch (IOException e) {
+ throw new SlcException("Cannot upload attachment " + attachment, e);
+ }
+ }
+
+ /** For monitoring purposes only */
+ protected void updateAttachmentToc(Attachment attachment, File file) {
+ Date date = new Date(file.lastModified());
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(attachmentsDirectory + File.separator
+ + attachmentsTocFileName, true);
+ writer.append(dateFormatDay.format(date));
+ writer.append(',');
+ writer.append(dateFormatTime.format(date));
+ writer.append(',');
+ writer.append(attachment.getUuid());
+ writer.append(',');
+ writer.append(attachment.getName());
+ writer.append(',');
+ writer.append(attachment.getContentType());
+ writer.append(',');
+ writer.append(Long.toString(file.length()));
+ writer.append(',');
+ writer.append(file.getCanonicalPath());
+ writer.append('\n');
+ } catch (IOException e) {
+ log.warn("Could not update attachments TOC for " + attachment
+ + " and file " + file, e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+
+ }
+