-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Ivan Senic
authored
Apr 17, 2023
1 parent
c841b16
commit 9b48a95
Showing
30 changed files
with
274 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
...in/java/io/stargate/sgv2/jsonapi/api/model/command/validation/MaxInsertManyDocuments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
.../stargate/sgv2/jsonapi/api/model/command/validation/MaxInsertManyDocumentsValidation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
package io.stargate.sgv2.jsonapi.api.model.command.validation; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.stargate.sgv2.jsonapi.config.OperationsConfig; | ||
import java.util.List; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Instance; | ||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
/** Validator for the {@link MaxInsertManyDocuments} annotation. */ | ||
@ApplicationScoped | ||
public class MaxInsertManyDocumentsValidation | ||
implements ConstraintValidator<MaxInsertManyDocuments, List<JsonNode>> { | ||
|
||
private final int limit; | ||
private final Instance<OperationsConfig> config; | ||
|
||
// due to https://github.com/quarkusio/quarkus/issues/32265 | ||
// I can only inject prop, not the whole config class | ||
public MaxInsertManyDocumentsValidation( | ||
@ConfigProperty(name = "stargate.jsonapi.doc-limits.max-insert-many-documents") int limit) { | ||
this.limit = limit; | ||
public MaxInsertManyDocumentsValidation(Instance<OperationsConfig> config) { | ||
this.config = config; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public boolean isValid(List<JsonNode> value, ConstraintValidatorContext context) { | ||
return null != value && value.size() <= limit; | ||
return null != value && value.size() <= config.get().maxDocumentInsertCount(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.