1 package org
.argeo
.slc
.vfs
;
3 import java
.util
.HashMap
;
6 import org
.apache
.commons
.vfs2
.FileObject
;
7 import org
.apache
.commons
.vfs2
.FileSystemException
;
8 import org
.apache
.commons
.vfs2
.FileSystemManager
;
9 import org
.apache
.commons
.vfs2
.VFS
;
10 import org
.argeo
.slc
.SlcException
;
11 import org
.argeo
.slc
.core
.deploy
.ResourceSet
;
12 import org
.springframework
.core
.io
.Resource
;
14 public class VfsResourceSet
implements ResourceSet
{
17 public Map
<String
, Resource
> listResources() {
19 FileSystemManager fileSystemManager
= VFS
.getManager();
20 FileObject fileObject
= fileSystemManager
.resolveFile(base
);
21 Map
<String
, Resource
> map
= new HashMap
<String
, Resource
>();
22 addToMap(map
, "", fileObject
);
26 } catch (FileSystemException e
) {
27 throw new SlcException("Cannot list VFS resources from " + base
, e
);
32 protected void addToMap(Map
<String
, Resource
> map
, String parentPath
,
33 FileObject fileObject
) {
35 String newParentPath
= parentPath
36 + fileObject
.getName().getBaseName() + '/';
37 if (fileObject
.getType().hasChildren()) {
38 for (FileObject child
: fileObject
.getChildren()) {
39 addToMap(map
, newParentPath
, child
);
42 map
.put(parentPath
+ fileObject
.getName().getBaseName(),
43 new VfsResource(fileObject
));
45 } catch (FileSystemException e
) {
46 throw new SlcException("Cannot add children from " + parentPath
, e
);
50 public void setBase(String base
) {