Package de.innovationgate.utils

Examples of de.innovationgate.utils.TemporaryFile


        IRunnableWithProgress runnable = null;
        if (_addDialog.isDownloadRequested()) {
          runnable = new IRunnableWithProgress() {
           
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
              TemporaryFile wgaWar = null;
              try {
                monitor.beginTask("Deploying wga", 100);
                SubProgressMonitor downloadMonitor = new SubProgressMonitor(monitor, 90);
                boolean isCustomDownloadLocation = false;
                if (_addDialog.getLocation() != null && !_addDialog.getLocation().trim().equalsIgnoreCase("")) {
                                    wgaWar = WGADesignerPlugin.getDefault().downloadWGA(downloadMonitor, _addDialog.getLocation());
                                    isCustomDownloadLocation = true;
                                } else {
                                    wgaWar = WGADesignerPlugin.getDefault().downloadCurrentWGARelease(downloadMonitor);                                
                                }
                if (!monitor.isCanceled()) {
                  SubProgressMonitor deployMonitor = new SubProgressMonitor(monitor, 10);
                  WGADeployment deployment = WGADesignerPlugin.getDefault().getWGADeploymentManager().createDeployment(_addDialog.getSymbolicName(), wgaWar.getFile(), deployMonitor);
                  if (deployment != null && isCustomDownloadLocation) {
                      deployment.setUpdateURL(_addDialog.getLocation());
                  }
                }
              } catch (Exception e) {
                throw new InterruptedException(e.getMessage());
              } finally {
                if (wgaWar != null) {
                  wgaWar.delete();
                }
                monitor.done();
              }
            }
          };
