File currentFile = thesisFiles[i];
System.out.println("Importing: " + currentFile.getPath());
if (currentFile.isDirectory()) {
continue;
}
StoredFile currentStoredFile = new StoredFileImpl();
try {
InputStream is = new FileInputStream(currentFile);
try {
currentStoredFile.setData(is);
GregorianCalendar lastModified = new GregorianCalendar();
lastModified.setTimeInMillis(currentFile.lastModified());
currentStoredFile.setName(currentFile.getName());
currentStoredFile.setLastModified(lastModified);
currentStoredFile.setParent(thesisFolder);
currentStoredFile.setMimeType(new MimetypesFileTypeMap().getContentType(currentFile));
storedFiles.add(currentStoredFile);
if (currentStoredFile.getReadUsers() == null) {
currentStoredFile.setReadUsers(new ArrayList());
}
currentStoredFile.getReadUsers().add(new UserImpl("anonymous", ""));
StoredFileDao.createInstance().save(currentStoredFile);
} finally {
is.close();
}