View | Details | Raw Unified | Return to bug 250140 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java (-24 / +89 lines)
Lines 48-53 Link Here
48
 * Martin Oberhuber (Wind River) - [235463][ftp][dstore] Incorrect case sensitivity reported on windows-remote
48
 * Martin Oberhuber (Wind River) - [235463][ftp][dstore] Incorrect case sensitivity reported on windows-remote
49
 * David McKnight   (IBM)        - [236039][dstore][efs] DStoreInputStream can report EOF too early - clean up how it waits for the local temp file to be created
49
 * David McKnight   (IBM)        - [236039][dstore][efs] DStoreInputStream can report EOF too early - clean up how it waits for the local temp file to be created
50
 * David McKnight   (IBM)        - [240710] [dstore] DStoreFileService.getFile() fails with NPE for valid root files
50
 * David McKnight   (IBM)        - [240710] [dstore] DStoreFileService.getFile() fails with NPE for valid root files
51
 * David McKnight   (IBM)        - [250140] backport of Save conflict dialog appears when saving files in the editor
52
 * David McKnight   (IBM)        - [250368] Backport  [dstore] Remote search doesn't find the right result
51
 *******************************************************************************/
53
 *******************************************************************************/
52
54
53
package org.eclipse.rse.internal.services.dstore.files;
55
package org.eclipse.rse.internal.services.dstore.files;
Lines 74-79 Link Here
74
import org.eclipse.dstore.core.model.DataStore;
76
import org.eclipse.dstore.core.model.DataStore;
75
import org.eclipse.dstore.core.model.DataStoreAttributes;
77
import org.eclipse.dstore.core.model.DataStoreAttributes;
76
import org.eclipse.dstore.core.model.DataStoreResources;
78
import org.eclipse.dstore.core.model.DataStoreResources;
79
import org.eclipse.dstore.core.model.DataStoreSchema;
77
import org.eclipse.dstore.core.model.IDataStoreProvider;
80
import org.eclipse.dstore.core.model.IDataStoreProvider;
78
import org.eclipse.osgi.util.NLS;
81
import org.eclipse.osgi.util.NLS;
79
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
82
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
Lines 195-202 Link Here
195
		return IUniversalDataStoreConstants.UNIVERSAL_FILESYSTEM_MINER_ID;
198
		return IUniversalDataStoreConstants.UNIVERSAL_FILESYSTEM_MINER_ID;
196
	}
199
	}
197
200
198
	protected String getByteStreamHandlerId()
201
	protected DataElement getMinerElement()
202
	{
203
		super.getMinerElement();
204
		if (_minerElement == null){
205
			// could be back-level version
206
			_minerElement = getMinerElement("com.ibm.etools.systems.universal.miners.UniversalFileSystemMiner"); //$NON-NLS-1$
207
		}
208
		return _minerElement;
209
	}
210
211
	private boolean isOldIBMMiner()
199
	{
212
	{
213
		if (_minerElement != null){
214
			return _minerElement.getSource().equals("com.ibm.etools.systems.universal.miners.UniversalFileSystemMiner"); //$NON-NLS-1$
215
		}
216
		return false;
217
	}
218
	
219
	protected String getByteStreamHandlerId()
220
	{	
221
		if (isOldIBMMiner())
222
		{
223
			// if so, use the old id
224
			return "com.ibm.etools.systems.universal.miners.UniversalByteStreamHandler"; //$NON-NLS-1$
225
		}
200
		return UniversalByteStreamHandler.class.getName();
226
		return UniversalByteStreamHandler.class.getName();
201
	}
227
	}
202
228
Lines 457-467 Link Here
457
		boolean transferSuccessful = false;
483
		boolean transferSuccessful = false;
458
484
459
		long totalBytes = file.length();
485
		long totalBytes = file.length();
486
		
487
		DataElement uploadLog = findUploadLog();
488
		String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
489
		
490
		DataStore ds = getDataStore();
491
		DataElement result = ds.find(uploadLog, DE.A_NAME, remotePath,1);
492
		if (result == null) 
