finished documentation for classes ArchDistribution, Distribution and AsyncRequestParse

This commit is contained in:
Djalim Simaila 2022-12-14 14:17:51 +01:00
parent 44ac927f6e
commit 052ba40800
3 changed files with 42 additions and 23 deletions

View File

@ -23,5 +23,16 @@ public interface Distribution {
*/ */
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);
} }

View File

@ -27,8 +27,8 @@ public abstract class AsyncRequestsParser {
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
@ -37,7 +37,15 @@ public abstract class AsyncRequestsParser {
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
@ -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;
}); });