- // TODO factorize with a traverser pattern?
- for (NodeIterator artifactBases = groupNode.getNodes(); artifactBases
- .hasNext();) {
- Node artifactBase = artifactBases.nextNode();
- if (artifactBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
- for (NodeIterator artifactVersions = artifactBase
- .getNodes(); artifactVersions.hasNext();) {
- Node artifactVersion = artifactVersions.nextNode();
- if (artifactVersion
- .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE))
- for (NodeIterator files = artifactVersion
- .getNodes(); files.hasNext();) {
- Node file = files.nextNode();
- if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
- preProcessBundleArtifact(file);
- file.getSession().save();
- if (log.isDebugEnabled())
- log.debug("Pre-processed "
- + file.getName());
- }
+ processGroupNode(groupNode, null);
+ } catch (Exception e) {
+ throw new SlcException("Cannot normalize group " + groupId + " in "
+ + workspace, e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ }
+ }
+
+ public static void processGroupNode(Node groupNode, String version,
+ Boolean overridePoms, ArgeoMonitor monitor)
+ throws RepositoryException {
+ // TODO set artifactsBase based on group node
+ NormalizeGroup ng = new NormalizeGroup();
+ String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
+ .getString();
+ ng.setGroupId(groupId);
+ ng.setVersion(version);
+ ng.setOverridePoms(overridePoms);
+ ng.processGroupNode(groupNode, monitor);
+ }
+
+ protected void processGroupNode(Node groupNode, ArgeoMonitor monitor)
+ throws RepositoryException {
+ if (monitor != null)
+ monitor.subTask("Group " + groupId);
+ Node allArtifactsHighestVersion = null;
+ Session session = groupNode.getSession();
+ aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
+ .hasNext();) {
+ Node aBase = aBases.nextNode();
+ if (aBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+ Node highestAVersion = null;
+ for (NodeIterator aVersions = aBase.getNodes(); aVersions
+ .hasNext();) {
+ Node aVersion = aVersions.nextNode();
+ if (aVersion.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+ if (highestAVersion == null) {
+ highestAVersion = aVersion;
+ if (allArtifactsHighestVersion == null)
+ allArtifactsHighestVersion = aVersion;
+
+ // BS will fail if artifacts arrive in this order
+ // Name1 - V1, name2 - V3, V1 will remain the
+ // allArtifactsHighestVersion
+ // Fixed below
+ else {
+ Version currVersion = extractOsgiVersion(aVersion);
+ Version highestVersion = extractOsgiVersion(allArtifactsHighestVersion);
+ if (currVersion.compareTo(highestVersion) > 0)
+ allArtifactsHighestVersion = aVersion;
+ }