493
		{
494
			result = ds.createObject(uploadLog, "uploadstatus", remotePath);
495
			result.setAttribute(DE.A_SOURCE, "running");
496
			result.setAttribute(DE.A_VALUE, "");
497
			
498
			DataElement cmd = getDataStore().findCommandDescriptor(DataStoreSchema.C_SET);
499
			
500
			DataElement setstatus = ds.command(cmd, uploadLog, true);
501
		}
460
502
461
		try
503
		try
462
		{
504
		{
463
			String byteStreamHandlerId = getByteStreamHandlerId();
505
			String byteStreamHandlerId = getByteStreamHandlerId();
464
			String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
506
465
507
466
			// create an empty file and append data to it later
508
			// create an empty file and append data to it later
467
			// this handles the case of uploading empty files as well
509
			// this handles the case of uploading empty files as well
Lines 473-481 Link Here
473
				//subMonitor = new SubProgressMonitor(monitor, (int)totalBytes);
515
				//subMonitor = new SubProgressMonitor(monitor, (int)totalBytes);
474
			}
516
			}
475
517
476
477
//			DataElement uploadLog = findUploadLog();
478
			findUploadLog();
479
//			listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog);
518
//			listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog);
480
	//		ds.getDomainNotifier().addDomainListener(listener);
519
	//		ds.getDomainNotifier().addDomainListener(listener);
481
520
Lines 583-588 Link Here
583
622
584
				available = bufInputStream.available();
623
				available = bufInputStream.available();
585
			}
624
			}
625
			
586
	//		if (listener.uploadHasFailed())
626
	//		if (listener.uploadHasFailed())
587
		//	{
627
		//	{
588
		//		showUploadFailedMessage(listener, source);
628
		//		showUploadFailedMessage(listener, source);
Lines 639-664 Link Here
639
			{
679
			{
640
			    if (transferSuccessful)
680
			    if (transferSuccessful)
641
			    {
681
			    {
642
682
			    	String resultStr = result.getSource();
643
683
			    	while (!resultStr.equals("success"))
644
//					try
684
			    	{
645
//					{
685
			    		// sleep until the upload is complete
646
//						listener.waitForUpdate(null, 2);
686
			    		try {
647
//
687
			    			Thread.sleep(200);
648
//					}
688
			    		}
649
//					catch (InterruptedException e)
689
			    		catch (InterruptedException e){			    			
650
//					{
690
			    		}
651
//						UniversalSystemPlugin.logError(CLASSNAME + " InterruptedException while waiting for command", e);
691
			    		resultStr = result.getSource();
652
//					}
692
			    	}
653
654
			    }
693
			    }
655
656
				//ds.getDomainNotifier().removeDomainListener(listener);
657
658
//				if (listener.uploadHasFailed())
659
//				{
660
//					showUploadFailedMessage(listener, source);
661
//				}
662
			}
694
			}
663
		}
695
		}
664
	}
696
	}
Lines 1130-1137 Link Here
1130
			de = getElementFor(name);
1162
			de = getElementFor(name);
1131
		}
1163
		}
1132
		
1164
		
1165
		
1133
		// with 207095, it's possible to get here unconnected such that there is no element
1166
		// with 207095, it's possible to get here unconnected such that there is no element
