Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-06-02 07:57:05 +0000
committerUwe Stieber2012-06-02 07:58:02 +0000
commitf5b16c432e34664f2a39e685d2bd3e519cf17904 (patch)
tree55442ca3f8d460ac5db5534d1baaf83da4e7cb99 /target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf
parent270fe1988ce84e3decffc9de277924fba01dc6d4 (diff)
downloadorg.eclipse.tcf-f5b16c432e34664f2a39e685d2bd3e519cf17904.tar.gz
org.eclipse.tcf-f5b16c432e34664f2a39e685d2bd3e519cf17904.tar.xz
org.eclipse.tcf-f5b16c432e34664f2a39e685d2bd3e519cf17904.zip
Target Explorer: Fix FindBugs warnings
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties19
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java25
3 files changed, 56 insertions, 43 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
index de0b2fedd..289c18bd7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.nls;
-import java.lang.reflect.Field;
-
import org.eclipse.osgi.util.NLS;
/**
@@ -30,49 +28,15 @@ public class Messages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
- /**
- * Returns if or if not this NLS manager contains a constant for
- * the given externalized strings key.
- *
- * @param key The externalized strings key or <code>null</code>.
- * @return <code>True</code> if a constant for the given key exists, <code>false</code> otherwise.
- */
- public static boolean hasString(String key) {
- if (key != null) {
- try {
- Field field = Messages.class.getDeclaredField(key);
- return field != null;
- } catch (NoSuchFieldException e) { /* ignored on purpose */ }
- }
-
- return false;
- }
+ // **** Declare externalized string id's down here *****
- /**
- * Returns the corresponding string for the given externalized strings
- * key or <code>null</code> if the key does not exist.
- *
- * @param key The externalized strings key or <code>null</code>.
- * @return The corresponding string or <code>null</code>.
- */
- public static String getString(String key) {
- if (key != null) {
- try {
- Field field = Messages.class.getDeclaredField(key);
- if (field != null) {
- return (String)field.get(null);
- }
- } catch (Exception e) { /* ignored on purpose */ }
- }
-
- return null;
- }
public static String FSTreeNodeContentProvider_rootNode_label;
public static String FSTreeNode_TypeFile;
public static String FSTreeNode_TypeFileFolder;
public static String FSTreeNode_TypeLocalDisk;
public static String FSTreeNode_TypeSystemFile;
public static String FSTreeNode_TypeUnknownFile;
+
public static String Operation_DeletingFileFailed;
public static String Operation_NotResponding;
public static String Operation_OpeningChannelFailureMessage;
@@ -81,40 +45,55 @@ public class Messages extends NLS {
public static String Operation_CopyNOfFile;
public static String Operation_CopyOfFile;
public static String Operation_CannotCreateDirectory;
+
public static String OpCopy_Copying;
public static String OpCopy_CannotCopyFile;
public static String OpCopy_CopyingFile;
+
public static String OpCreate_TaskName;
+
public static String TcfURLConnection_NoFileHandleReturned;
public static String TcfURLConnection_NoPeerFound;
public static String TcfURLConnection_NoSuchTcfAgent;
+
public static String OpDelete_Deleting;
public static String OpDelete_PrepareToDelete;
public static String OpDelete_RemovingFileFolder;
+
public static String OpDownload_Downloading;
public static String OpDownload_DownloadingMultipleFiles;
public static String OpDownload_DownloadingSingleFile;
+
public static String OpMove_Moving;
public static String OpMove_FileExistsError;
public static String OpMove_FolderExistsError;
public static String OpMove_CannotMove;
public static String OpMove_MovingFile;
+
public static String OpOutStreamOp_DownloadingProgress;
+
public static String OpRefresh_RefreshJobTitle;
+
public static String OpRename_CannotRename;
public static String OpRename_TitleRename;
+
public static String OpStreamOp_SetReadOnlyFailed;
public static String OpStreamOp_Bytes;
public static String OpStreamOp_KBs;
public static String OpStreamOp_MBs;
+
public static String OpUpload_UploadingProgress;
public static String OpUpload_UploadNFiles;
public static String OpUpload_UploadSingleFile;
+
public static String TcfInputStream_NoDataAvailable;
public static String TcfInputStream_StreamClosed;
public static String TcfOutputStream_StreamClosed;
public static String TcfURLStreamHandlerService_ErrorURLFormat;
public static String TcfURLStreamHandlerService_IllegalCharacter;
public static String TcfURLStreamHandlerService_OnlyDiskPartError;
+
public static String CacheManager_MkdirFailed;
+
+ public static String FileTransferService_error_mkdirFailed;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
index e933f0503..25be5c120 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
@@ -7,12 +7,14 @@
# Contributors:
# Wind River Systems - initial API and implementation
###############################################################################
+
FSTreeNodeContentProvider_rootNode_label=File System
FSTreeNode_TypeFile=File
FSTreeNode_TypeFileFolder=File Folder
FSTreeNode_TypeLocalDisk=Local Disk
FSTreeNode_TypeSystemFile=System file
FSTreeNode_TypeUnknownFile=Unknown File
+
Operation_DeletingFileFailed=Deleting {0} failed\!
Operation_NotResponding=The TCF agent on the target {0} is probably down. It is not responding.
Operation_OpeningChannelFailureMessage=We cannot open a TCF channel to the target: {0}. It is caused by {1}.
@@ -21,39 +23,56 @@ Operation_CannotOpenDir=Cannot open directory {0} because {1}
Operation_CopyNOfFile=Copy ({0}) of {1}
Operation_CopyOfFile=Copy of {0}
Operation_CannotCreateDirectory=Cannot create the directory {0} because: {1}
+
OpCopy_Copying=Copying {0} ...
OpCopy_CannotCopyFile=Cannot copy file {0} because: {1}
OpCopy_CopyingFile=Copying files
+
OpCreate_TaskName=Creating {0}...
+
TcfURLConnection_NoFileHandleReturned=No file handle returned\!
TcfURLConnection_NoPeerFound=Could not find the specified target with the ID {0}
TcfURLConnection_NoSuchTcfAgent=TCF agent is already disconnected\!
+
OpDelete_Deleting=Deleting files
OpDelete_PrepareToDelete=Prepare to delete files ...
OpDelete_RemovingFileFolder=Removing {0} ...
+
OpDownload_Downloading=Downloading file {0}:{1}/{2}
OpDownload_DownloadingMultipleFiles=Downloading {0} files...
OpDownload_DownloadingSingleFile=Downloading file {0}...
+
OpMove_Moving=Moving {0} ...
OpMove_FileExistsError=Cannot replace {0}: There is already a file with the same name as the folder you are moving.
OpMove_FolderExistsError=Cannot replace {0}: There is already a folder with the same name as the file you are moving.
OpMove_CannotMove=Cannot move {0} because {1}
OpMove_MovingFile=Moving files
+
OpOutStreamOp_DownloadingProgress=Downloading {0}/{1}.
+
OpRefresh_RefreshJobTitle=Refresh {0}
+
OpRename_CannotRename=Cannot rename {0} because {1}
OpRename_TitleRename=Rename
+
OpStreamOp_SetReadOnlyFailed=Setting the read-only attribute of {0} failed\!
OpStreamOp_Bytes=\ bytes
OpStreamOp_KBs=\ KBs
OpStreamOp_MBs=\ MBs
+
OpUpload_UploadingProgress=Uploading file {0}: {1}/{2}
OpUpload_UploadNFiles=Uploading {0} files...
OpUpload_UploadSingleFile=Uploading file {0}...
+
TcfInputStream_NoDataAvailable=No data available
TcfInputStream_StreamClosed=Stream is already closed\!
+
TcfOutputStream_StreamClosed=Stream is already closed\!
+
TcfURLStreamHandlerService_ErrorURLFormat=Error TCF URL format\!
TcfURLStreamHandlerService_IllegalCharacter=A Windows path does not permit character {0}.
TcfURLStreamHandlerService_OnlyDiskPartError=A Windows path should not contain only disk part.
+
CacheManager_MkdirFailed=Making directory {0} failed
+
+FileTransferService_error_mkdirFailed=Failed to create directory structure to {0}.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
index 5cfc58373..cb66b7e33 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.protocol.IChannel;
@@ -136,7 +137,15 @@ public class FileTransferService {
final FileSystemException[] error = new FileSystemException[1];
final IFileSystem.FileAttrs[] attrs = new IFileSystem.FileAttrs[1];
- item.getHostPath().removeLastSegments(1).toFile().mkdirs();
+ // Create necessary parent directory structure on host side
+ boolean rc = hostPath.removeLastSegments(1).toFile().mkdirs();
+ if (!rc) {
+ IOException e = new IOException(NLS.bind(Messages.FileTransferService_error_mkdirFailed, hostPath.removeLastSegments(1).toOSString()));
+ result = StatusHelper.getStatus(e);
+ if (callback != null) callback.done(peer, result);
+ return;
+ }
+
// If the host file is a directory, append the remote file name
if (hostPath.toFile().isDirectory()) {
hostPath = item.getHostPath().append(targetPath.lastSegment());
@@ -210,18 +219,24 @@ public class FileTransferService {
if (result.isOK()) {
if (mtime >= 0) {
- hostPath.toFile().setLastModified(mtime);
+ rc = hostPath.toFile().setLastModified(mtime);
+ if (!rc && Platform.inDebugMode()) {
+ System.err.println("Failed to set mtime for " + hostPath.toOSString()); //$NON-NLS-1$
+ }
}
}
else if (result.getSeverity() == IStatus.ERROR || result.getSeverity() == IStatus.CANCEL) {
try {
- hostPath.toFile().delete();
+ rc = hostPath.toFile().delete();
+ if (!rc && Platform.inDebugMode()) {
+ System.err.println("Failed to delete host file " + hostPath.toOSString()); //$NON-NLS-1$
+ }
}
catch (Throwable e) {
}
}
}
- callback.done(peer, result);
+ if (callback != null) callback.done(peer, result);
}
protected static void transferToTarget(IPeer peer, IFileSystem fileSystem, IFileTransferItem item, IProgressMonitor monitor, ICallback callback) {
@@ -321,7 +336,7 @@ public class FileTransferService {
fileSystem.remove(targetPath.toString(), null);
}
}
- callback.done(peer, result);
+ if (callback != null) callback.done(peer, result);
}
private static void copy(InputStream in, OutputStream out, long bytesTotal, IProgressMonitor monitor) throws IOException {

Back to the top