Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.files.ui.resources
Class SystemUniversalTempFileListener


java.lang.Object
  extended by 

org.eclipse.rse.files.ui.resources.SystemTempFileListener
      extended by 
org.eclipse.rse.files.ui.resources.SystemUniversalTempFileListener
All Implemented Interfaces:
EventListener, IResourceChangeListener

public class SystemUniversalTempFileListener
extends SystemTempFileListener

This class manages listening for resource changes within our temp file project It is used for listening to saves made in the editor so that we can upload changes to the remote files. This class specifically handles universal files and doesn't do anything for iSeries. For iSeries members we need to subclass this.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.rse.files.ui.resources. SystemTempFileListener
SystemTempFileListener.RefreshResourcesJob, SystemTempFileListener.RefreshResourcesUIJob
 
Constructor Summary
SystemUniversalTempFileListener ()
           
 
Method Summary
protected  boolean doesHandle ( ISubSystem subsystem)
          Indicate whether this tempfile listener handles the specified
protected  void doResourceSynchronization ( ISubSystem subsystem, IFile tempFile, String resourceId, IProgressMonitor monitor)
          Synchronize the specified remote file with the temporary local file using the specified remote file subsystem.
  SystemEditableRemoteFile getEditedFile ( IRemoteFile file)
           
static  SystemUniversalTempFileListener getListener ()
          Return singleton
 void registerEditedFile ( SystemEditableRemoteFile editMember)
           
 void unregisterEditedFile ( SystemEditableRemoteFile editMember)
           
 void upload ( IRemoteFileSubSystem fs, IRemoteFile remoteFile, IFile tempFile, SystemIFileProperties properties, long storedModifiedStamp, SystemEditableRemoteFile editable, IProgressMonitor monitor)
          This method attempts to upload a temporary file in the workspace to a corresponding remote file location.
 
Methods inherited from class org.eclipse.rse.files.ui.resources. SystemTempFileListener
addIgnoreFile, checkLocalChanges, getRunnableContext, isIgnorable, preScanForTempFiles, processDelta, refreshRemoteResource, removeIgnoreFile, resourceChanged, setEnabled, synchronizeTempWithRemote
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemUniversalTempFileListener

public SystemUniversalTempFileListener()
Method Detail

getListener

public static 
SystemUniversalTempFileListener getListener()
Return singleton


registerEditedFile

public void registerEditedFile(
SystemEditableRemoteFile editMember)

unregisterEditedFile

public void unregisterEditedFile(
SystemEditableRemoteFile editMember)

getEditedFile

public 
SystemEditableRemoteFile getEditedFile(
IRemoteFile file)

doesHandle

protected boolean doesHandle(
ISubSystem subsystem)
Indicate whether this tempfile listener handles the specified

Specified by:
doesHandle in class SystemTempFileListener
Parameters:
subsystem - the subsystem to check
Returns:
whether it handles this or not

doResourceSynchronization

protected void doResourceSynchronization(
ISubSystem subsystem,
                                         
IFile tempFile,
                                         
String resourceId,
                                         
IProgressMonitor monitor)
Synchronize the specified remote file with the temporary local file using the specified remote file subsystem.

Specified by:
doResourceSynchronization in class SystemTempFileListener
Parameters:
subsystem - the remote file subsystem of the remote file
tempFile - the temporary file
resourceId - the remote file
monitor - progress monitor

upload

public void upload(
IRemoteFileSubSystem fs,
                   
IRemoteFile remoteFile,
                   
IFile tempFile,
                   
SystemIFileProperties properties,
                   long storedModifiedStamp,
                   
SystemEditableRemoteFile editable,
                   
IProgressMonitor monitor)
This method attempts to upload a temporary file in the workspace to a corresponding remote file location. It checks whether the timestamp of the remote file has changed since the temporary file was last known to be in synch with the remote file. If the timestamp has not changed, then it is assumed that the remote file has not changed and therefore it is safe to do an upload. If the timestamp has changed, then the remote file must have changed independently and there is a conflict and the upload conflict action is invoked.

Warning It is important to make sure that the remoteFile that gets passed in is up-to-date AND is the current cached version. If the remoteFile is not up-to-date then the timestamp of the actual remote file may be wrong and lead to the following problems:

  • If the detected remote timestamp is not the actual remote timestamp but it is the same as the storedModifiedStamp, an upload without detecting a conflict will cause lost data on the remote side!
  • If the detected remote timestamp is not the actual remote timestamp and the actual timestamp is the same as the storedModifiedStamp, a conflict will be indicated that doesn't actually exist
If the remoteFile is not the current cached version then the following problem occurs. After the upload, the remote file is marked stale so that the up-to-date remote file can be retrieved with the updated actual timestamp. Because the remoteFile that was passed into this method is not the cached version, marking it stale will not mark the cached version stale and thus, when a re-query of the file is done after the upload, the original cached version gets returned as opposed to a fresh version with the correct timestamp.

Because of these problems, it is recommended that, before calling upload(), the remoteFile is retrieved from the cache and is marked stale like the following example: ... // get the remote file from the cache IRemoteFile remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor); // mark it stale remoteFile.markStale(true); // re-query the remote file to make sure you have the latest remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor); // call upload upload(fs, remoteFile, ...); ....

Parameters:
fs - the file subsystem that corresponds with the file to upload
remoteFile - the remote file location to upload to
tempFile - the source temp file to upload
properties - the remote file properties of the file to upload
storedModifiedStamp - the last timestamp of the remote file for which a temp file was in synch with the remote file
editable - the wrapper that associates the remote file, temp file and editor together
monitor - the progress monitor

RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire