Package net.sf.archimede.model.storedFile

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


    public void downloadFileAction(ActionEvent event) throws IOException {
       
        this.selectedStoredFile = (ViewStoredFile) this.storedFiles.getRowData();
        //Refresh the value
        StoredFileDao storedFileDao = StoredFileDao.createInstance();
        StoredFile storedFile = storedFileDao.retrieve(this.selectedStoredFile.getId());
        this.selectedStoredFile = new ViewStoredFile(storedFile);
       
        FacesContext facesContext = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();     
        
View Full Code Here


        }
        return "";
    }
   
    public String seePermissions() {
        StoredFile storedFile = StoredFileDao.createInstance().retrieve(this.selectedStoredFile.getId());
        this.selectedStoredFile = new ViewStoredFile(storedFile);
       
        return "workspace_storedFile_edition_permissions";
    }
View Full Code Here

   
    public String open() {
        this.selectedStoredFile = (ViewStoredFile) this.storedFiles.getRowData();
        //Refresh the value
        StoredFileDao storedFileDao = StoredFileDao.createInstance();
        StoredFile storedFile = storedFileDao.retrieve(this.selectedStoredFile.getId());
        this.selectedStoredFile = new ViewStoredFile(storedFile);
       
        return "workspace_storedFile_edition";
    }
View Full Code Here

                throw new IllegalStateException("The object cannot request cut and copy operations all at once.");
            }
            if (this.cutRequested) {
                for (Iterator it = this.selectedStoredFiles.iterator(); it.hasNext(); ){
                    ViewStoredFile viewStoredFile = (ViewStoredFile) it.next();
                    StoredFile cutStoredFile = viewStoredFile.getStoredFile();
                    storedFileDao.cutTo(cutStoredFile, destinationFolder);
                    this.cutRequested = false;
                }               
            } else if (this.copyRequested) {
                for (Iterator it = this.selectedStoredFiles.iterator(); it.hasNext(); ){
                    ViewStoredFile viewStoredFile = (ViewStoredFile) it.next();
                    StoredFile cutStoredFile = viewStoredFile.getStoredFile();
                    storedFileDao.copyTo(cutStoredFile, destinationFolder);
                    this.copyRequested = false;
               
            } else {
                //All false: nothing to do
View Full Code Here

            this.setLeaf(true);
          }

          Iterator filesIt = files.iterator();
          while (filesIt.hasNext()) {
            StoredFile currentFile = (StoredFile) filesIt.next();
            CustomTreeNode tnbFile = new CustomTreeNode("file",
                currentFile.getName(), true);
            tnbFile.setIdentifier(currentFile.getId());
            tnbFile.setParent(this);
            tnbFile.setContent(new ViewStoredFile(currentFile));
            this.children.add(tnbFile);
          }
View Full Code Here

    TreeNode treeNode = this.treeModel.getNode();
    String identifier = treeNode.getIdentifier();

    StoredFileDao fileDao = StoredFileDao.createInstance();
    StoredFile file = fileDao.retrieve(identifier);

    FacesContext facesContext = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) facesContext
        .getExternalContext().getResponse();

    response.setContentType(file.getMimeType());
    response.setHeader("Content-disposition", "attachment; filename=\""
        + file.getName() + "\"");

    ServletOutputStream out = response.getOutputStream();
    InputStream stream = file.getData();

    int bytesRead = 0;
    byte[] buffer = new byte[8192];
    // Write to servlet output stream
    while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
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

    }
   
    public void downloadFileAction(ActionEvent event) throws IOException {
       
        StoredFileDao fileDao = StoredFileDao.createInstance();
        StoredFile storedFile = (StoredFile) this.selectedFolder.getStoredFilesModel().getRowData();
        StoredFile file2download = fileDao.retrieve(storedFile.getId());
       
        FacesContext facesContext = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();     
        
        //text/plain, vnd.ms-excel, application/x-download, ...
        response.setContentType(file2download.getMimeType());
        response.setHeader("Content-disposition","attachment; filename=\"" + file2download.getName() + "\"");     
       
        ServletOutputStream out = response.getOutputStream()
        InputStream stream = file2download.getData();
       
        int bytesRead = 0;
        byte[] buffer = new byte[8192];
        //Write to servlet output stream
        while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
View Full Code Here

      String folderId = urlsPaths[urlsPaths.length - 2];
      String fileName = urlsPaths[urlsPaths.length - 1];
     
      Folder folder = FolderDao.createInstance().retrieve(folderId);
      List files = folder.getStoredFiles();
      StoredFile fileTodownload = null;
      for (Iterator it = files.iterator(); it.hasNext(); ) {
        StoredFile currentFile = (StoredFile) it.next();
        if (currentFile.getName().equals(fileName)) {
          fileTodownload = currentFile;
          break;
        }
      }
View Full Code Here

                              };
                              st.execute();
                          }
                           
                          //TODO Plus direct. Faire une m�thode publique, retrieve by node ?
                          StoredFile file = StoredFileDao.createInstance().retrieve(currentNode.getUUID());
                          files.add(file);
                          //System.out.println("File ADDDED !!!!");
                        }
                    }
                    Collections.sort(files, new Comparator() {
View Full Code Here

TOP

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

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.