Package net.sf.archimede.model.storedFile

Examples of net.sf.archimede.model.storedFile.StoredFileImpl


        List files = this.oldFolder.getFiles();
        for (Iterator it = files.iterator(); it.hasNext(); ) {
            String filePath = (String) it.next();
            File file = new File(filePath);
           
            StoredFile storedFile = new StoredFileImpl();
            InputStream is = new FileInputStream(filePath);
            storedFile.setData(is);
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTimeInMillis(file.lastModified());
            storedFile.setLastModified(cal);
            storedFile.setMimeType( new MimetypesFileTypeMap().getContentType(file) );
            storedFile.setName(file.getName());
            storedFile.setParent(folder);
           
            if (storedFile.getReadUsers() == null) {
              storedFile.setReadUsers(new ArrayList());
            }
            storedFile.getReadUsers().add(new UserImpl("anonymous", ""));
           
            StoredFileDao.createInstance().save(storedFile);
            try {
        is.close();
      } catch (IOException e) {
View Full Code Here


            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();
                }
View Full Code Here

        this.file = file1;
    }

    public String submitUpload() throws IOException {
        if (this.file != null) {
            StoredFile newFile = new StoredFileImpl();
           
            //FIXME Mieux tester...
            String filename = new File(this.file.getName()).getName();
            newFile.setName(filename);
            newFile.setParent(this.selectedFolder.getFolder());
            InputStream data = null;
            try {
                data = this.file.getInputStream();
                newFile.setData(data);
                String contentType = this.file.getContentType();
                newFile.setMimeType(contentType);
                newFile.setLastModified(new GregorianCalendar());
                StoredFileDao.createInstance().save(newFile);
            } finally {
                if (data != null) {
                    data.close();
                }
View Full Code Here

            folder.setDatestamp(new GregorianCalendar());
            folderDao.save(folder);
            for (Iterator it = this.files.values().iterator(); it.hasNext();) {
                UploadedFile currentFile = (UploadedFile) it.next();
                List storedFiles = new ArrayList();
                StoredFile newFile = new StoredFileImpl();
                newFile.setName("content" + Math.random() + ".doc");
                newFile.setParent(folder);
                try {
                    newFile.setData(currentFile.getInputStream());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                newFile.setMimeType("application/msword");
                newFile.setLastModified(new GregorianCalendar());
                StoredFileDao.createInstance().save(newFile);
                storedFiles.add(newFile);
                folder.setStoredFiles(storedFiles);
            }
View Full Code Here

        this.file = file;
    }

    public String submitUpload() {
        if (this.file != null) {
            StoredFile newFile = new StoredFileImpl();
            //FIXME Mieux tester...
            String filename = new File(this.file.getName()).getName();
            newFile.setName(filename);
            newFile.setParent(this.selectedFolder.getFolder());
            try {
                newFile.setData(this.file.getInputStream());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            String contentType = this.file.getContentType();
            newFile.setMimeType(contentType);
            newFile.setLastModified(new GregorianCalendar());
            StoredFileDao.createInstance().save(newFile);
            this.selectedFolder.getFolder().getStoredFiles().add(newFile);

            this.file = null;
            return "upload_done";
View Full Code Here

TOP

Related Classes of net.sf.archimede.model.storedFile.StoredFileImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.