1134
		if (de != null) {
1167
		if (de != null) {
1168
			if (isOldIBMMiner()){
1169
				// only accepts filters for file queries
1170
				if (!de.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)){
1171
					StringBuffer buf = new StringBuffer(remoteParent);
1172
					String sep = getSeparator(remoteParent);
1173
					if (sep.length()>0 && !remoteParent.endsWith(sep)) {
1174
					    buf.append(sep);
1175
					}
1176
					buf.append(name);
1177
					String fullPath = buf.toString();
1178
					de.setAttribute(DE.A_NAME, fullPath);
1179
					de.setAttribute(DE.A_VALUE, fullPath);
1180
					de.setAttribute(DE.A_TYPE, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR);
1181
				}
1182
			}
1183
			
1135
			dsQueryCommand(de, null,  IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor);
1184
			dsQueryCommand(de, null,  IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor);
1136
			//getFile call should also need to convert this DataElement into a HostFile using
1185
			//getFile call should also need to convert this DataElement into a HostFile using
1137
			//convertToHostFile() call.  This way, this DataElement will be put into _fileMap.
1186
			//convertToHostFile() call.  This way, this DataElement will be put into _fileMap.
Lines 1152-1160 Link Here
1152
1201
1153
		// construct default array of commands
1202
		// construct default array of commands
1154
		String[] queryStrings = new String[remoteParents.length];
1203
		String[] queryStrings = new String[remoteParents.length];
1204
		boolean oldMiner = isOldIBMMiner();
1205
		
1155
		for (int i = 0; i < queryStrings.length; i++)
1206
		for (int i = 0; i < queryStrings.length; i++)
1156
		{
1207
		{
1157
			queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT;
1208
			queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT;
1209
			if (oldMiner){
1210
				if (!subjects[i].getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)){
1211
					StringBuffer buf = new StringBuffer(remoteParents[i]);
1212
					String sep = getSeparator(remoteParents[i]);
1213
					if (sep.length()>0 && !remoteParents[i].endsWith(sep)) {
1214
					    buf.append(sep);
1215
					}
1216
					buf.append(names[i]);
1217
					String fullPath = buf.toString();
1218
					subjects[i].setAttribute(DE.A_NAME, fullPath);
1219
					subjects[i].setAttribute(DE.A_VALUE, fullPath);
1220
					subjects[i].setAttribute(DE.A_TYPE, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR);
1221
				}
1222
			}
1158
		}
1223
		}
1159
1224
1160
		dsQueryCommandMulti(subjects, null, queryStrings, monitor);
1225
		dsQueryCommandMulti(subjects, null, queryStrings, monitor);
(-)src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java (-4 / +43 lines)
Lines 23-28 Link Here
23
 * Kevin Doyle 		(IBM)		 - [204810] Saving file in Eclipse does not update remote file
23
 * Kevin Doyle 		(IBM)		 - [204810] Saving file in Eclipse does not update remote file
24
 * Kevin Doyle 		(IBM)		 - [210389] Display error dialog when setting file not read-only fails when saving
24
 * Kevin Doyle 		(IBM)		 - [210389] Display error dialog when setting file not read-only fails when saving
25
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
25
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
26
 * David McKnight   (IBM)        - [250140] backport of Save conflict dialog appears when saving files in the editor
26
 ********************************************************************************/
27
 ********************************************************************************/
27
28
28
package org.eclipse.rse.files.ui.resources;
29
package org.eclipse.rse.files.ui.resources;
Lines 302-313 Link Here
302
				}
303
				}
303
304
304
				// waiting to make sure the file's timestamp is uptodate
305
				// waiting to make sure the file's timestamp is uptodate
305
				Thread.sleep(1000);
306
				remoteFile = waitForTimestampToBeUpToDate(remoteFile,remoteModifiedStamp, monitor);
306
				
307
				
307
				// get the remote file object again so that we have a fresh remote timestamp
308
				remoteFile.markStale(true);
309
				remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
310
				
308
				
309
							
311
				registry.fireEvent(new SystemResourceChangeEvent(remoteFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, remoteFile));
310
				registry.fireEvent(new SystemResourceChangeEvent(remoteFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, remoteFile));
312
			
311
			
313
				long ts = remoteFile.getLastModified();
312
				long ts = remoteFile.getLastModified();
Lines 374-377 Link Here
374
			e.printStackTrace();
373
			e.printStackTrace();
375
		}
374
		}
376
	}
375
	}
376
	
377
	private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, long originalTimestamp, IProgressMonitor monitor)
