org.metaeffekt.artifact.resolver.rpm.RpmArtifactReference Maven / Gradle / Ivy
/*
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.metaeffekt.artifact.resolver.rpm;
import com.github.packageurl.PackageURL;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.metaeffekt.artifact.resolver.generic.FileLocation;
import org.metaeffekt.core.inventory.processor.model.Artifact;
@Getter
public class RpmArtifactReference {
private String name;
private String version;
private String vendor;
private String archOrSource;
private String distro;
private String epoch;
public RpmArtifactReference(String name, String version, String vendor, String archOrSource, String distro, String epoch) {
this.name = name;
this.version = version;
this.vendor = vendor;
this.archOrSource = archOrSource;
this.distro = distro;
this.epoch = epoch;
}
public RpmArtifactReference(PackageURL packageURL) {
if (packageURL.getType().equalsIgnoreCase(PackageURL.StandardTypes.RPM)) {
name = packageURL.getName();
version = packageURL.getVersion();
vendor = packageURL.getNamespace();
if (packageURL.getQualifiers() != null) {
archOrSource = packageURL.getQualifiers().get("arch");
archOrSource = packageURL.getQualifiers().get("distro");
archOrSource = packageURL.getQualifiers().get("epoch");
}
}
}
public RpmArtifactReference(Artifact artifact) {
// TODO: implement me; currently only supports PURLs
}
public boolean isValid() {
return StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(version);
}
public FileLocation deriveFileLocation() {
final FileLocation fileLocation = new FileLocation();
fileLocation.setEcosystem("rpm");
final String qualifier = getName() + "-" + getVersion();
fileLocation.setFilename(qualifier);
fileLocation.setResourceQualifier(qualifier);
fileLocation.setDispatchName(getName());
return fileLocation;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy