protected void removeLocalInputFile(File file) { synchronized (localInputFiles) { File loc = (File) this.localInputFiles.remove(file); if (loc != null && FileSystemManager.exists(loc)) { FileSystemManager.delete(loc); } } }
public boolean delete(File file) { removeLocalInputFile(file); String owner = this.buildNewOwnerId("delete"); AbstractProxy proxy = this.getAvailableProxy(owner); boolean res = false; try { FileCacheableInformations infos = this.getInformations(file); if (infos.isExists()) { if (infos.isDirectory()) { res = proxy.deleteDir(this.translateToRemote(file)); } else { res = proxy.deleteFile(this.translateToRemote(file)); } } else { res = true; } } catch (RemoteConnectionException e) { Logger.defaultLogger() .error("Error caught while deleting " + FileSystemManager.getDisplayPath(file), e); throw new UnexpectedConnectionException(e); } finally { this.releaseProxy(proxy, owner); } return res; }
private File getOrCreateLocalFile(File file) throws IOException { synchronized (localInputFiles) { File localFile = (File) localInputFiles.get(file); if (localFile == null) { localFile = FileTool.getInstance().generateNewWorkingFile(null, "java", "ftpin", true); this.localInputFiles.put(file, localFile); FileTool.getInstance() .copy( getFileInputStream(file), FileSystemManager.getFileOutputStream(localFile), true, true); FileSystemManager.deleteOnExit(localFile); } return localFile; } }
public boolean mkdir(File file) { String owner = this.buildNewOwnerId("mkdir"); AbstractProxy proxy = this.getAvailableProxy(owner); boolean res = false; try { res = proxy.mkdir(this.translateToRemote(file)); } catch (RemoteConnectionException e) { Logger.defaultLogger() .error("Error creating directory : " + FileSystemManager.getDisplayPath(file)); throw new UnexpectedConnectionException(e); } finally { this.releaseProxy(proxy, owner); } return res; }
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, false); layout.verticalSpacing = 10; composite.setLayout(layout); Group grpLocation = new Group(composite, SWT.NONE); grpLocation.setText(RM.getLabel("shrtc.location.label")); GridLayout grpLayout = new GridLayout(2, false); grpLocation.setLayout(grpLayout); grpLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); location = new Text(grpLocation, SWT.BORDER); GridData mainData2 = new GridData(SWT.FILL, SWT.CENTER, true, false); mainData2.widthHint = AbstractWindow.computeWidth(400); location.setLayoutData(mainData2); location.setText( FileSystemManager.getAbsolutePath(new File(initialDirectory, initialFileNameSelected))); monitorControl(location); Button btnBrowse = new Button(grpLocation, SWT.PUSH); btnBrowse.setText(RM.getLabel("common.browseaction.label")); btnBrowse.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { File f = new File(location.getText()); String path = application.showFileDialog( FileSystemManager.getParent(f), BackupShortcutWizardWindow.this, FileSystemManager.getName(f), RM.getLabel("app.buildbatch.label"), SWT.SAVE); if (path != null) { location.setText(path); } } }); btnBrowse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); Group grpType = new Group(composite, SWT.NONE); grpType.setText(RM.getLabel("shrtc.type.label")); grpType.setLayout(new GridLayout(1, false)); grpType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); radIncremental = new Button(grpType, SWT.RADIO); radIncremental.setText(RM.getLabel("archivedetail.incremental.label")); radIncremental.setToolTipText(RM.getLabel("archivedetail.incremental.tooltip")); radIncremental.setSelection(true); radDifferential = new Button(grpType, SWT.RADIO); radDifferential.setText(RM.getLabel("archivedetail.differential.label")); radDifferential.setToolTipText(RM.getLabel("archivedetail.differential.tooltip")); radFull = new Button(grpType, SWT.RADIO); radFull.setText(RM.getLabel("archivedetail.full.label")); radFull.setToolTipText(RM.getLabel("archivedetail.full.tooltip")); Group grpScope = new Group(composite, SWT.NONE); grpScope.setText(RM.getLabel("shrtc.scope.label")); grpScope.setLayout(new GridLayout(1, false)); grpScope.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); radSelectedOnly = new Button(grpScope, SWT.RADIO); radSelectedOnly.setText(RM.getLabel("shrtc.forselected.label")); radSelectedOnly.setLayoutData(new GridData()); radSelectedOnly.setSelection(true); radSelectedOnly.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { File loc = new File(location.getText()); if (FileSystemManager.getName(loc).equals(initialFileNameAll)) { location.setText( FileSystemManager.getAbsolutePath( new File(FileSystemManager.getParentFile(loc), initialFileNameSelected))); } } }); monitorControl(SWT.Selection, radSelectedOnly); radAll = new Button(grpScope, SWT.RADIO); radAll.setText(RM.getLabel("shrtc.forall.label")); radAll.setLayoutData(new GridData()); radAll.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { File loc = new File(location.getText()); if (FileSystemManager.getName(loc).equals(initialFileNameSelected)) { location.setText( FileSystemManager.getAbsolutePath( new File(FileSystemManager.getParentFile(loc), initialFileNameAll))); } } }); monitorControl(SWT.Selection, radAll); Group grpCheckArchive = new Group(composite, SWT.NONE); grpCheckArchive.setText(RM.getLabel("archivedetail.checkgroup.label")); grpCheckArchive.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); grpCheckArchive.setLayout(new GridLayout(1, false)); chkCheckArchive = new Button(grpCheckArchive, SWT.CHECK); chkCheckArchive.setText(RM.getLabel("archivedetail.checkarchive.label")); chkCheckArchive.setToolTipText(RM.getLabel("archivedetail.checkarchive.tooltip")); chkCheckArchive.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); chkCheckArchive.setSelection(true); monitorControl(chkCheckArchive); SavePanel pnlSave = new SavePanel(this); pnlSave.buildComposite(composite).setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true)); saveButton = pnlSave.getBtnSave(); composite.pack(); return composite; }
public InputStream getCachedFileInputStream(File file) throws IOException { return FileSystemManager.getFileInputStream(getOrCreateLocalFile(file)); }