Browse Source

Update parent pom to 26.0.1

tags/v1.6.0
Paweł Płazieński 2 months ago
parent
commit
9df66ed402
26 changed files with 137 additions and 90 deletions
  1. +18
    -8
      pom.xml
  2. +3
    -2
      src/main/java/org/perfectable/repositable/ArtifactHandler.java
  3. +1
    -2
      src/main/java/org/perfectable/repositable/HashMethod.java
  4. +7
    -3
      src/main/java/org/perfectable/repositable/MetadataHelper.java
  5. +8
    -7
      src/main/java/org/perfectable/repositable/ModuleMetadataLocation.java
  6. +14
    -11
      src/main/java/org/perfectable/repositable/PackageLocation.java
  7. +7
    -4
      src/main/java/org/perfectable/repositable/Server.java
  8. +11
    -6
      src/main/java/org/perfectable/repositable/SnapshotIdentifier.java
  9. +15
    -12
      src/main/java/org/perfectable/repositable/SnapshotLocation.java
  10. +2
    -1
      src/main/java/org/perfectable/repositable/VersionIdentifier.java
  11. +11
    -9
      src/main/java/org/perfectable/repositable/VersionMetadataLocation.java
  12. +1
    -3
      src/main/java/org/perfectable/repositable/authorization/User.java
  13. +1
    -0
      src/main/java/org/perfectable/repositable/configuration/FileRepositoryConfiguration.java
  14. +1
    -0
      src/main/java/org/perfectable/repositable/configuration/GroupFilterConfiguration.java
  15. +1
    -0
      src/main/java/org/perfectable/repositable/configuration/RepositoryConfiguration.java
  16. +1
    -0
      src/main/java/org/perfectable/repositable/configuration/UserConfiguration.java
  17. +1
    -0
      src/main/java/org/perfectable/repositable/configuration/VirtualRepositoryConfiguration.java
  18. +15
    -0
      src/main/java/org/perfectable/repositable/package-info.java
  19. +12
    -11
      src/main/java/org/perfectable/repositable/repository/FileRepository.java
  20. +1
    -5
      src/main/java/org/perfectable/repositable/repository/Repositories.java
  21. +1
    -1
      src/test/java/org/perfectable/repositable/AbstractServerTest.java
  22. +1
    -1
      src/test/java/org/perfectable/repositable/FileRepositoryTest.java
  23. +1
    -1
      src/test/java/org/perfectable/repositable/GroupFilterTest.java
  24. +1
    -1
      src/test/java/org/perfectable/repositable/ReleaseFilterTest.java
  25. +1
    -1
      src/test/java/org/perfectable/repositable/SnapshotFilterTest.java
  26. +1
    -1
      src/test/java/org/perfectable/repositable/VirtualRepositoryTest.java

+ 18
- 8
pom.xml View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.perfectable</groupId>
<artifactId>perfectable</artifactId>
<version>23</version>
<version>26.0.1</version>
</parent>

<artifactId>repositable</artifactId>
@@ -88,6 +88,11 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>

<!-- maven -->
<dependency>
@@ -139,6 +144,12 @@
<configuration>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
</configuration>
<executions>
<execution>
<id>check-javadoc</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -146,13 +157,12 @@
<configuration>
<includeTests>false</includeTests>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<includeTests>false</includeTests>
</configuration>
<executions>
<execution>
<id>check-javadoc</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>


+ 3
- 2
src/main/java/org/perfectable/repositable/ArtifactHandler.java View File

@@ -88,8 +88,9 @@ public final class ArtifactHandler implements RequestHandler {
return HttpResponse.status(HttpStatus.FORBIDDEN).withPlainTextContent("User is not allowed to upload");
}
catch (InsertionRejected e) {
LOGGER.info("User {} was denied upload {}: {}", uploader, location, e.getMessage());
return HttpResponse.status(HttpStatus.FORBIDDEN).withPlainTextContent(e.getMessage());
String message = e.getMessage() != null ? e.getMessage() : "<no message>";
LOGGER.info("User {} was denied upload {}: {}", uploader, location, message);
return HttpResponse.status(HttpStatus.FORBIDDEN).withPlainTextContent(message);
}
LOGGER.info("User {} uploaded {}", uploader, location);
return HttpResponse.status(HttpStatus.OK);


