Skip to content

Commit

Permalink
Remove support for listing directory as html page and cleanups
Browse files Browse the repository at this point in the history
- remove listing directory
- remove not implemented doDelete http method
- add missing override annotation
- remove unused methods
  • Loading branch information
slawekjaranowski committed Oct 7, 2023
1 parent 42cbe0e commit 4554d90
Show file tree
Hide file tree
Showing 33 changed files with 131 additions and 897 deletions.
36 changes: 7 additions & 29 deletions mrm-api/src/main/java/org/codehaus/mojo/mrm/api/AbstractEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,10 @@
/**
* Abstract implementation of {@link Entry}.
*
* @serial
* @since 1.0
*/
public abstract class AbstractEntry implements Entry {

/**
* Ensure consistent serialization.
*
* @since 1.0
*/
private static final long serialVersionUID = 1L;

/**
* The file system that this entry belongs to.
*
Expand Down Expand Up @@ -69,30 +61,22 @@ protected AbstractEntry(FileSystem fileSystem, DirectoryEntry parent, String nam
this.name = name;
}

/**
* {@inheritDoc}
*/
@Override
public FileSystem getFileSystem() {
return fileSystem;
}

/**
* {@inheritDoc}
*/
@Override
public DirectoryEntry getParent() {
return parent;
}

/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name;
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
Expand All @@ -112,18 +96,14 @@ public boolean equals(Object o) {
return Objects.equals(parent, abstractEntry.parent);
}

/**
* {@inheritDoc}
*/
@Override
public final int hashCode() {
int result = name.hashCode();
result = 31 * result + (parent != null ? parent.hashCode() : 0);
return result;
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Entry[");
Expand All @@ -132,9 +112,7 @@ public String toString() {
return sb.toString();
}

/**
* {@inheritDoc}
*/
@Override
public final String toPath() {
Stack<String> stack = new Stack<>();
Entry root = getFileSystem().getRoot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
* @since 1.0
*/
public abstract class BaseFileEntry extends AbstractEntry implements FileEntry {
/**
* Ensure consistent serialization.
*
* @since 1.0
*/
private static final long serialVersionUID = 1L;

/**
* Creates an entry in the specified file system with the specified parent and name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,24 @@

package org.codehaus.mojo.mrm.api;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
* Base implementation of {@link FileSystem} that all implementations should extend from.
*
* @since 1.0
*/
public abstract class BaseFileSystem implements FileSystem {
/**
* Ensure consistent serialization.
*
* @since 1.0
*/
private static final long serialVersionUID = 1L;

/**
* The root entry.
*/
private final DirectoryEntry root = new DefaultDirectoryEntry(this, null, "");

/**
* {@inheritDoc}
*/
@Override
public DirectoryEntry getRoot() {
return root;
}

/**
* {@inheritDoc}
*/
@Override
public Entry get(String path) {
if (path.startsWith("/")) {
path = path.substring(1);
Expand Down Expand Up @@ -87,32 +73,4 @@ protected Entry get(DirectoryEntry parent, String name) {
}
return null;
}

/**
* {@inheritDoc}
*/
public DirectoryEntry mkdir(DirectoryEntry parent, String name) {
throw new UnsupportedOperationException();
}

/**
* {@inheritDoc}
*/
public FileEntry put(DirectoryEntry parent, String name, InputStream content) throws IOException {
throw new UnsupportedOperationException();
}

/**
* {@inheritDoc}
*/
public FileEntry put(DirectoryEntry parent, String name, byte[] content) throws IOException {
return put(parent, name, new ByteArrayInputStream(content));
}

/**
* {@inheritDoc}
*/
public void remove(Entry entry) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
* @since 1.0
*/
public class DefaultDirectoryEntry extends AbstractEntry implements DirectoryEntry {
/**
* Ensure consistent serialization.
*
* @since 1.0
*/
private static final long serialVersionUID = 1L;

/**
* Creates an entry in the specified file system with the specified parent and name.
Expand Down Expand Up @@ -62,9 +56,7 @@ public static DirectoryEntry equivalent(FileSystem target, DirectoryEntry direct
return new DefaultDirectoryEntry(target, equivalent(target, directory.getParent()), directory.getName());
}

/**
* {@inheritDoc}
*/
@Override
public long getLastModified() throws IOException {
return getFileSystem().getLastModified(this);
}
Expand Down
3 changes: 1 addition & 2 deletions mrm-api/src/main/java/org/codehaus/mojo/mrm/api/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
package org.codehaus.mojo.mrm.api;

import java.io.IOException;
import java.io.Serializable;

/**
* An entry in the repository.
*
* @since 1.0
*/
public interface Entry extends Serializable {
public interface Entry {

/**
* Returns the repository that this entry belongs to.
Expand Down
36 changes: 1 addition & 35 deletions mrm-api/src/main/java/org/codehaus/mojo/mrm/api/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

/**
* A repository is just a type of file system.
*
* @since 1.0
*/
public interface FileSystem extends Serializable {
public interface FileSystem {
/**
* Lists the entries in the specified directory. Some implementations may be lazy caching
* implementations, in which case it is permitted to return either an empty array, or only those entries which
Expand Down Expand Up @@ -73,17 +72,6 @@ public interface FileSystem extends Serializable {
*/
long getLastModified(DirectoryEntry entry) throws IOException;

/**
* Makes the specified child directory.
*
* @param parent the directory in which the child is to be created.
* @param name the name of the child directory.
* @return the child directory entry.
* @throws UnsupportedOperationException if the repository is read-only.
* @since 1.0
*/
DirectoryEntry mkdir(DirectoryEntry parent, String name);

/**
* Puts the specified content into a the specified directory.
*
Expand All @@ -96,26 +84,4 @@ public interface FileSystem extends Serializable {
* @since 1.0
*/
FileEntry put(DirectoryEntry parent, String name, InputStream content) throws IOException;

/**
* Puts the specified content into a the specified directory.
*
* @param parent the directory in which the content is to be created/updated.
* @param name the name of the file.
* @param content the content.
* @return the {@link FileEntry} that was created/updated.
* @throws UnsupportedOperationException if the repository is read-only.
* @throws java.io.IOException if the content could not be read/written.
* @since 1.0
*/
FileEntry put(DirectoryEntry parent, String name, byte[] content) throws IOException;

/**
* Removes the specified entry (and if the entry is a directory, all its children).
*
* @param entry the entry to remove.
* @throws UnsupportedOperationException if the repository is read-only.
* @since 1.0
*/
void remove(Entry entry);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*/
public class ResolverUtils {

private ResolverUtils() {
// utility class
}

/**
* <p>Creates a new {@link org.eclipse.aether.artifact.Artifact} based on an {@link Artifact} object.</p>
* <p>Future deprecation: This method will be replaced with the new Maven 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.codehaus.mojo.mrm.api.maven;

import java.io.Serializable;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -30,14 +29,7 @@
* @serial
* @since 1.0
*/
public final class Artifact implements Serializable, Comparable<Artifact> {

/**
* Ensure consistent serialization.
*
* @since 1.0
*/
private static final long serialVersionUID = 1L;
public final class Artifact implements Comparable<Artifact> {

/**
* The groupId of the artifact.
Expand Down Expand Up @@ -95,15 +87,15 @@ public final class Artifact implements Serializable, Comparable<Artifact> {
*
* @since 1.0
*/
private transient String name;
private String name;

/**
* The lazy idempotent cache of the artifact's timestamp version string (which will be equal to the {@link #version}
* for either a release version or a non-timestamped SNAPSHOT.
*
* @since 1.0
*/
private transient String timestampVersion;
private String timestampVersion;

/**
* Common internal constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Set;

import org.apache.maven.archetype.catalog.ArchetypeCatalog;
Expand All @@ -29,7 +28,7 @@
*
* @since 1.0
*/
public interface ArtifactStore extends Serializable {
public interface ArtifactStore {

/**
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public abstract class BaseArtifactStore implements ArtifactStore {
*/
private static final long serialVersionUID = 1L;

/**
* {@inheritDoc}
*/
@Override
public void set(Artifact artifact, InputStream content) throws IOException {
throw new UnsupportedOperationException("Read-only artifact store");
}
Expand All @@ -33,24 +31,18 @@ public void setMetadata(String path, Metadata metadata) throws IOException {
throw new UnsupportedOperationException("Read-only artifact store");
}

/**
* {@inheritDoc}
*/
@Override
public void setArchetypeCatalog(InputStream content) throws IOException {
throw new UnsupportedOperationException("Read-only artifact store");
}

/**
* {@inheritDoc}
*/
@Override
public ArchetypeCatalog getArchetypeCatalog() throws IOException, ArchetypeCatalogNotFoundException {
throw new ArchetypeCatalogNotFoundException(
"Archetype Catalog not available", new UnsupportedOperationException());
}

/**
* {@inheritDoc}
*/
@Override
public long getArchetypeCatalogLastModified() throws IOException, ArchetypeCatalogNotFoundException {
throw new ArchetypeCatalogNotFoundException(
"Archetype Catalog not available", new UnsupportedOperationException());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public abstract class AbstractMRMMojo extends AbstractMojo {
* Creates a new instance
* @param proxyRepo injected proxyRepo
*/
public AbstractMRMMojo(ArtifactStoreFactory proxyRepo) {
protected AbstractMRMMojo(ArtifactStoreFactory proxyRepo) {
this.proxyRepo = proxyRepo;
}

Expand All @@ -78,6 +78,7 @@ public AbstractMRMMojo(ArtifactStoreFactory proxyRepo) {
* @throws MojoExecutionException If there is an exception occuring during the execution of the plugin.
* @throws MojoFailureException If there is an exception occuring during the execution of the plugin.
*/
@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping invocation per configuration."
Expand Down
Loading

0 comments on commit 4554d90

Please sign in to comment.