Skip to content

Commit

Permalink
Moving files over.
Browse files Browse the repository at this point in the history
  • Loading branch information
jachiaram committed Jul 31, 2024
1 parent 711243a commit 0dc7f74
Show file tree
Hide file tree
Showing 53 changed files with 279 additions and 1,684 deletions.
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

# Target files
target

# .idea Files
.idea

# LastIndexProcessed
lastIndexProcessed
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mvn-research-interface
# Maven Central Research Interface
An interface focused on creating an easy way to index and retrieve data from the Maven Central repository.

## Required Java Version
Expand Down Expand Up @@ -219,3 +219,4 @@ The Jar resolver collects information about jar files stored under a given G:A:V

### Usage
The jar resolver makes it easy to run static analysis on any amount of maven central jar artifacts.

69 changes: 69 additions & 0 deletions src/main/java/org/tudo/sse/ArtifactFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.tudo.sse;

import org.tudo.sse.model.*;
import org.tudo.sse.model.index.IndexInformation;
import org.tudo.sse.model.jar.JarInformation;
import org.tudo.sse.model.pom.PomInformation;

import java.util.HashMap;
import java.util.Map;

/**
* The ArtifactFactory handles the creation and storage of artifacts resolved.
* Using a map double resolutions are avoided and faster retrievals are possible.
*/
public class ArtifactFactory {

/**
* A map that stores all artifacts collected during index, pom, and jar resolution.
*/
public static final Map<ArtifactIdent, Artifact> artifacts = new HashMap<>();

/**
* This method creates a new Artifact or retrieves it from the map.
* @param artifactInformation an identifier used to keep track of artifacts
* @return a newly created or retrieved artifact
*/
public static Artifact createArtifact(ArtifactInformation artifactInformation) {

//first check if it exists in artifacts
if(artifacts.containsKey(artifactInformation.getIdent())) {
Artifact current = artifacts.get(artifactInformation.getIdent());

//see if it matches an empty field
if(current.getIndexInformation() == null && (artifactInformation instanceof IndexInformation)) {
current.setIndexInformation((IndexInformation) artifactInformation);
} else if(current.getPomInformation() == null && (artifactInformation instanceof PomInformation)) {
current.setPomInformation((PomInformation) artifactInformation);
} else if (current.getJarInformation() == null && (artifactInformation instanceof JarInformation)) {
current.setJarInformation((JarInformation) artifactInformation);
}

//return it
return current;
}

Artifact newArtifact;
if(artifactInformation instanceof IndexInformation) {
newArtifact = new Artifact((IndexInformation) artifactInformation);
} else if (artifactInformation instanceof PomInformation) {
newArtifact = new Artifact((PomInformation) artifactInformation);
} else {
newArtifact = new Artifact((JarInformation) artifactInformation);
}

artifacts.put(artifactInformation.getIdent(), newArtifact);
return newArtifact;
}

/**
* Searches for an artifact with the matching identifier, returning it if found.
*
*/
public static Artifact getArtifact(ArtifactIdent ident) {
if(artifacts.containsKey(ident)) {
return artifacts.get(ident);
}
return null;
}
}
13 changes: 13 additions & 0 deletions src/main/java/org/tudo/sse/OwnImplementation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.tudo.sse;

import org.tudo.sse.model.Artifact;

public class OwnImplementation extends MavenCentralAnalysis {
public OwnImplementation() {
super();
}

@Override
public void analyzeArtifact(Artifact toAnalyze) {
}
}
80 changes: 80 additions & 0 deletions src/main/java/org/tudo/sse/model/index/IndexInformation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.tudo.sse.model.index;

import org.tudo.sse.model.ArtifactIdent;
import org.tudo.sse.model.ArtifactInformation;

import java.util.ArrayList;
import java.util.List;

/**
* This class stores the metadata collected from walking the maven central index.
*/
public class IndexInformation extends ArtifactInformation {
private String name;
private long index;
private final long lastModified;
private final List<Package> packages;

public IndexInformation(ArtifactIdent ident, Package aPackage) {
super(ident);
packages = new ArrayList<>();
packages.add(aPackage);
this.lastModified = aPackage.getLastModified();
}

/**
* Retrieves the last modified value
* @return long represented the last modified value of the artifact
*/
public long getLastModified() {
return lastModified;
}

/**
* Retrieves the name of the artifact
* @return string representing the name of the artifact
*/
public String getName() {
return name;
}

/**
* Updates the name of the artifact
* @param name new name to update with
*/
public void setName(String name) {
this.name = name;
}

/**
* Retrieves the index of the artifact
* @return long representing the index of the artifact
*/
public long getIndex() {
return index;
}

/**
* Updates the value of the artifact index
* @param index new index value to set
*/
public void setIndex(long index) {
this.index = index;
}

/**
* Adds a package which has the same identifier as the current artifact
* @param pack package object to add
*/
public void addAPackage(Package pack) {
packages.add(pack);
}

/**
* Retrieves all the packages under the same identifier
* @return a list of packages
*/
public List<Package> getPackages() {
return packages;
}
}
82 changes: 82 additions & 0 deletions src/main/java/org/tudo/sse/model/index/Package.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.tudo.sse.model.index;

/**
* The Package represents each package stored under a single GAV.
* So multiple packages can be stored under a single GAV, so each are stored as a Package object.
*/

public class Package {
private final String packaging;
private final long lastModified;
private final long size;
private final String sha1checksum;
private final int sourcesExist;
private final int javadocExists;
private final long signatureExists;

public Package(String packaging, long lastModified, long size, int sourcesExist, int javadocExists, long signatureExists, String sha1checksum) {
this.lastModified = lastModified;
this.packaging = packaging;
this.size = size;
this.sha1checksum = sha1checksum;
this.sourcesExist = sourcesExist;
this.javadocExists = javadocExists;
this.signatureExists = signatureExists;
}

/**
* Retrieves the last modified value
* @return long representing the last modified value of the artifact
*/
public long getLastModified() {
return lastModified;
}

/**
* Retrieves the numerical sources exist value
* @return int representing sources exist metadata value
*/
public int getSourcesExist() {
return sourcesExist;
}

/**
* Retrieves the numerical javadoc exist value
* @return int representing source exist metadata value
*/
public int getJavadocExists() {
return javadocExists;
}

/**
* Retrieves the numerical signature exist value
* @return int representing signature exist metadata value
*/
public long getSignatureExists() {
return signatureExists;
}

/**
* Retrieves the packaging type of the artifact
* @return string representing the packaging of the current artifact
*/
public String getPackaging() {
return packaging;
}

/**
* Retrieves the size of the current artifact
* @return long representing the size of the current artifact
*/
public long getSize() {
return size;
}

/**
* Retrieves the Sha1checksum of the current artifact
* @return string representing the Sha1checksum of the current artifact
*/
public String getSha1checksum() {
return sha1checksum;
}
}
10 changes: 0 additions & 10 deletions target/classes/coordinates.txt

This file was deleted.

15 changes: 0 additions & 15 deletions target/classes/log4j2.xml

This file was deleted.

Binary file removed target/classes/org/tudo/sse/ArtifactFactory.class
Binary file not shown.
Binary file removed target/classes/org/tudo/sse/CliInformation.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 0dc7f74

Please sign in to comment.