View Full Code Here


      if (_updateDialog.getReturnCode() == Dialog.OK) {
        IRunnableWithProgress runnable = null;     
        if (_updateDialog.isDownloadRequested()) {
          runnable = new IRunnableWithProgress() {           
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
              TemporaryFile wgaWar = null;
              try {
                monitor.beginTask("Deploying wga", 100);
                SubProgressMonitor downloadMonitor = new SubProgressMonitor(monitor, 90);
                if (_updateDialog.getLocation() != null && !_updateDialog.getLocation().trim().equalsIgnoreCase("")) {
                    wgaWar = WGADesignerPlugin.getDefault().downloadWGA(downloadMonitor, _updateDialog.getLocation());
                } else {
                    wgaWar = WGADesignerPlugin.getDefault().downloadCurrentWGARelease(downloadMonitor);                   
                }
                if (!monitor.isCanceled()) {
                  SubProgressMonitor deployMonitor = new SubProgressMonitor(monitor, 10);
                  _selectedDeployment.updateWGA(wgaWar.getFile(), deployMonitor)
                }
              } catch (Exception e) {
                throw new InterruptedException(e.getMessage());
              } finally {
                if (wgaWar != null) {
                  wgaWar.delete();
                }
                monitor.done();
              }
            }
          };
View Full Code Here

        HttpClient client = new DefaultHttpClient((IProxyService)_proxyServiceTracker.getService(), new URI(url));
        GetMethod get = new GetMethod(url);
    int result = client.executeMethod(get);
    if (result == HttpURLConnection.HTTP_OK) {
      long size = get.getResponseContentLength();               
            TemporaryFile temp = new TemporaryFile("wga.war", new ProgressMonitorInputStream(monitor, "Downloading OpenWGA ", size, get.getResponseBodyAsStream()), getStateLocation().toFile());
      return temp;
    } else {
            throw new IOException("Download of OpenWGA failed. Server returned '" + result + "'.");
    }
   
View Full Code Here

        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {     
            monitor.beginTask("Initializing WGA distributions", 100);             
            SubProgressMonitor downloadMonitor = new SubProgressMonitor(monitor, 90);             
            TemporaryFile temp = downloadCurrentWGARelease(downloadMonitor);
            SubProgressMonitor deployMonitor = new SubProgressMonitor(monitor, 10);
            getWGADeploymentManager().createOrUpdateDefaultDeployment(temp.getFile(), deployMonitor);
            temp.delete();
            return Status.OK_STATUS;
          } catch (InputStreamCanceledException e) {
            logWarning("WGA distribution download has been canceled by user.");
            return Status.CANCEL_STATUS;
          } catch (UnknownHostException e) {
View Full Code Here

    return WGADesignerPlugin.getDefault().getResourceAsStream(_location);
  }
 
  public Properties getProperties() {
    if (_properties == null) {
      TemporaryFile tempFile = null;
      try {       
        tempFile = new TemporaryFile("template_" + _name, getContent(), WGADesignerPlugin.getDefault().getStateLocation().toFile());
        FileSystemManager fsManager = VFS.getManager();
        FileObject propFile = fsManager.resolveFile("zip:" + tempFile.getFile().toURI() + "!" + PROPERTIES_FILENAME);
        if (propFile.exists()) {
          _properties = new Properties();
          InputStream propIn = null;
          try {
            propIn = propFile.getContent().getInputStream();
            _properties.load(propIn);
          } finally {
            if (propIn != null) {
              try {
                propIn.close();
              } catch (IOException e) {
              }
            }
          }         
        } else {
          _properties = new Properties();
        }
       
      } catch (Exception e) {
        WGADesignerPlugin.getDefault().logError("Unable to load properties from template '" + _name + "'.", e);
      } finally {
        if (tempFile != null) {
          tempFile.delete();
        }
      }
    }
    return _properties;   
  }
View Full Code Here

                ZipEntry entry;
                while ((entry = zipIn.getNextEntry()) != null) {
                   
                    String entryName = entry.getName();
                    if (entryName.equals(DesignDirectory.DESIGN_DEFINITION_FILE) || entryName.equals(DesignDirectory.SYNCINFO_FILE)) {
                        TemporaryFile tempFile = new TemporaryFile("design", zipIn, null);
                        syncInfo = DesignDefinition.load(tempFile.getFile());
                        tempFile.delete();
                    }
                    else if (entryName.equals(SystemContainerManager.CSCONFIG_PATH)) {
                        TemporaryFile tempFile = new TemporaryFile("csconfig", zipIn, null);
                        csConfig = CSConfig.load(tempFile.getFile());
                        tempFile.delete();
                    }
                    else if (entryName.equals(SystemContainerManager.LICENSE_PATH)) {
                        licenseText = WGUtils.readString(new InputStreamReader(zipIn,  "UTF-8")).trim();
                    }
                   
View Full Code Here

                    // entityCopy
                  Iterator fileNames = originalImpl.getFileNames().iterator();
                  while (fileNames.hasNext()) {
                    String orgFileName = (String) fileNames.next();
                    String fileName = orgFileName.replace('/', '�');
                    TemporaryFile tempFile = new TemporaryFile(fileName, originalImpl.getFileData(orgFileName), WGFactory.getTempDir());
                    tempFile.deleteOnEviction(_db.getSessionContext());
                    entityCopy.attachFile(tempFile.getFile());
                  }
                 
                }
                else {
                  copy.setFiles(cloneContentFiles(original.getFiles(), copy));
View Full Code Here

    }

    public synchronized String addTemporaryDownload(HttpSession session, File file) throws IOException {

        InputStream in = new FileInputStream(file);
        TemporaryFile tempFile = new TemporaryFile(file.getName(), in, WGFactory.getTempDir());
        return addTemporaryDownload(session, tempFile);

    }
View Full Code Here

    public void attachAllFiles(WGDocument doc) throws IOException, WGAPIException {
       
        Iterator names = doc.getFileNames().iterator();
        while (names.hasNext()) {
            String name = (String) names.next();
            TemporaryFile tempFile = new TemporaryFile(name, doc.getFileData(name), WGFactory.getTempDir());           
            attachFile(tempFile.getFile());
            tempFile.deleteOnEviction(getDatabase().getSessionContext());
        }
       
    }
View Full Code Here

     * @throws WGAPIException
     * @throws IOException
     */
    public boolean attachFile(InputStream stream, String filename) throws WGAPIException, IOException {
       
        TemporaryFile tempFile = new TemporaryFile(filename, stream, WGFactory.getTempDir());
        attachFile(tempFile.getFile());
        tempFile.deleteOnEviction(getDatabase().getSessionContext());
        setEdited(true);
        return true;
       
    }
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.