1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 23:35:48 +02:00

[230821] [api][breaking] IRemoteFileSubsystem is inconsistent with IFileService

https://bugs.eclipse.org/bugs/show_bug.cgi?id=230821
This commit is contained in:
David Dykstal 2008-05-22 01:51:17 +00:00
parent 22dca8fe78
commit 4fb3bcbf26
8 changed files with 88 additions and 95 deletions

View file

@ -27,6 +27,7 @@
* Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND
* Kevin Doyle (IBM) - [210673] [efs][nls] Externalize Strings in RSEFileStore and RSEFileStoreImpl * Kevin Doyle (IBM) - [210673] [efs][nls] Externalize Strings in RSEFileStore and RSEFileStoreImpl
* Timur Shipilov (Xored) - [224540] [efs] RSEFileStore.mkdir(EFS.NONE, null) doesn't create parent folder * Timur Shipilov (Xored) - [224540] [efs] RSEFileStore.mkdir(EFS.NONE, null) doesn't create parent folder
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.efs; package org.eclipse.rse.internal.efs;
@ -560,28 +561,22 @@ public class RSEFileStoreImpl extends FileStore
* @see org.eclipse.core.filesystem.provider.FileStore#putInfo(org.eclipse.core.filesystem.IFileInfo, int, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.core.filesystem.provider.FileStore#putInfo(org.eclipse.core.filesystem.IFileInfo, int, org.eclipse.core.runtime.IProgressMonitor)
*/ */
public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException { public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
boolean success = true;
// connect if needed. Will throw exception if not successful. // connect if needed. Will throw exception if not successful.
IRemoteFile remoteFile = getRemoteFileObject(monitor, false); IRemoteFile remoteFile = getRemoteFileObject(monitor, false);
IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem();
try { try {
if ((options & EFS.SET_ATTRIBUTES) != 0) { if ((options & EFS.SET_ATTRIBUTES) != 0) {
//We cannot currently write isExecutable(), isHidden() //We cannot currently write isExecutable(), isHidden()
success &= subSys.setReadOnly(remoteFile, info.getAttribute(EFS.ATTRIBUTE_READ_ONLY), monitor); subSys.setReadOnly(remoteFile, info.getAttribute(EFS.ATTRIBUTE_READ_ONLY), monitor);
} }
if ((options & EFS.SET_LAST_MODIFIED) != 0) { if ((options & EFS.SET_LAST_MODIFIED) != 0) {
success &= subSys.setLastModified(remoteFile, info.getLastModified(), monitor); subSys.setLastModified(remoteFile, info.getLastModified(), monitor);
} }
} catch(Exception e) { } catch(Exception e) {
throw new CoreException(new Status(IStatus.ERROR, throw new CoreException(new Status(IStatus.ERROR,
Activator.getDefault().getBundle().getSymbolicName(), Activator.getDefault().getBundle().getSymbolicName(),
getExceptionMessage(toString(), e), e)); getExceptionMessage(toString(), e), e));
} }
if (!success) {
cacheRemoteFile(null);
//will throw exception if not exists
remoteFile = getRemoteFileObject(monitor, true);
}
} }
/* /*
@ -719,12 +714,7 @@ public class RSEFileStoreImpl extends FileStore
IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem();
try { try {
cacheRemoteFile(null); cacheRemoteFile(null);
boolean success = subSys.delete(remoteFile, monitor); subSys.delete(remoteFile, monitor);
if (!success) {
throw new CoreException(new Status(IStatus.ERROR,
Activator.getDefault().getBundle().getSymbolicName(),
Messages.DELETE_FAILED));
}
} }
catch (SystemMessageException e) { catch (SystemMessageException e) {
throw new CoreException(new Status(IStatus.ERROR, throw new CoreException(new Status(IStatus.ERROR,

View file

@ -23,6 +23,7 @@
* Rupen Mardirossian (IBM) - [210682] created checkForCollision method that returns a boolean for SystemCopyDialog enhancement * Rupen Mardirossian (IBM) - [210682] created checkForCollision method that returns a boolean for SystemCopyDialog enhancement
* David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
* David McKnight (IBM) - [224377] "open with" menu does not have "other" option * David McKnight (IBM) - [224377] "open with" menu does not have "other" option
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.files.ui.actions; package org.eclipse.rse.internal.files.ui.actions;
@ -264,9 +265,12 @@ implements IValidatorRemoteSelection
if (targetConnection == srcConnection) if (targetConnection == srcConnection)
{ {
ss = targetFolder.getParentRemoteFileSubSystem(); ss = targetFolder.getParentRemoteFileSubSystem();
try {
ss.copy(srcFileOrFolder, targetFolder, newName, null);
ok = ss.copy(srcFileOrFolder, targetFolder, newName, null); ok = true;
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during copy", e); //$NON-NLS-1$
}
if (!ok) if (!ok)
{ {
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getName()); String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getName());

View file

@ -24,6 +24,7 @@
* Rupen Mardirossian (IBM) - [210682] Modified MoveRemoteFileJob.runInWorkspace to use SystemCopyDialog for collisions in move operations * Rupen Mardirossian (IBM) - [210682] Modified MoveRemoteFileJob.runInWorkspace to use SystemCopyDialog for collisions in move operations
* David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
* David McKnight (IBM) - [224377] "open with" menu does not have "other" option * David McKnight (IBM) - [224377] "open with" menu does not have "other" option
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.files.ui.actions; package org.eclipse.rse.internal.files.ui.actions;
@ -51,6 +52,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.actions.SystemBaseCopyAction; import org.eclipse.rse.ui.actions.SystemBaseCopyAction;
import org.eclipse.rse.ui.messages.SystemMessageDialog; import org.eclipse.rse.ui.messages.SystemMessageDialog;
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection; import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
@ -246,8 +248,12 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem(); IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
boolean ok = false; boolean ok = false;
try {
ok = ss.move(srcFileOrFolder, targetFolder, newName, monitor); ss.move(srcFileOrFolder, targetFolder, newName, monitor);
ok = true;
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during a move operation", e); //$NON-NLS-1$
}
if (!ok) if (!ok)
{ {
String msgTxt = NLS.bind(FileResources.FILEMSG_MOVE_FILE_FAILED, srcFileOrFolder.getName()); String msgTxt = NLS.bind(FileResources.FILEMSG_MOVE_FILE_FAILED, srcFileOrFolder.getName());

View file

@ -54,6 +54,7 @@
* Rupen Mardirossian (IBM) - [198728] Folder being copied across systems is added to original set of files in order to extract empty (sub)folders in doDrop method * Rupen Mardirossian (IBM) - [198728] Folder being copied across systems is added to original set of files in order to extract empty (sub)folders in doDrop method
* David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding
* Rupen Mardirossian (IBM) - [227213] Copy and pasting to the parent folder will create a "Copy of" that resource * Rupen Mardirossian (IBM) - [227213] Copy and pasting to the parent folder will create a "Copy of" that resource
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.files.ui.view; package org.eclipse.rse.internal.files.ui.view;
@ -2255,24 +2256,9 @@ public class SystemViewRemoteFileAdapter
try try
{ {
if (targetFS.copy(srcFileOrFolder, targetFolder, name, monitor)) targetFS.copy(srcFileOrFolder, targetFolder, name, monitor);
{ IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor);
IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor); resultSet.addResource(copiedFile);
resultSet.addResource(copiedFile);
}
else
{
// need a failed message here
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getAbsolutePath());
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
resultSet.setMessage(msg);
}
} }
catch (SystemMessageException e) catch (SystemMessageException e)
{ {
@ -2593,12 +2579,9 @@ public class SystemViewRemoteFileAdapter
if (name != null) if (name != null)
{ {
monitor.subTask(copyMessage.getLevelOneText()); monitor.subTask(copyMessage.getLevelOneText());
if (targetFS.copy(srcFileOrFolder, targetFolder, name, monitor)) targetFS.copy(srcFileOrFolder, targetFolder, name, monitor);
{ IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor);
IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor); return copiedFile;
return copiedFile;
}
} }
} }
} }
@ -2799,8 +2782,8 @@ public class SystemViewRemoteFileAdapter
} }
} }
*/ */
ok = ss.delete(file, monitor); ss.delete(file, monitor);
ok = true;
file.markStale(true); file.markStale(true);
parentFile.markStale(true); parentFile.markStale(true);
} }
@ -2851,7 +2834,6 @@ public class SystemViewRemoteFileAdapter
} }
catch (Exception exc) catch (Exception exc)
{ {
ok = false;
ok = false; ok = false;
String msgTxt = NLS.bind(FileResources.FILEMSG_DELETE_FILE_FAILED, file.toString()); String msgTxt = NLS.bind(FileResources.FILEMSG_DELETE_FILE_FAILED, file.toString());
String msgDetails = FileResources.FILEMSG_DELETE_FILE_FAILED_DETAILS; String msgDetails = FileResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;
@ -2864,7 +2846,13 @@ public class SystemViewRemoteFileAdapter
} }
if (ss != null) if (ss != null)
{ {
ok = ss.deleteBatch(files, monitor); try {
ss.deleteBatch(files, monitor);
ok = true;
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during batch delete", e); //$NON-NLS-1$
ok = false;
}
return ok; return ok;
} }
else else
@ -2960,7 +2948,12 @@ public class SystemViewRemoteFileAdapter
localResource = UniversalFileTransferUtility.getTempFileFor(file); localResource = UniversalFileTransferUtility.getTempFileFor(file);
} }
ok = ss.rename(file, newName, monitor); try {
ss.rename(file, newName, monitor);
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during rename", e); //$NON-NLS-1$
ok = false;
}
if (localResource != null && localResource.exists()) if (localResource != null && localResource.exists())
{ {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others. * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.importexport.files; package org.eclipse.rse.internal.importexport.files;
@ -93,7 +94,7 @@ public class UniFilePlus extends File {
public boolean delete() { public boolean delete() {
boolean ok = true; boolean ok = true;
try { try {
ok = remoteFile.getParentRemoteFileSubSystem().delete(remoteFile, new NullProgressMonitor()); remoteFile.getParentRemoteFileSubSystem().delete(remoteFile, new NullProgressMonitor());
//hmm, should we set remoteFile to null? //hmm, should we set remoteFile to null?
} catch (RemoteFileException exc) { } catch (RemoteFileException exc) {
Exception e = exc.getRemoteException(); Exception e = exc.getRemoteException();
@ -321,7 +322,8 @@ public class UniFilePlus extends File {
public boolean renameTo(File dest) { public boolean renameTo(File dest) {
boolean ok = false; boolean ok = false;
try { try {
ok = remoteFile.getParentRemoteFileSubSystem().rename(remoteFile, dest.getName(), new NullProgressMonitor()); remoteFile.getParentRemoteFileSubSystem().rename(remoteFile, dest.getName(), new NullProgressMonitor());
ok = true;
} catch (RemoteFileException exc) { } catch (RemoteFileException exc) {
Exception e = exc.getRemoteException(); Exception e = exc.getRemoteException();
if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e;
@ -338,7 +340,8 @@ public class UniFilePlus extends File {
if (time < 0) throw new IllegalArgumentException(); if (time < 0) throw new IllegalArgumentException();
try { try {
IProgressMonitor monitor = new NullProgressMonitor(); IProgressMonitor monitor = new NullProgressMonitor();
ok = remoteFile.getParentRemoteFileSubSystem().setLastModified(remoteFile, time, monitor); remoteFile.getParentRemoteFileSubSystem().setLastModified(remoteFile, time, monitor);
ok = true;
} catch (RemoteFileException exc) { } catch (RemoteFileException exc) {
Exception e = exc.getRemoteException(); Exception e = exc.getRemoteException();
if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e;
@ -353,7 +356,8 @@ public class UniFilePlus extends File {
public boolean setReadOnly() { public boolean setReadOnly() {
boolean ok = false; boolean ok = false;
try { try {
ok = remoteFile.getParentRemoteFileSubSystem().setReadOnly(remoteFile, true, new NullProgressMonitor()); remoteFile.getParentRemoteFileSubSystem().setReadOnly(remoteFile, true, new NullProgressMonitor());
ok = true;
} catch (RemoteFileException exc) { } catch (RemoteFileException exc) {
Exception e = exc.getRemoteException(); Exception e = exc.getRemoteException();
if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e;

View file

@ -37,6 +37,7 @@
* Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading
* David Dykstal (IBM) - [221211] fix IFileService API for batch operations * David Dykstal (IBM) - [221211] fix IFileService API for batch operations
* Martin Oberhuber (Wind River) - [221211] Fix markStale() for delete() operation with exceptions * Martin Oberhuber (Wind River) - [221211] Fix markStale() for delete() operation with exceptions
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.subsystems.files.core.servicesubsystem; package org.eclipse.rse.subsystems.files.core.servicesubsystem;
@ -797,14 +798,13 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#copy(org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#copy(org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/ */
public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException public void copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException
{ {
IFileService service = getFileService(); IFileService service = getFileService();
service.copy(sourceFolderOrFile.getParentPath(), sourceFolderOrFile.getName(), targetFolder.getAbsolutePath(), newName, monitor); service.copy(sourceFolderOrFile.getParentPath(), sourceFolderOrFile.getName(), targetFolder.getAbsolutePath(), newName, monitor);
return true;
} }
public boolean copyBatch(IRemoteFile[] sourceFolderOrFiles, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException public void copyBatch(IRemoteFile[] sourceFolderOrFiles, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException
{ {
IFileService service = getFileService(); IFileService service = getFileService();
String[] sourceParents = new String[sourceFolderOrFiles.length]; String[] sourceParents = new String[sourceFolderOrFiles.length];
@ -816,7 +816,6 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
sourceNames[i] = sourceFolderOrFiles[i].getName(); sourceNames[i] = sourceFolderOrFiles[i].getName();
} }
service.copyBatch(sourceParents, sourceNames, targetFolder.getAbsolutePath(), monitor); service.copyBatch(sourceParents, sourceNames, targetFolder.getAbsolutePath(), monitor);
return true;
} }
public IRemoteFile getParentFolder(IRemoteFile folderOrFile, IProgressMonitor monitor) public IRemoteFile getParentFolder(IRemoteFile folderOrFile, IProgressMonitor monitor)
@ -854,7 +853,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
return createFolder(folderToCreate, monitor); return createFolder(folderToCreate, monitor);
} }
public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException public void delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException
{ {
IFileService service = getFileService(); IFileService service = getFileService();
String parent = folderOrFile.getParentPath(); String parent = folderOrFile.getParentPath();
@ -864,10 +863,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
} finally { } finally {
folderOrFile.markStale(true); folderOrFile.markStale(true);
} }
return true;
} }
public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException public void deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException
{ {
String[] parents = new String[folderOrFiles.length]; String[] parents = new String[folderOrFiles.length];
@ -882,10 +880,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
} }
IFileService service = getFileService(); IFileService service = getFileService();
service.deleteBatch(parents, names, monitor); service.deleteBatch(parents, names, monitor);
return true;
} }
public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException public void rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException
{ {
removeCachedRemoteFile(folderOrFile); removeCachedRemoteFile(folderOrFile);
IFileService service = getFileService(); IFileService service = getFileService();
@ -894,10 +891,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
String newPath = srcParent + folderOrFile.getSeparator() + newName; String newPath = srcParent + folderOrFile.getSeparator() + newName;
service.rename(srcParent, oldName, newName, monitor); service.rename(srcParent, oldName, newName, monitor);
folderOrFile.getHostFile().renameTo(newPath); folderOrFile.getHostFile().renameTo(newPath);
return true;
} }
public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException public void move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException
{ {
IFileService service = getFileService(); IFileService service = getFileService();
String srcParent = sourceFolderOrFile.getParentPath(); String srcParent = sourceFolderOrFile.getParentPath();
@ -910,23 +906,20 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
sourceFolderOrFile.markStale(true); sourceFolderOrFile.markStale(true);
targetFolder.markStale(true); targetFolder.markStale(true);
} }
return true;
} }
public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException public void setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException
{ {
String name = folderOrFile.getName(); String name = folderOrFile.getName();
String parent = folderOrFile.getParentPath(); String parent = folderOrFile.getParentPath();
_hostFileService.setLastModified(parent, name, newDate, monitor); _hostFileService.setLastModified(parent, name, newDate, monitor);
return true;
} }
public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException public void setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException
{ {
String name = folderOrFile.getName(); String name = folderOrFile.getName();
String parent = folderOrFile.getParentPath(); String parent = folderOrFile.getParentPath();
_hostFileService.setReadOnly(parent, name, readOnly, monitor); _hostFileService.setReadOnly(parent, name, readOnly, monitor);
return true;
} }
public ILanguageUtilityFactory getLanguageUtilityFactory() public ILanguageUtilityFactory getLanguageUtilityFactory()

View file

@ -21,6 +21,7 @@
* Kevin Doyle (IBM) - [208778] new API getOutputSteam for getting an output stream in append mode * Kevin Doyle (IBM) - [208778] new API getOutputSteam for getting an output stream in append mode
* David McKnight (IBM) - [209704] added supportsEncodingConversion() * David McKnight (IBM) - [209704] added supportsEncodingConversion()
* Martin Oberhuber (Wind River) - [226574][api] Add ISubSystemConfiguration#supportsEncoding() * Martin Oberhuber (Wind River) - [226574][api] Add ISubSystemConfiguration#supportsEncoding()
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.subsystems.files.core.subsystems; package org.eclipse.rse.subsystems.files.core.subsystems;
@ -370,40 +371,43 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* *
* @param folderOrFile represents the object to be deleted. * @param folderOrFile represents the object to be deleted.
* @param monitor progressMonitor * @param monitor progressMonitor
* @return false if the given folder/file didn't exist to begin with, else true. Throws an exception if anything fails.
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException; public void delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Delete the given batch of remote file or folder. * Delete the given batch of remote file or folder.
* <ul> * <ul>
* <li>If any of the inputs are a folder, those folders must be empty for this to succeed. * <li>If any of the inputs are a folder, those folders must be empty for this to succeed.
* </ul> * </ul>
* Should throw an exception if some files and folders were deleted and others were not due to an exception during the operation. * <p>
* If an error occurs during the deletion of an item, this operation stops on that item and a {@link SystemMessageException} is thrown.
* Items deleted before that item will remain deleted. Items specified after that item will not be deleted.
* The item on which the error occurs will not be deleted.
* Without an exception thrown in such cases, views may not be refreshed correctly to account for deleted resources. * Without an exception thrown in such cases, views may not be refreshed correctly to account for deleted resources.
* @param folderOrFiles represents the objects to be deleted. * @param folderOrFiles represents the objects to be deleted.
* @param monitor progressMonitor * @param monitor progressMonitor
* @return false if any of the given folder/file dont exist to begin with, else true. Throws an exception if anything fails.
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException; public void deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Rename the given remote file or folder. This renames it in memory and, iff it exists, on disk. * Rename the given remote file or folder. This renames it in memory and, iff it exists, on disk.
* @param folderOrFile represents the object to be renamed. * @param folderOrFile represents the object to be renamed.
* @param newName new name to give it. * @param newName new name to give it.
* @param monitor the progress monitor * @param monitor the progress monitor
* @return false if the given folder/file didn't exist on disk (still renamed in memory), else true. Throws an exception if anything fails.
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException; public void rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Move a file or folder to a new target parent folder. * Move a file or folder to a new target parent folder.
@ -412,12 +416,12 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* @param targetFolder The folder to move to. No guarantee it is on the same system, so be sure to check getSystemConnection()! * @param targetFolder The folder to move to. No guarantee it is on the same system, so be sure to check getSystemConnection()!
* @param newName The new name for the moved file or folder * @param newName The new name for the moved file or folder
* @param monitor progress monitor * @param monitor progress monitor
* @return true if the move succeeded
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName,IProgressMonitor monitor) throws SystemMessageException; public void move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName,IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Set the last modified date for the given file or folder. Like a Unix "touch" operation. * Set the last modified date for the given file or folder. Like a Unix "touch" operation.
@ -425,12 +429,12 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* @param folderOrFile represents the object to be renamed. * @param folderOrFile represents the object to be renamed.
* @param newDate new date, in milliseconds from epoch, to assign. * @param newDate new date, in milliseconds from epoch, to assign.
* @param monitor the progress monitor * @param monitor the progress monitor
* @return false if the given folder/file didn't exist on disk (operation fails), else true. Throws an exception if anything fails.
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException; public void setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Set a files read-only permissions. * Set a files read-only permissions.
@ -438,12 +442,12 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* @param folderOrFile represents the object to be renamed. * @param folderOrFile represents the object to be renamed.
* @param readOnly whether to set it to be read-only or not * @param readOnly whether to set it to be read-only or not
* @param monitor the progress monitor * @param monitor the progress monitor
* @return false if the given folder/file didn't exist on disk (operation fails), else true. Throws an exception if anything fails.
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException; public void setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException;
// ---------------------------- // ----------------------------
@ -454,29 +458,32 @@ public interface IRemoteFileSubSystem extends ISubSystem {
/** /**
* Copy a file or folder to a new target parent folder. * Copy a file or folder to a new target parent folder.
*
* @param sourceFolderOrFile The file or folder to copy * @param sourceFolderOrFile The file or folder to copy
* @param targetFolder The folder to copy to. No guarantee it is on the same system, so be sure to check getSystemConnection()! * @param targetFolder The folder to copy to. No guarantee it is on the same system, so be sure to check getSystemConnection()!
* @param newName The new name for the copied file or folder * @param newName The new name for the copied file or folder
* @param monitor progress monitor * @param monitor progress monitor
* @return true if the copy succeeded
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException; public void copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Copy a set of remote files or folders to a new target parent folder. Precondition: Sources and target must all be on the same system! * Copy a set of remote files or folders to a new target parent folder. Precondition: Sources and target must all be on the same system.
* <p>
* If an error occurs during the copy of an item, this operation stops on that item and a {@link SystemMessageException} is thrown.
* Items copied before that item will remain copied. Items copied after that item will not be copied.
* The item on which the error occurs will not be copied.
* @param sourceFolderOrFile The file or folder to copy * @param sourceFolderOrFile The file or folder to copy
* @param targetFolder The folder to copy to. * @param targetFolder The folder to copy to.
* @param monitor progress monitor * @param monitor progress monitor
* @return true if all copies succeeded
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the * Typically this would be one of those in the
* {@link RemoteFileException} family. * {@link RemoteFileException} family.
* @since org.eclipse.rse.subsystems.files.core 3.0
*/ */
public boolean copyBatch(IRemoteFile[] sourceFolderOrFile, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException; public void copyBatch(IRemoteFile[] sourceFolderOrFile, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Get the remote file and save it locally. * Get the remote file and save it locally.

View file

@ -12,6 +12,7 @@
* - <copied code from org.eclipse.core.tests.resources/ResourceTest (Copyright IBM)> * - <copied code from org.eclipse.core.tests.resources/ResourceTest (Copyright IBM)>
* - <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)> * - <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
* Martin Oberhuber (Wind River) - [195402] Add constructor with test name * Martin Oberhuber (Wind River) - [195402] Add constructor with test name
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.tests.subsystems.files; package org.eclipse.rse.tests.subsystems.files;
@ -110,16 +111,11 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
public IRemoteFile copySourceFileOrFolder(String sourceFullName, String sourceName, String targetFolderFullName) throws Exception public IRemoteFile copySourceFileOrFolder(String sourceFullName, String sourceName, String targetFolderFullName) throws Exception
{ {
boolean ok = false;
IRemoteFile result = null; IRemoteFile result = null;
IRemoteFile originalTargetArchiveFile = fss.getRemoteFileObject(sourceFullName, mon); IRemoteFile originalTargetArchiveFile = fss.getRemoteFileObject(sourceFullName, mon);
IRemoteFile targetFolder = fss.getRemoteFileObject(targetFolderFullName, mon); IRemoteFile targetFolder = fss.getRemoteFileObject(targetFolderFullName, mon);
ok = fss.copy(originalTargetArchiveFile, targetFolder, sourceName, mon); fss.copy(originalTargetArchiveFile, targetFolder, sourceName, mon);
if (ok) result = fss.getRemoteFileObject(getNewAbsoluteName(targetFolder, sourceName), mon);
{
//copy is successful
result = fss.getRemoteFileObject(getNewAbsoluteName(targetFolder, sourceName), mon);
}
//Need to call resolveFilterString of the parent to make sure the newly copied child //Need to call resolveFilterString of the parent to make sure the newly copied child
//is added to the DStore map. Otherwise, next time when query it, it will just created a //is added to the DStore map. Otherwise, next time when query it, it will just created a
//default filter string. And the dstore server cannot handler it correctly. //default filter string. And the dstore server cannot handler it correctly.