log.audit("ProjectBroker: Deleted ProjectBroker=" + projectBroker);
}
public void saveAttachedFile(Project project, String fileName, VFSLeaf uploadedItem, CourseEnvironment courseEnv, CourseNode cNode) {
log.debug("saveAttachedFile file-name=" + uploadedItem.getName());
OlatRootFolderImpl uploadVFSContainer = new OlatRootFolderImpl(getAttamchmentRelativeRootPath(project,courseEnv,cNode), null);
log.debug("saveAttachedFile uploadVFSContainer.relPath=" + uploadVFSContainer.getRelPath());
// only one attachment, delete other file
for (Iterator<VFSItem> iterator = uploadVFSContainer.getItems().iterator(); iterator.hasNext();) {
VFSItem item = iterator.next();
// Project.getAttachmentFileName is the previous file-name, will not be deleted; student could have open detail-project page with previous attachemnt-link
if (!item.getName().equals(project.getAttachmentFileName())) {
item.delete();
}
}
VFSLeaf newFile = (VFSLeaf)uploadVFSContainer.resolve(fileName);
if (newFile == null) {
newFile = uploadVFSContainer.createChildLeaf(fileName);
}
BufferedInputStream in = new BufferedInputStream(uploadedItem.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(newFile.getOutputStream(false));
boolean success = false;
if (in != null) {