Create a extension identifier from Maven artifact identifier elements.

@param groupId the group id
@param artifactId the artifact id
@param classifier the classifier
@param version the version
@return the extension identifier
@since 10.9
@since 10.8.1
332797
public static ExtensionId toExtensionId(String groupId, String artifactId, String classifier, String version)
    {
        return toExtensionId(groupId, artifactId, classifier, version != null ? new DefaultVersion(version) : null);
    }
92957
public static String getVersion(String groupId, String artifactId, String defaultVersion) {
        String answer = getVersion(groupId, artifactId);
        if (Strings.isNullOrBlank(answer)) {
            answer = defaultVersion;
        }
        return answer;
    }
1312788
private Map<Environment, Collection<ArtifactIdentifier>> getArtifactIdentifiers(List<Environment> environments) {
		Map<Environment, Collection<ArtifactIdentifier>> rt = new HashMap<>();
		
		for (Environment env : environments) {
			Set<ArtifactIdentifier> ids = new HashSet<>();
			
			if (env.getUnits() != null) {
				for (DeployableUnit du : env.getUnits()) {
			        String artifactName = du.getName();
			        String artifactExtension = null;
			        int dotIdx = artifactName.lastIndexOf('.');
			        if (dotIdx > 0) {
			        	// If idx is 0 starts with a dot... in which case not an extension
			        	
			        	artifactName = artifactName.substring(0, dotIdx);
			        	artifactExtension = artifactName.substring(dotIdx);
			        }
					
					ArtifactIdentifier id = new ArtifactIdentifier(null, artifactName, du.getVersion(), null, artifactExtension);
					
					ids.add(id);
				}
			}
			
			rt.put(env, new ArrayList<>(ids));
		}
		
		return rt;
	}
579465
@Override
  public D createServiceDescriptor(Class<?> interfaceClass, String version) {
    return adsServiceDescriptorFactory.create(interfaceClass, version);
  }
1235389
public String getAsPath() {
    // is that correct?
    if (StringUtils.isBlank(artifactId) || StringUtils.isBlank(versionId))
      return groupId.getAsString(); // do not replace dots "." at the tail, as a version id
    return groupId.getAsPath() + "/" + artifactId + "/" + versionId;
  }
933108
public Iterable<MavenProjectModel> findByGroupArtifactVersion(String groupId, String artifactId, String version)
    {
        String key = generateMavenKey(groupId, artifactId, version);
        Iterable<MavenProjectModel> facet = this.findAllByProperty(MavenProjectModel.MAVEN_IDENTIFIER, key);

        return facet;
    }
37166
public static String getId(Coordinates coordinates) {
        StringBuilder id = new StringBuilder();
        if (StringUtils.isNotEmpty(coordinates.getGroup())) {
            id.append(coordinates.getGroup());
        }
        id.append(':');
        id.append(coordinates.getName());
        id.append(':');
        id.append(coordinates.getType());
        String classifier = coordinates.getClassifier();
        if (StringUtils.isNotEmpty(classifier)) {
            id.append(':');
            id.append(classifier);
        }
        String version = coordinates.getVersion();
        if (StringUtils.isNotEmpty(version)) {
            id.append(':');
            id.append(version);
        }
        return id.toString();
    }
104195
private Element getMavenPluginElement() {
        try {
            final Element pluginsRoot = document.getRootElement().element("build").element("plugins");
            for (final Element element : pluginsRoot.elements()) {
                final String groupId = XMLUtils.getChildValue("groupId", element);
                final String artifactId = XMLUtils.getChildValue("artifactId", element);
                if (PLUGIN_GROUPID.equals(groupId) && PLUGIN_ARTIFACTID.equals(artifactId)) {
                    return element;
                }
            }
        } catch (NullPointerException e) {
            return null;
        }
        return null;
    }
462469
private File resolveArtifact(ClusterConfiguration config)
            throws ArtifactException, IOException
    {
        String flavour = config.getFlavour();
        String version = config.getVersion();
        String artifactId = getArtifactId(flavour, version);
        String classifier = getArtifactClassifier(version);
        String type = getArtifactType(version);

        ElasticsearchArtifact artifactReference = new ElasticsearchArtifact(artifactId, version, classifier, type);
        config.getLog().debug("Artifact ref: " + artifactReference);

        PluginArtifactResolver artifactResolver = config.getArtifactResolver();
        try
        {
            config.getLog().debug("Resolving artifact against the local maven repo (stage 1)");
            return artifactResolver
                    .resolveArtifact(artifactReference.getArtifactCoordinates());
        }
        catch (ArtifactException e)
        {
            config.getLog().debug("Artifact not found; downloading and installing it");

            File tempFile = downloadArtifact(artifactReference, config);

            config.getLog().debug("Installing " + tempFile + " in the local maven repo");
            config.getArtifactInstaller().installArtifact(
                    artifactReference.getGroupId(),
                    artifactReference.getArtifactId(),
                    artifactReference.getVersion(),
                    artifactReference.getClassifier(),
                    artifactReference.getType(),
                    tempFile);
            
            config.getLog().debug("Resolving artifact against the local maven repo (stage 2)");
            return artifactResolver
                    .resolveArtifact(artifactReference.getArtifactCoordinates());
        }
    }
