/** * Mounts the first available VFS file system on the given dataspace * * @param spaceInfo space information * @throws FileSystemException if no file system could be mounted */ private void mountFirstAvailableFileSystem(final SpaceInstanceInfo spaceInfo) throws FileSystemException { final DataSpacesURI mountingPoint = spaceInfo.getMountingPoint(); try { writeLock.lock(); if (!mountedSpaces.containsKey(mountingPoint)) { mountedSpaces.put(mountingPoint, new ConcurrentHashMap<String, FileObject>()); } ConcurrentHashMap<String, FileObject> fileSystems = mountedSpaces.get(mountingPoint); if (spaceInfo.getUrls().size() == 0) { throw new IllegalStateException("Empty Space configuration"); } DataSpacesURI spacePart = mountingPoint.getSpacePartOnly(); ArrayList<String> urls = new ArrayList<String>(spaceInfo.getUrls()); if (urls.size() == 1) { urls.add( 0, Utils.getLocalAccessURL(urls.get(0), spaceInfo.getPath(), spaceInfo.getHostname())); } logger.debug("[VFSMountManager] Request mounting VFS root list : " + urls); try { VFSMountManagerHelper.mountAny(urls, fileSystems); if (!accessibleFileObjectUris.containsKey(mountingPoint)) { LinkedHashSet<String> srl = new LinkedHashSet<String>(); accessibleFileObjectUris.put(mountingPoint, srl); } LinkedHashSet<String> srl = accessibleFileObjectUris.get(mountingPoint); for (String uri : urls) { if (fileSystems.containsKey(uri)) { srl.add(uri); } } if (srl.isEmpty()) { throw new IllegalStateException( "Invalid empty size list when trying to mount " + urls + " mounted map content is " + fileSystems); } accessibleFileObjectUris.put(mountingPoint, srl); if (logger.isDebugEnabled()) logger.debug( String.format( "[VFSMountManager] Mounted space: %s (access URL: %s)", spacePart, srl)); mountedSpaces.put(mountingPoint, fileSystems); } catch (org.apache.commons.vfs.FileSystemException e) { mountedSpaces.remove(mountingPoint); throw new FileSystemException( "An error occurred while trying to mount " + spaceInfo.getName(), e); } } finally { writeLock.unlock(); } }