From 305ecfa036fac8562fbb3af875c6ecf5822b6dcb Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sun, 16 Feb 2020 11:56:55 +0100 Subject: [PATCH] Rename CategoryNameVersion. --- ...NameVersion.java => CategoryNameVersion.java} | 6 +++--- ...sion.java => DefaultCategoryNameVersion.java} | 10 +++++----- .../argeo/slc/repo/ArgeoOsgiDistribution.java | 4 ++-- .../org/argeo/slc/repo/ArtifactDistribution.java | 8 ++++---- .../slc/repo/ModularDistributionFactory.java | 14 +++++++------- .../slc/repo/ModularDistributionIndexer.java | 16 ++++++++-------- .../org/argeo/slc/repo/osgi/ArchiveWrapper.java | 6 +++--- ...CategorizedNV.java => ArchiveWrapperCNV.java} | 8 ++++---- .../slc/repo/osgi/ArgeoOsgiDistributionImpl.java | 12 ++++++------ .../src/org/argeo/slc/repo/osgi/BndWrapper.java | 8 ++++---- .../argeo/slc/repo/osgi/ProcessDistribution.java | 8 ++++---- 11 files changed, 50 insertions(+), 50 deletions(-) rename org.argeo.slc.api/src/org/argeo/slc/{CategorizedNameVersion.java => CategoryNameVersion.java} (75%) rename org.argeo.slc.api/src/org/argeo/slc/{DefaultCategorizedNameVersion.java => DefaultCategoryNameVersion.java} (50%) rename org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/{OsgiCategorizedNV.java => ArchiveWrapperCNV.java} (57%) diff --git a/org.argeo.slc.api/src/org/argeo/slc/CategorizedNameVersion.java b/org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java similarity index 75% rename from org.argeo.slc.api/src/org/argeo/slc/CategorizedNameVersion.java rename to org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java index b890340cd..b335996dd 100644 --- a/org.argeo.slc.api/src/org/argeo/slc/CategorizedNameVersion.java +++ b/org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java @@ -4,17 +4,17 @@ package org.argeo.slc; * Adds a dimension to {@link NameVersion} by adding an arbitrary category (e.g. * Maven groupId, yum repository ID, etc.) */ -public interface CategorizedNameVersion extends NameVersion { +public interface CategoryNameVersion extends NameVersion { /** The category of the component. */ String getCategory(); - static CategorizedNameVersion parseCategoryNameVersion(String str) { + static CategoryNameVersion parseCategoryNameVersion(String str) { if (str == null || "".equals(str.trim())) throw new IllegalArgumentException("At least one character required."); String[] arr = str.trim().split(":"); if (arr.length > 3) throw new IllegalArgumentException(str + " does not respect the [category]:[name]:[version] pattern"); - DefaultCategorizedNameVersion res = new DefaultCategorizedNameVersion(); + DefaultCategoryNameVersion res = new DefaultCategoryNameVersion(); res.setCategory(arr[0]); if (arr.length > 1) res.setName(arr[1]); diff --git a/org.argeo.slc.api/src/org/argeo/slc/DefaultCategorizedNameVersion.java b/org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java similarity index 50% rename from org.argeo.slc.api/src/org/argeo/slc/DefaultCategorizedNameVersion.java rename to org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java index a30970e45..6506599a9 100644 --- a/org.argeo.slc.api/src/org/argeo/slc/DefaultCategorizedNameVersion.java +++ b/org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java @@ -1,18 +1,18 @@ package org.argeo.slc; -/** Canonical implementation of {@link CategorizedNameVersion} */ -public class DefaultCategorizedNameVersion extends DefaultNameVersion implements CategorizedNameVersion { +/** Canonical implementation of {@link CategoryNameVersion} */ +public class DefaultCategoryNameVersion extends DefaultNameVersion implements CategoryNameVersion { private String category; - public DefaultCategorizedNameVersion() { + public DefaultCategoryNameVersion() { } - public DefaultCategorizedNameVersion(String category, String name, String version) { + public DefaultCategoryNameVersion(String category, String name, String version) { super(name, version); this.category = category; } - public DefaultCategorizedNameVersion(String category, NameVersion nameVersion) { + public DefaultCategoryNameVersion(String category, NameVersion nameVersion) { super(nameVersion); this.category = category; } diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java index 493486e23..4b8878a5d 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java @@ -1,11 +1,11 @@ package org.argeo.slc.repo; -import org.argeo.slc.CategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; import org.argeo.slc.build.Distribution; import org.argeo.slc.build.ModularDistribution; /** Aether compatible OSGi distribution */ public interface ArgeoOsgiDistribution extends Distribution, - CategorizedNameVersion, ModularDistribution { + CategoryNameVersion, ModularDistribution { } diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java index 9a03b0157..bc496f18f 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java @@ -1,13 +1,13 @@ package org.argeo.slc.repo; -import org.argeo.slc.CategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; import org.argeo.slc.build.Distribution; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; /** A {@link Distribution} based on an Aether {@link Artifact} */ public class ArtifactDistribution implements Distribution, - CategorizedNameVersion { + CategoryNameVersion { private final Artifact artifact; public ArtifactDistribution(Artifact artifact) { @@ -46,8 +46,8 @@ public class ArtifactDistribution implements Distribution, @Override public boolean equals(Object obj) { - if (obj instanceof CategorizedNameVersion) { - CategorizedNameVersion cnv = (CategorizedNameVersion) obj; + if (obj instanceof CategoryNameVersion) { + CategoryNameVersion cnv = (CategoryNameVersion) obj; return getCategory().equals(cnv.getCategory()) && getName().equals(cnv.getName()) && getVersion().equals(cnv.getVersion()); diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java index 9c13ce048..19627d8ff 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java @@ -22,7 +22,7 @@ import javax.jcr.Session; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.argeo.jcr.JcrUtils; -import org.argeo.slc.CategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; import org.argeo.slc.NameVersion; import org.argeo.slc.SlcException; import org.eclipse.aether.artifact.Artifact; @@ -413,9 +413,9 @@ public class ModularDistributionFactory implements Runnable { b.append("\n"); for (Iterator it = osgiDistribution.nameVersions(); it.hasNext();) { NameVersion nameVersion = it.next(); - if (!(nameVersion instanceof CategorizedNameVersion)) + if (!(nameVersion instanceof CategoryNameVersion)) throw new SlcException("Unsupported type " + nameVersion.getClass()); - CategorizedNameVersion nv = (CategorizedNameVersion) nameVersion; + CategoryNameVersion nv = (CategoryNameVersion) nameVersion; b.append(getDependencySnippet(nv, false)); } b.append("\n"); @@ -425,7 +425,7 @@ public class ModularDistributionFactory implements Runnable { b.append("\n"); for (Iterator it = osgiDistribution.nameVersions(); it.hasNext();) - b.append(getDependencySnippet((CategorizedNameVersion) it.next(), true)); + b.append(getDependencySnippet((CategoryNameVersion) it.next(), true)); b.append("\n"); b.append("\n"); @@ -433,7 +433,7 @@ public class ModularDistributionFactory implements Runnable { return b.toString().getBytes(); } - private String getDependencySnippet(CategorizedNameVersion cnv, boolean includeVersion) { // , String type, String + private String getDependencySnippet(CategoryNameVersion cnv, boolean includeVersion) { // , String type, String // scope StringBuilder b = new StringBuilder(); b.append("\n"); @@ -469,9 +469,9 @@ public class ModularDistributionFactory implements Runnable { } private String getCsvLine(NameVersion nameVersion) throws RepositoryException { - if (!(nameVersion instanceof CategorizedNameVersion)) + if (!(nameVersion instanceof CategoryNameVersion)) throw new SlcException("Unsupported type " + nameVersion.getClass()); - CategorizedNameVersion cnv = (CategorizedNameVersion) nameVersion; + CategoryNameVersion cnv = (CategoryNameVersion) nameVersion; StringBuilder builder = new StringBuilder(); builder.append(cnv.getName()); diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java index adb591bbe..77e8f8422 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java @@ -21,8 +21,8 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.jcr.JcrUtils; -import org.argeo.slc.CategorizedNameVersion; -import org.argeo.slc.DefaultCategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; +import org.argeo.slc.DefaultCategoryNameVersion; import org.argeo.slc.NameVersion; import org.argeo.slc.SlcException; import org.argeo.slc.SlcNames; @@ -111,7 +111,7 @@ public class ModularDistributionIndexer implements NodeIndexer, SlcNames { // Helpers private Node addModule(Node modules, NameVersion nameVersion) throws RepositoryException { - CategorizedNameVersion cnv = (CategorizedNameVersion) nameVersion; + CategoryNameVersion cnv = (CategoryNameVersion) nameVersion; Node moduleCoord = null; moduleCoord = modules.addNode(cnv.getName(), SlcTypes.SLC_MODULE_COORDINATES); moduleCoord.setProperty(SlcNames.SLC_CATEGORY, cnv.getCategory()); @@ -126,7 +126,7 @@ public class ModularDistributionIndexer implements NodeIndexer, SlcNames { try { jarIn = new JarInputStream(fileBinary.getStream()); - List modules = new ArrayList(); + List modules = new ArrayList(); // meta data manifest = jarIn.getManifest(); @@ -169,7 +169,7 @@ public class ModularDistributionIndexer implements NodeIndexer, SlcNames { st.nextToken(); // moduleVersion String relativeUrl = st.nextToken(); Artifact currModule = AetherUtils.convertPathToArtifact(relativeUrl, null); - modules.add(new DefaultCategorizedNameVersion(currModule.getGroupId(), currModule.getArtifactId(), + modules.add(new DefaultCategoryNameVersion(currModule.getGroupId(), currModule.getArtifactId(), currModule.getVersion())); } return new MyModularDistribution(distribution, modules); @@ -186,14 +186,14 @@ public class ModularDistributionIndexer implements NodeIndexer, SlcNames { */ private class MyModularDistribution extends ArtifactDistribution implements ArgeoOsgiDistribution { - private List modules; + private List modules; - public MyModularDistribution(Artifact artifact, List modules) { + public MyModularDistribution(Artifact artifact, List modules) { super(artifact); this.modules = modules; } - public Iterator nameVersions() { + public Iterator nameVersions() { return modules.iterator(); } diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java index 8becba370..a6551a6e4 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java @@ -25,7 +25,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.jcr.JcrUtils; -import org.argeo.slc.CategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; import org.argeo.slc.DefaultNameVersion; import org.argeo.slc.ModuleSet; import org.argeo.slc.NameVersion; @@ -107,7 +107,7 @@ public class ArchiveWrapper implements Runnable, ModuleSet, Distribution { @SuppressWarnings("resource") protected Iterator osgiNameVersions() { - List nvs = new ArrayList(); + List nvs = new ArrayList(); Session distSession = null; ZipInputStream zin = null; @@ -139,7 +139,7 @@ public class ArchiveWrapper implements Runnable, ModuleSet, Distribution { if (nv != null) { if (nv.getName().endsWith(".source")) continue entries; - CategorizedNameVersion cnv = new OsgiCategorizedNV(groupId, nv.getName(), nv.getVersion(), + CategoryNameVersion cnv = new ArchiveWrapperCNV(groupId, nv.getName(), nv.getVersion(), this); nvs.add(cnv); // no need to process further includes diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiCategorizedNV.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java similarity index 57% rename from org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiCategorizedNV.java rename to org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java index b54d7f0c5..910d581f6 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiCategorizedNV.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java @@ -1,13 +1,13 @@ package org.argeo.slc.repo.osgi; -import org.argeo.slc.DefaultCategorizedNameVersion; +import org.argeo.slc.DefaultCategoryNameVersion; -/** */ -class OsgiCategorizedNV extends DefaultCategorizedNameVersion implements Runnable { +/** A module within an archive. */ +public class ArchiveWrapperCNV extends DefaultCategoryNameVersion implements Runnable { /** Build runnable */ private ArchiveWrapper build; - public OsgiCategorizedNV(String category, String name, String version, ArchiveWrapper build) { + public ArchiveWrapperCNV(String category, String name, String version, ArchiveWrapper build) { super(category, name, version); this.build = build; } diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java index 7521395e8..7e4a32e0e 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java @@ -16,7 +16,7 @@ import java.util.TreeSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.argeo.slc.CategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; import org.argeo.slc.ModuleSet; import org.argeo.slc.NameVersion; import org.argeo.slc.build.Distribution; @@ -59,7 +59,7 @@ public class ArgeoOsgiDistributionImpl extends ArtifactDistribution implements A str = str + "\t(Maven)"; else if (nv instanceof UriWrapper) str = str + "\t(URI)"; - else if (nv instanceof OsgiCategorizedNV) + else if (nv instanceof ArchiveWrapperCNV) str = str + "\t(OSGi from archive)"; else if (nv instanceof BndWrapper) str = str + "\t(Plain BND from archive)"; @@ -81,8 +81,8 @@ public class ArgeoOsgiDistributionImpl extends ArtifactDistribution implements A while (nvIt.hasNext()) { NameVersion nv = nvIt.next(); try { - if (nv instanceof CategorizedNameVersion) { - CategorizedNameVersion cnv = (CategorizedNameVersion) nv; + if (nv instanceof CategoryNameVersion) { + CategoryNameVersion cnv = (CategoryNameVersion) nv; // TODO add branch? Path categoryBase = baseDir.resolve(cnv.getCategory()); Files.createDirectories(categoryBase); @@ -138,8 +138,8 @@ public class ArgeoOsgiDistributionImpl extends ArtifactDistribution implements A if (log.isTraceEnabled()) log.trace("Wrote " + bndPath); } - } else if (cnv instanceof OsgiCategorizedNV) { - OsgiCategorizedNV onv = (OsgiCategorizedNV) cnv; + } else if (cnv instanceof ArchiveWrapperCNV) { + ArchiveWrapperCNV onv = (ArchiveWrapperCNV) cnv; ArchiveWrapper aw = onv.getBuild(); archiveWrappers.add(aw); // TODO specify and implement archive wrapper support diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java index 42111e7df..ab495d219 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java @@ -9,7 +9,7 @@ import java.util.jar.Manifest; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.argeo.slc.CategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; import org.argeo.slc.SlcException; import org.argeo.slc.build.Distribution; import org.argeo.slc.build.License; @@ -23,7 +23,7 @@ import aQute.bnd.osgi.Constants; import aQute.bnd.osgi.Jar; /** Utilities around the BND library, which manipulates OSGi metadata. */ -public class BndWrapper implements Constants, CategorizedNameVersion, Distribution, BeanNameAware { +public class BndWrapper implements Constants, CategoryNameVersion, Distribution, BeanNameAware { private final static Log log = LogFactory.getLog(BndWrapper.class); private String groupId; @@ -213,8 +213,8 @@ public class BndWrapper implements Constants, CategorizedNameVersion, Distributi @Override public boolean equals(Object obj) { - if (obj instanceof CategorizedNameVersion) { - CategorizedNameVersion cnv = (CategorizedNameVersion) obj; + if (obj instanceof CategoryNameVersion) { + CategoryNameVersion cnv = (CategoryNameVersion) obj; return getCategory().equals(cnv.getCategory()) && getName().equals(cnv.getName()) && getVersion().equals(cnv.getVersion()); } else diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java index 7f5999037..7d5d77900 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java @@ -8,7 +8,7 @@ import javax.jcr.Session; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.jcr.JcrUtils; -import org.argeo.slc.CategorizedNameVersion; +import org.argeo.slc.CategoryNameVersion; import org.argeo.slc.NameVersion; import org.argeo.slc.SlcException; import org.argeo.slc.repo.ArgeoOsgiDistribution; @@ -36,7 +36,7 @@ public class ProcessDistribution implements Runnable { // Check sources for (Iterator it = osgiDistribution .nameVersions(); it.hasNext();) { - CategorizedNameVersion nv = (CategorizedNameVersion) it.next(); + CategoryNameVersion nv = (CategoryNameVersion) it.next(); Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName() + ".source", "jar", nv.getVersion()); String path = MavenConventionsUtils.artifactPath("/", artifact); @@ -62,9 +62,9 @@ public class ProcessDistribution implements Runnable { NameVersion nameVersion) throws RepositoryException { if (log.isTraceEnabled()) log.trace("Check " + nameVersion + "..."); - if (!(nameVersion instanceof CategorizedNameVersion)) + if (!(nameVersion instanceof CategoryNameVersion)) throw new SlcException("Unsupported type " + nameVersion.getClass()); - CategorizedNameVersion nv = (CategorizedNameVersion) nameVersion; + CategoryNameVersion nv = (CategoryNameVersion) nameVersion; Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName(), "jar", nv.getVersion()); String path = MavenConventionsUtils.artifactPath("/", artifact); -- 2.39.2