1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-30 11:43:33 +02:00

[221211] [api][breaking][files] need batch operations to indicate which operations were successful

https://bugs.eclipse.org/bugs/show_bug.cgi?id=221211
This commit is contained in:
David Dykstal 2008-05-05 22:40:04 +00:00
parent 6c82af5a4b
commit ba07826c2f
7 changed files with 364 additions and 480 deletions

View file

@ -58,6 +58,7 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -272,7 +273,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
public boolean upload(InputStream inputStream, String remoteParent, String remoteFile, boolean isBinary, public void upload(InputStream inputStream, String remoteParent, String remoteFile, boolean isBinary,
String hostEncoding, IProgressMonitor monitor) throws SystemMessageException String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
BufferedInputStream bufInputStream = null; BufferedInputStream bufInputStream = null;
@ -438,12 +439,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
throw new RemoteFileCancelledException(); throw new RemoteFileCancelledException();
} }
} }
return true;
} }
public boolean upload(File file, String remoteParent, String remoteFile, boolean isBinary, public void upload(File file, String remoteParent, String remoteFile, boolean isBinary,
String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
FileInputStream inputStream = null; FileInputStream inputStream = null;
@ -658,12 +657,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// } // }
} }
} }
return true;
} }
public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary,
String encoding, IProgressMonitor monitor) throws SystemMessageException String encoding, IProgressMonitor monitor) throws SystemMessageException
{ {
DataStore ds = getDataStore(); DataStore ds = getDataStore();
@ -672,12 +669,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
//int mode = isBinary ? IUniversalDataStoreConstants.BINARY_MODE : IUniversalDataStoreConstants.TEXT_MODE; //int mode = isBinary ? IUniversalDataStoreConstants.BINARY_MODE : IUniversalDataStoreConstants.TEXT_MODE;
int mode = IUniversalDataStoreConstants.BINARY_MODE; int mode = IUniversalDataStoreConstants.BINARY_MODE;
if (!makeSureLocalExists(localFile)) makeSureLocalExists(localFile);
{
FileNotFoundException e = new FileNotFoundException();
throw new RemoteFileIOException(e);
}
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile; String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
@ -779,10 +771,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this); codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this);
} }
return true;
} }
else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION)) else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION))
{ {
@ -825,10 +813,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{ {
//monitor.done(); //monitor.done();
} }
return true;
} }
private boolean makeSureLocalExists(File localFile) private void makeSureLocalExists(File localFile) throws SystemMessageException
{ {
if (!localFile.exists()) if (!localFile.exists())
{ {
@ -844,19 +831,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
catch (IOException e) catch (IOException e)
{ {
return false; SimpleSystemMessage message = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage());
throw new SystemMessageException(message);
} }
return true;
} }
/** /**
* Default implementation - just iterate through each file * Default implementation - just iterate through each file
*/ */
public boolean downloadMultiple(String[] remoteParents, String[] remoteFiles, public void downloadMultiple(String[] remoteParents, String[] remoteFiles,
File[] localFiles, boolean[] isBinaries, String[] hostEncodings, File[] localFiles, boolean[] isBinaries, String[] hostEncodings,
IProgressMonitor monitor) throws SystemMessageException IProgressMonitor monitor) throws SystemMessageException
{ {
boolean result = true;
List downloadListeners = new ArrayList(); List downloadListeners = new ArrayList();
@ -900,7 +886,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// kick off all downloads // kick off all downloads
for (int i = 0; i < des.length && result == true; i++) for (int i = 0; i < des.length; i++)
{ {
int mode = IUniversalDataStoreConstants.BINARY_MODE; int mode = IUniversalDataStoreConstants.BINARY_MODE;
DataElement de = des[i]; DataElement de = des[i];
@ -909,11 +895,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
File localFile = localFiles[i]; File localFile = localFiles[i];
String hostEncoding = hostEncodings[i]; String hostEncoding = hostEncodings[i];
if (!makeSureLocalExists(localFile)) makeSureLocalExists(localFile);
{
FileNotFoundException e = new FileNotFoundException();
throw new RemoteFileIOException(e);
}
long fileLength = DStoreHostFile.getFileLength(de.getSource()); long fileLength = DStoreHostFile.getFileLength(de.getSource());
if (monitor != null) if (monitor != null)
@ -1018,8 +1000,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[i], localEncoding, this); codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[i], localEncoding, this);
} }
result = true;
} }
else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION)) else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION))
{ {
@ -1034,12 +1014,19 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_UNSUPPORTED_ENCODING_EXCEPTION)) else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_UNSUPPORTED_ENCODING_EXCEPTION))
{ {
// TODO inspect this
localFile.delete();
String msgTxt = ServiceResources.FILEMSG_SECURITY_ERROR;
String msgDetails = NLS.bind(ServiceResources.FILEMSG_SECURITY_ERROR_DETAILS, IUniversalDataStoreConstants.DOWNLOAD_RESULT_UNSUPPORTED_ENCODING_EXCEPTION);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_SECURITY_ERROR,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
//SystemMessage msg = getMessage(); //SystemMessage msg = getMessage();
//throw new SystemMessageException(msg); //throw new SystemMessageException(msg);
//UnsupportedEncodingException e = new UnsupportedEncodingException(resultChild.getName()); //UnsupportedEncodingException e = new UnsupportedEncodingException(resultChild.getName());
//UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error reading file " + remotePath, e); //UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error reading file " + remotePath, e);
//throw new RemoteFileIOException(e); //throw new RemoteFileIOException(e);
result = false;
} }
else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION)) else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION))
@ -1057,7 +1044,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
else else
{ {
result = false; // TODO inspect this
localFile.delete();
String msgTxt = ServiceResources.FILEMSG_SECURITY_ERROR;
String msgDetails = NLS.bind(ServiceResources.FILEMSG_SECURITY_ERROR_DETAILS, IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_SECURITY_ERROR,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
} }
} }
@ -1067,19 +1061,17 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
} }
} }
return result;
} }
/** /**
* Default implementation - just iterate through each file * Default implementation - just iterate through each file
*/ */
public boolean uploadMultiple(File[] localFiles, String[] remoteParents, public void uploadMultiple(File[] localFiles, String[] remoteParents,
String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings, String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings,
String[] hostEncodings, IProgressMonitor monitor) String[] hostEncodings, IProgressMonitor monitor)
throws SystemMessageException throws SystemMessageException
{ {
boolean result = true; for (int i = 0; i < localFiles.length; i++)
for (int i = 0; i < localFiles.length && result == true; i++)
{ {
File localFile = localFiles[i]; File localFile = localFiles[i];
String remoteParent = remoteParents[i]; String remoteParent = remoteParents[i];
@ -1088,9 +1080,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
boolean isBinary = isBinaries[i]; boolean isBinary = isBinaries[i];
String srcEncoding = srcEncodings[i]; String srcEncoding = srcEncodings[i];
String hostEncoding = hostEncodings[i]; String hostEncoding = hostEncodings[i];
result = upload(localFile, remoteParent, remoteFile, isBinary, srcEncoding, hostEncoding, monitor); upload(localFile, remoteParent, remoteFile, isBinary, srcEncoding, hostEncoding, monitor);
} }
return result;
} }
private DataElement getSubjectFor(String remoteParent, String name) private DataElement getSubjectFor(String remoteParent, String name)
@ -1359,7 +1350,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{ {
String remotePath = remoteParent + getSeparator(remoteParent) + fileName; String remotePath = remoteParent + getSeparator(remoteParent) + fileName;
DataElement de = getElementFor(remotePath); DataElement de = getElementFor(remotePath);
@ -1382,21 +1373,23 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// When running a server older than 2.0.1 success is not set for directories, so we must // When running a server older than 2.0.1 success is not set for directories, so we must
// check if the source message is an empty string // check if the source message is an empty string
if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$ if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$
return true; return;
} else {
String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_DELETE_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
} }
String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_DELETE_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
} }
public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException
{ {
if (remoteParents.length == 1) return delete(remoteParents[0], fileNames[0], monitor); if (remoteParents.length == 1) {
delete(remoteParents[0], fileNames[0], monitor);
return;
}
ArrayList dataElements = new ArrayList(remoteParents.length); ArrayList dataElements = new ArrayList(remoteParents.length);
for (int i = 0; i < remoteParents.length; i++) for (int i = 0; i < remoteParents.length; i++)
@ -1420,31 +1413,27 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// When running a server older than 2.0.1 success is not set for directories, so we must // When running a server older than 2.0.1 success is not set for directories, so we must
// check if the source message is an empty string // check if the source message is an empty string
if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$ if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$
return true; return;
} else {
String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_DELETE_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
} }
String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_DELETE_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
} }
else { else {
// no delete batch descriptor so need to fall back to single command approach // no delete batch descriptor so need to fall back to single command approach
boolean result = true; for (int i = 0; i < remoteParents.length; i++){
for (int i = 0; i < remoteParents.length && result; i++){
String parent = remoteParents[i]; String parent = remoteParents[i];
String name = fileNames[i]; String name = fileNames[i];
result = delete(parent, name, monitor); delete(parent, name, monitor);
} }
return result;
} }
} }
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
{ {
String oldPath, newPath = null; String oldPath, newPath = null;
// if remoteParent is null or empty then we are doing a move // if remoteParent is null or empty then we are doing a move
@ -1498,57 +1487,48 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
//This operation has been cancelled by the user. //This operation has been cancelled by the user.
throw new SystemMessageException(msg); throw new SystemMessageException(msg);
} }
if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) {
return true; return;
else
{
String msgTxt = NLS.bind(ServiceResources.FILEMSG_RENAME_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_RENAME_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
} }
String msgTxt = NLS.bind(ServiceResources.FILEMSG_RENAME_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_RENAME_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
} }
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException public void rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean retVal = rename(remoteParent, oldName, newName, monitor); rename(remoteParent, oldName, newName, monitor);
String newPath = remoteParent + getSeparator(remoteParent) + newName; String newPath = remoteParent + getSeparator(remoteParent) + newName;
oldFile.renameTo(newPath); oldFile.renameTo(newPath);
return retVal;
} }
protected boolean moveByCopy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException protected void moveByCopy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean movedOk = false; copy(srcParent, srcName, tgtParent, tgtName, monitor);
try
if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
{ {
try delete(srcParent, srcName, monitor);
{ }
movedOk = delete(srcParent, srcName, monitor); catch (SystemMessageException exc)
} {
catch (SystemMessageException exc) if (null != monitor && monitor.isCanceled())
{ {
if (null != monitor && monitor.isCanceled()) //This mean the copy operation is ok, but delete operation has been cancelled by user.
{ //The delete() call will take care of recovered from the cancel operation.
//This mean the copy operation is ok, but delete operation has been cancelled by user. //So we need to make sure to remove the already copied file/folder.
//The delete() call will take care of recovered from the cancel operation. getFile(tgtParent, tgtName, null); //need to call getFile first to put this object into DataElement map first
//So we need to make sure to remove the already copied file/folder. //otherwise it type will default to FilterObject, and could not be deleted properly for virtual object.
getFile(tgtParent, tgtName, null); //need to call getFile first to put this object into DataElement map first delete(tgtParent, tgtName, null);
//otherwise it type will default to FilterObject, and could not be deleted properly for virtual object. }
delete(tgtParent, tgtName, null); throw exc;
}
throw exc;
}
} }
return movedOk;
} }
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException public void move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
{ {
String src = srcParent + getSeparator(srcParent) + srcName; String src = srcParent + getSeparator(srcParent) + srcName;
String tgt = tgtParent + getSeparator(tgtParent) + tgtName; String tgt = tgtParent + getSeparator(tgtParent) + tgtName;
@ -1556,25 +1536,20 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
boolean isArchive = ArchiveHandlerManager.getInstance().isRegisteredArchive(tgt); boolean isArchive = ArchiveHandlerManager.getInstance().isRegisteredArchive(tgt);
if (isVirtual || isArchive) if (isVirtual || isArchive)
{ {
return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor); moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
} }
else else
{ {
boolean movedOk = false;
try try
{ {
movedOk = rename("", src, tgt, monitor); //$NON-NLS-1$ rename("", src, tgt, monitor); //$NON-NLS-1$
} }
catch (SystemMessageException e) catch (SystemMessageException e)
{ {
return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor); moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
} }
// movedOk should never be false otherwise the last DataElement status was null // movedOk should never be false otherwise the last DataElement status was null
if (!movedOk) moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
{
movedOk = moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
}
return movedOk;
} }
/* /*
@ -1669,7 +1644,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
} }
public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException public void copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
{ {
DataStore ds = getDataStore(); DataStore ds = getDataStore();
String srcRemotePath = srcParent + getSeparator(srcParent) + srcName; String srcRemotePath = srcParent + getSeparator(srcParent) + srcName;
@ -1722,7 +1697,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
monitor.setCanceled(true); monitor.setCanceled(true);
} }
} }
return true;
} }
else { else {
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
@ -1732,7 +1706,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
} }
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException public void copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException
{ {
DataStore ds = getDataStore(); DataStore ds = getDataStore();
@ -1788,18 +1762,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
//InterruptedException is used to report user cancellation, so no need to log //InterruptedException is used to report user cancellation, so no need to log
//This should be reviewed (use OperationCanceledException) with bug #190750 //This should be reviewed (use OperationCanceledException) with bug #190750
} }
return true;
} }
else { else {
// no copy batch descriptor so need to fall back to single command approach // no copy batch descriptor so need to fall back to single command approach
boolean result = true; for (int i = 0; i < srcParents.length; i++){
for (int i = 0; i < srcParents.length && result; i++){
String parent = srcParents[i]; String parent = srcParents[i];
String name = srcNames[i]; String name = srcNames[i];
result = copy(parent, name, tgtParent, name, monitor); copy(parent, name, tgtParent, name, monitor);
} }
return result;
} }
} }
@ -1875,17 +1845,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
public IHostFile[] listMultiple(String[] remoteParents, public void listMultiple(String[] remoteParents,
String[] fileFilters, int[] fileTypes, IProgressMonitor monitor) String[] fileFilters, int[] fileTypes, List hostFiles, IProgressMonitor monitor)
throws SystemMessageException throws SystemMessageException
{ {
String[] queryStrings = getQueryStrings(fileTypes); String[] queryStrings = getQueryStrings(fileTypes);
return fetchMulti(remoteParents, fileFilters, queryStrings, monitor); IHostFile[] result = fetchMulti(remoteParents, fileFilters, queryStrings, monitor);
hostFiles.addAll(Arrays.asList(result));
} }
public IHostFile[] listMultiple(String[] remoteParents, public void listMultiple(String[] remoteParents,
String[] fileFilters, int fileType, IProgressMonitor monitor) String[] fileFilters, int fileType, List hostFiles, IProgressMonitor monitor)
throws SystemMessageException throws SystemMessageException
{ {
String queryString = getQueryString(fileType); String queryString = getQueryString(fileType);
@ -1897,7 +1868,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
queryStrings[i] = queryString; queryStrings[i] = queryString;
} }
return fetchMulti(remoteParents, fileFilters, queryStrings, monitor); IHostFile[] result = fetchMulti(remoteParents, fileFilters, queryStrings, monitor);
hostFiles.addAll(Arrays.asList(result));
} }
protected String[] getPathsFor(String[] remoteParents, String[] remoteFiles) protected String[] getPathsFor(String[] remoteParents, String[] remoteFiles)
@ -2051,7 +2023,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
return true; return true;
} }
public boolean setLastModified(String parent, String name, public void setLastModified(String parent, String name,
long timestamp, IProgressMonitor monitor) throws SystemMessageException long timestamp, IProgressMonitor monitor) throws SystemMessageException
{ {
String remotePath = parent + getSeparator(parent) + name; String remotePath = parent + getSeparator(parent) + name;
@ -2065,7 +2037,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// first modify the source attribute to temporarily be the date field // first modify the source attribute to temporarily be the date field
de.setAttribute(DE.A_SOURCE, timestamp + ""); //$NON-NLS-1$ de.setAttribute(DE.A_SOURCE, timestamp + ""); //$NON-NLS-1$
ds.command(setCmd, de, true); ds.command(setCmd, de, true);
return true;
} }
} }
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
@ -2074,7 +2045,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
CommonMessages.MSG_ERROR_UNEXPECTED)); CommonMessages.MSG_ERROR_UNEXPECTED));
} }
public boolean setReadOnly(String parent, String name, public void setReadOnly(String parent, String name,
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException boolean readOnly, IProgressMonitor monitor) throws SystemMessageException
{ {
String remotePath = parent + getSeparator(parent) + name; String remotePath = parent + getSeparator(parent) + name;
@ -2096,7 +2067,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{ {
throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
} }
return true;
} }
} }
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,

View file

@ -99,6 +99,7 @@ import org.apache.commons.net.ftp.FTPClientConfig;
import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply; import org.apache.commons.net.ftp.FTPReply;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.IPropertySet;
@ -109,6 +110,7 @@ import org.eclipse.rse.services.clientserver.FileTypeMatcher;
import org.eclipse.rse.services.clientserver.IMatcher; import org.eclipse.rse.services.clientserver.IMatcher;
import org.eclipse.rse.services.clientserver.NamePatternMatcher; import org.eclipse.rse.services.clientserver.NamePatternMatcher;
import org.eclipse.rse.services.clientserver.PathUtility; import org.eclipse.rse.services.clientserver.PathUtility;
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.AbstractFileService; import org.eclipse.rse.services.files.AbstractFileService;
@ -756,9 +758,8 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#upload(org.eclipse.core.runtime.IProgressMonitor, java.io.File, java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String) * @see org.eclipse.rse.services.files.IFileService#upload(org.eclipse.core.runtime.IProgressMonitor, java.io.File, java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String)
*/ */
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean retValue = true;
remoteParent = checkEncoding(remoteParent); remoteParent = checkEncoding(remoteParent);
remoteFile = checkEncoding(remoteFile); remoteFile = checkEncoding(remoteFile);
@ -779,7 +780,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
{ {
try try
{ {
retValue = internalUpload(localFile, remoteParent, remoteFile, isBinary, srcEncoding, hostEncoding, progressMonitor); internalUpload(localFile, remoteParent, remoteFile, isBinary, srcEncoding, hostEncoding, progressMonitor);
} }
finally { finally {
_commandMutex.release(); _commandMutex.release();
@ -792,17 +793,14 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
} finally { } finally {
progressMonitor.end(); progressMonitor.end();
} }
return retValue;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#upload(org.eclipse.core.runtime.IProgressMonitor, java.io.InputStream, java.lang.String, java.lang.String, boolean, java.lang.String) * @see org.eclipse.rse.services.files.IFileService#upload(org.eclipse.core.runtime.IProgressMonitor, java.io.InputStream, java.lang.String, java.lang.String, boolean, java.lang.String)
*/ */
public boolean upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean retValue = true;
remoteParent = checkEncoding(remoteParent); remoteParent = checkEncoding(remoteParent);
remoteFile = checkEncoding(remoteFile); remoteFile = checkEncoding(remoteFile);
@ -818,31 +816,24 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
while( (readCount = bis.read(buffer)) > 0) while( (readCount = bis.read(buffer)) > 0)
{ {
bos.write(buffer, 0, readCount); bos.write(buffer, 0, readCount);
if (monitor!=null){ if (monitor!=null) {
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
retValue = false;
break; break;
} }
} }
} }
bos.close(); bos.close();
upload(tempFile, remoteParent, remoteFile, isBinary, null, hostEncoding, monitor);
if(retValue == true){
retValue = upload(tempFile, remoteParent, remoteFile, isBinary, null, hostEncoding, monitor);
}
} }
catch (Exception e) { catch (Exception e) {
throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
} }
return retValue;
} }
private boolean internalUpload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, MyProgressMonitor progressMonitor) throws IOException, RemoteFileIOException private void internalUpload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, MyProgressMonitor progressMonitor) throws IOException, RemoteFileIOException, SystemMessageException
{ {
boolean retValue = true;
InputStream input = null; InputStream input = null;
OutputStream output = null; OutputStream output = null;
@ -867,22 +858,17 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
output.write(buffer, 0, readCount); output.write(buffer, 0, readCount);
progressMonitor.count(readCount); progressMonitor.count(readCount);
if (progressMonitor.isCanceled()) { if (progressMonitor.isCanceled()) {
retValue = false; throw new RemoteFileCancelledException();
break;
} }
} }
if (retValue) { output.flush();
output.flush();
}
output.close(); output.close();
output = null; output = null;
ftpClient.completePendingCommand(); ftpClient.completePendingCommand();
} else { } else {
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString())); throw new RemoteFileIOException(new Exception(ftpClient.getReplyString()));
} }
if(retValue==false) { ftpClient.deleteFile(remoteFile);
ftpClient.deleteFile(remoteFile);
}
}finally{ }finally{
try { try {
@ -891,8 +877,6 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
if (output!=null) output.close(); if (output!=null) output.close();
} }
} }
return retValue;
} }
@ -900,9 +884,8 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#download(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.io.File, boolean, java.lang.String) * @see org.eclipse.rse.services.files.IFileService#download(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.io.File, boolean, java.lang.String)
*/ */
public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean retValue = true;
if (monitor!=null){ if (monitor!=null){
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
@ -919,7 +902,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
{ {
try try
{ {
retValue = internalDownload(remoteParent, remoteFile, localFile, isBinary, hostEncoding, progressMonitor); internalDownload(remoteParent, remoteFile, localFile, isBinary, hostEncoding, progressMonitor);
} }
finally finally
{ {
@ -934,14 +917,10 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
progressMonitor.end(); progressMonitor.end();
} }
return retValue;
} }
private boolean internalDownload(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, MyProgressMonitor progressMonitor) throws SystemMessageException, IOException private void internalDownload(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, MyProgressMonitor progressMonitor) throws SystemMessageException, IOException
{ {
boolean retValue = true;
InputStream input = null; InputStream input = null;
OutputStream output = null; OutputStream output = null;
@ -968,17 +947,20 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
output = new FileOutputStream(localFile); output = new FileOutputStream(localFile);
byte[] buffer = new byte[4096]; byte[] buffer = new byte[4096];
int readCount; int readCount;
boolean ok = true;
while((readCount = input.read(buffer)) > 0) while((readCount = input.read(buffer)) > 0)
{ {
output.write(buffer, 0, readCount); output.write(buffer, 0, readCount);
progressMonitor.count(readCount); progressMonitor.count(readCount);
if (progressMonitor.isCanceled()) { if (progressMonitor.isCanceled()) {
retValue = false; ok = false;
break; break;
} }
} }
if (retValue) output.flush(); if (ok) {
output.flush();
}
input.close(); input.close();
input = null; input = null;
ftpClient.completePendingCommand(); ftpClient.completePendingCommand();
@ -996,8 +978,6 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
if (output!=null) output.close(); if (output!=null) output.close();
} }
} }
return retValue;
} }
@ -1040,8 +1020,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#delete(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String) * @see org.eclipse.rse.services.files.IFileService#delete(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String)
*/ */
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException { public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException {
boolean hasSucceeded = false;
remoteParent = checkEncoding(remoteParent); remoteParent = checkEncoding(remoteParent);
fileName = checkEncoding(fileName); fileName = checkEncoding(fileName);
@ -1053,7 +1032,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
if (_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) { if (_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) {
try { try {
FTPClient ftpClient = getFTPClient(); FTPClient ftpClient = getFTPClient();
hasSucceeded = internalDelete(ftpClient, remoteParent, fileName, file.isFile(), progressMonitor); internalDelete(ftpClient, remoteParent, fileName, file.isFile(), progressMonitor);
} }
catch (IOException e) catch (IOException e)
{ {
@ -1066,11 +1045,9 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
} finally { } finally {
progressMonitor.end(); progressMonitor.end();
} }
// Can only return true since !hasSucceeded always leads to Exception
return hasSucceeded;
} }
private boolean internalDelete(FTPClient ftpClient, String parentPath, String fileName, boolean isFile, MyProgressMonitor monitor) private void internalDelete(FTPClient ftpClient, String parentPath, String fileName, boolean isFile, MyProgressMonitor monitor)
throws RemoteFileException, IOException throws RemoteFileException, IOException
{ {
if(monitor.isCanceled()) if(monitor.isCanceled())
@ -1079,64 +1056,54 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
} }
clearCache(parentPath); clearCache(parentPath);
boolean hasSucceeded = FTPReply.isPositiveCompletion(ftpClient.cwd(parentPath)); FTPReply.isPositiveCompletion(ftpClient.cwd(parentPath));
monitor.worked(1); monitor.worked(1);
if(hasSucceeded) if(isFile)
{ {
if(isFile) ftpClient.deleteFile(fileName);
{ monitor.worked(1);
hasSucceeded = ftpClient.deleteFile(fileName); }
monitor.worked(1); else
} {
else ftpClient.removeDirectory(fileName);
{ monitor.worked(1);
hasSucceeded = ftpClient.removeDirectory(fileName);
monitor.worked(1);
}
} }
if(!hasSucceeded){ if(isFile)
if(isFile) {
{ throw new RemoteFileIOException(new Exception(ftpClient.getReplyString()+" ("+concat(parentPath,fileName)+")")); //$NON-NLS-1$ //$NON-NLS-2$
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString()+" ("+concat(parentPath,fileName)+")")); //$NON-NLS-1$ //$NON-NLS-2$ }
else //folder recursively
{
String newParentPath = concat(parentPath,fileName);
ftpClient.changeWorkingDirectory(newParentPath);
FTPFile[] fileNames = ftpClient.listFiles();
for (int i = 0; i < fileNames.length; i++) {
String curName = fileNames[i].getName();
if (curName == null || curName.equals(".") || curName.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
continue;
}
internalDelete(ftpClient, newParentPath, curName, fileNames[i].isFile(), monitor);
} }
else //folder recursively
//remove empty folder
ftpClient.changeWorkingDirectory(parentPath);
boolean hasSucceeded = ftpClient.removeDirectory(fileName);
if (!hasSucceeded)
{ {
String newParentPath = concat(parentPath,fileName); throw new RemoteFileIOException(new Exception(ftpClient.getReplyString() + " (" + concat(parentPath, fileName) + ")")); //$NON-NLS-1$ //$NON-NLS-2$
ftpClient.changeWorkingDirectory(newParentPath);
FTPFile[] fileNames = ftpClient.listFiles();
for (int i = 0; i < fileNames.length; i++) {
String curName = fileNames[i].getName();
if (curName == null || curName.equals(".") || curName.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
continue;
}
hasSucceeded = internalDelete(ftpClient, newParentPath, curName, fileNames[i].isFile(), monitor);
}
//remove empty folder
ftpClient.changeWorkingDirectory(parentPath);
hasSucceeded = ftpClient.removeDirectory(fileName);
if (!hasSucceeded)
{
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString() + " (" + concat(parentPath, fileName) + ")")); //$NON-NLS-1$ //$NON-NLS-2$
}
} }
} }
// Can only return true since !hasSucceeded always leads to Exception
return hasSucceeded;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#rename(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String) * @see org.eclipse.rse.services.files.IFileService#rename(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String)
*/ */
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException { public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException {
boolean success = false;
remoteParent = checkEncoding(remoteParent); remoteParent = checkEncoding(remoteParent);
oldName = checkEncoding(oldName); oldName = checkEncoding(oldName);
newName = checkEncoding(newName); newName = checkEncoding(newName);
@ -1152,7 +1119,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString())); throw new RemoteFileIOException(new Exception(ftpClient.getReplyString()));
} }
success = ftpClient.rename(oldName, newName); boolean success = ftpClient.rename(oldName, newName);
if(!success) if(!success)
{ {
@ -1165,26 +1132,19 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
_commandMutex.release(); _commandMutex.release();
} }
} }
return success;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#rename(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String, org.eclipse.rse.services.files.IHostFile) * @see org.eclipse.rse.services.files.IFileService#rename(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String, org.eclipse.rse.services.files.IHostFile)
*/ */
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) { public void rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) {
boolean hasSucceeded = false;
oldFile.renameTo(newName); oldFile.renameTo(newName);
return hasSucceeded;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#move(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String, java.lang.String) * @see org.eclipse.rse.services.files.IFileService#move(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/ */
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException{ public void move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException{
boolean success = false;
srcParent = checkEncoding(srcParent); srcParent = checkEncoding(srcParent);
srcName = checkEncoding(srcName); srcName = checkEncoding(srcName);
tgtParent = checkEncoding(tgtParent); tgtParent = checkEncoding(tgtParent);
@ -1200,7 +1160,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
clearCache(srcParent); clearCache(srcParent);
clearCache(tgtParent); clearCache(tgtParent);
success = ftpClient.rename(source, target); boolean success = ftpClient.rename(source, target);
if(!success) if(!success)
{ {
@ -1214,7 +1174,6 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
} }
} }
return success;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -1261,10 +1220,9 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
try { try {
File tempFile = File.createTempFile("ftp", "temp"); //$NON-NLS-1$ //$NON-NLS-2$ File tempFile = File.createTempFile("ftp", "temp"); //$NON-NLS-1$ //$NON-NLS-2$
tempFile.deleteOnExit(); tempFile.deleteOnExit();
boolean success = upload(tempFile, remoteParent, fileName, _isBinaryFileType, null, null, monitor); try {
upload(tempFile, remoteParent, fileName, _isBinaryFileType, null, null, monitor);
if(!success) } catch (SystemMessageException e) {
{
throw new RemoteFileIOException(new Exception(getFTPClient().getReplyString())); throw new RemoteFileIOException(new Exception(getFTPClient().getReplyString()));
} }
} }
@ -1279,10 +1237,8 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#copy(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.rse.services.files.IFileService#copy(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
*/ */
public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException public void copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean success = false;
srcParent = checkEncoding(srcParent); srcParent = checkEncoding(srcParent);
srcName = checkEncoding(srcName); srcName = checkEncoding(srcName);
tgtParent = checkEncoding(tgtParent); tgtParent = checkEncoding(tgtParent);
@ -1302,7 +1258,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) { if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) {
try { try {
success = internalCopy(getFTPClient(), srcParent, srcName, tgtParent, tgtName, remoteHostFile.isDirectory(), progressMonitor); internalCopy(getFTPClient(), srcParent, srcName, tgtParent, tgtName, remoteHostFile.isDirectory(), progressMonitor);
} }
catch(IOException e) catch(IOException e)
{ {
@ -1312,26 +1268,22 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
_commandMutex.release(); _commandMutex.release();
} }
} }
return success;
} }
private boolean internalCopy(FTPClient ftpClient, String srcParent, String srcName, String tgtParent, String tgtName, boolean isDirectory, MyProgressMonitor monitor) throws SystemMessageException, IOException private void internalCopy(FTPClient ftpClient, String srcParent, String srcName, String tgtParent, String tgtName, boolean isDirectory, MyProgressMonitor monitor) throws SystemMessageException, IOException
{ {
if (monitor.isCanceled()) if (monitor.isCanceled())
{ {
throw new RemoteFileCancelledException(); throw new RemoteFileCancelledException();
} }
boolean success = false;
if(isDirectory) if(isDirectory)
{ {
//create folder //create folder
// TODO what happens if the destination folder already exists? // TODO what happens if the destination folder already exists?
// Success=true or false? // Success=true or false?
success = ftpClient.makeDirectory(concat(tgtParent,tgtName)); ftpClient.makeDirectory(concat(tgtParent,tgtName));
//copy contents //copy contents
String newSrcParentPath = concat(srcParent,srcName); String newSrcParentPath = concat(srcParent,srcName);
@ -1346,7 +1298,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
continue; continue;
} }
// TODO should we bail out in case a single file fails? // TODO should we bail out in case a single file fails?
success = internalCopy(ftpClient, newSrcParentPath, curName, newTgtParentPath, curName, fileNames[i].isDirectory(), monitor); internalCopy(ftpClient, newSrcParentPath, curName, newTgtParentPath, curName, fileNames[i].isDirectory(), monitor);
} }
} }
@ -1363,33 +1315,21 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
//Use binary raw transfer since the file will be uploaded again //Use binary raw transfer since the file will be uploaded again
try { try {
success = internalDownload(srcParent, srcName, tempFile, true, null, monitor); internalDownload(srcParent, srcName, tempFile, true, null, monitor);
if (success) { internalUpload(tempFile, tgtParent, tgtName, true, null, null, monitor);
success = internalUpload(tempFile, tgtParent, tgtName, true, null, null, monitor);
}
} finally { } finally {
tempFile.delete(); tempFile.delete();
} }
} }
return success;
} }
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException public void copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean hasSucceeded = false;
for(int i=0; i<srcNames.length; i++) for(int i=0; i<srcNames.length; i++)
{ {
hasSucceeded = copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor); copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor);
if(!hasSucceeded)
{
break;
}
} }
return hasSucceeded;
} }
public boolean isCaseSensitive() public boolean isCaseSensitive()
@ -1570,21 +1510,19 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#setLastModified(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, long) * @see org.eclipse.rse.services.files.IFileService#setLastModified(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, long)
*/ */
public boolean setLastModified(String parent, String name, public void setLastModified(String parent, String name,
long timestamp, IProgressMonitor monitor) throws SystemMessageException long timestamp, IProgressMonitor monitor) throws SystemMessageException
{ {
// not applicable for FTP // not applicable for FTP
return false;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#setReadOnly(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, boolean) * @see org.eclipse.rse.services.files.IFileService#setReadOnly(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, boolean)
*/ */
public boolean setReadOnly(String parent, String name, public void setReadOnly(String parent, String name,
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException { boolean readOnly, IProgressMonitor monitor) throws SystemMessageException {
boolean result = false;
FTPHostFile file = getFileInternal(parent,name, monitor); FTPHostFile file = getFileInternal(parent,name, monitor);
int userPermissions = file.getUserPermissions(); int userPermissions = file.getUserPermissions();
@ -1601,20 +1539,22 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
} }
int newPermissions = userPermissions * 100 + groupPermissions * 10 + otherPermissions; int newPermissions = userPermissions * 100 + groupPermissions * 10 + otherPermissions;
if (newPermissions==oldPermissions) { if (newPermissions == oldPermissions) {
result = true; // do nothing
} else if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) { } else if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) {
try { try {
clearCache(parent); clearCache(parent);
result =_ftpClient.sendSiteCommand("CHMOD "+newPermissions+" "+file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ _ftpClient.sendSiteCommand("CHMOD "+newPermissions+" "+file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
} catch (IOException e) { } catch (IOException e) {
result = false; String pluginId = Activator.getDefault().getBundle().getSymbolicName();
String messageText = e.getLocalizedMessage();
SystemMessage message = new SimpleSystemMessage(pluginId, IStatus.ERROR, messageText, e);
throw new SystemMessageException(message);
} finally { } finally {
_commandMutex.release(); _commandMutex.release();
} }
} }
return result;
} }
/* /*

View file

@ -90,6 +90,7 @@ import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.services.files.IHostFile; import org.eclipse.rse.services.files.IHostFile;
import org.eclipse.rse.services.files.IHostFilePermissions; import org.eclipse.rse.services.files.IHostFilePermissions;
import org.eclipse.rse.services.files.IHostFilePermissionsContainer; import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
import org.eclipse.rse.services.files.RemoteFileCancelledException;
import org.eclipse.rse.services.files.RemoteFileException; import org.eclipse.rse.services.files.RemoteFileException;
import org.eclipse.rse.services.files.RemoteFileIOException; import org.eclipse.rse.services.files.RemoteFileIOException;
import org.eclipse.rse.services.files.RemoteFileSecurityException; import org.eclipse.rse.services.files.RemoteFileSecurityException;
@ -241,7 +242,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
} }
} }
public boolean upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean isCancelled = false; boolean isCancelled = false;
@ -260,16 +261,20 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
ISystemArchiveHandler handler = child.getHandler(); ISystemArchiveHandler handler = child.getHandler();
if (handler == null) if (handler == null)
throwCorruptArchiveException(this.getClass() + ".upload()"); //$NON-NLS-1$ throwCorruptArchiveException(this.getClass() + ".upload()"); //$NON-NLS-1$
else else {
return handler.add(stream, child.path, remoteFile, SystemEncodingUtil.ENCODING_UTF_8, hostEncoding, !isBinary, null); handler.add(stream, child.path, remoteFile, SystemEncodingUtil.ENCODING_UTF_8, hostEncoding, !isBinary, null);
return;
}
} }
if (ArchiveHandlerManager.getInstance().isArchive(destinationFile)) if (ArchiveHandlerManager.getInstance().isArchive(destinationFile))
{ {
ISystemArchiveHandler handler = ArchiveHandlerManager.getInstance().getRegisteredHandler(destinationFile); ISystemArchiveHandler handler = ArchiveHandlerManager.getInstance().getRegisteredHandler(destinationFile);
if (handler == null) if (handler == null)
throwCorruptArchiveException(this.getClass() + ".copyToArchive()"); //$NON-NLS-1$ throwCorruptArchiveException(this.getClass() + ".copyToArchive()"); //$NON-NLS-1$
else else {
return handler.add(stream, "", remoteFile, SystemEncodingUtil.ENCODING_UTF_8, hostEncoding, !isBinary, null); //$NON-NLS-1$ handler.add(stream, "", remoteFile, SystemEncodingUtil.ENCODING_UTF_8, hostEncoding, !isBinary, null); //$NON-NLS-1$
return;
}
} }
File destinationParent = destinationFile.getParentFile(); File destinationParent = destinationFile.getParentFile();
@ -343,20 +348,19 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
if (isCancelled) if (isCancelled)
{ {
// throw new RemoteFileCancelledException(); // TODO inspect this
return false; throw new RemoteFileCancelledException();
} }
} }
catch (IOException e) catch (IOException e)
{ {
} }
} }
return true;
} }
public boolean download(String remoteParent, String remoteFile, File destinationFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void download(String remoteParent, String remoteFile, File destinationFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
File file = new File(remoteParent, remoteFile); File file = new File(remoteParent, remoteFile);
FileInputStream inputStream = null; FileInputStream inputStream = null;
@ -372,11 +376,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(destinationFile.getParentFile()); boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(destinationFile.getParentFile());
if (sourceIsVirtual) if (sourceIsVirtual)
{ {
return copyFromArchive(file, destinationFile.getParentFile(), destinationFile.getName(), monitor, hostEncoding, SystemEncodingUtil.ENCODING_UTF_8, !isBinary); copyFromArchive(file, destinationFile.getParentFile(), destinationFile.getName(), monitor, hostEncoding, SystemEncodingUtil.ENCODING_UTF_8, !isBinary);
return;
} }
if (targetIsVirtual || targetIsArchive) if (targetIsVirtual || targetIsArchive)
{ {
return copyToArchive(file, destinationFile.getParentFile(), destinationFile.getName(), monitor, hostEncoding, SystemEncodingUtil.ENCODING_UTF_8, !isBinary); copyToArchive(file, destinationFile.getParentFile(), destinationFile.getName(), monitor, hostEncoding, SystemEncodingUtil.ENCODING_UTF_8, !isBinary);
return;
} }
try try
@ -450,20 +456,19 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
// SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e); // SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e);
// throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
return false;
} }
catch (UnsupportedEncodingException e) catch (UnsupportedEncodingException e)
{ {
// SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e); // SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e);
// throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
return false; // return false;
} }
catch (IOException e) catch (IOException e)
{ {
// SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e); // SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e);
// throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
return false; // return false;
} }
finally finally
{ {
@ -481,26 +486,25 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
if (isCancelled) if (isCancelled)
{ {
// throw new RemoteFileCancelledException(); throw new RemoteFileCancelledException();
return false; // return false;
} else if (file.exists()) { } else if (file.exists()) {
destinationFile.setLastModified(file.lastModified()); destinationFile.setLastModified(file.lastModified());
//TODO check if we want to preserve permissions //TODO check if we want to preserve permissions
//if(!file.canWrite()) destinationFile.setReadOnly(); //if(!file.canWrite()) destinationFile.setReadOnly();
if (destinationFile.length() != file.length()) { if (destinationFile.length() != file.length()) {
// throw new RemoteFileCancelledException(); throw new RemoteFileCancelledException();
System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$ // System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$
return false; // return false;
} }
} }
} }
catch (IOException e) catch (IOException e)
{ {
// SystemPlugin.logError("Closing streams: " + file.getAbsolutePath(), e); // SystemPlugin.logError("Closing streams: " + file.getAbsolutePath(), e);
// throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
} }
} }
return true;
} }
private boolean copyToArchive(File file, File destination, String newName, IProgressMonitor monitor, String sourceEncoding, String targetEncoding, boolean isText) throws SystemMessageException private boolean copyToArchive(File file, File destination, String newName, IProgressMonitor monitor, String sourceEncoding, String targetEncoding, boolean isText) throws SystemMessageException
@ -563,7 +567,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
return true; return true;
} }
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean isCancelled = false; boolean isCancelled = false;
FileInputStream inputStream = null; FileInputStream inputStream = null;
@ -579,11 +583,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(target.getAbsolutePath()); boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(target.getAbsolutePath());
if (sourceIsVirtual) if (sourceIsVirtual)
{ {
return copyFromArchive(localFile, target, remoteFile, monitor, srcEncoding, hostEncoding, !isBinary); copyFromArchive(localFile, target, remoteFile, monitor, srcEncoding, hostEncoding, !isBinary);
return;
} }
if (targetIsVirtual) if (targetIsVirtual)
{ {
return copyToArchive(localFile, target, remoteFile, monitor, srcEncoding, hostEncoding, !isBinary); copyToArchive(localFile, target, remoteFile, monitor, srcEncoding, hostEncoding, !isBinary);
return;
} }
try try
@ -669,8 +675,8 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
if (isCancelled) if (isCancelled)
{ {
// throw new RemoteFileCancelledException(); throw new RemoteFileCancelledException();
return false; // return false;
} else if (destinationFile!=null) { } else if (destinationFile!=null) {
destinationFile.setLastModified(localFile.lastModified()); destinationFile.setLastModified(localFile.lastModified());
//TODO check if we want to preserve permissions //TODO check if we want to preserve permissions
@ -688,7 +694,6 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
{ {
} }
} }
return true;
} }
protected IHostFile[] internalFetch(String remoteParent, String fileFilter, int type, IProgressMonitor monitor) { protected IHostFile[] internalFetch(String remoteParent, String fileFilter, int type, IProgressMonitor monitor) {
@ -1043,7 +1048,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
return new LocalVirtualHostFile(child); return new LocalVirtualHostFile(child);
} }
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{ {
if (fileName.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR)) if (fileName.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR))
{ {
@ -1057,35 +1062,33 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
File fileToDelete = new File(remoteParent, fileName); File fileToDelete = new File(remoteParent, fileName);
if (ArchiveHandlerManager.isVirtual(fileToDelete.getAbsolutePath())) if (ArchiveHandlerManager.isVirtual(fileToDelete.getAbsolutePath()))
{ {
return deleteFromArchive(fileToDelete, monitor); deleteFromArchive(fileToDelete, monitor);
} }
else if (ArchiveHandlerManager.getInstance().isArchive(fileToDelete)) else if (ArchiveHandlerManager.getInstance().isArchive(fileToDelete))
{ {
return deleteArchive(fileToDelete); deleteArchive(fileToDelete);
} }
if (fileToDelete.isDirectory()) if (fileToDelete.isDirectory())
{ {
return deleteContents(fileToDelete, monitor); deleteContents(fileToDelete, monitor);
} }
else else
{ {
return fileToDelete.delete(); fileToDelete.delete();
} }
} }
public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean ok = true;
String deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_DELETING, ""); //$NON-NLS-1$ String deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_DELETING, ""); //$NON-NLS-1$
monitor.beginTask(deletingMessage, remoteParents.length); monitor.beginTask(deletingMessage, remoteParents.length);
for (int i = 0; i < remoteParents.length; i++) for (int i = 0; i < remoteParents.length; i++)
{ {
deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_DELETING, fileNames[i]); deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_DELETING, fileNames[i]);
monitor.subTask(deletingMessage); monitor.subTask(deletingMessage);
ok = ok && delete(remoteParents[i], fileNames[i], monitor); delete(remoteParents[i], fileNames[i], monitor);
monitor.worked(1); monitor.worked(1);
} }
return ok;
} }
private boolean deleteContents(File folder, IProgressMonitor monitor) private boolean deleteContents(File folder, IProgressMonitor monitor)
@ -1153,12 +1156,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
return file.delete(); return file.delete();
} }
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
{ {
File fileToRename = new File(remoteParent, oldName); File fileToRename = new File(remoteParent, oldName);
if (ArchiveHandlerManager.isVirtual(fileToRename.getAbsolutePath())) if (ArchiveHandlerManager.isVirtual(fileToRename.getAbsolutePath()))
{ {
return renameVirtualFile(fileToRename, newName, monitor); renameVirtualFile(fileToRename, newName, monitor);
return;
} }
File newFile = new File(remoteParent, newName); File newFile = new File(remoteParent, newName);
boolean result = fileToRename.renameTo(newFile); boolean result = fileToRename.renameTo(newFile);
@ -1171,15 +1175,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED, ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails)); IStatus.ERROR, msgTxt, msgDetails));
} }
return result;
} }
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException public void rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean retVal = rename(remoteParent, oldName, newName, monitor); rename(remoteParent, oldName, newName, monitor);
File newFile = new File(remoteParent, newName); File newFile = new File(remoteParent, newName);
oldFile.renameTo(newFile.getAbsolutePath()); oldFile.renameTo(newFile.getAbsolutePath());
return retVal;
} }
/** /**
@ -1228,11 +1230,10 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
return false; return false;
} }
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException public void move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
{ {
File sourceFolderOrFile = new File(srcParent, srcName); File sourceFolderOrFile = new File(srcParent, srcName);
File targetFolder = new File(tgtParent, tgtName); File targetFolder = new File(tgtParent, tgtName);
boolean movedOk = false;
boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(sourceFolderOrFile.getAbsolutePath()); boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(sourceFolderOrFile.getAbsolutePath());
boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(targetFolder.getAbsolutePath()); boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(targetFolder.getAbsolutePath());
boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(targetFolder); boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(targetFolder);
@ -1245,34 +1246,29 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
{ {
File fileToMove = new File(srcParent, srcName); File fileToMove = new File(srcParent, srcName);
File newFile = new File(tgtParent, tgtName); File newFile = new File(tgtParent, tgtName);
movedOk = fileToMove.renameTo(newFile); fileToMove.renameTo(newFile);
return;
} }
if (!movedOk) copy(srcParent, srcName, tgtParent, tgtName, monitor);
try
{ {
if (copy(srcParent, srcName, tgtParent, tgtName, monitor)) delete(srcParent, srcName, monitor);
{ }
try catch (SystemMessageException exc)
{ {
movedOk = delete(srcParent, srcName, monitor); if (monitor.isCanceled())
} {
catch (SystemMessageException exc) //This mean the copy operation is ok, but delete operation has been cancelled by user.
{ //The delete() call will take care of recovered from the cancel operation.
if (monitor.isCanceled()) //So we need to make sure to remove the already copied file/folder.
{ delete(tgtParent, tgtName, null);
//This mean the copy operation is ok, but delete operation has been cancelled by user. }
//The delete() call will take care of recovered from the cancel operation. throw exc;
//So we need to make sure to remove the already copied file/folder.
delete(tgtParent, tgtName, null);
}
throw exc;
}
}
} }
return movedOk;
} }
public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException public void copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
{ {
File srcFile = new File(srcParent, srcName); File srcFile = new File(srcParent, srcName);
File tgtFile = new File(tgtParent, tgtName); File tgtFile = new File(tgtParent, tgtName);
@ -1287,11 +1283,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(new File(tgtParent)); boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(new File(tgtParent));
if (sourceIsVirtual) if (sourceIsVirtual)
{ {
return copyFromArchive(srcFile, new File(tgtParent), tgtName, monitor, SystemEncodingUtil.ENCODING_UTF_8, SystemEncodingUtil.ENCODING_UTF_8, false); copyFromArchive(srcFile, new File(tgtParent), tgtName, monitor, SystemEncodingUtil.ENCODING_UTF_8, SystemEncodingUtil.ENCODING_UTF_8, false);
return;
} }
if (targetIsVirtual || targetIsArchive) if (targetIsVirtual || targetIsArchive)
{ {
return copyToArchive(srcFile, new File(tgtParent), tgtName, monitor, SystemEncodingUtil.ENCODING_UTF_8, SystemEncodingUtil.ENCODING_UTF_8, false); copyToArchive(srcFile, new File(tgtParent), tgtName, monitor, SystemEncodingUtil.ENCODING_UTF_8, SystemEncodingUtil.ENCODING_UTF_8, false);
return;
} }
// handle special characters in source and target strings // handle special characters in source and target strings
@ -1332,7 +1330,6 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
command = "cp -p " + src + " " + target; //$NON-NLS-1$ //$NON-NLS-2$ command = "cp -p " + src + " " + target; //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
int rc = -1;
try try
{ {
Process p = null; Process p = null;
@ -1354,7 +1351,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
} }
//Process p = Runtime.getRuntime().exec(command); //Process p = Runtime.getRuntime().exec(command);
rc = p.waitFor(); p.waitFor();
//rc = p.exitValue(); //rc = p.exitValue();
} }
@ -1362,7 +1359,6 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
{ {
throw new RemoteFileException(e.getMessage(), e); throw new RemoteFileException(e.getMessage(), e);
} }
return (rc == 0);
} }
/** /**
@ -1551,40 +1547,47 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
return !isWindows(); return !isWindows();
} }
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException public void copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean ok = true;
String deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_COPYING, ""); //$NON-NLS-1$ String deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_COPYING, ""); //$NON-NLS-1$
monitor.beginTask(deletingMessage, srcParents.length); monitor.beginTask(deletingMessage, srcParents.length);
for (int i = 0; i < srcParents.length; i++) for (int i = 0; i < srcParents.length; i++)
{ {
deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_COPYING, srcNames[i]); deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_COPYING, srcNames[i]);
monitor.subTask(deletingMessage); monitor.subTask(deletingMessage);
ok = ok && copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor); copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor);
monitor.worked(1); monitor.worked(1);
} }
return ok;
} }
public boolean setLastModified(String parent, String name, long timestamp, IProgressMonitor monitor) public void setLastModified(String parent, String name, long timestamp, IProgressMonitor monitor)
{ {
File file = new File(parent, name); File file = new File(parent, name);
return file.setLastModified(timestamp); file.setLastModified(timestamp);
} }
public boolean setReadOnly(String parent, String name, public void setReadOnly(String parent, String name,
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException boolean readOnly, IProgressMonitor monitor) throws SystemMessageException
{ {
File file = new File(parent, name); File file = new File(parent, name);
if (!file.exists()) { if (!file.exists()) {
return false; String pluginId = Activator.PLUGIN_ID;
String messageText = "File does not exist";
SimpleSystemMessage message = new SimpleSystemMessage(pluginId, IStatus.ERROR, messageText);
throw new SystemMessageException(message);
} }
if (readOnly != file.canWrite()) { if (readOnly != file.canWrite()) {
return true; return;
} }
if (readOnly) if (readOnly)
{ {
return file.setReadOnly(); if (!file.setReadOnly()) {
String pluginId = Activator.PLUGIN_ID;
String messageText = "Cannot set file read only";
SimpleSystemMessage message = new SimpleSystemMessage(pluginId, IStatus.ERROR, messageText);
throw new SystemMessageException(message);
}
return;
} }
else else
{ {
@ -1604,7 +1607,12 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
catch (Exception e) catch (Exception e)
{ {
} }
return (exitValue == 0); if (exitValue != 0) {
String pluginId = Activator.PLUGIN_ID;
String messageText = "Cannot set file read-write";
SimpleSystemMessage message = new SimpleSystemMessage(pluginId, IStatus.ERROR, messageText);
throw new SystemMessageException(message);
}
} }
// windows version // windows version
else else
@ -1622,7 +1630,12 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
catch (Exception e) catch (Exception e)
{ {
} }
return (exitValue == 0); if (exitValue != 0) {
String pluginId = Activator.PLUGIN_ID;
String messageText = "Cannot set file read-write";
SimpleSystemMessage message = new SimpleSystemMessage(pluginId, IStatus.ERROR, messageText);
throw new SystemMessageException(message);
}
} }
} }
} }
@ -1734,7 +1747,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
String group = newPermissions.getGroupOwner(); String group = newPermissions.getGroupOwner();
// set the permissions // set the permissions
String result = simpleShellCommand("chmod " + permissionsInOctal, file); //$NON-NLS-1$ simpleShellCommand("chmod " + permissionsInOctal, file); //$NON-NLS-1$
// set the user // set the user
simpleShellCommand("chown " + user, file); //$NON-NLS-1$ simpleShellCommand("chown " + user, file); //$NON-NLS-1$

View file

@ -638,7 +638,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
return "/"; //$NON-NLS-1$ return "/"; //$NON-NLS-1$
} }
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
String dst = remoteParent; String dst = remoteParent;
if( remoteFile!=null ) { if( remoteFile!=null ) {
@ -660,7 +660,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
channel.put(localFile.getAbsolutePath(), dst, sftpMonitor, mode); channel.put(localFile.getAbsolutePath(), dst, sftpMonitor, mode);
Activator.trace("SftpFileService.upload "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$ Activator.trace("SftpFileService.upload "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
return false; throw new RemoteFileCancelledException();
} else { } else {
SftpATTRS attr = channel.stat(dst); SftpATTRS attr = channel.stat(dst);
attr.setACMODTIME(attr.getATime(), (int)(localFile.lastModified()/1000)); attr.setACMODTIME(attr.getATime(), (int)(localFile.lastModified()/1000));
@ -685,7 +685,6 @@ public class SftpFileService extends AbstractFileService implements ISshService,
finally { finally {
if (channel!=null) channel.disconnect(); if (channel!=null) channel.disconnect();
} }
return true;
} }
public static class MyProgressMonitor implements SftpProgressMonitor public static class MyProgressMonitor implements SftpProgressMonitor
@ -740,7 +739,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
} }
} }
public boolean upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
//TODO hack for now //TODO hack for now
try try
@ -763,10 +762,9 @@ public class SftpFileService extends AbstractFileService implements ISshService,
throw makeSystemMessageException(e); throw makeSystemMessageException(e);
//return false; //return false;
} }
return true;
} }
public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException
{ {
ChannelSftp channel = null; ChannelSftp channel = null;
String remotePath = concat(remoteParent, remoteFile); String remotePath = concat(remoteParent, remoteFile);
@ -788,7 +786,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
channel.get(remotePathRecoded, localFile.getAbsolutePath(), sftpMonitor, mode); channel.get(remotePathRecoded, localFile.getAbsolutePath(), sftpMonitor, mode);
Activator.trace("SftpFileService.download "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$ Activator.trace("SftpFileService.download "+remoteFile+ " ok"); //$NON-NLS-1$ //$NON-NLS-2$
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
return false; throw new RemoteFileCancelledException();
} else { } else {
SftpATTRS attr = channel.stat(remotePathRecoded); SftpATTRS attr = channel.stat(remotePathRecoded);
localFile.setLastModified(1000L * attr.getMTime()); localFile.setLastModified(1000L * attr.getMTime());
@ -817,7 +815,6 @@ public class SftpFileService extends AbstractFileService implements ISshService,
channel.disconnect(); channel.disconnect();
} }
} }
return true;
} }
public IHostFile getUserHome() { public IHostFile getUserHome() {
@ -892,9 +889,8 @@ public class SftpFileService extends AbstractFileService implements ISshService,
return result; return result;
} }
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean ok=false;
String fullPath = concat(remoteParent, fileName); String fullPath = concat(remoteParent, fileName);
Activator.trace("SftpFileService.delete.waitForLock"); //$NON-NLS-1$ Activator.trace("SftpFileService.delete.waitForLock"); //$NON-NLS-1$
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) { if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
@ -914,25 +910,21 @@ public class SftpFileService extends AbstractFileService implements ISshService,
} }
if (attrs==null) { if (attrs==null) {
//doesn't exist, nothing to do //doesn't exist, nothing to do
ok=true;
} else if (attrs.isDir()) { } else if (attrs.isDir()) {
try { try {
getChannel("SftpFileService.delete.rmdir").rmdir(fullPathRecoded); //$NON-NLS-1$ getChannel("SftpFileService.delete.rmdir").rmdir(fullPathRecoded); //$NON-NLS-1$
ok=true;
} catch(SftpException e) { } catch(SftpException e) {
if(e.id==ChannelSftp.SSH_FX_FAILURE) { if(e.id==ChannelSftp.SSH_FX_FAILURE) {
//Bug 153649: Recursive directory delete //Bug 153649: Recursive directory delete
//throw new RemoteFolderNotEmptyException(); //throw new RemoteFolderNotEmptyException();
String fullPathQuoted = PathUtility.enQuoteUnix(fullPathRecoded); String fullPathQuoted = PathUtility.enQuoteUnix(fullPathRecoded);
int rv = runCommand("rm -rf "+fullPathQuoted, monitor); //$NON-NLS-1$ int rv = runCommand("rm -rf "+fullPathQuoted, monitor); //$NON-NLS-1$
ok = (rv==0);
} else { } else {
throw e; throw e;
} }
} }
} else { } else {
getChannel("SftpFileService.delete.rm").rm(fullPathRecoded); //$NON-NLS-1$ getChannel("SftpFileService.delete.rm").rm(fullPathRecoded); //$NON-NLS-1$
ok=true;
} }
Activator.trace("SftpFileService.delete ok"); //$NON-NLS-1$ Activator.trace("SftpFileService.delete ok"); //$NON-NLS-1$
} catch (Exception e) { } catch (Exception e) {
@ -942,18 +934,15 @@ public class SftpFileService extends AbstractFileService implements ISshService,
fDirChannelMutex.release(); fDirChannelMutex.release();
} }
} }
return ok;
} }
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean ok=false;
String fullPathOld = concat(remoteParent, oldName); String fullPathOld = concat(remoteParent, oldName);
String fullPathNew = concat(remoteParent, newName); String fullPathNew = concat(remoteParent, newName);
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) { if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
try { try {
getChannel("SftpFileService.rename").rename(recode(fullPathOld), recodeSafe(fullPathNew)); //$NON-NLS-1$ getChannel("SftpFileService.rename").rename(recode(fullPathOld), recodeSafe(fullPathNew)); //$NON-NLS-1$
ok=true;
Activator.trace("SftpFileService.rename ok"); //$NON-NLS-1$ Activator.trace("SftpFileService.rename ok"); //$NON-NLS-1$
} catch (Exception e) { } catch (Exception e) {
Activator.trace("SftpFileService.rename "+fullPathOld+" -> "+fullPathNew+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Activator.trace("SftpFileService.rename "+fullPathOld+" -> "+fullPathNew+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@ -962,12 +951,11 @@ public class SftpFileService extends AbstractFileService implements ISshService,
fDirChannelMutex.release(); fDirChannelMutex.release();
} }
} }
return ok;
} }
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException { public void rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException {
// TODO dont know how to update // TODO dont know how to update
return rename(remoteParent, oldName, newName, monitor); rename(remoteParent, oldName, newName, monitor);
} }
private boolean progressWorked(IProgressMonitor monitor, int work) { private boolean progressWorked(IProgressMonitor monitor, int work) {
@ -1035,7 +1023,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
return result; return result;
} }
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException public void move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
{ {
// move is not supported by sftp directly. Use the ssh shell instead. // move is not supported by sftp directly. Use the ssh shell instead.
// TODO check if newer versions of sftp support move directly // TODO check if newer versions of sftp support move directly
@ -1044,32 +1032,28 @@ public class SftpFileService extends AbstractFileService implements ISshService,
Activator.trace("SftpFileService.move "+srcName); //$NON-NLS-1$ Activator.trace("SftpFileService.move "+srcName); //$NON-NLS-1$
String fullPathOld = PathUtility.enQuoteUnix(recode(concat(srcParent, srcName))); String fullPathOld = PathUtility.enQuoteUnix(recode(concat(srcParent, srcName)));
String fullPathNew = PathUtility.enQuoteUnix(recodeSafe(concat(tgtParent, tgtName))); String fullPathNew = PathUtility.enQuoteUnix(recodeSafe(concat(tgtParent, tgtName)));
int rv = runCommand("mv "+fullPathOld+' '+fullPathNew, monitor); //$NON-NLS-1$ runCommand("mv "+fullPathOld+' '+fullPathNew, monitor); //$NON-NLS-1$
return (rv==0);
} }
public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException { public void copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException {
// copy is not supported by sftp directly. Use the ssh shell instead. // copy is not supported by sftp directly. Use the ssh shell instead.
// TODO check if newer versions of sftp support copy directly // TODO check if newer versions of sftp support copy directly
// TODO Interpret some error messages like "command not found" (use (x)copy instead of cp on windows) // TODO Interpret some error messages like "command not found" (use (x)copy instead of cp on windows)
Activator.trace("SftpFileService.copy "+srcName); //$NON-NLS-1$ Activator.trace("SftpFileService.copy "+srcName); //$NON-NLS-1$
String fullPathOld = PathUtility.enQuoteUnix(recode(concat(srcParent, srcName))); String fullPathOld = PathUtility.enQuoteUnix(recode(concat(srcParent, srcName)));
String fullPathNew = PathUtility.enQuoteUnix(recodeSafe(concat(tgtParent, tgtName))); String fullPathNew = PathUtility.enQuoteUnix(recodeSafe(concat(tgtParent, tgtName)));
int rv = runCommand("cp -Rp "+fullPathOld+' '+fullPathNew, monitor); //$NON-NLS-1$ runCommand("cp -Rp "+fullPathOld+' '+fullPathNew, monitor); //$NON-NLS-1$
return (rv==0);
} }
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException public void copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException
{ {
Activator.trace("SftpFileService.copyBatch "+srcNames); //$NON-NLS-1$ Activator.trace("SftpFileService.copyBatch "+srcNames); //$NON-NLS-1$
boolean ok = true;
for (int i = 0; i < srcParents.length; i++) for (int i = 0; i < srcParents.length; i++)
{ {
//TODO check what should happen if one file throws an Exception //TODO check what should happen if one file throws an Exception
//should the batch job continue? //should the batch job continue?
ok = ok && copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor); copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor);
} }
return ok;
} }
public void initService(IProgressMonitor monitor) { public void initService(IProgressMonitor monitor) {
@ -1095,15 +1079,13 @@ public class SftpFileService extends AbstractFileService implements ISshService,
return true; return true;
} }
public boolean setLastModified(String parent, String name, public void setLastModified(String parent, String name,
long timestamp, IProgressMonitor monitor) throws SystemMessageException long timestamp, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean ok=false;
String path = concat(parent, name); String path = concat(parent, name);
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) { if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
try { try {
getChannel("SftpFileService.setLastModified").setMtime(recode(path), (int)(timestamp/1000)); //$NON-NLS-1$ getChannel("SftpFileService.setLastModified").setMtime(recode(path), (int)(timestamp/1000)); //$NON-NLS-1$
ok=true;
Activator.trace("SftpFileService.setLastModified ok"); //$NON-NLS-1$ Activator.trace("SftpFileService.setLastModified ok"); //$NON-NLS-1$
} catch (Exception e) { } catch (Exception e) {
Activator.trace("SftpFileService.setLastModified "+path+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ Activator.trace("SftpFileService.setLastModified "+path+" failed: "+e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
@ -1112,12 +1094,10 @@ public class SftpFileService extends AbstractFileService implements ISshService,
fDirChannelMutex.release(); fDirChannelMutex.release();
} }
} }
return ok; }
}
public boolean setReadOnly(String parent, String name, public void setReadOnly(String parent, String name,
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException { boolean readOnly, IProgressMonitor monitor) throws SystemMessageException {
boolean ok=false;
String path = concat(parent, name); String path = concat(parent, name);
if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) { if (fDirChannelMutex.waitForLock(monitor, fDirChannelTimeout)) {
try { try {
@ -1135,7 +1115,6 @@ public class SftpFileService extends AbstractFileService implements ISshService,
getChannel("SftpFileService.setReadOnly").setStat(recode(path), attr); //$NON-NLS-1$ ok=true; getChannel("SftpFileService.setReadOnly").setStat(recode(path), attr); //$NON-NLS-1$ ok=true;
Activator.trace("SftpFileService.setReadOnly ok"); //$NON-NLS-1$ Activator.trace("SftpFileService.setReadOnly ok"); //$NON-NLS-1$
} else { } else {
ok=true;
Activator.trace("SftpFileService.setReadOnly nothing-to-do"); //$NON-NLS-1$ Activator.trace("SftpFileService.setReadOnly nothing-to-do"); //$NON-NLS-1$
} }
} catch (Exception e) { } catch (Exception e) {
@ -1145,7 +1124,6 @@ public class SftpFileService extends AbstractFileService implements ISshService,
fDirChannelMutex.release(); fDirChannelMutex.release();
} }
} }
return ok;
} }
/** /**

View file

@ -64,38 +64,34 @@ public abstract class AbstractFileService extends AbstractService implements IFi
return internalFetch(remoteParent, fileFilter, fileType, monitor); return internalFetch(remoteParent, fileFilter, fileType, monitor);
} }
public IHostFile[] listMultiple(String[] remoteParents, public void listMultiple(String[] remoteParents,
String[] fileFilters, int fileTypes[], IProgressMonitor monitor) String[] fileFilters, int fileTypes[], List hostFiles, IProgressMonitor monitor)
throws SystemMessageException { throws SystemMessageException {
List files = new ArrayList();
for (int i = 0; i < remoteParents.length; i++) for (int i = 0; i < remoteParents.length; i++)
{ {
IHostFile[] result = list(remoteParents[i], fileFilters[i], fileTypes[i], monitor); IHostFile[] result = list(remoteParents[i], fileFilters[i], fileTypes[i], monitor);
for (int j = 0; j < result.length; j++) for (int j = 0; j < result.length; j++)
{ {
files.add(result[j]); hostFiles.add(result[j]);
} }
} }
return (IHostFile[])files.toArray(new IHostFile[files.size()]);
} }
public IHostFile[] listMultiple(String[] remoteParents, public void listMultiple(String[] remoteParents,
String[] fileFilters, int fileType, IProgressMonitor monitor) String[] fileFilters, int fileType, List hostFiles, IProgressMonitor monitor)
throws SystemMessageException { throws SystemMessageException {
List files = new ArrayList();
for (int i = 0; i < remoteParents.length; i++) for (int i = 0; i < remoteParents.length; i++)
{ {
IHostFile[] result = list(remoteParents[i], fileFilters[i], fileType, monitor); IHostFile[] result = list(remoteParents[i], fileFilters[i], fileType, monitor);
for (int j = 0; j < result.length; j++) for (int j = 0; j < result.length; j++)
{ {
files.add(result[j]); hostFiles.add(result[j]);
} }
} }
return (IHostFile[])files.toArray(new IHostFile[files.size()]);
} }
protected boolean isRightType(int fileType, IHostFile node) protected boolean isRightType(int fileType, IHostFile node)
@ -128,46 +124,42 @@ public abstract class AbstractFileService extends AbstractService implements IFi
} }
public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException
{ {
boolean ok = true;
for (int i = 0; i < remoteParents.length; i++) for (int i = 0; i < remoteParents.length; i++)
{ {
ok = ok && delete(remoteParents[i], fileNames[i], monitor); delete(remoteParents[i], fileNames[i], monitor);
} }
return ok;
} }
/** /**
* Default implementation - just iterate through each file * Default implementation - just iterate through each file
*/ */
public boolean downloadMultiple(String[] remoteParents, String[] remoteFiles, public void downloadMultiple(String[] remoteParents, String[] remoteFiles,
File[] localFiles, boolean[] isBinaries, String[] hostEncodings, File[] localFiles, boolean[] isBinaries, String[] hostEncodings,
IProgressMonitor monitor) throws SystemMessageException IProgressMonitor monitor) throws SystemMessageException
{ {
boolean result = true; for (int i = 0; i < remoteParents.length; i++)
for (int i = 0; i < remoteParents.length && result == true; i++)
{ {
String remoteParent = remoteParents[i]; String remoteParent = remoteParents[i];
String remoteFile = remoteFiles[i]; String remoteFile = remoteFiles[i];
File localFile = localFiles[i]; File localFile = localFiles[i];
boolean isBinary = isBinaries[i]; boolean isBinary = isBinaries[i];
String hostEncoding = hostEncodings[i]; String hostEncoding = hostEncodings[i];
result = download(remoteParent, remoteFile, localFile, isBinary, hostEncoding, monitor); download(remoteParent, remoteFile, localFile, isBinary, hostEncoding, monitor);
} }
return result;
} }
/** /**
* Default implementation - just iterate through each file * Default implementation - just iterate through each file
*/ */
public boolean uploadMultiple(File[] localFiles, String[] remoteParents, public void uploadMultiple(File[] localFiles, String[] remoteParents,
String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings, String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings,
String[] hostEncodings, IProgressMonitor monitor) String[] hostEncodings, IProgressMonitor monitor)
throws SystemMessageException throws SystemMessageException
{ {
boolean result = true; boolean result = true;
for (int i = 0; i < localFiles.length && result == true; i++) for (int i = 0; i < localFiles.length; i++)
{ {
File localFile = localFiles[i]; File localFile = localFiles[i];
String remoteParent = remoteParents[i]; String remoteParent = remoteParents[i];
@ -176,9 +168,8 @@ public abstract class AbstractFileService extends AbstractService implements IFi
boolean isBinary = isBinaries[i]; boolean isBinary = isBinaries[i];
String srcEncoding = srcEncodings[i]; String srcEncoding = srcEncodings[i];
String hostEncoding = hostEncodings[i]; String hostEncoding = hostEncodings[i];
result = upload(localFile, remoteParent, remoteFile, isBinary, srcEncoding, hostEncoding, monitor); upload(localFile, remoteParent, remoteFile, isBinary, srcEncoding, hostEncoding, monitor);
} }
return result;
} }
/** /**

View file

@ -31,6 +31,7 @@ package org.eclipse.rse.services.files;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -69,8 +70,8 @@ public interface IFileService extends IService
* return from the query. * return from the query.
* *
* @see IFileService#list(String,String,int,IProgressMonitor) * @see IFileService#list(String,String,int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int,IProgressMonitor) * @see IFileService#listMultiple(String[],String[],int,List,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int[],IProgressMonitor) * @see IFileService#listMultiple(String[],String[],int[],List,IProgressMonitor)
* *
* @since org.eclipse.rse.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
@ -86,8 +87,8 @@ public interface IFileService extends IService
* return from the query. * return from the query.
* *
* @see IFileService#list(String,String,int,IProgressMonitor) * @see IFileService#list(String,String,int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int,IProgressMonitor) * @see IFileService#listMultiple(String[],String[],int,List,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int[],IProgressMonitor) * @see IFileService#listMultiple(String[],String[],int[],List,IProgressMonitor)
* *
* @since org.eclipse.rse.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
@ -105,8 +106,8 @@ public interface IFileService extends IService
* return from the query. * return from the query.
* *
* @see IFileService#list(String,String,int,IProgressMonitor) * @see IFileService#list(String,String,int,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int,IProgressMonitor) * @see IFileService#listMultiple(String[],String[],int,List,IProgressMonitor)
* @see IFileService#listMultiple(String[],String[],int[],IProgressMonitor) * @see IFileService#listMultiple(String[],String[],int[],List,IProgressMonitor)
* *
* @since org.eclipse.rse.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
@ -151,11 +152,10 @@ public interface IFileService extends IService
* @param isBinary - indicates whether the file is text or binary * @param isBinary - indicates whether the file is text or binary
* @param hostEncoding - the tgt encoding of the file (if text) * @param hostEncoding - the tgt encoding of the file (if text)
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return true if the file was uploaded
* @throws SystemMessageException if an error occurs. * @throws SystemMessageException if an error occurs.
* Typically this would be one of those in the RemoteFileException family. * Typically this would be one of those in the RemoteFileException family.
*/ */
public boolean upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; public void upload(InputStream stream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Copy a file to the remote file system. The remote target is denoted by a * Copy a file to the remote file system. The remote target is denoted by a
@ -167,12 +167,11 @@ public interface IFileService extends IService
* @param srcEncoding - the src encoding of the file (if text) * @param srcEncoding - the src encoding of the file (if text)
* @param hostEncoding - the tgt encoding of the file (if text) * @param hostEncoding - the tgt encoding of the file (if text)
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return true if the file was uploaded
* @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.
*/ */
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; public void upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException;
/** /**
@ -189,14 +188,13 @@ public interface IFileService extends IService
* @param srcEncodings - the src encodings of the files (if text) * @param srcEncodings - the src encodings of the files (if text)
* @param hostEncodings - the tgt encodings of the files (if text) * @param hostEncodings - the tgt encodings of the files (if text)
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return true if the files were uploaded
* @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.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
public boolean uploadMultiple(File[] localFiles, String[] remoteParents, String[] remoteFiles, boolean[] isBinary, String[] srcEncodings, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException; public void uploadMultiple(File[] localFiles, String[] remoteParents, String[] remoteFiles, boolean[] isBinary, String[] srcEncodings, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException;
/** /**
@ -208,12 +206,11 @@ public interface IFileService extends IService
* @param isBinary - indicates whether the file is text on binary * @param isBinary - indicates whether the file is text on binary
* @param hostEncoding - the encoding on the host (if text) * @param hostEncoding - the encoding on the host (if text)
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return true if the file was copied from the remote system.
* @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.
*/ */
public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Copy files from the remote file system to the local system. * Copy files from the remote file system to the local system.
@ -230,13 +227,12 @@ public interface IFileService extends IService
* @param isBinary - indicates whether the files are text on binary * @param isBinary - indicates whether the files are text on binary
* @param hostEncodings - the encodings on the host (if text) * @param hostEncodings - the encodings on the host (if text)
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return true if the files were copied from the remote system.
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the {@link RemoteFileException} family. * be one of those in the {@link RemoteFileException} family.
* *
* @since org.eclipse.rse.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
public boolean downloadMultiple(String[] remoteParents, String[] remoteFiles, File[] localFiles, boolean[] isBinary, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException; public void downloadMultiple(String[] remoteParents, String[] remoteFiles, File[] localFiles, boolean[] isBinary, String[] hostEncodings, IProgressMonitor monitor) throws SystemMessageException;
@ -317,15 +313,14 @@ public interface IFileService extends IService
* some other type. For each remoteParent, there must be a * some other type. For each remoteParent, there must be a
* corresponding fileType. For the default list of available file * corresponding fileType. For the default list of available file
* types see <code>IFileServiceContants</code> * types see <code>IFileServiceContants</code>
* @param hostFiles a list to which the found {@link IHostFile} objects will be appended
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return the collective list of host files that reside in each of the
* remoteParents with it's corresponding filter.
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
* *
* @since org.eclipse.rse.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException; public void listMultiple(String[] remoteParents, String[] fileFilters, int[] fileTypes, List hostFiles, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* List the contents of multiple remote folders. * List the contents of multiple remote folders.
@ -345,15 +340,14 @@ public interface IFileService extends IService
* other type. All results will be of the specified type. For the * other type. All results will be of the specified type. For the
* default list of available file types see * default list of available file types see
* <code>IFileServiceContants</code> * <code>IFileServiceContants</code>
* @param hostFiles a list to which the found {@link IHostFile} objects will be appended
* @param monitor the monitor for this potentially long running operation * @param monitor the monitor for this potentially long running operation
* @return the collective list of host files that reside in each of the
* remoteParents with it's corresponding filter.
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
* *
* @since org.eclipse.rse.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
public IHostFile[] listMultiple(String[] remoteParents, String[] fileFilters, int fileType, IProgressMonitor monitor) throws SystemMessageException; public void listMultiple(String[] remoteParents, String[] fileFilters, int fileType, List hostFiles, IProgressMonitor monitor) throws SystemMessageException;
/** /**
@ -413,11 +407,10 @@ public interface IFileService extends IService
* @param remoteParent the folder containing the file to delete * @param remoteParent the folder containing the file to delete
* @param fileName the name of the file or folder to delete * @param fileName the name of the file or folder to delete
* @param monitor the progress monitor * @param monitor the progress monitor
* @return true if successful
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
*/ */
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException; public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Delete a set of files or folders on the host. Should throw an exception * Delete a set of files or folders on the host. Should throw an exception
@ -433,12 +426,10 @@ public interface IFileService extends IService
* @param remoteParents the array of folders containing the files to delete * @param remoteParents the array of folders containing the files to delete
* @param fileNames the names of the files or folders to delete * @param fileNames the names of the files or folders to delete
* @param monitor the progress monitor * @param monitor the progress monitor
* @return <code>true</code> if all delete operations are successful,
* <code>false</code> otherwise.
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
*/ */
public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException; public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Rename a file or folder on the host. * Rename a file or folder on the host.
@ -447,11 +438,10 @@ public interface IFileService extends IService
* @param oldName the old name of the file or folder to rename * @param oldName the old name of the file or folder to rename
* @param newName the new name for the file * @param newName the new name for the file
* @param monitor the progress monitor * @param monitor the progress monitor
* @return true if successful
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
*/ */
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException; public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Rename a file or folder on the host. * Rename a file or folder on the host.
@ -461,11 +451,10 @@ public interface IFileService extends IService
* @param newName the new name for the file * @param newName the new name for the file
* @param oldFile the file to update with the change * @param oldFile the file to update with the change
* @param monitor the progress monitor * @param monitor the progress monitor
* @return true if successful
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
*/ */
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException; public void rename(String remoteParent, String oldName, String newName, IHostFile oldFile, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Move the file or folder specified to a different remote path. * Move the file or folder specified to a different remote path.
@ -475,11 +464,10 @@ public interface IFileService extends IService
* @param tgtParent the destination folder for the move * @param tgtParent the destination folder for the move
* @param tgtName the name of the moved file or folder * @param tgtName the name of the moved file or folder
* @param monitor the progress monitor * @param monitor the progress monitor
* @return true if the file was moved
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
*/ */
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException; public void move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Copy the file or folder to the specified destination. * Copy the file or folder to the specified destination.
@ -489,11 +477,10 @@ public interface IFileService extends IService
* @param tgtParent the destination folder for the copy * @param tgtParent the destination folder for the copy
* @param tgtName the name of the copied file or folder * @param tgtName the name of the copied file or folder
* @param monitor the progress monitor * @param monitor the progress monitor
* @return true if the file was copied successfully
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
*/ */
public boolean copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException; public void copy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Copy a set of files or folders to the specified destination. * Copy a set of files or folders to the specified destination.
@ -506,12 +493,10 @@ public interface IFileService extends IService
* @param srcNames the names of the files or folders to copy * @param srcNames the names of the files or folders to copy
* @param tgtParent the destination folder for the copy * @param tgtParent the destination folder for the copy
* @param monitor the progress monitor * @param monitor the progress monitor
* @return <code>true</code> if all files were copied, <code>false</code>
* or exception otherwise.
* @throws SystemMessageException if an error occurs. Typically this would * @throws SystemMessageException if an error occurs. Typically this would
* be one of those in the RemoteFileException family. * be one of those in the RemoteFileException family.
*/ */
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException; public void copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Indicates whether the file system is case sensitive. * Indicates whether the file system is case sensitive.
@ -536,11 +521,9 @@ public interface IFileService extends IService
* @param timestamp the new timestamp in milliseconds from January 1, 1970, * @param timestamp the new timestamp in milliseconds from January 1, 1970,
* 00:00:00 UTC. * 00:00:00 UTC.
* @param monitor the progress monitor * @param monitor the progress monitor
* @return true if the file timestamp was changed successfully
*
* @see IHostFile#getModifiedDate() * @see IHostFile#getModifiedDate()
*/ */
public boolean setLastModified(String parent, String name, long timestamp, IProgressMonitor monitor) throws SystemMessageException; public void setLastModified(String parent, String name, long timestamp, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Set the read-only permission of the specified file or folder. * Set the read-only permission of the specified file or folder.
@ -550,10 +533,8 @@ public interface IFileService extends IService
* @param readOnly indicates whether to make the file read-only or * @param readOnly indicates whether to make the file read-only or
* read-write * read-write
* @param monitor the progress monitor * @param monitor the progress monitor
* @return true if the read-only permission was changed successfully, or the
* permission already was as desired
*/ */
public boolean setReadOnly(String parent, String name, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException; public void setReadOnly(String parent, String name, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Gets the remote encoding. * Gets the remote encoding.

View file

@ -407,7 +407,10 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
parentPaths[i] = parents[i].getAbsolutePath(); parentPaths[i] = parents[i].getAbsolutePath();
} }
IHostFile[] results = getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, monitor); List hostFiles = new ArrayList(10);
getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, hostFiles, monitor);
IHostFile[] results = new IHostFile[hostFiles.size()];
hostFiles.toArray(results);
RemoteFileContext context = getDefaultContext(); RemoteFileContext context = getDefaultContext();
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
@ -457,7 +460,10 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
parentPaths[i] = parents[i].getAbsolutePath(); parentPaths[i] = parents[i].getAbsolutePath();
} }
IHostFile[] results = getFileService().listMultiple(parentPaths, fileNameFilters, fileType, monitor); List hostFiles = new ArrayList(10);
getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor);
IHostFile[] results = new IHostFile[hostFiles.size()];
hostFiles.toArray(results);
RemoteFileContext context = getDefaultContext(); RemoteFileContext context = getDefaultContext();
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
@ -789,7 +795,8 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException
{ {
IFileService service = getFileService(); IFileService service = getFileService();
return 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 boolean copyBatch(IRemoteFile[] sourceFolderOrFiles, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException
@ -803,7 +810,8 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
sourceParents[i] = sourceFolderOrFiles[i].getParentPath(); sourceParents[i] = sourceFolderOrFiles[i].getParentPath();
sourceNames[i] = sourceFolderOrFiles[i].getName(); sourceNames[i] = sourceFolderOrFiles[i].getName();
} }
return 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)
@ -846,9 +854,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
IFileService service = getFileService(); IFileService service = getFileService();
String parent = folderOrFile.getParentPath(); String parent = folderOrFile.getParentPath();
String name = folderOrFile.getName(); String name = folderOrFile.getName();
boolean result = service.delete(parent, name, monitor); service.delete(parent, name, monitor);
folderOrFile.markStale(true); folderOrFile.markStale(true);
return result; return true;
} }
public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException
@ -865,7 +873,8 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
removeCachedRemoteFile(folderOrFiles[i]); removeCachedRemoteFile(folderOrFiles[i]);
} }
IFileService service = getFileService(); IFileService service = getFileService();
return service.deleteBatch(parents, names, monitor); service.deleteBatch(parents, names, monitor);
return true;
} }
public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException
@ -875,9 +884,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
String srcParent = folderOrFile.getParentPath(); String srcParent = folderOrFile.getParentPath();
String oldName = folderOrFile.getName(); String oldName = folderOrFile.getName();
String newPath = srcParent + folderOrFile.getSeparator() + newName; String newPath = srcParent + folderOrFile.getSeparator() + newName;
boolean result = service.rename(srcParent, oldName, newName, monitor); service.rename(srcParent, oldName, newName, monitor);
folderOrFile.getHostFile().renameTo(newPath); folderOrFile.getHostFile().renameTo(newPath);
return result; return true;
} }
public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException
@ -887,24 +896,26 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
String srcName = sourceFolderOrFile.getName(); String srcName = sourceFolderOrFile.getName();
String tgtParent = targetFolder.getAbsolutePath(); String tgtParent = targetFolder.getAbsolutePath();
removeCachedRemoteFile(sourceFolderOrFile); removeCachedRemoteFile(sourceFolderOrFile);
boolean result = service.move(srcParent, srcName, tgtParent, newName, monitor); service.move(srcParent, srcName, tgtParent, newName, monitor);
sourceFolderOrFile.markStale(true); sourceFolderOrFile.markStale(true);
targetFolder.markStale(true); targetFolder.markStale(true);
return result; return true;
} }
public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException public boolean 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();
return _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 boolean 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();
return _hostFileService.setReadOnly(parent, name, readOnly, monitor); _hostFileService.setReadOnly(parent, name, readOnly, monitor);
return true;
} }
public ILanguageUtilityFactory getLanguageUtilityFactory() public ILanguageUtilityFactory getLanguageUtilityFactory()