use of org.apache.commons.vfs2.FileSystemException in project jackrabbit by apache.
the class VFSTestUtils method deleteAllDescendantFiles.
/**
* Deletes all the descendant files under the folder.
* @param folderObject folder object
* @throws FileSystemException if any file system exception occurs
* @throws DataStoreException if any file system exception occurs
*/
static void deleteAllDescendantFiles(FileObject folderObject) throws FileSystemException, DataStoreException {
List<FileObject> children = VFSUtils.getChildFileOrFolders(folderObject);
FileType fileType;
for (FileObject child : children) {
fileType = child.getType();
if (fileType == FileType.FILE) {
boolean deleted = child.delete();
if (!deleted) {
LOG.warn("File not deleted: {}", child.getName().getFriendlyURI());
}
} else if (fileType == FileType.FOLDER) {
deleteAllDescendantFiles(child);
}
}
}
use of org.apache.commons.vfs2.FileSystemException in project jackrabbit by apache.
the class VFSBackend method getExistingFileObject.
/**
* Returns the identified file object. If not existing, returns null.
*
* @param identifier data identifier
* @return identified file object
* @throws DataStoreException if any file system exception occurs
*/
protected FileObject getExistingFileObject(DataIdentifier identifier) throws DataStoreException {
String relPath = resolveFileObjectRelPath(identifier);
String[] segments = relPath.split("/");
FileObject tempFileObject = getBaseFolderObject();
try {
for (int i = 0; i < segments.length; i++) {
tempFileObject = tempFileObject.getChild(segments[i]);
if (tempFileObject == null) {
return null;
}
}
return tempFileObject;
} catch (FileSystemException e) {
throw new DataStoreException("File object not resolved: " + identifier, e);
}
}
use of org.apache.commons.vfs2.FileSystemException 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.FileSystemException 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.FileSystemException in project jackrabbit by apache.
the class VFSDataStore method createFileSystemManager.
/**
* Creates a {@link FileSystemManager} instance.
* @return a {@link FileSystemManager} instance.
* @throws RepositoryException if an error occurs creating the manager.
*/
protected FileSystemManager createFileSystemManager() throws RepositoryException {
FileSystemManager fileSystemManager = null;
try {
if (getFileSystemManagerClassName() == null) {
fileSystemManager = new StandardFileSystemManager();
} else {
final Class<?> mgrClass = Class.forName(getFileSystemManagerClassName());
fileSystemManager = (FileSystemManager) mgrClass.newInstance();
}
if (fileSystemManager instanceof DefaultFileSystemManager) {
((DefaultFileSystemManager) fileSystemManager).init();
}
} catch (final FileSystemException e) {
throw new RepositoryException("Could not initialize file system manager of class: " + getFileSystemManagerClassName(), e);
} catch (final Exception e) {
throw new RepositoryException("Could not create file system manager of class: " + getFileSystemManagerClassName(), e);
}
return fileSystemManager;
}
Aggregations