Package de.innovationgate.utils

Examples of de.innovationgate.utils.TemporaryFile


                suffix = ".png";
            }
            finalFileName = fileName.substring(0, fileName.lastIndexOf(".")) + suffix;
        }
       
        TemporaryFile targetFile = new TemporaryFile(finalFileName, null, WGFactory.getTempDir());
        targetFile.deleteOnEviction(doc.getDatabase().getSessionContext());
       
        // Write scaled image to target file
        scaler.writeImage(targetFile.getFile());      
           
        // Attach scaled image
        doc.attachFile(targetFile.getFile());                 
    }
View Full Code Here


   
    if( altFileName != null && !altFileName.equals("") ) {
      // only the first file, because -> only one filename given
      File file = (File) fileIter.next();
      if (!file.getName().equals(altFileName)) {
        TemporaryFile targetFile = new TemporaryFile(altFileName, new FileInputStream(file), WGFactory.getTempDir());
        targetFile.deleteOnEviction(doc.getDatabase().getSessionContext());
                boolean result = doc.attachFile( targetFile.getFile() );
                return result;
      }
      else {
          return doc.attachFile(file);
      }
View Full Code Here

      else {
          String fileName = file.getName();
          targetFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".jpg";
      }
     
      TemporaryFile tempTargetFile = new TemporaryFile(targetFileName, null, WGFactory.getTempDir());
        tempTargetFile.deleteOnEviction(doc.getDatabase().getSessionContext());    
        File targetFile = tempTargetFile.getFile();
         
        ImageScaler scaler = TMLContext.getThreadMainContext().createimagescaler(file);
        scaler.useJPEGForOutput();       
        scaler.setQuality(fCompression.floatValue());
       
View Full Code Here

      // Files   
    try {
      Iterator fileNames = getFileNames().iterator();
      while (fileNames.hasNext()) {
        String fileName = (String) fileNames.next();
        TemporaryFile tempFile = new TemporaryFile(fileName, getFileData(fileName), WGFactory.getTempDir());
        tempFile.deleteOnEviction(getDatabase().getSessionContext());
        container.attachFile(tempFile.getFile());
      }
    } catch (IOException e) {
      WGFactory.getLogger().error("Error cloning file container", e);
      throw new WGCreationException("IO Error copying files for file container clone", e);
    }   
View Full Code Here

            // to the filesystem - therefore '/' is replaced by '�'
            // the attachFile method of the JDBC-ContentStore do the back convertion so
            // the file name stays constant after migration
            String convertedFileName = fileName.replace('/', '�');
                                   
            TemporaryFile tempFile = new TemporaryFile(convertedFileName, getFileData(fileName), WGFactory.getTempDir());
            tempFile.deleteOnEviction(getDatabase().getSessionContext());
            newContent.attachFile(tempFile.getFile());
          }
        }
      catch (IOException e) {
            WGFactory.getLogger().error("Error pushing content data", e);
            throw new WGCreationException("IO Error copying files for content clone", e);
View Full Code Here

        }
       
        if (_tempfiles != null) {
            Iterator tempFiles = _tempfiles.iterator();
            while (tempFiles.hasNext()) {
                TemporaryFile temp = (TemporaryFile) tempFiles.next();
                messageBodyPart = new MimeBodyPart();
                DataSource source = new FileDataSource(temp.getFile());
                messageBodyPart.setDataHandler(new DataHandler(source));
                messageBodyPart.setFileName(temp.getFile().getName());
                multipart.addBodyPart(messageBodyPart);

            }
        }       
        message.setContent(multipart);
View Full Code Here

      // delete tempfiles
        try {
            if (_tempfiles != null) {
              Iterator tempfiles = _tempfiles.iterator();
              while (tempfiles.hasNext()) {
                TemporaryFile temp = (TemporaryFile) tempfiles.next();
                temp.delete();
              }
            }
        } finally {
            super.finalize();
        }
View Full Code Here

     */
    @CodeCompletion
    public void addAttachment(InputStream in, String filename) throws WGMailException {
       
        try {
            TemporaryFile temp = new TemporaryFile(filename, in, WGFactory.getTempDir());
                if (_tempfiles == null) {
                    _tempfiles = new ArrayList();
                }
                _tempfiles.add(temp);
        }
View Full Code Here

    }
   
    // If the design directory has a java classes folder we put those into a jar and zip them to "files/system"
    File javaClassesDir = new File(_designDirectory, DesignDirectory.FOLDERNAME_JAVA);
    if (javaClassesDir.exists() && javaClassesDir.isDirectory()) {
        TemporaryFile jar = new TemporaryFile("plugin-classes.jar", null, null);
        ZipOutputStream jarStream = new ZipOutputStream(new FileOutputStream(jar.getFile()));
        jarStream.setLevel(0);
        DirZipper jarZipper = new DirZipper();
        jarZipper.addFilePatternToIgnore("^\\..*$");
        jarZipper.zipDirectory(javaClassesDir, jarStream);
       
        jarStream.close();
       
        zipper.zipNormalFile(jar.getFile(), zipOutputStream, "files/system/");
       
        jar.delete();
    }
   
    // If we were given a java source folder we put its contents into plugin-sources.zip and put that into "files/system" (for OSS plugins)
        if (javaSourceFolder != null) {
            File javaSourceDir = new File(javaSourceFolder);
            TemporaryFile zip = new TemporaryFile("plugin-sources.zip", null, null);
            ZipOutputStream zipStream = new ZipOutputStream(new FileOutputStream(zip.getFile()));
            zipStream.setLevel(0);
            DirZipper jarZipper = new DirZipper();
            jarZipper.addFilePatternToIgnore("^\\..*$");
            jarZipper.zipDirectory(javaSourceDir, zipStream);
           
            zipStream.close();
           
            zipper.zipNormalFile(zip.getFile(), zipOutputStream, "files/system/");
           
            zip.delete();
        }
   

   

View Full Code Here

TOP

Related Classes of de.innovationgate.utils.TemporaryFile

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.