Skip to content

Commit

Permalink
More renamings.
Browse files Browse the repository at this point in the history
  • Loading branch information
And1sS committed Jul 26, 2024
1 parent 3b00fef commit ec0ab65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.prebid.cache.builders.PrebidServerResponseBuilder;
import org.prebid.cache.config.StorageConfig;
import org.prebid.cache.exceptions.BadRequestException;
import org.prebid.cache.model.ModulePayload;
import org.prebid.cache.model.StoragePayload;
import org.prebid.cache.model.Payload;
import org.prebid.cache.model.PayloadWrapper;
import org.prebid.cache.repository.redis.module.storage.ModuleCompositeRepository;
Expand Down Expand Up @@ -42,12 +42,12 @@ public Mono<ServerResponse> save(final ServerRequest request) {
return ServerResponse.status(HttpStatus.UNAUTHORIZED).build();
}

return request.body(BodyExtractors.toMono(ModulePayload.class))
return request.body(BodyExtractors.toMono(StoragePayload.class))
.switchIfEmpty(Mono.error(new BadRequestException("Empty body")))
.handle(this::validateModulePayload)
.flatMap(modulePayload -> moduleRepository.save(
modulePayload.getApplication(),
mapToPayloadWrapper(modulePayload)))
.flatMap(storagePayload -> moduleRepository.save(
storagePayload.getApplication(),
mapToPayloadWrapper(storagePayload)))
.subscribeOn(Schedulers.parallel())
.flatMap(ignored -> ServerResponse.noContent().build())
.onErrorResume(error -> responseBuilder.error(Mono.just(error), request));
Expand All @@ -57,7 +57,7 @@ private boolean isApiKeyValid(final ServerRequest request) {
return StringUtils.equals(request.headers().firstHeader(API_KEY_HEADER), apiConfig.getApiKey());
}

private void validateModulePayload(final ModulePayload payload, final SynchronousSink<ModulePayload> sink) {
private void validateModulePayload(final StoragePayload payload, final SynchronousSink<StoragePayload> sink) {
final var result = validator.validate(payload);
if (result.isEmpty()) {
sink.next(payload);
Expand All @@ -69,7 +69,7 @@ private void validateModulePayload(final ModulePayload payload, final Synchronou
}
}

private PayloadWrapper mapToPayloadWrapper(final ModulePayload payload) {
private PayloadWrapper mapToPayloadWrapper(final StoragePayload payload) {
final long ttlSeconds = Optional.ofNullable(payload.getTtlseconds())
.map(Integer::longValue)
.orElse(storageConfig.getDefaultTtlSeconds());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Value
@Builder
public class ModulePayload {
public class StoragePayload {

@NotEmpty
public String key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.prebid.cache.builders.PrebidServerResponseBuilder;
import org.prebid.cache.config.StorageConfig;
import org.prebid.cache.handlers.storage.PostStorageHandler;
import org.prebid.cache.model.ModulePayload;
import org.prebid.cache.model.StoragePayload;
import org.prebid.cache.model.Payload;
import org.prebid.cache.model.PayloadWrapper;
import org.prebid.cache.repository.redis.module.storage.ModuleCompositeRepository;
Expand Down Expand Up @@ -78,7 +78,7 @@ public void teardown() {
void testVerifySave() {
given(validator.validate(any())).willReturn(Collections.emptySet());

final var payload = ModulePayload.builder()
final var payload = StoragePayload.builder()
.key("key")
.type(PayloadType.TEXT)
.application("application")
Expand Down Expand Up @@ -113,7 +113,7 @@ void testVerifySave() {
void testVerifyApiKeyAuthorization() {
given(validator.validate(any())).willReturn(Collections.emptySet());

final var payload = ModulePayload.builder()
final var payload = StoragePayload.builder()
.key("key")
.type(PayloadType.TEXT)
.application("application")
Expand Down

0 comments on commit ec0ab65

Please sign in to comment.