1 package org
.argeo
.eclipse
.ui
.jcr
;
3 import java
.util
.ArrayList
;
4 import java
.util
.Arrays
;
8 import javax
.jcr
.RepositoryException
;
9 import javax
.jcr
.Session
;
11 import org
.argeo
.ArgeoException
;
12 import org
.argeo
.jcr
.JcrUtils
;
14 /** Simple JCR node content provider taking a list of String as base path. */
15 public class SimpleNodeContentProvider
extends AbstractNodeContentProvider
{
16 private final List
<String
> basePaths
;
17 private Boolean mkdirs
= false;
19 public SimpleNodeContentProvider(Session session
, String
... basePaths
) {
20 this(session
, Arrays
.asList(basePaths
));
23 public SimpleNodeContentProvider(Session session
, List
<String
> basePaths
) {
25 this.basePaths
= basePaths
;
29 protected Boolean
isBasePath(String path
) {
30 if (basePaths
.contains(path
))
32 return super.isBasePath(path
);
35 public Object
[] getElements(Object inputElement
) {
37 List
<Node
> baseNodes
= new ArrayList
<Node
>();
38 for (String basePath
: basePaths
)
39 if (mkdirs
&& !getSession().itemExists(basePath
))
40 baseNodes
.add(JcrUtils
.mkdirs(getSession(), basePath
));
42 baseNodes
.add(getSession().getNode(basePath
));
43 return baseNodes
.toArray();
44 } catch (RepositoryException e
) {
45 throw new ArgeoException("Cannot get base nodes for " + basePaths
,
50 public List
<String
> getBasePaths() {
54 public void setMkdirs(Boolean mkdirs
) {