mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 15:45:25 +02:00
[209593] [api] updated support for "file permissions" and "owner" properties
This commit is contained in:
parent
d75235d2d0
commit
5c91cc751b
29 changed files with 640 additions and 745 deletions
|
@ -282,8 +282,6 @@ public class FileResources extends NLS
|
|||
public static String MESSAGE_PENDING;
|
||||
public static String MESSAGE_NOT_SUPPORTED;
|
||||
public static String MESSAGE_GETTING_PERMISSIONS;
|
||||
public static String MESSAGE_GETTING_OWNER;
|
||||
public static String MESSAGE_GETTING_GROUP;
|
||||
|
||||
static
|
||||
{
|
||||
|
|
|
@ -283,6 +283,4 @@ RESID_PREF_PERMISSIONS_OWNERSHIP_LABEL=Ownership
|
|||
MESSAGE_PENDING=Pending...
|
||||
MESSAGE_NOT_SUPPORTED=Not supported
|
||||
MESSAGE_GETTING_PERMISSIONS=Getting permissions for {0}
|
||||
MESSAGE_GETTING_OWNER=Getting user owner for {0}
|
||||
MESSAGE_GETTING_GROUP=Getting group owner for {0}
|
||||
|
||||
|
|
|
@ -24,11 +24,10 @@ import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
|||
import org.eclipse.rse.core.events.SystemResourceChangeEvent;
|
||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||
import org.eclipse.rse.internal.files.ui.FileResources;
|
||||
import org.eclipse.rse.services.files.IFileOwnerService;
|
||||
import org.eclipse.rse.services.files.IFilePermissionsService;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.PendingHostFilePermissions;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -81,7 +80,8 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
|
||||
IRemoteFile file = getRemoteFile();
|
||||
IFilePermissionsService service = getPermissionsService(file);
|
||||
if (service == null || !service.canGetFilePermissions(file.getParentPath(), file.getName())){
|
||||
if (service == null ||
|
||||
(service.getCapabilities(file.getHostFile()) & IFilePermissionsService.FS_CAN_GET_PERMISSIONS) == 0){
|
||||
// not supported
|
||||
SystemWidgetHelpers.createLabel(parent, FileResources.MESSAGE_FILE_PERMISSIONS_NOT_SUPPORTED);
|
||||
}
|
||||
|
@ -227,14 +227,6 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
}
|
||||
|
||||
|
||||
private IFileOwnerService getOwnerService(IRemoteFile remoteFile){
|
||||
|
||||
if (remoteFile instanceof IAdaptable){
|
||||
return (IFileOwnerService)((IAdaptable)remoteFile).getAdapter(IFileOwnerService.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void initFields() {
|
||||
|
@ -243,17 +235,10 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
IFilePermissionsService ps = getPermissionsService(remoteFile);
|
||||
if (ps == null){
|
||||
enablePermissionFields(false);
|
||||
}
|
||||
else {
|
||||
initPermissionFields(remoteFile, ps);
|
||||
}
|
||||
|
||||
IFileOwnerService os = getOwnerService(remoteFile);
|
||||
if (ps == null){
|
||||
enableOwnershipFields(false);
|
||||
}
|
||||
else {
|
||||
initOwnershipFields(remoteFile, os);
|
||||
initPermissionFields(remoteFile, ps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,26 +247,34 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
|
||||
final IRemoteFile rFile = file;
|
||||
final IFilePermissionsService pService = service;
|
||||
String remoteParent = file.getParentPath();
|
||||
String name = file.getName();
|
||||
|
||||
if (service.canGetFilePermissions(remoteParent, name)){
|
||||
|
||||
int capabilities = service.getCapabilities(file.getHostFile());
|
||||
if ((capabilities & IFilePermissionsService.FS_CAN_SET_PERMISSIONS) != 0){
|
||||
enablePermissionFields(true);
|
||||
}
|
||||
else {
|
||||
enablePermissionFields(false);
|
||||
}
|
||||
|
||||
if ((capabilities & IFilePermissionsService.FS_CAN_SET_OWNER) != 0){
|
||||
enableOwnershipFields(true);
|
||||
}
|
||||
else {
|
||||
enableOwnershipFields(false);
|
||||
}
|
||||
|
||||
if ((capabilities & IFilePermissionsService.FS_CAN_GET_PERMISSIONS) != 0){
|
||||
|
||||
try
|
||||
{
|
||||
_permissions = file.getPermissions();
|
||||
if (_permissions == null){
|
||||
if (_permissions == null || _permissions instanceof PendingHostFilePermissions){
|
||||
Job deferredFetch = new Job(FileResources.MESSAGE_GETTING_PERMISSIONS)
|
||||
{
|
||||
public IStatus run(IProgressMonitor monitor){
|
||||
try
|
||||
{
|
||||
String remoteParent = rFile.getParentPath();
|
||||
String fname = rFile.getName();
|
||||
_permissions = pService.getFilePermissions(remoteParent, fname, monitor);
|
||||
if (_permissions != null && rFile instanceof RemoteFile){
|
||||
((RemoteFile)rFile).setPermissions(_permissions);
|
||||
}
|
||||
_permissions = pService.getFilePermissions(rFile.getHostFile(), monitor);
|
||||
|
||||
// notify change
|
||||
Display.getDefault().asyncExec(new Runnable()
|
||||
|
@ -297,6 +290,13 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
_otherRead.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_OTHER_READ));
|
||||
_otherWrite.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_OTHER_WRITE));
|
||||
_otherExecute.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_OTHER_EXECUTE));
|
||||
|
||||
_owner = _permissions.getUserOwner();
|
||||
_group = _permissions.getGroupOwner();
|
||||
|
||||
_userEntry.setText(_owner);
|
||||
_groupEntry.setText(_group);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -317,102 +317,12 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
_groupExecute.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_GROUP_EXECUTE));
|
||||
_otherRead.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_OTHER_READ));
|
||||
_otherWrite.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_OTHER_WRITE));
|
||||
_otherExecute.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_OTHER_EXECUTE));
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
enablePermissionFields(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initOwnershipFields(IRemoteFile file, IFileOwnerService service){
|
||||
_owner = null;
|
||||
_group = null;
|
||||
|
||||
String remoteParent = file.getParentPath();
|
||||
String name = file.getName();
|
||||
final IRemoteFile rFile = file;
|
||||
final IFileOwnerService oService = service;
|
||||
|
||||
if (service.canGetFileOwner(remoteParent, name)){
|
||||
enableOwnershipFields(true);
|
||||
try
|
||||
{
|
||||
_owner = file.getOwner();
|
||||
if (_owner == null){
|
||||
Job deferredFetch = new Job(FileResources.MESSAGE_GETTING_OWNER)
|
||||
{
|
||||
public IStatus run(IProgressMonitor monitor){
|
||||
try
|
||||
{
|
||||
String remoteParent = rFile.getParentPath();
|
||||
String fname = rFile.getName();
|
||||
_owner = oService.getFileUserOwner(remoteParent, fname, monitor);
|
||||
if (_owner != null && rFile instanceof RemoteFile){
|
||||
((RemoteFile)rFile).setOwner(_owner);
|
||||
}
|
||||
|
||||
// notify change
|
||||
Display.getDefault().asyncExec(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_userEntry.setText(_owner);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
deferredFetch.schedule();
|
||||
_userEntry.setText(FileResources.MESSAGE_PENDING);
|
||||
}
|
||||
else {
|
||||
_otherExecute.setSelection(_permissions.getPermission(IHostFilePermissions.PERM_OTHER_EXECUTE));
|
||||
|
||||
_owner = _permissions.getUserOwner();
|
||||
_group = _permissions.getGroupOwner();
|
||||
|
||||
_userEntry.setText(_owner);
|
||||
}
|
||||
|
||||
_group = file.getGroup();
|
||||
if (_group == null){
|
||||
Job deferredFetch = new Job(FileResources.MESSAGE_GETTING_GROUP)
|
||||
{
|
||||
public IStatus run(IProgressMonitor monitor){
|
||||
try
|
||||
{
|
||||
String remoteParent = rFile.getParentPath();
|
||||
String fname = rFile.getName();
|
||||
_group = oService.getFileGroupOwner(remoteParent, fname, monitor);
|
||||
if (_group != null && rFile instanceof RemoteFile){
|
||||
((RemoteFile)rFile).setGroup(_group);
|
||||
}
|
||||
|
||||
// notify change
|
||||
Display.getDefault().asyncExec(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_groupEntry.setText(_group);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
deferredFetch.schedule();
|
||||
_groupEntry.setText(FileResources.MESSAGE_PENDING);
|
||||
}
|
||||
else {
|
||||
_groupEntry.setText(_group);
|
||||
}
|
||||
}
|
||||
|
@ -421,10 +331,13 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
}
|
||||
}
|
||||
else {
|
||||
enablePermissionFields(false);
|
||||
enableOwnershipFields(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean performOk() {
|
||||
IRemoteFile remoteFile = getRemoteFile();
|
||||
|
||||
|
@ -434,11 +347,8 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
if (_permissions != null){
|
||||
IFilePermissionsService service = getPermissionsService(remoteFile);
|
||||
|
||||
String remoteParent = remoteFile.getParentPath();
|
||||
String name = remoteFile.getName();
|
||||
|
||||
|
||||
if (service.canSetFilePermissions(remoteParent, name)){
|
||||
int capabilities = service.getCapabilities(remoteFile.getHostFile());
|
||||
if ((capabilities & IFilePermissionsService.FS_CAN_SET_PERMISSIONS) != 0){
|
||||
try
|
||||
{
|
||||
|
||||
|
@ -479,9 +389,19 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
changed = true;
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_OTHER_EXECUTE, _otherExecute.getSelection());
|
||||
}
|
||||
|
||||
|
||||
if (_owner != _userEntry.getText()){
|
||||
changed = true;
|
||||
_permissions.setUserOwner(_userEntry.getText());
|
||||
}
|
||||
if (_group != _groupEntry.getText()){
|
||||
changed = true;
|
||||
_permissions.setGroupOwner(_groupEntry.getText());
|
||||
}
|
||||
|
||||
|
||||
if (changed){
|
||||
service.setFilePermissions(remoteParent, name, _permissions, new NullProgressMonitor());
|
||||
service.setFilePermissions(remoteFile.getHostFile(), _permissions, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
|
@ -489,37 +409,7 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (_owner != null){
|
||||
IFileOwnerService service = getOwnerService(remoteFile);
|
||||
|
||||
String remoteParent = remoteFile.getParentPath();
|
||||
String name = remoteFile.getName();
|
||||
|
||||
if (service.canSetFileOwner(remoteParent, name)){
|
||||
try
|
||||
{
|
||||
if (_owner != _userEntry.getText()){
|
||||
changed = true;
|
||||
if (remoteFile instanceof RemoteFile){
|
||||
((RemoteFile)remoteFile).setOwner(_owner);
|
||||
}
|
||||
|
||||
service.setFileUserOwner(remoteParent, name, _userEntry.getText(), new NullProgressMonitor());
|
||||
}
|
||||
if (_group != _groupEntry.getText()){
|
||||
changed = true;
|
||||
if (remoteFile instanceof RemoteFile){
|
||||
((RemoteFile)remoteFile).setGroup(_group);
|
||||
}
|
||||
service.setFileGroupOwner(remoteParent, name, _groupEntry.getText(), new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (changed){
|
||||
// notify views of change
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
|
|
|
@ -117,9 +117,9 @@ import org.eclipse.rse.services.clientserver.SystemSearchString;
|
|||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.files.IFileOwnerService;
|
||||
import org.eclipse.rse.services.files.IFilePermissionsService;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
||||
import org.eclipse.rse.services.files.PendingHostFilePermissions;
|
||||
import org.eclipse.rse.services.search.HostSearchResultSet;
|
||||
import org.eclipse.rse.services.search.IHostSearchConstants;
|
||||
|
@ -1317,133 +1317,45 @@ public class SystemViewRemoteFileAdapter
|
|||
IHostFilePermissions permissions = file.getPermissions();
|
||||
if (permissions == null){
|
||||
|
||||
if (file instanceof IAdaptable){
|
||||
final IFilePermissionsService service = (IFilePermissionsService)((IAdaptable)file).getAdapter(IFilePermissionsService.class);
|
||||
if (service != null && service.canGetFilePermissions(file.getParentPath(), file.getName())){
|
||||
final IRemoteFile rFile = file;
|
||||
|
||||
|
||||
Job deferredFetch = new Job(MessageFormat.format(FileResources.MESSAGE_GETTING_PERMISSIONS, new Object[] {file.getAbsolutePath()}))
|
||||
{
|
||||
public IStatus run(IProgressMonitor monitor){
|
||||
try
|
||||
{
|
||||
String remoteParent = rFile.getParentPath();
|
||||
String fname = rFile.getName();
|
||||
IHostFilePermissions perm = service.getFilePermissions(remoteParent, fname, monitor);
|
||||
if (perm != null && rFile instanceof RemoteFile){
|
||||
((RemoteFile)rFile).setPermissions(perm);
|
||||
// notify change to property sheet
|
||||
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
registry.fireEvent(new SystemResourceChangeEvent(rFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, rFile));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
deferredFetch.schedule();
|
||||
if (file instanceof RemoteFile){
|
||||
// using pending host file permssions as dummy until we have the real thing
|
||||
((RemoteFile)file).setPermissions(new PendingHostFilePermissions());
|
||||
}
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
if (getFilePermissions(file)){
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
return FileResources.MESSAGE_NOT_SUPPORTED;
|
||||
}
|
||||
return permissions.toUserString();
|
||||
if (permissions instanceof PendingHostFilePermissions){
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
return permissions.toAlphaString();
|
||||
}
|
||||
else if (name.equals(ISystemPropertyConstants.P_FILE_OWNER))
|
||||
{
|
||||
String owner = file.getOwner();
|
||||
if (owner == null){
|
||||
if (file instanceof IAdaptable){
|
||||
|
||||
final IFileOwnerService service = (IFileOwnerService)((IAdaptable)file).getAdapter(IFileOwnerService.class);
|
||||
if (service != null && service.canGetFileOwner(file.getParentPath(), file.getName())){
|
||||
|
||||
final IRemoteFile rFile = file;
|
||||
|
||||
Job deferredFetch = new Job(MessageFormat.format(FileResources.MESSAGE_GETTING_OWNER, new Object[] {file.getAbsolutePath()}))
|
||||
{
|
||||
public IStatus run(IProgressMonitor monitor){
|
||||
try
|
||||
{
|
||||
String remoteParent = rFile.getParentPath();
|
||||
String fname = rFile.getName();
|
||||
String uowner = service.getFileUserOwner(remoteParent, fname, monitor);
|
||||
if (uowner != null && rFile instanceof RemoteFile){
|
||||
((RemoteFile)rFile).setOwner(uowner);
|
||||
}
|
||||
|
||||
// notify change to property sheet
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
registry.fireEvent(new SystemResourceChangeEvent(rFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, rFile));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
deferredFetch.schedule();
|
||||
|
||||
if (file instanceof RemoteFile){
|
||||
// using pending host file owner as dummy until we have the real thing
|
||||
((RemoteFile)file).setOwner("Pending"); //pending for now
|
||||
}
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
IHostFilePermissions permissions = file.getPermissions();
|
||||
if (permissions == null){
|
||||
|
||||
if (getFilePermissions(file)){
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
return FileResources.MESSAGE_NOT_SUPPORTED;
|
||||
}
|
||||
return owner;
|
||||
if (permissions instanceof PendingHostFilePermissions){
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
return permissions.getUserOwner();
|
||||
}
|
||||
else if (name.equals(ISystemPropertyConstants.P_FILE_GROUP))
|
||||
{
|
||||
String group = file.getGroup();
|
||||
if (group == null){
|
||||
if (file instanceof IAdaptable){
|
||||
final IFileOwnerService service = (IFileOwnerService)((IAdaptable)file).getAdapter(IFileOwnerService.class);
|
||||
if (service != null && service.canGetFileOwner(file.getParentPath(), file.getName())){
|
||||
final IRemoteFile rFile = file;
|
||||
|
||||
Job deferredFetch = new Job(MessageFormat.format(FileResources.MESSAGE_GETTING_GROUP, new Object[] {file.getAbsolutePath()}))
|
||||
{
|
||||
public IStatus run(IProgressMonitor monitor){
|
||||
try
|
||||
{
|
||||
String remoteParent = rFile.getParentPath();
|
||||
String fname = rFile.getName();
|
||||
String ugroup = service.getFileGroupOwner(remoteParent, fname, monitor);
|
||||
if (ugroup != null && rFile instanceof RemoteFile){
|
||||
((RemoteFile)rFile).setGroup(ugroup);
|
||||
}
|
||||
// notify change to property sheet
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
registry.fireEvent(new SystemResourceChangeEvent(rFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, rFile));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
deferredFetch.schedule();
|
||||
if (file instanceof RemoteFile){
|
||||
// using pending host file owner as dummy until we have the real thing
|
||||
((RemoteFile)file).setGroup("Pending"); //pending for now
|
||||
}
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
IHostFilePermissions permissions = file.getPermissions();
|
||||
if (permissions == null){
|
||||
|
||||
if (getFilePermissions(file)){
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
return FileResources.MESSAGE_NOT_SUPPORTED;
|
||||
}
|
||||
return group;
|
||||
if (permissions instanceof PendingHostFilePermissions){
|
||||
return FileResources.MESSAGE_PENDING;
|
||||
}
|
||||
return permissions.getGroupOwner();
|
||||
}
|
||||
else if (name.equals(ISystemPropertyConstants.P_FILE_CLASSIFICATION))
|
||||
{
|
||||
|
@ -1498,6 +1410,43 @@ public class SystemViewRemoteFileAdapter
|
|||
else
|
||||
return null; //super.getPropertyValue(name);
|
||||
}
|
||||
|
||||
private boolean getFilePermissions(IRemoteFile file){
|
||||
if (file instanceof IAdaptable){
|
||||
final IFilePermissionsService service = (IFilePermissionsService)((IAdaptable)file).getAdapter(IFilePermissionsService.class);
|
||||
|
||||
if (service != null && (service.getCapabilities(file.getHostFile()) & IFilePermissionsService.FS_CAN_GET_PERMISSIONS) != 0){
|
||||
|
||||
final IRemoteFile rFile = file;
|
||||
if (rFile.getHostFile() instanceof IHostFilePermissionsContainer){
|
||||
((IHostFilePermissionsContainer)rFile.getHostFile()).setPermissions(new PendingHostFilePermissions());
|
||||
}
|
||||
|
||||
Job deferredFetch = new Job(MessageFormat.format(FileResources.MESSAGE_GETTING_PERMISSIONS, new Object[] {file.getAbsolutePath()}))
|
||||
{
|
||||
public IStatus run(IProgressMonitor monitor){
|
||||
try
|
||||
{
|
||||
// service will take care of setting this on the host file
|
||||
service.getFilePermissions(rFile.getHostFile(), monitor);
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
registry.fireEvent(new SystemResourceChangeEvent(rFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, rFile));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
deferredFetch.schedule();
|
||||
|
||||
|
||||
return true; // query kicked off
|
||||
}
|
||||
}
|
||||
return false; // no query kicked off
|
||||
}
|
||||
|
||||
|
||||
// Drag and Drop Implementation
|
||||
|
||||
|
@ -3559,7 +3508,8 @@ public class SystemViewRemoteFileAdapter
|
|||
if (tgt instanceof IAdaptable){
|
||||
IFilePermissionsService service = (IFilePermissionsService)((IAdaptable)tgt).getAdapter(IFilePermissionsService.class);
|
||||
if (service != null){
|
||||
return service.canGetFilePermissions(tgt.getParentPath(), tgt.getName());
|
||||
|
||||
return (service.getCapabilities(tgt.getHostFile()) & IFilePermissionsService.FS_CAN_GET_PERMISSIONS) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [183165] Do not implement constant interfaces
|
||||
* David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup
|
||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners;
|
||||
|
@ -97,15 +98,10 @@ public interface IUniversalDataStoreConstants
|
|||
public static final String TYPE_QUALIFIED_CLASSNAME = "fullClassName"; //$NON-NLS-1$
|
||||
|
||||
// permissions commands
|
||||
public static final String C_QUERY_FILE_PERMISSIONS = "C_QUERY_FILE_PERMISSIONS";
|
||||
public static final String C_SET_FILE_PERMISSIONS = "C_SET_FILE_PERMISSIONS";
|
||||
|
||||
// ownership commands
|
||||
public static final String C_QUERY_FILE_USER_OWNER = "C_QUERY_FILE_USER_OWNER";
|
||||
public static final String C_SET_FILE_USER_OWNER = "C_SET_FILE_USER_OWNER";
|
||||
public static final String C_QUERY_FILE_GROUP_OWNER = "C_QUERY_FILE_GROUP_OWNER";
|
||||
public static final String C_SET_FILE_GROUP_OWNER = "C_SET_FILE_GROUP_OWNER";
|
||||
public static final String C_QUERY_FILE_PERMISSIONS = "C_QUERY_FILE_PERMISSIONS"; //$NON-NLS-1$
|
||||
public static final String C_SET_FILE_PERMISSIONS = "C_SET_FILE_PERMISSIONS"; //$NON-NLS-1$
|
||||
|
||||
|
||||
// Mode of transfer: text or binary
|
||||
public static final int TEXT_MODE = -1;
|
||||
public static final int BINARY_MODE = -2;
|
||||
|
|
|
@ -216,16 +216,6 @@ public class UniversalFileSystemMiner extends Miner {
|
|||
} else if (IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS.equals(name)) {
|
||||
DataElement newPermissions = getCommandArgument(theElement, 1);
|
||||
return handleSetFilePermissions(subject, newPermissions, status);
|
||||
} else if (IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER.equals(name)) {
|
||||
return handleQueryFileOwner(subject, status);
|
||||
} else if (IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER.equals(name)) {
|
||||
DataElement newOwner = getCommandArgument(theElement, 1);
|
||||
return handleSetFileOwner(subject, newOwner, status);
|
||||
} else if (IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER.equals(name)) {
|
||||
return handleQueryFileGroupOwner(subject, status);
|
||||
} else if (IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER.equals(name)) {
|
||||
DataElement newOwner = getCommandArgument(theElement, 1);
|
||||
return handleSetFileGroupOwner(subject, newOwner, status);
|
||||
} else {
|
||||
UniversalServerUtilities.logError(CLASSNAME,
|
||||
"Invalid query to handlecommand", null); //$NON-NLS-1$
|
||||
|
@ -1608,37 +1598,6 @@ public class UniversalFileSystemMiner extends Miner {
|
|||
createCommandDescriptor(FileDescriptors._deUniversalArchiveFileObject, "SetPermissions",IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFileObject, "SetPermissions", IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFolderObject, "SetPermissions", IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS); //$NON-NLS-1$
|
||||
|
||||
|
||||
// descriptors for ownership
|
||||
createCommandDescriptor(UniversalFilter, "GetOwner", IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFolderObject, "GetOwner", IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFileObject, "GetOwner", IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalArchiveFileObject, "GetOwner",IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFileObject, "GetOwner", IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFolderObject, "GetOwner", IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
|
||||
createCommandDescriptor(UniversalFilter, "SetOwner", IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFolderObject, "SetOwner", IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFileObject, "SetOwner", IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalArchiveFileObject, "SetOwner",IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFileObject, "SetOwner", IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFolderObject, "SetOwner", IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER); //$NON-NLS-1$
|
||||
|
||||
createCommandDescriptor(UniversalFilter, "GetGroupOwner", IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFolderObject, "GetGroupOwner", IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFileObject, "GetGroupOwner", IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalArchiveFileObject, "GetGroupOwner",IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFileObject, "GetGroupOwner", IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFolderObject, "GetGroupOwner", IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
|
||||
createCommandDescriptor(UniversalFilter, "SetGroupOwner", IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFolderObject, "SetGroupOwner", IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalFileObject, "SetGroupOwner", IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalArchiveFileObject, "SetGroupOwner",IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFileObject, "SetGroupOwner", IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
createCommandDescriptor(FileDescriptors._deUniversalVirtualFolderObject, "SetGroupOwner", IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1886,16 +1845,23 @@ public class UniversalFileSystemMiner extends Miner {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets file permissions in the form <octal permissions>|<user>|<group>
|
||||
* @param subject
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
private DataElement handleQueryFilePermissions(DataElement subject, DataElement status)
|
||||
{
|
||||
File file = getFileFor(subject);
|
||||
|
||||
String result = null;
|
||||
// permissions
|
||||
String octalPermissions = null;
|
||||
String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
|
||||
|
||||
if (os.startsWith("linux")){ //$NON-NLS-1$
|
||||
// permissions in octal form
|
||||
result = simpleShellCommand("stat -c%a", file); //$NON-NLS-1$
|
||||
octalPermissions = simpleShellCommand("stat -c%a", file); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
// permissions in form "drwxrwxrwx ..."
|
||||
|
@ -1905,95 +1871,53 @@ public class UniversalFileSystemMiner extends Miner {
|
|||
|
||||
// permissions in form "rwxrwxrwx"
|
||||
String permString = ldStr.substring(1, firstSpace);
|
||||
result = alphaPermissionsToOctal(permString);
|
||||
octalPermissions = alphaPermissionsToOctal(permString);
|
||||
}
|
||||
|
||||
// user and group
|
||||
String ldStr = simpleShellCommand("ls -ld", file); //$NON-NLS-1$
|
||||
StringTokenizer tokenizer = new StringTokenizer(ldStr, " \t"); //$NON-NLS-1$
|
||||
tokenizer.nextToken();
|
||||
tokenizer.nextToken();
|
||||
String user = tokenizer.nextToken(); // 3rd
|
||||
String group = tokenizer.nextToken(); // 4th
|
||||
|
||||
String result = octalPermissions + '|' + user + '|' + group;
|
||||
status.setAttribute(DE.A_SOURCE, result);
|
||||
statusDone(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file permissions including user and group
|
||||
* @param subject
|
||||
* @param newPermissions permissions in the form <octal permissions>|<user>|<group>
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
private DataElement handleSetFilePermissions(DataElement subject, DataElement newPermissions, DataElement status)
|
||||
{
|
||||
File file = getFileFor(subject);
|
||||
String result = simpleShellCommand("chmod " + newPermissions.getName(), file); //$NON-NLS-1$
|
||||
|
||||
status.setAttribute(DE.A_SOURCE, result);
|
||||
statusDone(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
private DataElement handleQueryFileOwner(DataElement subject, DataElement status)
|
||||
{
|
||||
File file = getFileFor(subject);
|
||||
String result = null;
|
||||
String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
|
||||
String permissionsStr = newPermissions.getName();
|
||||
String[] permAttributes = permissionsStr.split("\\"+IServiceConstants.TOKEN_SEPARATOR); //$NON-NLS-1$
|
||||
|
||||
if (os.startsWith("linux")){ //$NON-NLS-1$
|
||||
result = simpleShellCommand("stat -c%U", file); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
// in form "<permissions> <n> <owner> <group> ..."
|
||||
String ldStr = simpleShellCommand("ls -ld", file); //$NON-NLS-1$
|
||||
StringTokenizer tokenizer = new StringTokenizer(ldStr, " \t"); //$NON-NLS-1$
|
||||
tokenizer.nextToken();
|
||||
tokenizer.nextToken();
|
||||
result = tokenizer.nextToken(); // 3rd
|
||||
}
|
||||
// set the permissions
|
||||
String result = simpleShellCommand("chmod " + permAttributes[0], file); //$NON-NLS-1$
|
||||
|
||||
// set the user
|
||||
simpleShellCommand("chown " + permAttributes[1], file); //$NON-NLS-1$
|
||||
|
||||
// set the group
|
||||
simpleShellCommand("chown :" + permAttributes[2], file); //$NON-NLS-1$
|
||||
|
||||
status.setAttribute(DE.A_SOURCE, result);
|
||||
statusDone(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
private DataElement handleSetFileOwner(DataElement subject, DataElement newOwner, DataElement status)
|
||||
{
|
||||
File file = getFileFor(subject);
|
||||
String result = simpleShellCommand("chown " + newOwner.getName(), file); //$NON-NLS-1$
|
||||
|
||||
status.setAttribute(DE.A_SOURCE, result);
|
||||
statusDone(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
private DataElement handleQueryFileGroupOwner(DataElement subject, DataElement status)
|
||||
{
|
||||
File file = getFileFor(subject);
|
||||
String result = null;
|
||||
String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
|
||||
|
||||
if (os.startsWith("linux")){ //$NON-NLS-1$
|
||||
result = simpleShellCommand("stat -c%G", file); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
// in form "<permissions> <n> <owner> <group> ..."
|
||||
String ldStr = simpleShellCommand("ls -ld", file); //$NON-NLS-1$
|
||||
|
||||
StringTokenizer tokenizer = new StringTokenizer(ldStr, " \t"); //$NON-NLS-1$
|
||||
tokenizer.nextToken();
|
||||
tokenizer.nextToken();
|
||||
tokenizer.nextToken();
|
||||
result = tokenizer.nextToken(); // 4rd
|
||||
}
|
||||
|
||||
status.setAttribute(DE.A_SOURCE, result);
|
||||
statusDone(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
private DataElement handleSetFileGroupOwner(DataElement subject, DataElement newGroup, DataElement status)
|
||||
{
|
||||
File file = getFileFor(subject);
|
||||
String result = simpleShellCommand("chown :" + newGroup.getName(), file); //$NON-NLS-1$
|
||||
|
||||
status.setAttribute(DE.A_SOURCE, result);
|
||||
statusDone(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
private String simpleShellCommand(String cmd)
|
||||
{
|
||||
|
|
|
@ -177,6 +177,9 @@ public class CommandMinerThread extends MinerThread
|
|||
else
|
||||
{
|
||||
isBash = true;
|
||||
// no bash!
|
||||
theShell = "sh";
|
||||
|
||||
}
|
||||
}
|
||||
else if (theShell.endsWith("sh") && isZ)//$NON-NLS-1$
|
||||
|
|
|
@ -76,15 +76,15 @@ import org.eclipse.rse.services.dstore.util.DownloadListener;
|
|||
import org.eclipse.rse.services.dstore.util.FileSystemMessageUtil;
|
||||
import org.eclipse.rse.services.files.CodePageConverterManager;
|
||||
import org.eclipse.rse.services.files.HostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IFileOwnerService;
|
||||
import org.eclipse.rse.services.files.IFilePermissionsService;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.files.IFileServiceCodePageConverter;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.PendingHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.RemoteFileSecurityException;
|
||||
|
||||
public class DStoreFileService extends AbstractDStoreService implements IFileService, IFilePermissionsService, IFileOwnerService
|
||||
public class DStoreFileService extends AbstractDStoreService implements IFileService, IFilePermissionsService
|
||||
{
|
||||
|
||||
protected org.eclipse.dstore.core.model.DataElement _uploadLogElement = null;
|
||||
|
@ -2076,10 +2076,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
|
||||
|
||||
|
||||
public boolean canGetFilePermissions(String remoteParent, String name) {
|
||||
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
public boolean canGetFilePermissions(IHostFile file) {
|
||||
DataElement remoteFile = ((DStoreHostFile)file).getDataElement();
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS);
|
||||
if (queryCmd != null){
|
||||
|
@ -2088,68 +2086,76 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean canGetFileOwner(String remoteParent, String name) {
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER);
|
||||
if (queryCmd != null){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canSetFilePermissions(String remoteParent, String name) {
|
||||
public boolean canSetFilePermissions(IHostFile file) {
|
||||
// for now just falling back to the same as get
|
||||
return canGetFilePermissions(remoteParent, name);
|
||||
}
|
||||
|
||||
public boolean canSetFileOwner(String remoteParent, String name) {
|
||||
// for now just falling back to the same as get
|
||||
return canGetFileOwner(remoteParent, name);
|
||||
return canGetFilePermissions(file);
|
||||
}
|
||||
|
||||
|
||||
public IHostFilePermissions getFilePermissions(String remoteParent,
|
||||
String name, IProgressMonitor monitor)
|
||||
public IHostFilePermissions getFilePermissions(IHostFile rfile, IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
|
||||
DataElement status = dsStatusCommand(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS, monitor);
|
||||
if (status != null) {
|
||||
int permissionsInt = 0;
|
||||
String accessString = status.getSource(); // access string in octal
|
||||
if (accessString != null && accessString.length() > 0) {
|
||||
try
|
||||
{
|
||||
int accessInt = Integer.parseInt(accessString, 8);
|
||||
permissionsInt = accessInt; // leave permissions in decimal
|
||||
}
|
||||
catch (Exception e){
|
||||
DStoreHostFile file = (DStoreHostFile)rfile;
|
||||
IHostFilePermissions result = file.getPermissions();
|
||||
if (result == null || result instanceof PendingHostFilePermissions){
|
||||
/*
|
||||
* // for now, leaving this to the adapter since it needs to prevent duplicate jobs
|
||||
if (result == null) { // create a pending one
|
||||
result = new PendingHostFilePermissions();
|
||||
file.setPermissions(result);
|
||||
}
|
||||
*/
|
||||
|
||||
DataElement remoteFile = file.getDataElement();
|
||||
|
||||
DataElement status = dsStatusCommand(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS, monitor);
|
||||
if (status != null) {
|
||||
int permissionsInt = 0;
|
||||
|
||||
// access string in the form <octal permissions>|<user>|<group>
|
||||
String permissionsStr = status.getSource();
|
||||
|
||||
if (permissionsStr != null && permissionsStr.length() > 0) {
|
||||
String[] permAttributes = permissionsStr.split("\\"+IServiceConstants.TOKEN_SEPARATOR); //$NON-NLS-1$
|
||||
|
||||
// permissions bits
|
||||
String accessString = permAttributes[0];
|
||||
try
|
||||
{
|
||||
int accessInt = Integer.parseInt(accessString, 8);
|
||||
permissionsInt = accessInt; // leave permissions in decimal
|
||||
}
|
||||
catch (Exception e){
|
||||
}
|
||||
|
||||
// user
|
||||
String user = permAttributes[1];
|
||||
|
||||
// group
|
||||
String group = permAttributes[2];
|
||||
|
||||
result = new HostFilePermissions(permissionsInt, user, group);
|
||||
file.setPermissions(result);
|
||||
}
|
||||
HostFilePermissions permissions = new HostFilePermissions(permissionsInt);
|
||||
return permissions;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing - server may not be up-to-date - missing permissions and owner support
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setFilePermissions(String remoteParent, String name,
|
||||
public void setFilePermissions(IHostFile file,
|
||||
IHostFilePermissions permissions, IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
DataElement remoteFile = ((DStoreHostFile)file).getDataElement();
|
||||
|
||||
ArrayList args = new ArrayList();
|
||||
int bits = permissions.getPermissionBits();
|
||||
String permissionsInOctal = Integer.toOctalString(bits); // from decimal to octal
|
||||
String user = permissions.getUserOwner();
|
||||
String group = permissions.getGroupOwner();
|
||||
|
||||
DataElement newPermissionsElement = getDataStore().createObject(null, "permissions", permissionsInOctal); //$NON-NLS-1$
|
||||
String permissionsStr = permissionsInOctal + '|' + user + '|' + group;
|
||||
DataElement newPermissionsElement = getDataStore().createObject(null, "permissions", permissionsStr); //$NON-NLS-1$
|
||||
args.add(newPermissionsElement);
|
||||
|
||||
DataElement status = dsStatusCommand(remoteFile, args, IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS, monitor);
|
||||
|
@ -2159,78 +2165,28 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
}
|
||||
}
|
||||
|
||||
public int getCapabilities(IHostFile file) {
|
||||
int capabilities = 0;
|
||||
// dstore supports setting and getting
|
||||
if (file == null){
|
||||
capabilities = IFilePermissionsService.FS_CAN_GET_ALL | IFilePermissionsService.FS_CAN_SET_ALL;
|
||||
}
|
||||
else {
|
||||
|
||||
DataElement remoteFile = ((DStoreHostFile)file).getDataElement();
|
||||
DataElement getCmd = getCommandDescriptor(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS);
|
||||
DataElement setCmd = getCommandDescriptor(remoteFile, IUniversalDataStoreConstants.C_SET_FILE_PERMISSIONS);
|
||||
|
||||
public String getFileUserOwner(String remoteParent, String name,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
|
||||
DataElement status = dsStatusCommand(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_USER_OWNER, monitor);
|
||||
if (status != null)
|
||||
{
|
||||
String ownerString = status.getSource();
|
||||
if (ownerString != null && ownerString.length() > 0){
|
||||
return ownerString;
|
||||
if (getCmd != null){
|
||||
capabilities = capabilities | IFilePermissionsService.FS_CAN_GET_ALL;
|
||||
}
|
||||
if (setCmd != null){
|
||||
capabilities = capabilities | IFilePermissionsService.FS_CAN_SET_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing - server may not be up-to-date - missing permissions and owner support
|
||||
return null;
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
public void setFileUserOwner(String remoteParent, String name, String newOwner,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
|
||||
ArrayList args = new ArrayList();
|
||||
DataElement newOwnerElement = getDataStore().createObject(null, "owner", newOwner); //$NON-NLS-1$
|
||||
args.add(newOwnerElement);
|
||||
|
||||
DataElement status = dsStatusCommand(remoteFile, args, IUniversalDataStoreConstants.C_SET_FILE_USER_OWNER, monitor);
|
||||
if (status != null)
|
||||
{
|
||||
// check status to make sure the file really changed
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileGroupOwner(String remoteParent, String name,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
|
||||
DataElement status = dsStatusCommand(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_GROUP_OWNER, monitor);
|
||||
if (status != null)
|
||||
{
|
||||
String ownerString = status.getSource();
|
||||
if (ownerString != null && ownerString.length() > 0){
|
||||
return ownerString;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing - server may not be up-to-date - missing permissions and owner support
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFileGroupOwner(String remoteParent, String name, String newOwner,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + name;
|
||||
DataElement remoteFile = getElementFor(remotePath);
|
||||
|
||||
ArrayList args = new ArrayList();
|
||||
DataElement newOwnerElement = getDataStore().createObject(null, "group", newOwner); //$NON-NLS-1$
|
||||
args.add(newOwnerElement);
|
||||
|
||||
DataElement status = dsStatusCommand(remoteFile, args, IUniversalDataStoreConstants.C_SET_FILE_GROUP_OWNER, monitor);
|
||||
if (status != null)
|
||||
{
|
||||
// check status to make sure the file really changed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -29,8 +29,10 @@ import org.eclipse.rse.services.clientserver.IServiceConstants;
|
|||
import org.eclipse.rse.services.clientserver.PathUtility;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
||||
|
||||
public class DStoreHostFile implements IHostFile
|
||||
public class DStoreHostFile implements IHostFile, IHostFilePermissionsContainer
|
||||
{
|
||||
public static final int ATTRIBUTE_MODIFIED_DATE=1;
|
||||
public static final int ATTRIBUTE_SIZE = 2;
|
||||
|
@ -43,6 +45,7 @@ public class DStoreHostFile implements IHostFile
|
|||
protected DataElement _element;
|
||||
protected boolean _isArchive;
|
||||
protected String _absolutePath;
|
||||
protected IHostFilePermissions _permissions;
|
||||
|
||||
public DStoreHostFile(DataElement element)
|
||||
{
|
||||
|
@ -416,4 +419,12 @@ public class DStoreHostFile implements IHostFile
|
|||
return "true".equals(str); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void setPermissions(IHostFilePermissions permissions){
|
||||
_permissions = permissions;
|
||||
}
|
||||
|
||||
public IHostFilePermissions getPermissions() {
|
||||
return _permissions;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes
|
||||
* David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout
|
||||
* David McKnight (IBM) - [207095] check for null datastore
|
||||
* David McKnight (IBM) - [209593] [api] check for existing query to avoid duplicates
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore;
|
||||
|
@ -102,11 +103,12 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
DataStore ds = getDataStore();
|
||||
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
DataElement status = null;
|
||||
|
||||
// check if there already is an active command for this query
|
||||
DataElement status = smonitor.getCommandStatus(queryCmd, subject);
|
||||
if (args != null)
|
||||
{
|
||||
status = ds.command(queryCmd, args, subject, true);
|
||||
|
@ -117,8 +119,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
try
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
smon.waitForUpdate(status, monitor);
|
||||
smonitor.waitForUpdate(status, monitor);
|
||||
|
||||
int resultSize = subject.getNestedSize();
|
||||
|
||||
|
@ -163,7 +164,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
{
|
||||
List statuses = new ArrayList();
|
||||
DataStore ds = getDataStore();
|
||||
DStoreStatusMonitor smon = getStatusMonitor(ds);
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
|
||||
for (int i = 0; i < subjects.length && !monitor.isCanceled(); i++)
|
||||
|
@ -172,15 +173,17 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
|
||||
DataElement queryCmd = getCommandDescriptor(subject, commands[i]);
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
DataElement status = null;
|
||||
if (argses != null)
|
||||
{
|
||||
status = ds.command(queryCmd, argses[i], subject, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ds.command(queryCmd, subject, true);
|
||||
{
|
||||
// check if there already is an active command for this query
|
||||
DataElement status = smonitor.getCommandStatus(queryCmd, subject);
|
||||
|
||||
if (status == null){
|
||||
if (argses != null){
|
||||
status = ds.command(queryCmd, argses[i], subject, true);
|
||||
}
|
||||
else{
|
||||
status = ds.command(queryCmd, subject, true);
|
||||
}
|
||||
}
|
||||
statuses.add(status);
|
||||
}
|
||||
|
@ -196,9 +199,9 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
|
||||
try
|
||||
{
|
||||
smon.waitForUpdate(status, monitor);
|
||||
smonitor.waitForUpdate(status, monitor);
|
||||
|
||||
if (!monitor.isCanceled() && smon.determineStatusDone(status))
|
||||
if (!monitor.isCanceled() && smonitor.determineStatusDone(status))
|
||||
{
|
||||
List nested = deObj.getNestedData();
|
||||
if (nested != null)
|
||||
|
@ -230,17 +233,22 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
|
||||
protected DataElement dsStatusCommand(DataElement subject, ArrayList args, String command, IProgressMonitor monitor)
|
||||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
DataStore ds = getDataStore();
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
DataElement status = ds.command(queryCmd, args, subject, true);
|
||||
// check if there already is an active command for this query
|
||||
DataElement status = smonitor.getCommandStatus(queryCmd, subject);
|
||||
|
||||
if (status == null){
|
||||
status = ds.command(queryCmd, args, subject, true);
|
||||
}
|
||||
try
|
||||
{
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
smon.waitForUpdate(status, monitor);
|
||||
smonitor.waitForUpdate(status, monitor);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
|
@ -261,16 +269,22 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
|
||||
protected DataElement dsStatusCommand(DataElement subject, String command, IProgressMonitor monitor)
|
||||
{
|
||||
// query roots
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
DataStore ds = getDataStore();
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
DataElement status = ds.command(queryCmd, subject, true);
|
||||
// check if there already is an active command for this query
|
||||
DataElement status = smonitor.getCommandStatus(queryCmd, subject);
|
||||
|
||||
if (status == null){
|
||||
status = ds.command(queryCmd, subject, true);
|
||||
}
|
||||
try
|
||||
{
|
||||
getStatusMonitor(ds).waitForUpdate(status, monitor);
|
||||
smonitor.waitForUpdate(status, monitor);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout
|
||||
* David McKnight (IBM) - [190010] When status is "cancelled" the wait should complete
|
||||
* David McKnight (IBM) - [197480] eliminating UI dependencies
|
||||
* David McKnight (IBM) - [209593] [api] check for existing query to avoid duplicates
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore.util;
|
||||
|
@ -306,6 +307,31 @@ public class DStoreStatusMonitor implements IDomainListener
|
|||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of a running command for the specified cmd desciptor and subject.
|
||||
* If there is no such command running, then null is returned.
|
||||
*
|
||||
* @param cmdDescriptor
|
||||
* @param subject
|
||||
* @return the status of the command.
|
||||
*/
|
||||
public DataElement getCommandStatus(DataElement cmdDescriptor, DataElement subject)
|
||||
{
|
||||
synchronized (_workingStatuses){
|
||||
for (int i = 0; i < _workingStatuses.size(); i++){
|
||||
DataElement status = (DataElement)_workingStatuses.get(i);
|
||||
DataElement cmd = status.getParent();
|
||||
if (cmd.getDescriptor() == cmdDescriptor){
|
||||
DataElement cmdSubject = cmd.get(0).dereference();
|
||||
if (subject == cmdSubject){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void wakeupServer(DataElement status)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Javier Montalvo Orus (Symbian) - [198272] FTP should return classification for symbolic links so they show a link overlay
|
||||
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
|
||||
* Javier Montalvo Orus (Symbian) - [198692] FTP should mark files starting with "." as hidden
|
||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.files.ftp;
|
||||
|
@ -30,9 +31,12 @@ import java.io.File;
|
|||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.eclipse.rse.services.clientserver.PathUtility;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.files.HostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
||||
|
||||
public class FTPHostFile implements IHostFile
|
||||
public class FTPHostFile implements IHostFile, IHostFilePermissionsContainer
|
||||
{
|
||||
|
||||
private String _name;
|
||||
|
@ -46,6 +50,7 @@ public class FTPHostFile implements IHostFile
|
|||
private boolean _canWrite = true;
|
||||
private boolean _isRoot;
|
||||
private boolean _exists;
|
||||
private IHostFilePermissions _permissions;
|
||||
private FTPFile _ftpFile;
|
||||
|
||||
public FTPHostFile(String parentPath, String name, boolean isDirectory, boolean isRoot, long lastModified, long size, boolean exists)
|
||||
|
@ -80,8 +85,12 @@ public class FTPHostFile implements IHostFile
|
|||
|
||||
_isRoot = false;
|
||||
_exists = true;
|
||||
|
||||
initPermissions(ftpFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public long getSize()
|
||||
{
|
||||
|
@ -283,5 +292,30 @@ public class FTPHostFile implements IHostFile
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void initPermissions(FTPFile ftpFile){
|
||||
_permissions = new HostFilePermissions();
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_USER_READ, ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_USER_WRITE, ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_USER_EXECUTE, ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_GROUP_READ, ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_GROUP_WRITE, ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_GROUP_EXECUTE, ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_OTHER_READ, ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_OTHER_WRITE, ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
|
||||
_permissions.setPermission(IHostFilePermissions.PERM_OTHER_EXECUTE, ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
|
||||
|
||||
|
||||
_permissions.setUserOwner(ftpFile.getUser());
|
||||
_permissions.setGroupOwner(ftpFile.getGroup());
|
||||
}
|
||||
|
||||
public IHostFilePermissions getPermissions() {
|
||||
return _permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(IHostFilePermissions permissions) {
|
||||
_permissions = permissions;
|
||||
}
|
||||
|
||||
}
|
|
@ -68,6 +68,7 @@
|
|||
* Javier Montalvo Orus (Symbian) - [208912] Cannot expand /C on a VxWorks SSH Server
|
||||
* David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants
|
||||
* Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND
|
||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.files.ftp;
|
||||
|
@ -108,13 +109,16 @@ import org.eclipse.rse.services.clientserver.messages.IndicatorException;
|
|||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.files.AbstractFileService;
|
||||
import org.eclipse.rse.services.files.IFilePermissionsService;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
||||
import org.eclipse.rse.services.files.RemoteFileCancelledException;
|
||||
import org.eclipse.rse.services.files.RemoteFileIOException;
|
||||
import org.eclipse.rse.services.files.RemoteFileSecurityException;
|
||||
|
||||
public class FTPService extends AbstractFileService implements IFileService, IFTPService
|
||||
public class FTPService extends AbstractFileService implements IFileService, IFTPService, IFilePermissionsService
|
||||
{
|
||||
private FTPClient _ftpClient;
|
||||
private FTPFile[] _ftpFiles;
|
||||
|
@ -1709,5 +1713,24 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
|||
path.append(fileName);
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
|
||||
public IHostFilePermissions getFilePermissions(IHostFile file,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
if (file instanceof IHostFilePermissionsContainer)
|
||||
{
|
||||
return ((IHostFilePermissionsContainer)file).getPermissions();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFilePermissions(IHostFile file,
|
||||
IHostFilePermissions permissions, IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
}
|
||||
|
||||
public int getCapabilities(IHostFile file) {
|
||||
return IFilePermissionsService.FS_CAN_GET_ALL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants
|
||||
* Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND
|
||||
* Kevin Doyle (IBM) - [211374] [ssh] New File on SSH has unnecessary space in its contents
|
||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.ssh.files;
|
||||
|
@ -65,13 +66,17 @@ import org.eclipse.rse.services.clientserver.messages.IndicatorException;
|
|||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.files.AbstractFileService;
|
||||
import org.eclipse.rse.services.files.HostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IFilePermissionsService;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
||||
import org.eclipse.rse.services.files.RemoteFileCancelledException;
|
||||
import org.eclipse.rse.services.files.RemoteFileIOException;
|
||||
import org.eclipse.rse.services.files.RemoteFileSecurityException;
|
||||
|
||||
public class SftpFileService extends AbstractFileService implements IFileService, ISshService
|
||||
public class SftpFileService extends AbstractFileService implements IFileService, ISshService, IFilePermissionsService
|
||||
{
|
||||
|
||||
private static class SftpBufferedInputStream extends BufferedInputStream {
|
||||
|
@ -462,7 +467,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
|||
if (".".equals(fileName) || "..".equals(fileName)) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
//don't show the trivial names
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (filematcher.matches(fileName) || (lsEntry.getAttrs().isDir() && fileType!=IFileService.FILE_TYPE_FOLDERS)) {
|
||||
//get ALL directory names (unless looking for folders only)
|
||||
SftpHostFile node = makeHostFile(parentPath, fileName, lsEntry.getAttrs());
|
||||
|
@ -521,6 +526,8 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SftpHostFile node = new SftpHostFile(parentPath, fileName, attrsTarget.isDir(), false, attrs.isLink(), 1000L * attrs.getMTime(), attrs.getSize());
|
||||
if (linkTarget!=null) {
|
||||
node.setLinkTarget(linkTarget);
|
||||
|
@ -545,6 +552,12 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
|||
if (attrs.getExtended()!=null) {
|
||||
node.setExtendedData(attrs.getExtended());
|
||||
}
|
||||
|
||||
// permissions
|
||||
// TODO get the user and owner from the uid and gid
|
||||
HostFilePermissions permissions = new HostFilePermissions(perms, "" + attrs.getUId(), "" + attrs.getGId());
|
||||
node.setPermissions(permissions);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -1122,4 +1135,30 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
|||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.rse.services.files.IFilePermissionsService#getFilePermissions(IHostFile, IProgressMonitor)
|
||||
*/
|
||||
public IHostFilePermissions getFilePermissions(IHostFile file,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
if (file instanceof IHostFilePermissionsContainer){
|
||||
return ((IHostFilePermissionsContainer)file).getPermissions();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.rse.services.files.IFilePermissionsService#setFilePermissions(IHostFile, IHostFilePermissions, IProgressMonitor)
|
||||
*/
|
||||
public void setFilePermissions(IHostFile file,
|
||||
IHostFilePermissions permissions, IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
return;
|
||||
}
|
||||
|
||||
public int getCapabilities(IHostFile file) {
|
||||
return IFilePermissionsService.FS_CAN_GET_ALL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - Adapted from FTPHostFile.
|
||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.ssh.files;
|
||||
|
@ -21,8 +22,10 @@ import java.io.File;
|
|||
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
||||
|
||||
public class SftpHostFile implements IHostFile {
|
||||
public class SftpHostFile implements IHostFile, IHostFilePermissionsContainer {
|
||||
|
||||
private String fName;
|
||||
private String fParentPath;
|
||||
|
@ -39,6 +42,8 @@ public class SftpHostFile implements IHostFile {
|
|||
private String fLinkTarget;
|
||||
private String[] fExtended = null;
|
||||
|
||||
private IHostFilePermissions _permissions = null;
|
||||
|
||||
//TODO just re-use or extend FTPHostFile instead of copying here?
|
||||
public SftpHostFile(String parentPath, String name, boolean isDirectory, boolean isRoot, boolean isLink, long lastModified, long size) {
|
||||
fParentPath = parentPath;
|
||||
|
@ -215,4 +220,12 @@ public class SftpHostFile implements IHostFile {
|
|||
public boolean canExecute() {
|
||||
return fIsExecutable;
|
||||
}
|
||||
|
||||
public IHostFilePermissions getPermissions() {
|
||||
return _permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(IHostFilePermissions permissions) {
|
||||
_permissions = permissions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,69 @@ public class HostFilePermissions implements
|
|||
IHostFilePermissions {
|
||||
|
||||
private int _permissions = 0;
|
||||
|
||||
private String _user;
|
||||
private String _group;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor that take the initial permissions as a bitmask
|
||||
* @param initialPermissions the intial permissions bitmask
|
||||
* Constructor without any intial values. Users of this
|
||||
* need to set fields as appropriate
|
||||
*/
|
||||
public HostFilePermissions(int initialPermissions){
|
||||
public HostFilePermissions(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor that takes the initial permissions in rwxrwxrwx form
|
||||
* @param alphaPermissions the initial permissions in alpha form
|
||||
*/
|
||||
public HostFilePermissions(String alphaPermissions, String user, String group){
|
||||
String accessString = alphaPermissionsToOctal(alphaPermissions);
|
||||
_permissions = Integer.parseInt(accessString, 8);
|
||||
_user = user;
|
||||
_group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor that takes the initial permissions as a bitmask
|
||||
* @param initialPermissions the initial permissions bitmask
|
||||
*/
|
||||
public HostFilePermissions(int initialPermissions, String user, String group){
|
||||
_permissions = initialPermissions;
|
||||
_user = user;
|
||||
_group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert permissions in rwxrwxrwx form to octal
|
||||
* @param userPermissions
|
||||
* @return
|
||||
*/
|
||||
private String alphaPermissionsToOctal(String alphaPermissions)
|
||||
{
|
||||
if (alphaPermissions.length() == 10){ // directory bit?
|
||||
alphaPermissions = alphaPermissions.substring(1);
|
||||
}
|
||||
StringBuffer buf = new StringBuffer();
|
||||
// permissions
|
||||
char[] chars = alphaPermissions.toCharArray();
|
||||
|
||||
int offset = -1;
|
||||
for (int i = 0; i < 3; i++){
|
||||
int value = 0;
|
||||
|
||||
if (chars[++offset] == 'r'){
|
||||
value = 4;
|
||||
}
|
||||
if (chars[++offset] == 'w'){
|
||||
value += 2;
|
||||
}
|
||||
if (chars[++offset] == 'x'){
|
||||
value += 1;
|
||||
}
|
||||
buf.append(value);
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public void setPermission(int permission, boolean value) {
|
||||
|
@ -53,7 +109,6 @@ public class HostFilePermissions implements
|
|||
return "" + _permissions;
|
||||
}
|
||||
|
||||
|
||||
private boolean isSet(long mask) {
|
||||
return (_permissions & mask) != 0;
|
||||
}
|
||||
|
@ -69,7 +124,7 @@ public class HostFilePermissions implements
|
|||
/**
|
||||
* return permissions in rwxrwxrwx form
|
||||
*/
|
||||
public String toUserString(){
|
||||
public String toAlphaString(){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(getPermission(IHostFilePermissions.PERM_USER_READ) ? 'r' : '-');
|
||||
|
@ -83,4 +138,20 @@ public class HostFilePermissions implements
|
|||
buf.append(getPermission(IHostFilePermissions.PERM_OTHER_EXECUTE) ? 'x' : '-');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String getGroupOwner() {
|
||||
return _group;
|
||||
}
|
||||
|
||||
public String getUserOwner() {
|
||||
return _user;
|
||||
}
|
||||
|
||||
public void setGroupOwner(String group) {
|
||||
_group = group;
|
||||
}
|
||||
|
||||
public void setUserOwner(String user) {
|
||||
_user = user;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight.
|
||||
*
|
||||
* Contributors:
|
||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.services.files;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
|
||||
/**
|
||||
* Service used to get and set the owner of a file.
|
||||
*/
|
||||
public interface IFileOwnerService {
|
||||
/**
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* @param monitor the monitor for this potentially long running operation
|
||||
* @return the host file owner
|
||||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public String getFileUserOwner(String remoteParent, String name, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* @param monitor the monitor for this potentially long running operation
|
||||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public void setFileUserOwner(String remoteParent, String name, String newOwner, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* @param monitor the monitor for this potentially long running operation
|
||||
* @return the host file owner
|
||||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public String getFileGroupOwner(String remoteParent, String name, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* @param monitor the monitor for this potentially long running operation
|
||||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public void setFileGroupOwner(String remoteParent, String name, String newGroupOwner, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the file owner can be retrieved for the specified file
|
||||
* In some cases the service will need to determine whether it supports ownership
|
||||
* depending on the current server.
|
||||
*
|
||||
* @param remoteParent the
|
||||
* @param name
|
||||
* @return whether the file owner can be retrieved
|
||||
*/
|
||||
public boolean canGetFileOwner(String remoteParent, String name);
|
||||
|
||||
/**
|
||||
* Indicates whether the file owner can be set for the specified file
|
||||
*
|
||||
* @param remoteParent the
|
||||
* @param name
|
||||
* @return whether the file owner can be set
|
||||
*/
|
||||
public boolean canSetFileOwner(String remoteParent, String name);
|
||||
}
|
|
@ -22,43 +22,47 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
|||
*/
|
||||
public interface IFilePermissionsService {
|
||||
|
||||
public static int FS_CAN_GET_OWNER = 1 << 0;
|
||||
public static int FS_CAN_GET_GROUP = 1 << 1;
|
||||
public static int FS_CAN_GET_PERMISSIONS = 1 << 2;
|
||||
public static int FS_CAN_SET_OWNER = 1 << 3;
|
||||
public static int FS_CAN_SET_GROUP = 1 << 4;
|
||||
public static int FS_CAN_SET_PERMISSIONS = 1 << 5;
|
||||
|
||||
public static final int FS_CAN_GET_ALL = FS_CAN_GET_OWNER | FS_CAN_GET_GROUP | FS_CAN_GET_PERMISSIONS;
|
||||
public static final int FS_CAN_SET_ALL = FS_CAN_SET_OWNER | FS_CAN_SET_GROUP | FS_CAN_SET_PERMISSIONS;
|
||||
|
||||
|
||||
/**
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* Gets the permissions for a file including the user and group owner
|
||||
*
|
||||
* @param file the remote file
|
||||
* @param monitor the monitor for this potentially long running operation
|
||||
* @return the host file permissions
|
||||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public IHostFilePermissions getFilePermissions(String remoteParent, String name, IProgressMonitor monitor) throws SystemMessageException;
|
||||
public IHostFilePermissions getFilePermissions(IHostFile file, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* Sets the permissions for a file including the user and group owner as specified in the permissions
|
||||
*
|
||||
* @param file the remote file
|
||||
* @param permissions the new permissions for this file
|
||||
* @param monitor the monitor for this potentially long running operation
|
||||
* @throws SystemMessageException if an error occurs.
|
||||
* Typically this would be one of those in the RemoteFileException family.
|
||||
*/
|
||||
public void setFilePermissions(String remoteParent, String name, IHostFilePermissions permissions, IProgressMonitor monitor) throws SystemMessageException;
|
||||
public void setFilePermissions(IHostFile file, IHostFilePermissions permissions, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Indicates whether the file permissions can be retrieved for the specified file.
|
||||
* In some cases the service will need to determine whether it supports permissions
|
||||
* depending on the current server.
|
||||
*
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* @return whether the file permissions can be retrieved
|
||||
*/
|
||||
public boolean canGetFilePermissions(String remoteParent, String name);
|
||||
|
||||
/**
|
||||
* Indicates whether the file permissions can be set for the specified file
|
||||
* Returns the capabilities of this file permissions service for the corresponding file. If
|
||||
* null is specified, this returns the general capabilities of this service.
|
||||
*
|
||||
* @param remoteParent
|
||||
* @param name
|
||||
* @return whether the file permissions can be set
|
||||
* @param file the remote file
|
||||
* @return the capabilities of this service against this file
|
||||
*/
|
||||
public boolean canSetFilePermissions(String remoteParent, String name);
|
||||
public int getCapabilities(IHostFile file);
|
||||
|
||||
}
|
||||
|
|
|
@ -168,4 +168,5 @@ public interface IHostFile {
|
|||
* this file will be renamed to.
|
||||
*/
|
||||
public void renameTo(String newAbsolutePath);
|
||||
|
||||
}
|
||||
|
|
|
@ -114,9 +114,34 @@ public interface IHostFilePermissions {
|
|||
*/
|
||||
public void setPermissionBits(int bits);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* return permissions in rwxrwxrwx form
|
||||
*/
|
||||
public String toUserString();
|
||||
public String toAlphaString();
|
||||
|
||||
/**
|
||||
* returns the user owner of the file
|
||||
* @return the user owner
|
||||
*/
|
||||
public String getUserOwner();
|
||||
|
||||
/**
|
||||
* returns the group owner of the file
|
||||
* @return the group owner
|
||||
*/
|
||||
public String getGroupOwner();
|
||||
|
||||
/**
|
||||
* Sets the user owner attribute
|
||||
* @param user the user owner attribute
|
||||
*/
|
||||
public void setUserOwner(String user);
|
||||
|
||||
/**
|
||||
* Sets the group owner attribute
|
||||
* @param group the group owner attribute
|
||||
*/
|
||||
public void setGroupOwner(String group);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.services.files;
|
||||
|
||||
/**
|
||||
* A container of permissions. Implementations of IHostFile that support
|
||||
* IHostFilePermissions should implement this too
|
||||
*
|
||||
*/
|
||||
public interface IHostFilePermissionsContainer {
|
||||
|
||||
/**
|
||||
* Returns the host file permissions (including user and group) for this file
|
||||
* @return the host file permissions
|
||||
*/
|
||||
public IHostFilePermissions getPermissions();
|
||||
|
||||
/**
|
||||
* TODO remove this API - here for now because we want to prevent duplicate
|
||||
* query jobs from being triggered from SystemViewRemoteFileAdapter.getPropertyValue()
|
||||
*
|
||||
* Sets the permissions attributes for this file. Right now, using this
|
||||
* to set a dummy "Pending" set of permissions from UI when doing asynchronous queries
|
||||
* from property sheet or table view
|
||||
*/
|
||||
public void setPermissions(IHostFilePermissions permissions);
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@ public class PendingHostFilePermissions extends HostFilePermissions {
|
|||
|
||||
public PendingHostFilePermissions()
|
||||
{
|
||||
super(0);
|
||||
super(0, "Pending", "Pending"); //$NON-NLS-2$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
********************************************************************************/
|
||||
package org.eclipse.rse.internal.subsystems.files.core;
|
||||
|
||||
import org.eclipse.rse.services.files.IFileOwnerService;
|
||||
import org.eclipse.rse.services.files.IFilePermissionsService;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
|
||||
|
@ -44,11 +43,6 @@ public class RemoteFilePermissionsAdapterFactory extends
|
|||
return fileService;
|
||||
}
|
||||
}
|
||||
else if (adapterType == IFileOwnerService.class){
|
||||
if (fileService instanceof IFileOwnerService){
|
||||
return fileService;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,6 +54,6 @@ public class RemoteFilePermissionsAdapterFactory extends
|
|||
*/
|
||||
public Class[] getAdapterList()
|
||||
{
|
||||
return new Class[] {IFilePermissionsService.class, IFileOwnerService.class};
|
||||
return new Class[] {IFilePermissionsService.class};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,4 +199,5 @@ public abstract class AbstractRemoteFile extends RemoteFile implements IRemoteFi
|
|||
return _hostFile;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -342,16 +342,4 @@ public interface IRemoteFile extends IRemoteContainer, IRemotePropertyHolder, IS
|
|||
*/
|
||||
public IHostFilePermissions getPermissions();
|
||||
|
||||
/**
|
||||
* Returns the owner for this file if it exists
|
||||
* @return the owner
|
||||
*/
|
||||
public String getOwner();
|
||||
|
||||
/**
|
||||
* Returns the group for this file if it exists
|
||||
* @return the group
|
||||
*/
|
||||
public String getGroup();
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,9 @@ import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType;
|
|||
import org.eclipse.rse.services.clientserver.StringComparePatternMatcher;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
||||
import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry;
|
||||
import org.eclipse.rse.ui.SystemBasePlugin;
|
||||
|
@ -100,10 +102,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
|||
protected HashMap properties = new HashMap();
|
||||
protected HashMap propertyStates = new HashMap();
|
||||
|
||||
// permissions
|
||||
protected IHostFilePermissions _permissions;
|
||||
protected String _owner;
|
||||
protected String _group;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor that takes a context object containing important information.
|
||||
|
@ -907,9 +906,6 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
|||
public void markStale(boolean isStale, boolean clearCache)
|
||||
{
|
||||
_isStale = isStale;
|
||||
_owner = null;
|
||||
_group = null;
|
||||
_permissions = null;
|
||||
|
||||
if (isStale && clearCache)
|
||||
{
|
||||
|
@ -1207,32 +1203,12 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
|||
public void setEncoding(String encoding) {
|
||||
RemoteFileEncodingManager.getInstance().setEncoding(getHostName(), getAbsolutePath(), encoding);
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
_group = group;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public void setPermissions(IHostFilePermissions permissions) {
|
||||
_permissions = permissions;
|
||||
}
|
||||
|
||||
|
||||
public String getGroup() {
|
||||
return _group;
|
||||
}
|
||||
|
||||
|
||||
public String getOwner() {
|
||||
return _owner;
|
||||
}
|
||||
|
||||
|
||||
public IHostFilePermissions getPermissions() {
|
||||
return _permissions;
|
||||
IHostFile hostFile = getHostFile();
|
||||
if (hostFile instanceof IHostFilePermissionsContainer){
|
||||
return ((IHostFilePermissionsContainer)hostFile).getPermissions();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -200,7 +201,12 @@ public class RemoteFileEmpty extends RemoteFile
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override this to provide permissions
|
||||
*/
|
||||
public IHostFilePermissions getPermissions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
|
||||
/**
|
||||
* A root node used to drive a CheckboxTreeAndListGroup, or any viewer which
|
||||
|
@ -102,8 +103,7 @@ public class RemoteFileRoot extends RemoteFile
|
|||
}
|
||||
public String getRoot()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return rootFile.getAbsolutePath();
|
||||
}
|
||||
public String getParentName()
|
||||
{
|
||||
|
@ -112,68 +112,71 @@ public class RemoteFileRoot extends RemoteFile
|
|||
}
|
||||
public boolean isRoot()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public boolean isDirectory()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public boolean isFile()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canRead()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return rootFile.canRead();
|
||||
}
|
||||
|
||||
public boolean canWrite()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return rootFile.canWrite();
|
||||
}
|
||||
|
||||
public boolean exists()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return rootFile.exists();
|
||||
}
|
||||
|
||||
public long getLastModified()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return rootFile.getLastModified();
|
||||
}
|
||||
|
||||
public long getLength()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return rootFile.getLength();
|
||||
}
|
||||
|
||||
public boolean showReadOnlyProperty()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return rootFile.showReadOnlyProperty();
|
||||
}
|
||||
|
||||
public String getClassification()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return rootFile.getClassification();
|
||||
}
|
||||
|
||||
public String getCanonicalPath()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return rootFile.getCanonicalPath();
|
||||
}
|
||||
|
||||
public IHostFile getHostFile()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return rootFile.getHostFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this to provide permissions
|
||||
*/
|
||||
public IHostFilePermissions getPermissions() {
|
||||
return rootFile.getPermissions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,9 +202,4 @@ public class DStoreFile extends AbstractRemoteFile implements IRemoteFile
|
|||
return _dstoreHostFile.getClassification();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue