|
Lines 41-46
Link Here
|
| 41 |
* Martin Oberhuber (Wind River) - [234038] Mark IRemoteFile stale when changing permissions |
41 |
* Martin Oberhuber (Wind River) - [234038] Mark IRemoteFile stale when changing permissions |
| 42 |
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile |
42 |
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile |
| 43 |
* David McKnight (IBM) - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter |
43 |
* David McKnight (IBM) - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter |
|
|
44 |
* Martin Oberhuber (Wind River) - [240704] Protect against illegal API use of getRemoteFileObject() with relative path as name |
| 44 |
*******************************************************************************/ |
45 |
*******************************************************************************/ |
| 45 |
|
46 |
|
| 46 |
package org.eclipse.rse.subsystems.files.core.servicesubsystem; |
47 |
package org.eclipse.rse.subsystems.files.core.servicesubsystem; |
|
Lines 54-59
Link Here
|
| 54 |
import org.eclipse.core.runtime.IProgressMonitor; |
55 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 55 |
import org.eclipse.core.runtime.IStatus; |
56 |
import org.eclipse.core.runtime.IStatus; |
| 56 |
import org.eclipse.core.runtime.NullProgressMonitor; |
57 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
|
58 |
import org.eclipse.core.runtime.Status; |
| 57 |
import org.eclipse.osgi.util.NLS; |
59 |
import org.eclipse.osgi.util.NLS; |
| 58 |
import org.eclipse.rse.core.RSECorePlugin; |
60 |
import org.eclipse.rse.core.RSECorePlugin; |
| 59 |
import org.eclipse.rse.core.events.ISystemRemoteChangeEvents; |
61 |
import org.eclipse.rse.core.events.ISystemRemoteChangeEvents; |
|
Lines 73-78
Link Here
|
| 73 |
import org.eclipse.rse.services.clientserver.messages.CommonMessages; |
75 |
import org.eclipse.rse.services.clientserver.messages.CommonMessages; |
| 74 |
import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds; |
76 |
import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds; |
| 75 |
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; |
77 |
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; |
|
|
78 |
import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException; |
| 76 |
import org.eclipse.rse.services.clientserver.messages.SystemMessage; |
79 |
import org.eclipse.rse.services.clientserver.messages.SystemMessage; |
| 77 |
import org.eclipse.rse.services.clientserver.messages.SystemMessageException; |
80 |
import org.eclipse.rse.services.clientserver.messages.SystemMessageException; |
| 78 |
import org.eclipse.rse.services.files.IFileService; |
81 |
import org.eclipse.rse.services.files.IFileService; |
|
Lines 174-179
Link Here
|
| 174 |
*/ |
177 |
*/ |
| 175 |
public IRemoteFile getRemoteFileObject(IRemoteFile parent, String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException |
178 |
public IRemoteFile getRemoteFileObject(IRemoteFile parent, String folderOrFileName, IProgressMonitor monitor) throws SystemMessageException |
| 176 |
{ |
179 |
{ |
|
|
180 |
// Consistency would be totally messed up if folderOrFileName were a relative path |
| 181 |
// Because IHostFiles would be incorrectly generated, getParent() would return wrong results etc |
| 182 |
assert folderOrFileName.indexOf(getSeparator())<0; |
| 177 |
// for bug 207095, implicit connect if the connection is not connected |
183 |
// for bug 207095, implicit connect if the connection is not connected |
| 178 |
checkIsConnected(monitor); |
184 |
checkIsConnected(monitor); |
| 179 |
|
185 |
|
|
Lines 183-188
Link Here
|
| 183 |
{ |
189 |
{ |
| 184 |
return file; |
190 |
return file; |
| 185 |
} |
191 |
} |
|
|
192 |
// Fallback in case of incorrect API usage |
| 193 |
// TODO remove this in next release for Performance, |
| 194 |
// since it is just for bad clients using the API incorrectly |
| 195 |
if (folderOrFileName.indexOf(getSeparator()) >= 0) { |
| 196 |
try { |
| 197 |
throw new IllegalArgumentException("getRemoteFileObject: folderOrFileName must not be a relative path"); //$NON-NLS-1$ |
| 198 |
} catch (IllegalArgumentException e) { |
| 199 |
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Illegal API use: " + e.getLocalizedMessage(), e)); //$NON-NLS-1$ |
| 200 |
} |
| 201 |
return getRemoteFileObject(fullPath, monitor); |
| 202 |
} |
| 186 |
|
203 |
|
| 187 |
IHostFile node = getFile(parent.getAbsolutePath(), folderOrFileName, monitor); |
204 |
IHostFile node = getFile(parent.getAbsolutePath(), folderOrFileName, monitor); |
| 188 |
return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, node); |
205 |
return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), parent, node); |
|
Lines 420-435
Link Here
|
| 420 |
} |
437 |
} |
| 421 |
|
438 |
|
| 422 |
List hostFiles = new ArrayList(10); |
439 |
List hostFiles = new ArrayList(10); |
| 423 |
|
440 |
|
| 424 |
// query children via the service |
441 |
// query children via the service |
| 425 |
getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, hostFiles, monitor); |
442 |
getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, hostFiles, monitor); |
| 426 |
RemoteFileContext context = getDefaultContext(); |
443 |
RemoteFileContext context = getDefaultContext(); |
| 427 |
|
444 |
|
| 428 |
IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); |
445 |
IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); |
| 429 |
|
446 |
|
| 430 |
// convert the IHostFiles into AbstractRemoteFiles |
447 |
// convert the IHostFiles into AbstractRemoteFiles |
| 431 |
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
448 |
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
| 432 |
|
449 |
|
| 433 |
// cache the results corresponding to each parent under each parent |
450 |
// cache the results corresponding to each parent under each parent |
| 434 |
for (int i = 0; i < parents.length; i++) |
451 |
for (int i = 0; i < parents.length; i++) |
| 435 |
{ |
452 |
{ |
|
Lines 449-462
Link Here
|
| 449 |
underParent.add(child); |
466 |
underParent.add(child); |
| 450 |
} |
467 |
} |
| 451 |
} |
468 |
} |
| 452 |
|
469 |
|
| 453 |
// update the parent with it's latest properties |
470 |
// update the parent with it's latest properties |
| 454 |
// null is passed for the second argument because we currently don't get the parent in our results query |
471 |
// null is passed for the second argument because we currently don't get the parent in our results query |
| 455 |
updateRemoteFile(parent, null, monitor); |
472 |
updateRemoteFile(parent, null, monitor); |
| 456 |
|
473 |
|
| 457 |
if (underParent.size() > 0) |
474 |
if (underParent.size() > 0) |
| 458 |
{ |
475 |
{ |
| 459 |
Object[] qresults = underParent.toArray(); |
476 |
Object[] qresults = underParent.toArray(); |
| 460 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); |
477 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); |
| 461 |
} |
478 |
} |
| 462 |
} |
479 |
} |
|
Lines 483-493
Link Here
|
| 483 |
getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor); |
500 |
getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor); |
| 484 |
RemoteFileContext context = getDefaultContext(); |
501 |
RemoteFileContext context = getDefaultContext(); |
| 485 |
|
502 |
|
| 486 |
IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); |
503 |
IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]); |
| 487 |
|
504 |
|
| 488 |
// convert the IHostFiles into AbstractRemoteFiles |
505 |
// convert the IHostFiles into AbstractRemoteFiles |
| 489 |
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
506 |
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
| 490 |
|
507 |
|
| 491 |
// cache the results corresponding to each parent under each parent |
508 |
// cache the results corresponding to each parent under each parent |
| 492 |
for (int i = 0; i < parents.length; i++) |
509 |
for (int i = 0; i < parents.length; i++) |
| 493 |
{ |
510 |
{ |
|
Lines 510-520
Link Here
|
| 510 |
|
527 |
|
| 511 |
// update the parent with it's latest properties |
528 |
// update the parent with it's latest properties |
| 512 |
// null is passed for the second argument because we currently don't get the parent in our results query |
529 |
// null is passed for the second argument because we currently don't get the parent in our results query |
| 513 |
updateRemoteFile(parent, null, monitor); |
530 |
updateRemoteFile(parent, null, monitor); |
| 514 |
|
531 |
|
| 515 |
if (underParent.size() > 0) |
532 |
if (underParent.size() > 0) |
| 516 |
{ |
533 |
{ |
| 517 |
Object[] qresults = underParent.toArray(); |
534 |
Object[] qresults = underParent.toArray(); |
| 518 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); |
535 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); |
| 519 |
} |
536 |
} |
| 520 |
} |
537 |
} |
|
Lines 544-557
Link Here
|
| 544 |
IStatus.INFO, msgTxt); |
561 |
IStatus.INFO, msgTxt); |
| 545 |
throw new SystemMessageException(msg); |
562 |
throw new SystemMessageException(msg); |
| 546 |
} |
563 |
} |
| 547 |
|
564 |
|
| 548 |
// query children of the parent |
565 |
// query children of the parent |
| 549 |
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); |
566 |
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); |
| 550 |
|
567 |
|
| 551 |
// update the parent with it's latest properties |
568 |
// update the parent with it's latest properties |
| 552 |
// null is passed for the second argument because we currently don't get the parent in our results query |
569 |
// null is passed for the second argument because we currently don't get the parent in our results query |
| 553 |
updateRemoteFile(parent, null, monitor); |
570 |
updateRemoteFile(parent, null, monitor); |
| 554 |
|
571 |
|
| 555 |
// convert the IHostFiles to AbstractRemoteFile[] |
572 |
// convert the IHostFiles to AbstractRemoteFile[] |
| 556 |
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
573 |
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
| 557 |
if (parent != null) |
574 |
if (parent != null) |
|
Lines 559-577
Link Here
|
| 559 |
return farr; |
576 |
return farr; |
| 560 |
} |
577 |
} |
| 561 |
|
578 |
|
| 562 |
|
579 |
|
| 563 |
|
580 |
|
| 564 |
private void updateRemoteFile(IRemoteFile parent, IHostFile newHostParent, IProgressMonitor monitor) throws SystemMessageException |
581 |
private void updateRemoteFile(IRemoteFile parent, IHostFile newHostParent, IProgressMonitor monitor) throws SystemMessageException |
| 565 |
{ |
582 |
{ |
| 566 |
// now newHostParent file passed in so we'll assume it wasn't returned and explicitly get it |
583 |
// now newHostParent file passed in so we'll assume it wasn't returned and explicitly get it |
| 567 |
if (newHostParent == null){ |
584 |
if (newHostParent == null){ |
| 568 |
String parentParentPath = parent.getParentPath(); |
585 |
String parentParentPath = parent.getParentPath(); |
| 569 |
if (parentParentPath == null){ |
586 |
if (parentParentPath == null){ |
| 570 |
parentParentPath = ""; //$NON-NLS-1$ |
587 |
parentParentPath = ""; //$NON-NLS-1$ |
| 571 |
} |
588 |
} |
| 572 |
newHostParent = getFileService().getFile(parentParentPath, parent.getName(), monitor); |
589 |
newHostParent = getFileService().getFile(parentParentPath, parent.getName(), monitor); |
| 573 |
} |
590 |
} |
| 574 |
|
591 |
|
| 575 |
if (newHostParent != null){ |
592 |
if (newHostParent != null){ |
| 576 |
IHostFile oldHostParent = parent.getHostFile(); |
593 |
IHostFile oldHostParent = parent.getHostFile(); |
| 577 |
if (!newHostParent.equals(oldHostParent)){ |
594 |
if (!newHostParent.equals(oldHostParent)){ |
|
Lines 581-587
Link Here
|
| 581 |
} |
598 |
} |
| 582 |
} |
599 |
} |
| 583 |
|
600 |
|
| 584 |
|
601 |
|
| 585 |
public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException |
602 |
public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException |
| 586 |
{ |
603 |
{ |
| 587 |
IHostFile[] roots = null; |
604 |
IHostFile[] roots = null; |
|
Lines 907-913
Link Here
|
| 907 |
|
924 |
|
| 908 |
public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException |
925 |
public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException |
| 909 |
{ |
926 |
{ |
| 910 |
return createFolder(folderToCreate, monitor); |
927 |
return createFolder(folderToCreate, monitor); |
| 911 |
} |
928 |
} |
| 912 |
|
929 |
|
| 913 |
/** |
930 |
/** |