use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class QuickFindAction method performAction.
@Override
public void performAction() {
AbstractFile currentFile = mainFrame.getActivePanel().getCurrentFolder();
FileURL searchURL = SearchUtils.toSearchURL(currentFile);
LocationTextField locationTextField = mainFrame.getActivePanel().getLocationTextField();
locationTextField.setText(searchURL.toString());
locationTextField.requestFocus();
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class VSphereFile method ls.
@Override
public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException {
List<GuestFileInfo> fileInfos = new ArrayList<GuestFileInfo>();
int index = 0;
VsphereConnHandler connHandler = null;
try {
connHandler = getConnHandler();
ManagedObjectReference fileManager = getFileManager(connHandler);
boolean haveRemaining;
do {
GuestListFileInfo res = connHandler.getClient().getVimPort().listFilesInGuest(fileManager, vm, credentials, getPathInVm(), index, null, null);
haveRemaining = (res.getRemaining() != 0);
fileInfos.addAll(res.getFiles());
index = fileInfos.size();
} while (haveRemaining);
String parentPath = PathUtils.removeTrailingSeparator(fileURL.getPath()) + SEPARATOR;
Collection<AbstractFile> res = new ArrayList<AbstractFile>();
for (GuestFileInfo f : fileInfos) {
final String name = getFileName(f.getPath());
if (name.equals(".") || name.equals("..")) {
continue;
}
FileURL childURL = (FileURL) fileURL.clone();
childURL.setPath(parentPath + name);
AbstractFile newFile = new VSphereFile(childURL, this, f);
res.add(newFile);
}
return res.toArray(new AbstractFile[0]);
} catch (FileFaultFaultMsg e) {
translateandLogException(e);
} catch (GuestOperationsFaultFaultMsg e) {
translateandLogException(e);
} catch (InvalidStateFaultMsg e) {
translateandLogException(e);
} catch (RuntimeFaultFaultMsg e) {
translateandLogException(e);
} catch (TaskInProgressFaultMsg e) {
translateandLogException(e);
} catch (InvalidPropertyFaultMsg e) {
translateandLogException(e);
} catch (URISyntaxException e) {
translateandLogException(e);
} finally {
releaseConnHandler(connHandler);
}
// we never get here..
return null;
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class VSphereFile method getRoot.
@Override
public AbstractFile getRoot() {
FileURL rootURL = (FileURL) getURL().clone();
String rootPath = getRootPath();
rootURL.setPath("/" + vmIdentifier + "/" + rootPath);
return FileFactory.getFile(rootURL);
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class S3File method getParent.
// ///////////////////////////////
// ProtocolFile implementation //
// ///////////////////////////////
@Override
public AbstractFile getParent() {
if (!parentSet) {
FileURL parentFileURL = this.fileURL.getParent();
if (parentFileURL != null) {
try {
parent = FileFactory.getFile(parentFileURL, null, Collections.singletonMap("service", service));
} catch (IOException e) {
// No parent
}
}
parentSet = true;
}
return parent;
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class S3File method listObjects.
protected AbstractFile[] listObjects(String bucketName, String prefix, S3File parent) throws IOException {
try {
StorageObjectsChunk chunk = service.listObjectsChunked(bucketName, prefix, "/", Constants.DEFAULT_OBJECT_LIST_CHUNK_SIZE, null, true);
StorageObject[] objects = chunk.getObjects();
String[] commonPrefixes = chunk.getCommonPrefixes();
if (objects.length == 0 && !prefix.equals("")) {
// This happens only when the directory does not exist
throw new IOException();
}
AbstractFile[] children = new AbstractFile[objects.length + commonPrefixes.length];
FileURL childURL;
int i = 0;
String objectKey;
for (StorageObject object : objects) {
// Discard the object corresponding to the prefix itself
objectKey = object.getKey();
if (objectKey.equals(prefix))
continue;
childURL = (FileURL) fileURL.clone();
childURL.setPath(bucketName + "/" + objectKey);
Map<String, Object> parameters = new HashMap<>();
parameters.put("service", service);
parameters.put("object", object);
children[i] = FileFactory.getFile(childURL, parent, parameters);
i++;
}
org.jets3t.service.model.S3Object directoryObject;
for (String commonPrefix : commonPrefixes) {
childURL = (FileURL) fileURL.clone();
childURL.setPath(bucketName + "/" + commonPrefix);
directoryObject = new org.jets3t.service.model.S3Object(commonPrefix);
// Common prefixes are not objects per se, and therefore do not have a date, content-length nor owner.
directoryObject.setLastModifiedDate(new Date(System.currentTimeMillis()));
directoryObject.setContentLength(0);
Map<String, Object> parameters = new HashMap<>();
parameters.put("service", service);
parameters.put("object", directoryObject);
children[i] = FileFactory.getFile(childURL, parent, parameters);
i++;
}
// to know in advance whether the prefix will appear in the results or not.
if (i < children.length) {
AbstractFile[] childrenTrimmed = new AbstractFile[i];
System.arraycopy(children, 0, childrenTrimmed, 0, i);
return childrenTrimmed;
}
return children;
} catch (ServiceException e) {
throw getIOException(e);
}
}
Aggregations