use of org.apache.commons.vfs2.FileObject in project jackrabbit by apache.
the class VFSBackend method getAllIdentifiers.
/**
* {@inheritDoc}
*/
@Override
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException {
List<DataIdentifier> identifiers = new LinkedList<DataIdentifier>();
try {
for (FileObject fileObject : VFSUtils.getChildFolders(getBaseFolderObject())) {
// skip top-level files
pushIdentifiersRecursively(identifiers, fileObject);
}
} catch (FileSystemException e) {
throw new DataStoreException("Object identifiers not resolved.", e);
}
LOG.debug("Found " + identifiers.size() + " identifiers.");
return identifiers.iterator();
}
use of org.apache.commons.vfs2.FileObject in project jackrabbit by apache.
the class VFSBackend method updateLastModifiedTime.
/**
* Set the last modified time of a fileObject, if the fileObject is writable.
* @param fileObject the file object
* @throws DataStoreException if the fileObject is writable but modifying the date fails
*/
private void updateLastModifiedTime(FileObject fileObject) throws DataStoreException {
try {
if (isTouchFilePreferred()) {
getTouchFileObject(fileObject, true);
} else {
long time = System.currentTimeMillis() + ACCESS_TIME_RESOLUTION;
fileObject.getContent().setLastModifiedTime(time);
}
} catch (FileSystemException e) {
throw new DataStoreException("An IO Exception occurred while trying to set the last modified date: " + fileObject.getName().getFriendlyURI(), e);
}
}
use of org.apache.commons.vfs2.FileObject in project jackrabbit by apache.
the class VFSUtils method createChildFile.
/**
* Creates a child file by the {@code name} under the {@code baseFolder} and retrieves the created file.
* @param baseFolder base folder object
* @param name child file name
* @return a child file by the {@code name} under the {@code baseFolder} and retrieves the created file
* @throws DataStoreException if any file system exception occurs
*/
static FileObject createChildFile(FileObject baseFolder, String name) throws DataStoreException {
FileObject childFile = null;
try {
childFile = baseFolder.resolveFile(name);
if (!childFile.exists()) {
childFile.createFile();
childFile = baseFolder.getChild(childFile.getName().getBaseName());
}
} catch (FileSystemException e) {
throw new DataStoreException("Could not create a child file, '" + name + "' under " + baseFolder.getName().getFriendlyURI(), e);
}
return childFile;
}
use of org.apache.commons.vfs2.FileObject in project jackrabbit by apache.
the class VFSUtils method createChildFolder.
/**
* Creates a child folder by the {@code name} under the {@code baseFolder} and retrieves the created folder.
* @param baseFolder base folder object
* @param name child folder name
* @return a child folder by the {@code name} under the {@code baseFolder} and retrieves the created folder
* @throws DataStoreException if any file system exception occurs
*/
static FileObject createChildFolder(FileObject baseFolder, String name) throws DataStoreException {
FileObject childFolder = null;
try {
childFolder = baseFolder.resolveFile(name);
if (!childFolder.exists()) {
childFolder.createFolder();
childFolder = baseFolder.getChild(childFolder.getName().getBaseName());
}
} catch (FileSystemException e) {
throw new DataStoreException("Could not create a child folder, '" + name + "' under " + baseFolder.getName().getFriendlyURI(), e);
}
return childFolder;
}
use of org.apache.commons.vfs2.FileObject in project zeppelin by apache.
the class VFSNotebookRepo method getNote.
private Note getNote(FileObject noteDir) throws IOException {
if (!isDirectory(noteDir)) {
throw new IOException(noteDir.getName().toString() + " is not a directory");
}
FileObject noteJson = noteDir.resolveFile("note.json", NameScope.CHILD);
if (!noteJson.exists()) {
throw new IOException(noteJson.getName().toString() + " not found");
}
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setPrettyPrinting();
Gson gson = gsonBuilder.registerTypeAdapter(Date.class, new NotebookImportDeserializer()).create();
FileContent content = noteJson.getContent();
InputStream ins = content.getInputStream();
String json = IOUtils.toString(ins, conf.getString(ConfVars.ZEPPELIN_ENCODING));
ins.close();
Note note = gson.fromJson(json, Note.class);
for (Paragraph p : note.getParagraphs()) {
if (p.getStatus() == Status.PENDING || p.getStatus() == Status.RUNNING) {
p.setStatus(Status.ABORT);
}
List<ApplicationState> appStates = p.getAllApplicationStates();
if (appStates != null) {
for (ApplicationState app : appStates) {
if (app.getStatus() != ApplicationState.Status.ERROR) {
app.setStatus(ApplicationState.Status.UNLOADED);
}
}
}
}
return note;
}
Aggregations