1332191
public Url fromIdentifier(String identifier) {
        Matcher matcher = identifierPattern.matcher(identifier);
        if (!matcher.matches()) {
            throw new RuntimeException(String.format("Couldn't parse identifier %s", identifier));
        }

        String resourceType = matcher.group(1);
        if (resourceType != null) {
            resourceType(resourceType);
        }

        String type = matcher.group(2);
        if (type != null) {
            type(type);
        }

        String version = matcher.group(3);
        if (version != null) {
            version(version);
        }

        String publicId = matcher.group(4);
        if (publicId != null) {
            publicId(publicId);
        }

        String format = matcher.group(5);
        if (format != null) {
            format(format);
        }

        // Signature (group 6) is not used

        return this;
    }
1190690
@Override
  public PackageDescriptor add(String pm, String groupId, String artifactId, String version) {
    PackageCoordinate pkg = PackageCoordinate.newBuilder()
        .withFormat(pm)
        .withNamespace(groupId)
        .withName(artifactId)
        .withVersion(version)
        .build();
    return add(Collections.singletonList(pkg));
  }
368979
public DbArtifact getDbArtifact(final Artifact artifact) {
        final DbArtifact dbArtifact = new DbArtifact();
        dbArtifact.setGroupId(artifact.getGroupId());
        dbArtifact.setArtifactId(artifact.getArtifactId());
        dbArtifact.setVersion(artifact.getVersion());
        dbArtifact.setClassifier(artifact.getClassifier());
        dbArtifact.setType(artifact.getType());
        dbArtifact.setExtension(artifact.getExtension());
        dbArtifact.setOrigin(artifact.getOrigin());
        dbArtifact.setPromoted(artifact.isPromoted());
        dbArtifact.setLicenses(artifact.getLicenses());

        dbArtifact.setSize(artifact.getSize());
        dbArtifact.setSha256(artifact.getSha256());
        dbArtifact.setDescription(artifact.getDescription());
        dbArtifact.setDownloadUrl(artifact.getDownloadUrl());
        dbArtifact.setProvider(artifact.getProvider());
        dbArtifact.setCreatedDateTime(artifact.getCreatedDateTime());
        dbArtifact.setUpdatedDateTime(artifact.getUpdatedDateTime());

        return dbArtifact;
    }
1196030
def getFileName(self, suffix=None, extension="jar"):
        

        assert (self._artifactId is not None)
        assert (self._version is not None)

        return "{0}-{1}{2}{3}".format(
            self._artifactId,
            self._version.getRawString(),
            "-" + suffix.lstrip("-") if suffix is not None else "",
            "." + extension.lstrip(".") if extension is not None else ""
        )
948008
public void setArtifactId(final String artifactId) {
        if (artifactId == null && this.artifactId == null) {
            return;
        } else if (artifactId == null) {
            removeChild(this.artifactId);
            this.artifactId = null;
        } else if (this.artifactId == null) {
            this.artifactId = new KeyValueNode<String>(CommonConstants.CS_MAVEN_ARTIFACT_ID_TITLE, artifactId);
            appendChild(this.artifactId, false);
        } else {
            this.artifactId.setValue(artifactId);
        }
    }
69919
public static Plugin plugin(String groupId, String artifactId, String version) {
		Plugin plugin = new Plugin();
		plugin.setArtifactId(artifactId);
		plugin.setGroupId(groupId);
		plugin.setVersion(version);
		return plugin;
	}
1306189
public static String getVersion(Class<?> aClass, String groupId, String artifactId) {
        String version = null;
        // lets try find the maven property - as the Java API rarely works :)
        InputStream is = null;
        String fileName = "/META-INF/maven/" +
                groupId + "/" + artifactId +
                "/pom.properties";
        // try to load from maven properties first
        try {
            Properties p = new Properties();
            is = aClass.getResourceAsStream(fileName);
            if (is != null) {
                p.load(is);
                version = p.getProperty("version", "");
            }
        } catch (Exception e) {
            // ignore
        } finally {
            if (is != null) {
                IOHelper.close(is, fileName, LOG);
            }
        }
        if (version == null) {
            Package aPackage = aClass.getPackage();
            if (aPackage != null) {
                version = aPackage.getImplementationVersion();
                if (Strings.isBlank(version)) {
                    version = aPackage.getSpecificationVersion();
                }
            }
        }
        if (version == null) {
            Enumeration<URL> resources = null;
            try {
                resources = aClass.getClassLoader().getResources("META-INF/MANIFEST.MF");
            } catch (IOException e) {
                // ignore
            }
            if (resources != null) {
                String expectedBundleName = groupId + "." + artifactId;
                while (resources.hasMoreElements()) {
                    try {
                        Manifest manifest = new Manifest(resources.nextElement().openStream());
                        Attributes attributes = manifest.getMainAttributes();
                        String bundleName = attributes.getValue("Bundle-SymbolicName");
                        if (Objects.equals(expectedBundleName, bundleName)) {
                            version = attributes.getValue("Implementation-Version");
                            if (Strings.isNotBlank(version)) break;
                        }
                    } catch (IOException e) {
                        // ignore
                    }
                }
            }
        }
        return version;
    }
1094571
public static String findMavenUrlForRoboconf( String artifactId, String version )
	throws IOException {
		return findMavenUrl( "net.roboconf", artifactId, version, "jar" );
	}