finished documentation for class FedoraDistribution and fixed formating

This commit is contained in:
Djalim Simaila 2022-12-14 14:22:33 +01:00
parent 052ba40800
commit 6db7bc4b31

View File

@ -17,10 +17,28 @@ import fr.packageviewer.LoggerManager;
import fr.packageviewer.pack.Package;
import fr.packageviewer.pack.SearchedPackage;
/**
* This class handles package requests for Fedora. All return objects in
* this class are wrapped by a CompletableFuture to ensure async workload.
*
* @author S.Djalim, R.Thomas
* @version 1.0
*/
public class FedoraDistribution extends AsyncRequestsParser implements Distribution {
/**
* Logger object used to split debug output and the application output
*/
private static final Logger logger = LoggerManager.getLogger("FedoraDistribution");
/**
* This function return a package from Fedora metadata api in the form of a
* Pair Composed of a Package object, and a set of string containing the
* names of the dependecies of the package.
*
* @param packageName String, The package's exact name
* @return Pair of Package and Set of String
*/
protected CompletableFuture<Pair<Package, Set<String>>> getPackageFromAPI(String packageName) {
// create a new http client
HttpClient client = HttpClient.newHttpClient();
@ -60,10 +78,8 @@ public class FedoraDistribution extends AsyncRequestsParser implements Distribut
json.getString("basename"),
json.getString("version"),
json.getString("repo"),
json.getString("description")
),
dependenciesNames
));
json.getString("description")),
dependenciesNames));
}).exceptionally(error -> {
error.printStackTrace();
logger.warning("Error while fetching package %s from the API : \n%s".formatted(packageName, error));
@ -74,6 +90,13 @@ public class FedoraDistribution extends AsyncRequestsParser implements Distribut
return futureResult;
}
/**
* Search for a package matching a pattern and return a list of packages and
* return a list of string matching this pattern.
*
* @param packageName String, the pattern to search in the repositories
* @return List of SearchedPackage objects
*/
@Override
public CompletableFuture<List<SearchedPackage>> searchPackage(String packageName) {