Lines 41-47
Link Here
|
41 |
* David McKnight (IBM) - [220379] [api] Provide a means for contributing custom BIDI encodings |
41 |
* David McKnight (IBM) - [220379] [api] Provide a means for contributing custom BIDI encodings |
42 |
* David McKnight (IBM) - [225573] [dstore] client not falling back to single operation when missing batch descriptors (due to old server) |
42 |
* David McKnight (IBM) - [225573] [dstore] client not falling back to single operation when missing batch descriptors (due to old server) |
43 |
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable |
43 |
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable |
44 |
* David McKnight (IBM) - [227406][api][dstore] need apis for getting buffer size in IDataStoreProvider |
44 |
* David McKnight (IBM) - [227406][api][dstore] need apis for getting buffer size in IDataStoreProvider |
|
|
45 |
* David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding |
46 |
* David McKnight (IBM) - [221211] [api][breaking][files] need batch operations to indicate which operations were successful |
45 |
*******************************************************************************/ |
47 |
*******************************************************************************/ |
46 |
|
48 |
|
47 |
package org.eclipse.rse.internal.services.dstore.files; |
49 |
package org.eclipse.rse.internal.services.dstore.files; |
Lines 80-85
Link Here
|
80 |
import org.eclipse.rse.services.clientserver.ISystemFileTypes; |
82 |
import org.eclipse.rse.services.clientserver.ISystemFileTypes; |
81 |
import org.eclipse.rse.services.clientserver.NamePatternMatcher; |
83 |
import org.eclipse.rse.services.clientserver.NamePatternMatcher; |
82 |
import org.eclipse.rse.services.clientserver.PathUtility; |
84 |
import org.eclipse.rse.services.clientserver.PathUtility; |
|
|
85 |
import org.eclipse.rse.services.clientserver.SystemEncodingUtil; |
83 |
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; |
86 |
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; |
84 |
import org.eclipse.rse.services.clientserver.messages.CommonMessages; |
87 |
import org.eclipse.rse.services.clientserver.messages.CommonMessages; |
85 |
import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds; |
88 |
import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds; |
Lines 98-103
Link Here
|
98 |
import org.eclipse.rse.services.files.IHostFilePermissions; |
101 |
import org.eclipse.rse.services.files.IHostFilePermissions; |
99 |
import org.eclipse.rse.services.files.IHostFilePermissionsContainer; |
102 |
import org.eclipse.rse.services.files.IHostFilePermissionsContainer; |
100 |
import org.eclipse.rse.services.files.PendingHostFilePermissions; |
103 |
import org.eclipse.rse.services.files.PendingHostFilePermissions; |
|
|
104 |
import org.eclipse.rse.services.files.RemoteFileCancelledException; |
105 |
import org.eclipse.rse.services.files.RemoteFileIOException; |
101 |
import org.eclipse.rse.services.files.RemoteFileSecurityException; |
106 |
import org.eclipse.rse.services.files.RemoteFileSecurityException; |
102 |
|
107 |
|
103 |
public class DStoreFileService extends AbstractDStoreService implements IFileService, IFilePermissionsService |
108 |
public class DStoreFileService extends AbstractDStoreService implements IFileService, IFilePermissionsService |
Lines 268-274
Link Here
|
268 |
|
273 |
|
269 |
|
274 |
|
270 |
public boolean upload(InputStream inputStream, String remoteParent, String remoteFile, boolean isBinary, |
275 |
public boolean upload(InputStream inputStream, String remoteParent, String remoteFile, boolean isBinary, |
271 |
String hostEncoding, IProgressMonitor monitor) |
276 |
String hostEncoding, IProgressMonitor monitor) throws SystemMessageException |
272 |
{ |
277 |
{ |
273 |
BufferedInputStream bufInputStream = null; |
278 |
BufferedInputStream bufInputStream = null; |
274 |
|
279 |
|
Lines 396-421
Link Here
|
396 |
catch (FileNotFoundException e) |
401 |
catch (FileNotFoundException e) |
397 |
{ |
402 |
{ |
398 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
403 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
399 |
// throw new RemoteFileIOException(e); |
404 |
throw new RemoteFileIOException(e); |
400 |
return false; |
|
|
401 |
} |
405 |
} |
402 |
catch (UnsupportedEncodingException e) |
406 |
catch (UnsupportedEncodingException e) |
403 |
{ |
407 |
{ |
404 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
408 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
405 |
// throw new RemoteFileIOException(e); |
409 |
throw new RemoteFileIOException(e); |
406 |
return false; |
|
|
407 |
} |
410 |
} |
408 |
catch (IOException e) |
411 |
catch (IOException e) |
409 |
{ |
412 |
{ |
410 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
413 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
411 |
// throw new RemoteFileIOException(e); |
414 |
throw new RemoteFileIOException(e); |
412 |
return false; |
|
|
413 |
} |
415 |
} |
414 |
catch (Exception e) |
416 |
catch (Exception e) |
415 |
{ |
417 |
{ |
416 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
418 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
417 |
// throw new RemoteFileIOException(e); |
419 |
throw new RemoteFileIOException(e); |
418 |
return false; |
|
|
419 |
} |
420 |
} |
420 |
finally |
421 |
finally |
421 |
{ |
422 |
{ |
Lines 428-442
Link Here
|
428 |
|
429 |
|
429 |
if (isCancelled) |
430 |
if (isCancelled) |
430 |
{ |
431 |
{ |
431 |
return false; |
432 |
throw new RemoteFileCancelledException(); |
432 |
//throw new RemoteFileCancelledException(); |
|
|
433 |
} |
433 |
} |
434 |
} |
434 |
} |
435 |
catch (IOException e) |
435 |
catch (IOException e) |
436 |
{ |
436 |
{ |
437 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
437 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
438 |
// throw new RemoteFileIOException(e); |
438 |
throw new RemoteFileIOException(e); |
439 |
return false; |
|
|
440 |
} |
439 |
} |
441 |
|
440 |
|
442 |
} |
441 |
} |
Lines 446-452
Link Here
|
446 |
|
445 |
|
447 |
|
446 |
|
448 |
public boolean upload(File file, String remoteParent, String remoteFile, boolean isBinary, |
447 |
public boolean upload(File file, String remoteParent, String remoteFile, boolean isBinary, |
449 |
String srcEncoding, String hostEncoding, IProgressMonitor monitor) |
448 |
String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException |
450 |
{ |
449 |
{ |
451 |
FileInputStream inputStream = null; |
450 |
FileInputStream inputStream = null; |
452 |
BufferedInputStream bufInputStream = null; |
451 |
BufferedInputStream bufInputStream = null; |
Lines 595-620
Link Here
|
595 |
catch (FileNotFoundException e) |
594 |
catch (FileNotFoundException e) |
596 |
{ |
595 |
{ |
597 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
596 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
598 |
// throw new RemoteFileIOException(e); |
597 |
throw new RemoteFileIOException(e); |
599 |
return false; |
|
|
600 |
} |
598 |
} |
601 |
catch (UnsupportedEncodingException e) |
599 |
catch (UnsupportedEncodingException e) |
602 |
{ |
600 |
{ |
603 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
601 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
604 |
// throw new RemoteFileIOException(e); |
602 |
throw new RemoteFileIOException(e); |
605 |
return false; |
|
|
606 |
} |
603 |
} |
607 |
catch (IOException e) |
604 |
catch (IOException e) |
608 |
{ |
605 |
{ |
609 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
606 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
610 |
// throw new RemoteFileIOException(e); |
607 |
throw new RemoteFileIOException(e); |
611 |
return false; |
|
|
612 |
} |
608 |
} |
613 |
catch (Exception e) |
609 |
catch (Exception e) |
614 |
{ |
610 |
{ |
615 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
611 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
616 |
// throw new RemoteFileIOException(e); |
612 |
throw new RemoteFileIOException(e); |
617 |
return false; |
|
|
618 |
} |
613 |
} |
619 |
finally |
614 |
finally |
620 |
{ |
615 |
{ |
Lines 627-641
Link Here
|
627 |
|
622 |
|
628 |
if (isCancelled) |
623 |
if (isCancelled) |
629 |
{ |
624 |
{ |
630 |
return false; |
625 |
throw new RemoteFileCancelledException(); |
631 |
//throw new RemoteFileCancelledException(); |
|
|
632 |
} |
626 |
} |
633 |
} |
627 |
} |
634 |
catch (IOException e) |
628 |
catch (IOException e) |
635 |
{ |
629 |
{ |
636 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
630 |
// UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error writing file " + remotePath, e); |
637 |
// throw new RemoteFileIOException(e); |
631 |
throw new RemoteFileIOException(e); |
638 |
return false; |
|
|
639 |
} |
632 |
} |
640 |
|
633 |
|
641 |
if (totalBytes > 0) |
634 |
if (totalBytes > 0) |
Lines 680-686
Link Here
|
680 |
|
673 |
|
681 |
if (!makeSureLocalExists(localFile)) |
674 |
if (!makeSureLocalExists(localFile)) |
682 |
{ |
675 |
{ |
683 |
return false; |
676 |
FileNotFoundException e = new FileNotFoundException(); |
|
|
677 |
throw new RemoteFileIOException(e); |
684 |
} |
678 |
} |
685 |
|
679 |
|
686 |
|
680 |
|
Lines 742-748
Link Here
|
742 |
} |
736 |
} |
743 |
catch (Exception e) |
737 |
catch (Exception e) |
744 |
{ |
738 |
{ |
745 |
return false; |
739 |
throw new RemoteFileIOException(e); |
746 |
} |
740 |
} |
747 |
|
741 |
|
748 |
//long t2 = System.currentTimeMillis(); |
742 |
//long t2 = System.currentTimeMillis(); |
Lines 761-766
Link Here
|
761 |
} |
755 |
} |
762 |
catch (Exception e) |
756 |
catch (Exception e) |
763 |
{ |
757 |
{ |
|
|
758 |
throw new RemoteFileIOException(e); |
764 |
} |
759 |
} |
765 |
} |
760 |
} |
766 |
|
761 |
|
Lines 775-781
Link Here
|
775 |
if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_SUCCESS_TYPE)) |
770 |
if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_SUCCESS_TYPE)) |
776 |
{ |
771 |
{ |
777 |
if (!isBinary){ // do standard conversion if this is text! |
772 |
if (!isBinary){ // do standard conversion if this is text! |
778 |
String localEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ |
773 |
String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding(); |
779 |
|
774 |
|
780 |
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this); |
775 |
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this); |
781 |
|
776 |
|
Lines 801-809
Link Here
|
801 |
{ |
796 |
{ |
802 |
//SystemMessage msg = getMessage(); |
797 |
//SystemMessage msg = getMessage(); |
803 |
//throw new SystemMessageException(msg); |
798 |
//throw new SystemMessageException(msg); |
804 |
//UnsupportedEncodingException e = new UnsupportedEncodingException(resultChild.getName()); |
799 |
UnsupportedEncodingException e = new UnsupportedEncodingException(resultChild.getName()); |
805 |
//UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error reading file " + remotePath, e); |
800 |
//UniversalSystemPlugin.logError(CLASSNAME + "." + "copy: " + "error reading file " + remotePath, e); |
806 |
//throw new RemoteFileIOException(e); |
801 |
throw new RemoteFileIOException(e); |
807 |
} |
802 |
} |
808 |
|
803 |
|
809 |
else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION)) |
804 |
else if (resultChild.getType().equals(IUniversalDataStoreConstants.DOWNLOAD_RESULT_IO_EXCEPTION)) |
Lines 846-852
Link Here
|
846 |
} |
841 |
} |
847 |
catch (IOException e) |
842 |
catch (IOException e) |
848 |
{ |
843 |
{ |
849 |
return false; |
844 |
throw new RemoteFileIOException(e); |
850 |
} |
845 |
} |
851 |
return true; |
846 |
return true; |
852 |
} |
847 |
} |
Lines 913-919
Link Here
|
913 |
|
908 |
|
914 |
if (!makeSureLocalExists(localFile)) |
909 |
if (!makeSureLocalExists(localFile)) |
915 |
{ |
910 |
{ |
916 |
return false; |
911 |
FileNotFoundException e = new FileNotFoundException(); |
|
|
912 |
throw new RemoteFileIOException(e); |
917 |
} |
913 |
} |
918 |
|
914 |
|
919 |
long fileLength = DStoreHostFile.getFileLength(de.getSource()); |
915 |
long fileLength = DStoreHostFile.getFileLength(de.getSource()); |
Lines 942-952
Link Here
|
942 |
DataElement subject = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); |
938 |
DataElement subject = ds.createObject(universaltemp, de.getType(), remotePath, String.valueOf(mode)); |
943 |
|
939 |
|
944 |
DataElement status = ds.command(queryCmd, argList, subject); |
940 |
DataElement status = ds.command(queryCmd, argList, subject); |
945 |
if (status == null) |
|
|
946 |
{ |
947 |
System.out.println("no download descriptor for "+remoteElement); //$NON-NLS-1$ |
948 |
return false; |
949 |
} |
950 |
|
941 |
|
951 |
DownloadListener dlistener = new DownloadListener(status, localFile, remotePath, fileLength, monitor); |
942 |
DownloadListener dlistener = new DownloadListener(status, localFile, remotePath, fileLength, monitor); |
952 |
downloadListeners.add(dlistener); |
943 |
downloadListeners.add(dlistener); |
Lines 981-987
Link Here
|
981 |
} |
972 |
} |
982 |
catch (Exception e) |
973 |
catch (Exception e) |
983 |
{ |
974 |
{ |
984 |
return false; |
975 |
throw new RemoteFileIOException(e); |
985 |
} |
976 |
} |
986 |
|
977 |
|
987 |
// now wait till we have all the bytes local |
978 |
// now wait till we have all the bytes local |
Lines 1000-1005
Link Here
|
1000 |
} |
991 |
} |
1001 |
catch (Exception e) |
992 |
catch (Exception e) |
1002 |
{ |
993 |
{ |
|
|
994 |
throw new RemoteFileIOException(e); |
1003 |
} |
995 |
} |
1004 |
} |
996 |
} |
1005 |
|
997 |
|
Lines 1018-1024
Link Here
|
1018 |
{ |
1010 |
{ |
1019 |
// do standard conversion if this is text! |
1011 |
// do standard conversion if this is text! |
1020 |
if (!isBinaries[i]){ // do standard conversion if this is text! |
1012 |
if (!isBinaries[i]){ // do standard conversion if this is text! |
1021 |
String localEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ |
1013 |
String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding(); |
1022 |
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[i], this); |
1014 |
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[i], this); |
1023 |
|
1015 |
|
1024 |
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[i], localEncoding, this); |
1016 |
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[i], localEncoding, this); |
Lines 1369-1375
Link Here
|
1369 |
String remotePath = remoteParent + getSeparator(remoteParent) + fileName; |
1361 |
String remotePath = remoteParent + getSeparator(remoteParent) + fileName; |
1370 |
DataElement de = getElementFor(remotePath); |
1362 |
DataElement de = getElementFor(remotePath); |
1371 |
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_DELETE, monitor); |
1363 |
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_DELETE, monitor); |
1372 |
if (status == null) return false; |
1364 |
if (status == null) |
|
|
1365 |
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, |
1366 |
ICommonMessageIds.MSG_ERROR_UNEXPECTED, |
1367 |
IStatus.ERROR, |
1368 |
CommonMessages.MSG_ERROR_UNEXPECTED)); |
1369 |
|
1373 |
if (null != monitor && monitor.isCanceled()) |
1370 |
if (null != monitor && monitor.isCanceled()) |
1374 |
{ |
1371 |
{ |
1375 |
//This operation has been cancelled by the user. |
1372 |
//This operation has been cancelled by the user. |
Lines 1484-1491
Link Here
|
1484 |
} |
1481 |
} |
1485 |
|
1482 |
|
1486 |
|
1483 |
|
1487 |
|
1484 |
if (status == null) |
1488 |
if (status == null) return false; |
1485 |
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, |
|
|
1486 |
ICommonMessageIds.MSG_ERROR_UNEXPECTED, |
1487 |
IStatus.ERROR, |
1488 |
CommonMessages.MSG_ERROR_UNEXPECTED)); |
1489 |
|
1489 |
if (null != monitor && monitor.isCanceled()) |
1490 |
if (null != monitor && monitor.isCanceled()) |
1490 |
{ |
1491 |
{ |
1491 |
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, |
1492 |
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, |
Lines 1720-1726
Link Here
|
1720 |
} |
1721 |
} |
1721 |
return true; |
1722 |
return true; |
1722 |
} |
1723 |
} |
1723 |
return false; |
1724 |
else { |
|
|
1725 |
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, |
1726 |
ICommonMessageIds.MSG_ERROR_UNEXPECTED, |
1727 |
IStatus.ERROR, |
1728 |
CommonMessages.MSG_ERROR_UNEXPECTED)); |
1729 |
} |
1724 |
} |
1730 |
} |
1725 |
|
1731 |
|
1726 |
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException |
1732 |
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException |
Lines 2059-2066
Link Here
|
2059 |
return true; |
2065 |
return true; |
2060 |
} |
2066 |
} |
2061 |
} |
2067 |
} |
2062 |
|
2068 |
else { |
2063 |
return false; |
2069 |
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, |
|
|
2070 |
ICommonMessageIds.MSG_ERROR_UNEXPECTED, |
2071 |
IStatus.ERROR, |
2072 |
CommonMessages.MSG_ERROR_UNEXPECTED)); |
2073 |
} |
2064 |
} |
2074 |
} |
2065 |
|
2075 |
|
2066 |
public boolean setReadOnly(String parent, String name, |
2076 |
public boolean setReadOnly(String parent, String name, |
Lines 2088-2094
Link Here
|
2088 |
return true; |
2098 |
return true; |
2089 |
} |
2099 |
} |
2090 |
} |
2100 |
} |
2091 |
return false; |
2101 |
else { |
|
|
2102 |
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, |
2103 |
ICommonMessageIds.MSG_ERROR_UNEXPECTED, |
2104 |
IStatus.ERROR, |
2105 |
CommonMessages.MSG_ERROR_UNEXPECTED)); |
2106 |
} |
2092 |
} |
2107 |
} |
2093 |
|
2108 |
|
2094 |
/** |
2109 |
/** |