- if (defaultSession == null)
- return null;
- else {
- Query groupQuery = defaultSession
- .getWorkspace()
- .getQueryManager()
- .createQuery(
- "select * from [" + SlcTypes.SLC_GROUP_BASE
- + "] as group order by group.["
- + SlcNames.SLC_GROUP_BASE_ID + "]",
- Query.JCR_SQL2);
- NodeIterator groups = groupQuery.execute().getNodes();
- while (groups.hasNext()) {
- addChild(new GroupBaseElem(WorkspaceElem.this, groups
- .nextNode()
- .getProperty(SlcNames.SLC_GROUP_BASE_ID)
- .getString()));
+ // Lazy connect the first time we retrieve children
+ if (currSession == null)
+ login();
+
+ // Retrieve already existing distribution
+
+ // Use QOM rather than SQL2 - it seems more robust for remoting
+ // with JCR 2.2 (might also be some model refresh issue with the
+ // remoting)
+ QueryManager queryManager = currSession.getWorkspace()
+ .getQueryManager();
+ QueryObjectModelFactory factory = queryManager.getQOMFactory();
+ Selector selector = factory.selector(
+ SlcTypes.SLC_MODULAR_DISTRIBUTION,
+ SlcTypes.SLC_MODULAR_DISTRIBUTION);
+ // Curiously this works...
+ // Selector selector = factory.selector(
+ // SlcTypes.SLC_JAR_FILE,
+ // SlcTypes.SLC_JAR_FILE);
+
+ QueryObjectModel query = factory.createQuery(selector, null,
+ null, null);
+
+ // Query groupQuery = currSession
+ // .getWorkspace()
+ // .getQueryManager()
+ // .createQuery(
+ // "select * from ["
+ // + SlcTypes.SLC_MODULAR_DISTRIBUTION
+ // + "]", Query.JCR_SQL2);
+ NodeIterator distributions = null;
+ try {
+ distributions = query.execute().getNodes();
+ } catch (InvalidQueryException iqe) {
+ // For legacy only does not throw an exception while
+ // browsing
+ // legacy repositories that does not know
+ // SLC_MODULAR_DISTRIBUTION type
+ }
+ distribs: while (distributions != null
+ && distributions.hasNext()) {
+ Node currDist = distributions.nextNode();
+ Node distBase = currDist.getParent().getParent();
+ if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
+ continue distribs;
+ String groupId = distBase
+ .getProperty(SlcNames.SLC_GROUP_ID).getString();
+ String artifactId = distBase.getProperty(
+ SlcNames.SLC_ARTIFACT_ID).getString();
+
+ String name;
+ String type;
+ if (ModularDistVersionBaseElem.AETHER_BINARIES_TYPE
+ .equals(artifactId)) {
+ name = groupId;
+ type = ModularDistVersionBaseElem.AETHER_BINARIES_TYPE;
+ } else {
+ name = artifactId;
+ type = ModularDistVersionBaseElem.AETHER_DEP_TYPE;