finished documentation for classes ArchDistribution, Distribution and AsyncRequestParse
This commit is contained in:
parent
44ac927f6e
commit
052ba40800
@ -25,8 +25,8 @@ import org.json.*;
|
|||||||
public class ArchDistribution extends AsyncRequestsParser implements Distribution {
|
public class ArchDistribution extends AsyncRequestsParser implements Distribution {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger object used to split debug output and the application output
|
* Logger object used to split debug output and the application output
|
||||||
*/
|
*/
|
||||||
private static final Logger logger = LoggerManager.getLogger("ArchDistribution");
|
private static final Logger logger = LoggerManager.getLogger("ArchDistribution");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,13 +15,24 @@ import java.util.concurrent.Future;
|
|||||||
*/
|
*/
|
||||||
public interface Distribution {
|
public interface Distribution {
|
||||||
/**
|
/**
|
||||||
* Search for a package matching a pattern and return a list of packages and
|
* Search for a package matching a pattern and return a list of packages and
|
||||||
* return a list of string matching this pattern.
|
* return a list of string matching this pattern.
|
||||||
*
|
*
|
||||||
* @param packageName String, the pattern to search in the repositories
|
* @param packageName String, the pattern to search in the repositories
|
||||||
* @return List of SearchedPackage objects
|
* @return List of SearchedPackage objects
|
||||||
*/
|
*/
|
||||||
Future<List<SearchedPackage>> searchPackage(String packageName);
|
Future<List<SearchedPackage>> searchPackage(String packageName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns a fully completed package containing all
|
||||||
|
* information about the package identified by it's exact name passed as
|
||||||
|
* parametter, the package contains in its dependency list fully formed
|
||||||
|
* packages that also contains its dependencies, the dependency depth is
|
||||||
|
* specified by the parametter with the same name.
|
||||||
|
*
|
||||||
|
* @param packageName String, The package's exact name
|
||||||
|
* @param depth int, the depth of the dependency tree
|
||||||
|
* @return Package, the fully completed package
|
||||||
|
*/
|
||||||
Future<Package> getPackageTree(String packageName, int depth);
|
Future<Package> getPackageTree(String packageName, int depth);
|
||||||
}
|
}
|
||||||
|
@ -22,22 +22,30 @@ import java.util.logging.Logger;
|
|||||||
*/
|
*/
|
||||||
public abstract class AsyncRequestsParser {
|
public abstract class AsyncRequestsParser {
|
||||||
/**
|
/**
|
||||||
* Logger object used to split debug output and the application output
|
* Logger object used to split debug output and the application output
|
||||||
*/
|
*/
|
||||||
private static final Logger logger = LoggerManager.getLogger("AsyncRequestsParser");
|
private static final Logger logger = LoggerManager.getLogger("AsyncRequestsParser");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function return a package from the distribution's api in the form
|
* This function returns a package from the distribution's api in the form
|
||||||
* of a Pair Composed of a Package object, and a set of string containing
|
* of a Pair Composed of a Package object and a set of string containing
|
||||||
* the names of the dependecies of the package.
|
* the names of the dependecies of the package.
|
||||||
*
|
*
|
||||||
* @param packageName String, The package's exact name
|
* @param packageName String, The package's exact name
|
||||||
* @return Pair of Package and Set of String
|
* @return Pair of Package and Set of String
|
||||||
*/
|
*/
|
||||||
protected abstract CompletableFuture<Pair<Package, Set<String>>> getPackageFromAPI(String name);
|
protected abstract CompletableFuture<Pair<Package, Set<String>>> getPackageFromAPI(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This function returns a fully completed package containing all
|
||||||
|
* information about the package identified by it's exact name passed as
|
||||||
|
* parametter, the package contains in its dependency list fully formed
|
||||||
|
* packages that also contains its dependencies, the dependency depth is
|
||||||
|
* specified by the parametter with the same name.
|
||||||
*
|
*
|
||||||
|
* @param packageName String, The package's exact name
|
||||||
|
* @param depth int, the depth of the dependency tree
|
||||||
|
* @return Package, the fully completed package
|
||||||
*/
|
*/
|
||||||
public CompletableFuture<Package> getPackageTree(String packageName, int depth) {
|
public CompletableFuture<Package> getPackageTree(String packageName, int depth) {
|
||||||
// parse the json
|
// parse the json
|
||||||
@ -53,7 +61,7 @@ public abstract class AsyncRequestsParser {
|
|||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
futureRequest.thenAccept(result -> {
|
futureRequest.thenAccept(result -> {
|
||||||
if(result==null){
|
if (result == null) {
|
||||||
logger.fine("Completing callback INVALID for package %s (depth=%s)".formatted(packageName, depth));
|
logger.fine("Completing callback INVALID for package %s (depth=%s)".formatted(packageName, depth));
|
||||||
futurePackage.complete(null);
|
futurePackage.complete(null);
|
||||||
return;
|
return;
|
||||||
@ -61,7 +69,6 @@ public abstract class AsyncRequestsParser {
|
|||||||
Package pack = result.getFirst();
|
Package pack = result.getFirst();
|
||||||
Set<String> dependenciesNames = result.getSecond();
|
Set<String> dependenciesNames = result.getSecond();
|
||||||
|
|
||||||
|
|
||||||
// if we're at the maximum depth, return the package without its dependencies
|
// if we're at the maximum depth, return the package without its dependencies
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
logger.fine("Completing callback NODEP for package %s (depth=%s)".formatted(packageName, depth));
|
logger.fine("Completing callback NODEP for package %s (depth=%s)".formatted(packageName, depth));
|
||||||
@ -93,7 +100,8 @@ public abstract class AsyncRequestsParser {
|
|||||||
futurePackage.complete(pack);
|
futurePackage.complete(pack);
|
||||||
}).exceptionally(error -> {
|
}).exceptionally(error -> {
|
||||||
error.printStackTrace();
|
error.printStackTrace();
|
||||||
logger.warning("Error while manipulating package %s (depth=%s) : \n%s".formatted(packageName, depth, error));
|
logger.warning(
|
||||||
|
"Error while manipulating package %s (depth=%s) : \n%s".formatted(packageName, depth, error));
|
||||||
futurePackage.complete(null);
|
futurePackage.complete(null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user