Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Sep 23, 2019
1 parent a53b3f5 commit 6c8d349
Show file tree
Hide file tree
Showing 25 changed files with 379 additions and 234 deletions.
12 changes: 10 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -75,7 +77,7 @@
<dependency>
<groupId>gov.nist.decima</groupId>
<artifactId>decima-xml</artifactId>
<version>${dependency.version.decima}</version>
<version>${dependency.version.decima}</version>
</dependency>
<dependency>
<groupId>gov.nist.decima</groupId>
Expand Down Expand Up @@ -109,6 +111,12 @@
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.12</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
18 changes: 12 additions & 6 deletions swid-builder/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -14,12 +16,12 @@
<name>SWID Tag Generation Java API</name>
<description>Supports the generation of ISO/IEC 19770-2:2015 SWID tag in Java. A number of other formats are also supported (e.g., CBOR).</description>

<url>https://github.com/usnistgov/swid-tools/tree/master/swid-builder</url>
<url>https://github.com/usnistgov/swid-tools/tree/master/swid-builder</url>

<scm>
<url>https://github.com/usnistgov/swid-tools/tree/master/swid-builder</url>
<tag>HEAD</tag>
</scm>
<scm>
<url>https://github.com/usnistgov/swid-tools/tree/master/swid-builder</url>
<tag>HEAD</tag>
</scm>

<developers>
<developer>
Expand Down Expand Up @@ -51,6 +53,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,5 @@ public void validate() throws ValidationException {
super.validate();
validateNonEmpty("name", name);
validateNonEmpty("role", roles);
if (!roles.contains(KnownRole.TAG_CREATOR)) {
throw new ValidationException("at least the role '" + KnownRole.TAG_CREATOR.getName() + "' must be provided");
}
}
}
10 changes: 5 additions & 5 deletions swid-builder/src/main/java/gov/nist/swid/builder/KnownRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
package gov.nist.swid.builder;

public enum KnownRole implements Role {
TAG_CREATOR(0, "tagCreator"),
SOFTWARE_CREATOR(1, "softwareCreator"),
AGGREGATOR(2, "aggregator"),
DISTRIBUTOR(3, "distributor"),
LICENSOR(4, "licensor");
TAG_CREATOR(1, "tagCreator"),
SOFTWARE_CREATOR(2, "softwareCreator"),
AGGREGATOR(3, "aggregator"),
DISTRIBUTOR(4, "distributor"),
LICENSOR(5, "licensor");

private final int index;
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ public enum KnownVersionScheme implements VersionScheme {
* Numbers separated by dots, where the numbers are interpreted as integers (e.g., 1.2.3, 1.4.5.6,
* 1.2.3.4.5.6.7).
*/
MULTIPART_NUMERIC(0, "multipartnumeric"),
MULTIPART_NUMERIC(1, "multipartnumeric"),
/**
* Numbers separated by dots, where the numbers are interpreted as integers with an additional
* string suffix: (e.g., 1.2.3a).
*/
MULTIPART_NUMERIC_WITH_SUFFIX(1, "multipartnumeric+suffix"),
MULTIPART_NUMERIC_WITH_SUFFIX(2, "multipartnumeric+suffix"),
/**
* an alpha-numeric string, that can be sorted based on alpha-numeric order.
*/
ALPHANUMERIC(2, "alphanumeric"),
ALPHANUMERIC(3, "alphanumeric"),
/**
* A decimal number (e.g., 1.25 is less than 1.3 ).
*/
DECIMAL(3, "decimal"),
DECIMAL(4, "decimal"),
/**
* Follows the <a href="http://semver.org/">Semantic Versioning</a> specificatio.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
import java.util.Objects;

public class LinkBuilder extends AbstractLanguageSpecificBuilder<LinkBuilder> {

public static LinkBuilder create() {
return new LinkBuilder();
}

private String artifact;
private URI href;
private String media;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import static gov.nist.swid.builder.util.Util.requireNonEmpty;

public class MetaBuilder extends AbstractLanguageSpecificBuilder<MetaBuilder> {
public static MetaBuilder create() {
return new MetaBuilder();
}
private String activationStatus;
private String channelType;
private String colloquialVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,15 @@ public void validate() throws ValidationException {
validateNonEmpty("name", name);
validateNonEmpty("tagId", tagId);
validateNonEmpty("entity", entities);
boolean foundTagCreator = false;
for (EntityBuilder entity : entities) {
entity.validate();
if (entity.getRoles().contains(KnownRole.TAG_CREATOR)) {
foundTagCreator = true;
}
}
if (!foundTagCreator) {
throw new ValidationException("at least one entity wwith the role '" + KnownRole.TAG_CREATOR.getName() + "' must be provided");
}

if (payload != null && evidence != null) {
Expand Down
Loading

0 comments on commit 6c8d349

Please sign in to comment.