use of org.haiku.haikudepotserver.api1.model.pkg.IncrementViewCounterRequest in project haikudepotserver by haiku.
the class PkgApiImpl method incrementViewCounter.
@Override
public IncrementViewCounterResult incrementViewCounter(IncrementViewCounterRequest request) {
Preconditions.checkArgument(null != request, "the request object must be supplied");
Preconditions.checkArgument(!Strings.isNullOrEmpty(request.name), "the package name must be supplied");
Preconditions.checkArgument(!Strings.isNullOrEmpty(request.architectureCode), "the architecture must be supplied");
Preconditions.checkArgument(!Strings.isNullOrEmpty(request.repositoryCode), "the repository code must be supplied");
Preconditions.checkArgument(!Strings.isNullOrEmpty(request.major), "the version major must be supplied");
ObjectContext context = serverRuntime.newContext();
VersionCoordinates versionCoordinates = new VersionCoordinates(request.major, request.minor, request.micro, request.preRelease, request.revision);
PkgVersion pkgVersion = PkgVersion.getForPkg(context, Pkg.getByName(context, request.name), Repository.getByCode(context, request.repositoryCode), Architecture.getByCode(context, request.architectureCode), versionCoordinates).orElseThrow(() -> new ObjectNotFoundException(PkgVersion.class.getSimpleName(), versionCoordinates));
incrementCounter(pkgVersion);
return new IncrementViewCounterResult();
}
use of org.haiku.haikudepotserver.api1.model.pkg.IncrementViewCounterRequest in project haikudepotserver by haiku.
the class PkgApiImpl method incrementViewCounter.
@Override
public ResponseEntity<IncrementViewCounterResponseEnvelope> incrementViewCounter(@Valid IncrementViewCounterRequestEnvelope incrementViewCounterRequestEnvelope) {
IncrementViewCounterRequest requestV1 = new IncrementViewCounterRequest();
requestV1.architectureCode = incrementViewCounterRequestEnvelope.getArchitectureCode();
requestV1.repositoryCode = incrementViewCounterRequestEnvelope.getRepositoryCode();
requestV1.name = incrementViewCounterRequestEnvelope.getName();
requestV1.major = incrementViewCounterRequestEnvelope.getMajor();
requestV1.minor = incrementViewCounterRequestEnvelope.getMinor();
requestV1.micro = incrementViewCounterRequestEnvelope.getMicro();
requestV1.preRelease = incrementViewCounterRequestEnvelope.getPreRelease();
requestV1.revision = incrementViewCounterRequestEnvelope.getRevision();
pkgApiV1.incrementViewCounter(requestV1);
return ResponseEntity.ok(new IncrementViewCounterResponseEnvelope());
}
use of org.haiku.haikudepotserver.api1.model.pkg.IncrementViewCounterRequest in project haikudepotserver by haiku.
the class PkgApiIT method testIncrementViewCounter.
@Test
public void testIncrementViewCounter() {
integrationTestSupportService.createStandardTestData();
IncrementViewCounterRequest request = new IncrementViewCounterRequest();
request.major = "1";
request.micro = "2";
request.revision = 3;
request.name = "pkg1";
request.architectureCode = "x86_64";
request.repositoryCode = "testrepo";
// ------------------------------------
IncrementViewCounterResult result = pkgApi.incrementViewCounter(request);
// ------------------------------------
Assertions.assertThat(result).isNotNull();
{
ObjectContext context = serverRuntime.newContext();
Pkg pkg1 = Pkg.getByName(context, "pkg1");
Repository repository = Repository.getByCode(context, "testrepo");
Architecture architecture = Architecture.getByCode(context, "x86_64");
PkgVersion pkgVersion = PkgVersion.getForPkg(context, pkg1, repository, architecture, new VersionCoordinates("1", null, "2", null, 3)).get();
Assertions.assertThat(pkgVersion.getViewCounter()).isEqualTo(1L);
}
}
Aggregations