+ 1
- 2
src/main/java/org/perfectable/repositable/HashMethod.java View File

@@ -4,11 +4,10 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

import javax.annotation.Nullable;

import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
import com.google.common.net.MediaType;
import org.checkerframework.checker.nullness.qual.Nullable;

public enum HashMethod implements OutputStreamTransformer {
NONE {


+ 7
- 3
src/main/java/org/perfectable/repositable/MetadataHelper.java View File

@@ -15,6 +15,7 @@ import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.repository.metadata.SnapshotVersion;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
import org.checkerframework.checker.nullness.qual.Nullable;

public final class MetadataHelper {
private static final MetadataXpp3Writer METADATA_WRITER = new MetadataXpp3Writer();
@@ -70,9 +71,10 @@ public final class MetadataHelper {
&& versioning.getSnapshotVersions().isEmpty();
}

@SuppressWarnings("argument.type.incompatible")
private static void updateVersions(Versioning targetVersioning) {
targetVersioning.getVersions().sort(Comparator.reverseOrder());
String latest = targetVersioning.getVersions().stream().findAny().orElse(null);
@Nullable String latest = targetVersioning.getVersions().stream().findAny().orElse(null);
targetVersioning.setLatest(latest);
}

@@ -103,11 +105,12 @@ public final class MetadataHelper {
return snapshotVersion;
}

@SuppressWarnings("argument.type.incompatible")
private static void updateSnapshot(Versioning versioning) {
Optional<SnapshotVersion> firstSnapshotOption = versioning.getSnapshotVersions().stream()
.filter(snapshotVersion -> snapshotVersion.getClassifier().isEmpty())
.findAny();
Snapshot snapshot = firstSnapshotOption.map(MetadataHelper::snapshotFromSnapshotVersion).orElse(null);
@Nullable Snapshot snapshot = firstSnapshotOption.map(MetadataHelper::snapshotFromSnapshotVersion).orElse(null);
versioning.setSnapshot(snapshot);
}

@@ -123,10 +126,11 @@ public final class MetadataHelper {
return snapshot;
}

@SuppressWarnings("argument.type.incompatible")
private static void updateLastUpdated(Versioning versioning) {
Optional<SnapshotVersion> firstSnapshotOption = versioning.getSnapshotVersions().stream()
.findAny();
String lastUpdated = firstSnapshotOption.map(SnapshotVersion::getUpdated).orElse(null);
@Nullable String lastUpdated = firstSnapshotOption.map(SnapshotVersion::getUpdated).orElse(null);
versioning.setLastUpdated(lastUpdated);
}



+ 8
- 7
src/main/java/org/perfectable/repositable/ModuleMetadataLocation.java View File

@@ -6,6 +6,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.maven.artifact.repository.metadata.Metadata;
import org.checkerframework.checker.nullness.qual.NonNull;

import static com.google.common.base.Preconditions.checkState;

@@ -17,8 +18,6 @@ public final class ModuleMetadataLocation implements MetadataLocation {
"/([a-zA-Z][\\w-]*)" + // artifactId
"/maven-metadata\\.xml(?:\\.(\\w+))?");

private static final String REPRESENTATION_FORMAT = "ModuleMetadataLocation(%s, %s, %s)";

private final String repositoryName;
private final ModuleIdentifier moduleIdentifier;
private final HashMethod hashMethod;
@@ -29,13 +28,14 @@ public final class ModuleMetadataLocation implements MetadataLocation {
this.hashMethod = hashMethod;
}

@SuppressWarnings({"dereference.of.nullable", "MagicNumber", "cast.unsafe"})
public static ModuleMetadataLocation fromPath(String path) {
Matcher matcher = PATH_PATTERN.matcher(path);
checkState(matcher.matches());
String repositoryName = matcher.group(1); // SUPPRESS MagicNumber
String groupId = matcher.group(2).replace("/", "."); // SUPPRESS MagicNumber
String artifactId = matcher.group(3); // SUPPRESS MagicNumber
HashMethod hashMethod = HashMethod.byExtension(matcher.group(4)); // SUPPRESS MagicNumber
@NonNull String repositoryName = (@NonNull String) matcher.group(1);
String groupId = matcher.group(2).replace("/", ".");
@NonNull String artifactId = (@NonNull String) matcher.group(3);
HashMethod hashMethod = HashMethod.byExtension(matcher.group(4));
ModuleIdentifier moduleIdentifier = ModuleIdentifier.of(groupId, artifactId);
return new ModuleMetadataLocation(repositoryName, moduleIdentifier, hashMethod);
}
@@ -53,6 +53,7 @@ public final class ModuleMetadataLocation implements MetadataLocation {

@Override
public String toString() {
return String.format(REPRESENTATION_FORMAT, repositoryName, moduleIdentifier.asBasePath(), hashMethod);
return String.format("ModuleMetadataLocation(%s, %s, %s)",
repositoryName, moduleIdentifier.asBasePath(), hashMethod);
}
}

+ 14
- 11
src/main/java/org/perfectable/repositable/PackageLocation.java View File

@@ -8,6 +8,9 @@ import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import static com.google.common.base.Preconditions.checkState;

public final class PackageLocation implements ArtifactLocation {
@@ -21,8 +24,6 @@ public final class PackageLocation implements ArtifactLocation {
"/([\\d.]+)(?:-([\\w.-]+))?/" + // version
"\\3-\\4(?:-\\5)?(?:-([a-z-]+))?\\.([\\w.]+?)(?:\\.(md5|sha1))?$"); // filename

private static final String REPRESENTATION_FORMAT = "PackageLocation(%s, %s, %s)";

private final String repositoryName;
private final PackageIdentifier packageIdentifier;
private final HashMethod hashMethod;
@@ -33,17 +34,18 @@ public final class PackageLocation implements ArtifactLocation {
this.hashMethod = hashMethod;
}

@SuppressWarnings({"MagicNumber", "cast.unsafe"})
public static PackageLocation fromPath(String path) {
Matcher matcher = PATH_PATTERN.matcher(path);
checkState(matcher.matches());
String repositoryName = matcher.group(1); // SUPPRESS MagicNumber
String groupId = matcher.group(2).replace('/', '.'); // SUPPRESS MagicNumber
String artifactId = matcher.group(3); // SUPPRESS MagicNumber
String versionBare = matcher.group(4); // SUPPRESS MagicNumber
String versionQualifier = matcher.group(5); // SUPPRESS MagicNumber
String classifier = matcher.group(6); // SUPPRESS MagicNumber
String packaging = matcher.group(7); // SUPPRESS MagicNumber
HashMethod hashMethod = HashMethod.byExtension(matcher.group(8)); // SUPPRESS MagicNumber
String repositoryName = (@NonNull String) matcher.group(1);
String groupId = ((@NonNull String) matcher.group(2)).replace('/', '.');
String artifactId = (@NonNull String) matcher.group(3);
String versionBare = (@NonNull String) matcher.group(4);
String versionQualifier = (@NonNull String) matcher.group(5);
@Nullable String classifier = matcher.group(6);
String packaging = (@NonNull String) matcher.group(7);
HashMethod hashMethod = HashMethod.byExtension(matcher.group(8));
ModuleIdentifier moduleIdentifier = ModuleIdentifier.of(groupId, artifactId);
VersionIdentifier versionIdentifier =
VersionIdentifier.of(moduleIdentifier, versionBare, Optional.ofNullable(versionQualifier));
@@ -72,6 +74,7 @@ public final class PackageLocation implements ArtifactLocation {

@Override
public String toString() {
return String.format(REPRESENTATION_FORMAT, repositoryName, packageIdentifier.asArtifactPath(), hashMethod);
return String.format("PackageLocation(%s, %s, %s)",
repositoryName, packageIdentifier.asArtifactPath(), hashMethod);
}
}

+ 7
- 4
src/main/java/org/perfectable/repositable/Server.java View File

@@ -17,6 +17,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;

import com.google.common.base.StandardSystemProperty;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -52,9 +53,8 @@ public final class Server {

public Server withConfiguratorExtension(
ServerConfigurator.Extension<ServerConfigurator<?>, ServerConfigurator<?>> extension) {
ServerConfigurator.Extension<ServerConfigurator<?>, ServerConfigurator<?>> newConfiguratorExtension =
configurator -> configurator.extend(this.configuratorExtension).extend(extension);
return new Server(repositorySelector, loggableUsers, newConfiguratorExtension);
return new Server(repositorySelector, loggableUsers, configurator ->
configurator.extend(this.configuratorExtension).extend(extension));
}

private ServerConfigurator<?> createServerConfiguration() {
@@ -81,7 +81,10 @@ public final class Server {
}

public static void main(String[] args) throws IOException {
String workingDirectory = StandardSystemProperty.USER_DIR.value();
@Nullable String workingDirectory = StandardSystemProperty.USER_DIR.value();
if (workingDirectory == null) {
workingDirectory = "<unknown>";
}
LOGGER.info("Starting server; Working directory is {}", workingDirectory);
if (args.length < REQUIRED_ARGUMENTS_COUNT) {
LOGGER.error("No configuration file provided");


+ 11
- 6
src/main/java/org/perfectable/repositable/SnapshotIdentifier.java View File

@@ -10,6 +10,7 @@ import java.util.regex.Pattern;

import com.google.common.collect.Ordering;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.checkerframework.checker.nullness.qual.NonNull;

public final class SnapshotIdentifier implements ArtifactIdentifier {

@@ -32,6 +33,7 @@ public final class SnapshotIdentifier implements ArtifactIdentifier {
return new SnapshotIdentifier(packageIdentifier, timestamp, buildId);
}

@SuppressWarnings({"MagicNumber", "cast.unsafe"})
public static Optional<SnapshotIdentifier> ofEntry(VersionIdentifier versionIdentifier, String entry) {
String baseName = versionIdentifier.asFileBaseName();
if (!entry.startsWith(baseName)) {
@@ -42,10 +44,10 @@ public final class SnapshotIdentifier implements ArtifactIdentifier {
if (!matcher.matches()) {
return Optional.empty();
}
LocalDateTime timestamp = LocalDateTime.parse(matcher.group(1), TIMESTAMP_FORMATTER); // SUPPRESS MagicNumber
int buildId = Integer.parseInt(matcher.group(2)); // SUPPRESS MagicNumber
String classifier = matcher.group(3); // SUPPRESS MagicNumber
String packaging = matcher.group(4); // SUPPRESS MagicNumber
LocalDateTime timestamp = LocalDateTime.parse((@NonNull String) matcher.group(1), TIMESTAMP_FORMATTER);
int buildId = Integer.parseInt((@NonNull String) matcher.group(2));
String classifier = (@NonNull String) matcher.group(3);
String packaging = (@NonNull String) matcher.group(4);
PackageIdentifier packageIdentifier =
PackageIdentifier.of(versionIdentifier, Optional.ofNullable(classifier), packaging);
SnapshotIdentifier snapshotIdentifier = of(packageIdentifier, timestamp, buildId);
@@ -80,8 +82,11 @@ public final class SnapshotIdentifier implements ArtifactIdentifier {
return filter.matchesSnapshot(packageIdentifier, timestamp, buildId);
}

public static SnapshotIdentifier newest(List<SnapshotIdentifier> candidates) {
return Ordering.natural().<SnapshotIdentifier>onResultOf(candidate -> candidate.timestamp).max(candidates);
@SuppressWarnings("dereference.of.nullable")
public static SnapshotIdentifier newest(List<@NonNull SnapshotIdentifier> candidates) {
return Ordering.natural()
.<@NonNull SnapshotIdentifier>onResultOf(candidate -> candidate.timestamp)
.max(candidates);
}

boolean hasClassifier(Optional<String> candidateClassifier) {


+ 15
- 12
src/main/java/org/perfectable/repositable/SnapshotLocation.java View File

@@ -9,11 +9,12 @@ import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import static com.google.common.base.Preconditions.checkState;

public final class SnapshotLocation implements ArtifactLocation {
private static final String REPRESENTATION_FORMAT = "SnapshotLocation(%s, %s, %s)";

// ex. "/libs-snapshot-local/org/perfectable/buildable/1.2.1-SNAPSHOT/buildable-1.2.1-20161022.184306-1.jar"
static final Pattern PATH_PATTERN =
Pattern.compile("/([a-zA-Z-]+)" + // repository
@@ -32,19 +33,20 @@ public final class SnapshotLocation implements ArtifactLocation {
this.hashMethod = hashMethod;
}

@SuppressWarnings({"MagicNumber", "cast.unsafe"})
public static SnapshotLocation fromPath(String path) {
Matcher matcher = PATH_PATTERN.matcher(path);
checkState(matcher.matches());
String repositoryName = matcher.group(1); // SUPPRESS MagicNumber
String groupId = matcher.group(2).replace('/', '.'); // SUPPRESS MagicNumber
String artifactId = matcher.group(3); // SUPPRESS MagicNumber
String versionBare = matcher.group(4); // SUPPRESS MagicNumber
String timestampString = matcher.group(5); // SUPPRESS MagicNumber
String repositoryName = (@NonNull String) matcher.group(1);
String groupId = ((@NonNull String) matcher.group(2)).replace('/', '.');
String artifactId = (@NonNull String) matcher.group(3);
String versionBare = (@NonNull String) matcher.group(4);
String timestampString = (@NonNull String) matcher.group(5);
LocalDateTime timestamp = LocalDateTime.parse(timestampString, SnapshotIdentifier.TIMESTAMP_FORMATTER);
int buildId = Integer.parseInt(matcher.group(6)); // SUPPRESS MagicNumber
String classifier = matcher.group(7); // SUPPRESS MagicNumber
String packaging = matcher.group(8); // SUPPRESS MagicNumber
HashMethod hashMethod = HashMethod.byExtension(matcher.group(9)); // SUPPRESS MagicNumber
int buildId = Integer.parseInt((@NonNull String) matcher.group(6));
@Nullable String classifier = matcher.group(7);
String packaging = (@NonNull String) matcher.group(8);
HashMethod hashMethod = HashMethod.byExtension((@NonNull String) matcher.group(9));
ModuleIdentifier moduleIdentifier =
ModuleIdentifier.of(groupId, artifactId);
VersionIdentifier versionIdentifier =
@@ -76,6 +78,7 @@ public final class SnapshotLocation implements ArtifactLocation {

@Override
public String toString() {
return String.format(REPRESENTATION_FORMAT, repositoryName, snapshotIdentifier.asBuildPath(), hashMethod);
return String.format("SnapshotLocation(%s, %s, %s)",
repositoryName, snapshotIdentifier.asBuildPath(), hashMethod);
}
}

+ 2
- 1
src/main/java/org/perfectable/repositable/VersionIdentifier.java View File

@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Optional;

import org.apache.maven.artifact.repository.metadata.Metadata;
import org.checkerframework.checker.nullness.qual.NonNull;

import static org.perfectable.repositable.SnapshotIdentifier.TIMESTAMP_FORMATTER;

@@ -88,7 +89,7 @@ public final class VersionIdentifier implements MetadataIdentifier {

public Path asFetchPath(EntryLister lister, Optional<String> classifier, String packaging) {
if (isSnapshot()) {
List<SnapshotIdentifier> candidates = new ArrayList<>();
List<@NonNull SnapshotIdentifier> candidates = new ArrayList<>();
lister.list(element -> {
SnapshotIdentifier.ofEntry(this, element)
.filter(candidate -> candidate.hasClassifier(classifier))


+ 11
- 9
src/main/java/org/perfectable/repositable/VersionMetadataLocation.java View File

@@ -7,6 +7,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.maven.artifact.repository.metadata.Metadata;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import static com.google.common.base.Preconditions.checkState;

@@ -20,8 +22,6 @@ public final class VersionMetadataLocation implements MetadataLocation {
"/([\\d.]+)(?:-([\\w.-]+))?" + // version
"/maven-metadata\\.xml(?:\\.(\\w+))?"); // filename

private static final String REPRESENTATION_FORMAT = "VersionMetadataLocation(%s, %s, %s)";

private final String repositoryName;
private final VersionIdentifier versionIdentifier;
private final HashMethod hashMethod;
@@ -32,15 +32,16 @@ public final class VersionMetadataLocation implements MetadataLocation {
this.hashMethod = hashMethod;
}

@SuppressWarnings({"MagicNumber", "cast.unsafe"})
public static VersionMetadataLocation fromPath(String path) {
Matcher matcher = PATH_PATTERN.matcher(path);
checkState(matcher.matches());
String repositoryName = matcher.group(1); // SUPPRESS MagicNumber
String groupId = matcher.group(2).replace("/", "."); // SUPPRESS MagicNumber
String artifactId = matcher.group(3); // SUPPRESS MagicNumber
String versionBare = matcher.group(4); // SUPPRESS MagicNumber
String versionQualifier = matcher.group(5); // SUPPRESS MagicNumber
HashMethod hashMethod = HashMethod.byExtension(matcher.group(6)); // SUPPRESS MagicNumber
String repositoryName = (@NonNull String) matcher.group(1);
String groupId = ((@NonNull String) matcher.group(2)).replace("/", ".");
String artifactId = (@NonNull String) matcher.group(3);
String versionBare = (@NonNull String) matcher.group(4);
@Nullable String versionQualifier = matcher.group(5);
HashMethod hashMethod = HashMethod.byExtension(matcher.group(6));
ModuleIdentifier moduleIdentifier =
ModuleIdentifier.of(groupId, artifactId);
VersionIdentifier versionIdentifier =
@@ -61,7 +62,8 @@ public final class VersionMetadataLocation implements MetadataLocation {

@Override
public String toString() {
return String.format(REPRESENTATION_FORMAT, repositoryName, versionIdentifier.asBasePath(), hashMethod);
return String.format("VersionMetadataLocation(%s, %s, %s)",
repositoryName, versionIdentifier.asBasePath(), hashMethod);
}

}

+ 1
- 3
src/main/java/org/perfectable/repositable/authorization/User.java View File

@@ -1,8 +1,6 @@
package org.perfectable.repositable.authorization;

public final class User {
private static final String REPRESENTATION_FORMAT = "User(%s)";

private final String username;
private final String password;

@@ -23,6 +21,6 @@ public final class User {

@Override
public String toString() {
return String.format(REPRESENTATION_FORMAT, username);
return String.format("User(%s)", username);
}
}

+ 1
- 0
src/main/java/org/perfectable/repositable/configuration/FileRepositoryConfiguration.java View File

@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@SuppressWarnings("initialization.fields.uninitialized")
@XmlType(name = "FileRepository", propOrder = {"location", "filters", "users"})
@XmlRootElement(name = "repository")
@XmlAccessorType(XmlAccessType.NONE)


+ 1
- 0
src/main/java/org/perfectable/repositable/configuration/GroupFilterConfiguration.java View File

@@ -9,6 +9,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;

@SuppressWarnings("initialization.fields.uninitialized")
@XmlType(name = "GroupFilter", propOrder = {"groupId"})
@XmlAccessorType(XmlAccessType.NONE)
public class GroupFilterConfiguration implements FilterConfiguration {


+ 1
- 0
src/main/java/org/perfectable/repositable/configuration/RepositoryConfiguration.java View File

@@ -13,6 +13,7 @@ import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlAdapter;

@SuppressWarnings("initialization.fields.uninitialized")
@XmlType(name = "Repository", propOrder = {"name"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso({FileRepositoryConfiguration.class, VirtualRepositoryConfiguration.class})


+ 1
- 0
src/main/java/org/perfectable/repositable/configuration/UserConfiguration.java View File

@@ -13,6 +13,7 @@ import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlAdapter;

@SuppressWarnings("initialization.fields.uninitialized")
@XmlType(name = "User", propOrder = {"identifier", "username", "password"})
@XmlAccessorType(XmlAccessType.NONE)
public class UserConfiguration implements Serializable {


+ 1
- 0
src/main/java/org/perfectable/repositable/configuration/VirtualRepositoryConfiguration.java View File

@@ -12,6 +12,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@SuppressWarnings("initialization.fields.uninitialized")
@XmlType(name = "VirtualRepository", propOrder = {"sources"})
@XmlRootElement(name = "virtual")
@XmlAccessorType(XmlAccessType.NONE)


+ 15
- 0
src/main/java/org/perfectable/repositable/package-info.java View File

@@ -1,2 +1,17 @@
@DefaultQualifier(value = NonNull.class, locations = {
TypeUseLocation.FIELD,
TypeUseLocation.RETURN,
TypeUseLocation.RECEIVER,
TypeUseLocation.PARAMETER,
TypeUseLocation.EXCEPTION_PARAMETER,
TypeUseLocation.CONSTRUCTOR_RESULT,
TypeUseLocation.RESOURCE_VARIABLE,
TypeUseLocation.LOCAL_VARIABLE,
TypeUseLocation.IMPLICIT_LOWER_BOUND
})
@javax.annotation.ParametersAreNonnullByDefault
package org.perfectable.repositable;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import org.checkerframework.framework.qual.TypeUseLocation;

+ 12
- 11
src/main/java/org/perfectable/repositable/repository/FileRepository.java View File

@@ -7,6 +7,7 @@ import org.perfectable.repositable.FileArtifact;
import org.perfectable.repositable.HashMethod;
import org.perfectable.repositable.InsertionRejected;
import org.perfectable.repositable.MetadataIdentifier;
import org.perfectable.repositable.PackageIdentifier;
import org.perfectable.repositable.Repository;
import org.perfectable.repositable.SnapshotIdentifier;
import org.perfectable.repositable.authorization.UnauthorizedUserException;
@@ -31,8 +32,6 @@ import org.apache.maven.artifact.repository.metadata.Metadata;
import static java.nio.file.Files.newDirectoryStream;

public final class FileRepository implements Repository {
private static final ArtifactIdentifier.BuildGenerator DEFAULT_BUILD_GENERATOR =
packageIdentifier -> SnapshotIdentifier.of(packageIdentifier, LocalDateTime.now(ZoneOffset.UTC), 1);

private final Path location;

@@ -44,9 +43,10 @@ public final class FileRepository implements Repository {
}

public static FileRepository create(Path location) {
return new FileRepository(location, DEFAULT_BUILD_GENERATOR);
return new FileRepository(location, FileRepository::generateBuild);
}


public FileRepository withBuildGenerator(ArtifactIdentifier.BuildGenerator newBuildGenerator) {
return new FileRepository(location, newBuildGenerator);
}
@@ -98,19 +98,20 @@ public final class FileRepository implements Repository {
parent.toFile().mkdirs();
}

private static SnapshotIdentifier generateBuild(PackageIdentifier packageIdentifier) {
return SnapshotIdentifier.of(packageIdentifier, LocalDateTime.now(ZoneOffset.UTC), 1);
}

private static class MetadataDirectoryLister implements EntryLister {
private static final ImmutableSet<String> IGNORED_SUFFIXES = ImmutableSet.of("asc");

private static final DirectoryStream.Filter<Path> FILE_FILTER = new DirectoryStream.Filter<Path>() {
@Override
public boolean accept(Path entry) {
for (String ignoredSuffix : IGNORED_SUFFIXES) {
if (entry.getFileName().toString().endsWith(ignoredSuffix)) {
return false;
}
private static final DirectoryStream.Filter<Path> FILE_FILTER = entry -> {
for (String ignoredSuffix : IGNORED_SUFFIXES) {
if (entry.getFileName().toString().endsWith(ignoredSuffix)) {
return false;
}
return true;
}
return true;
};

private final Path basePath;


+ 1
- 5
src/main/java/org/perfectable/repositable/repository/Repositories.java View File

@@ -8,8 +8,6 @@ import org.perfectable.repositable.RepositorySelector;
import org.perfectable.repositable.RepositorySet;

import java.util.Collection;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@@ -54,10 +52,8 @@ public final class Repositories implements RepositorySelector, RepositorySet {

@Override
public Collection<Artifact> listArtifacts(ArtifactIdentifier artifactIdentifier) {
Function<Repository, Optional<Artifact>> transformation =
repository -> repository.findArtifact(artifactIdentifier);
return repositoryByName.values().stream()
.map(transformation)
.map(repository -> repository.findArtifact(artifactIdentifier))
.flatMap(candidate -> candidate.isPresent() ? Stream.of(candidate.get()) : Stream.empty())
.collect(Collectors.toList());
}


+ 1
- 1
src/test/java/org/perfectable/repositable/AbstractServerTest.java View File

@@ -9,7 +9,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

import javax.servlet.http.HttpServletResponse;

import com.google.common.hash.Hashing;
@@ -24,6 +23,7 @@ import static org.perfectable.testable.http.HttpConnectionAssertions.assertConne
// SUPPRESS FILE MethodCount
// SUPPRESS FILE LineLength
// SUPPRESS FILE MultipleStringLiterals
@SuppressWarnings("initialization.fields.uninitialized")
@ExtendWith(FilesExtension.class)
public abstract class AbstractServerTest {



+ 1
- 1
src/test/java/org/perfectable/repositable/FileRepositoryTest.java View File

@@ -21,7 +21,7 @@ import static org.perfectable.testable.http.HttpConnectionAssertions.assertConne
// SUPPRESS FILE LineLength
// SUPPRESS FILE MagicNumber
// SUPPRESS FILE MultipleStringLiterals
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "initialization.fields.uninitialized"})
@ExtendWith(ResourcesExtension.class)
@LoadResourcesWith(StringResourceLoader.class)
public class FileRepositoryTest extends AbstractServerTest { // SUPPRESS TooManyMethods


+ 1
- 1
src/test/java/org/perfectable/repositable/GroupFilterTest.java View File

@@ -20,7 +20,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
// SUPPRESS FILE LineLength
// SUPPRESS FILE MagicNumber
// SUPPRESS FILE MultipleStringLiterals
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "initialization.fields.uninitialized"})
@ExtendWith(ResourcesExtension.class)
@LoadResourcesWith(StringResourceLoader.class)
public class GroupFilterTest extends AbstractServerTest {


+ 1
- 1
src/test/java/org/perfectable/repositable/ReleaseFilterTest.java View File

@@ -19,7 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
// SUPPRESS FILE LineLength
// SUPPRESS FILE MagicNumber
// SUPPRESS FILE MultipleStringLiterals
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "initialization.fields.uninitialized"})
@ExtendWith(ResourcesExtension.class)
@LoadResourcesWith(StringResourceLoader.class)
public class ReleaseFilterTest extends AbstractServerTest {


+ 1
- 1
src/test/java/org/perfectable/repositable/SnapshotFilterTest.java View File

@@ -19,7 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
// SUPPRESS FILE LineLength
// SUPPRESS FILE MagicNumber
// SUPPRESS FILE MultipleStringLiterals
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "initialization.fields.uninitialized"})
@ExtendWith(ResourcesExtension.class)
@LoadResourcesWith(StringResourceLoader.class)
public class SnapshotFilterTest extends AbstractServerTest {


+ 1
- 1
src/test/java/org/perfectable/repositable/VirtualRepositoryTest.java View File

@@ -21,7 +21,7 @@ import static org.perfectable.testable.http.HttpConnectionAssertions.assertConne
// SUPPRESS FILE LineLength
// SUPPRESS FILE MagicNumber
// SUPPRESS FILE MultipleStringLiterals
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "initialization.fields.uninitialized"})
@ExtendWith(ResourcesExtension.class)
@LoadResourcesWith(StringResourceLoader.class)
public class VirtualRepositoryTest extends AbstractServerTest {


Loading…
Cancel
Save