378
	{
379
		IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
380
		String path = remoteFile.getAbsolutePath();
381
		try {
382
			long timestamp = originalTimestamp;
383
384
			boolean fileUpdated = false;
385
			boolean timestampChanging = true;
386
			
387
			while (timestampChanging || !fileUpdated){	// wait until the timestamp stops changing AND timestamp did change at least once		
388
				try {
389
					Thread.sleep(500); // sleep 
390
				}
391
				catch (InterruptedException e){				
392
				}
393
			
394
				// query the remote file again
395
				remoteFile.markStale(true);
396
				remoteFile = fs.getRemoteFileObject(path, monitor);
397
398
				// what's the timestamp now?
399
				long nextTimestamp = remoteFile.getLastModified();		
400
401
				timestampChanging = (timestamp != nextTimestamp);
402
403
				if (!fileUpdated){	// indicate the file has changed if the timestamp has			
404
					fileUpdated = timestampChanging;
405
				}
406
				
407
				timestamp = nextTimestamp;
408
			}
409
		}
410
		catch (SystemMessageException e){
411
			
412
		}
413
		
414
		return remoteFile;
415
	}
377
}
416
}
(-)src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java (-8 / +46 lines)
Lines 21-26 Link Here
21
 * David McKnight   (IBM)        - [224377] "open with" menu does not have "other" option
21
 * David McKnight   (IBM)        - [224377] "open with" menu does not have "other" option
22
 * Xuan Chen        (IBM)        - [225506] [api][breaking] RSE UI leaks non-API types
22
 * Xuan Chen        (IBM)        - [225506] [api][breaking] RSE UI leaks non-API types
23
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
23
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
24
 * David McKnight   (IBM)        - [250140] backport of Save conflict dialog appears when saving files in the editor
24
 *******************************************************************************/
25
 *******************************************************************************/
25
26
26
package org.eclipse.rse.internal.files.ui.actions;
27
package org.eclipse.rse.internal.files.ui.actions;
Lines 197-212 Link Here
197
            {
198
            {
198
            	IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
199
            	IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
199
            	SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
200
            	SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
201
            	long originalTimestamp = _remoteFile.getLastModified();
202
            	
200
                fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
203
                fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
204
201
                // wait for timestamp to update before re-fetching remote file
205
                // wait for timestamp to update before re-fetching remote file
202
                try {
206
                _remoteFile = waitForTimestampToBeUpToDate(_remoteFile, originalTimestamp, monitor);
203
                	Thread.sleep(1000);
207
204
                }
205
                catch (Exception e){
206
                	
207
                }
208
                _remoteFile.markStale(true);
209
                _remoteFile = fs.getRemoteFileObject(_remoteFile.getAbsolutePath(), new NullProgressMonitor());
210
                long ts = _remoteFile.getLastModified();
208
                long ts = _remoteFile.getLastModified();
211
                properties.setRemoteFileTimeStamp(ts);
209
                properties.setRemoteFileTimeStamp(ts);
212
                properties.setDirty(false);
210
                properties.setDirty(false);
Lines 222-227 Link Here
222
            }
220
            }
223
            return Status.OK_STATUS;
221
            return Status.OK_STATUS;
224
		}
222
		}
223
		
224
		private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, long originalTimestamp, IProgressMonitor monitor)
225
		{
226
			IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
227
			String path = remoteFile.getAbsolutePath();
228
			try {
229
				long timestamp = originalTimestamp;
230
231
				boolean fileUpdated = false;
232
				boolean timestampChanging = true;
233
				
234
				while (timestampChanging || !fileUpdated){	// wait until the timestamp stops changing AND timestamp did change at least once		
235
					try {
236
						Thread.sleep(500); // sleep 
237
					}
238
					catch (InterruptedException e){				
239
					}
240
				
241
					// query the remote file again
242
					remoteFile.markStale(true);
243
					remoteFile = fs.getRemoteFileObject(path, monitor);
244
245
					// what's the timestamp now?
246
					long nextTimestamp = remoteFile.getLastModified();		
247
248
					timestampChanging = (timestamp != nextTimestamp);
249
250
					if (!fileUpdated){	// indicate the file has changed if the timestamp has			
251
						fileUpdated = timestampChanging;
252
					}
253
					
254
					timestamp = nextTimestamp;
255
				}
256
			}
257
			catch (SystemMessageException e){
258
				
259
			}
260
			
261
			return remoteFile;
262
		}		
225
	}
263
	}
226
264
227
	/**
265
	/**

Return to bug 250140