use of org.graylog2.contentpacks.model.constraints.Constraint in project graylog2-server by Graylog2.
the class PluginVersionConstraintChecker method ensureConstraints.
@Override
public Set<Constraint> ensureConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<Constraint> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof PluginVersionConstraint) {
final PluginVersionConstraint versionConstraint = (PluginVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
for (Semver pluginVersion : pluginVersions) {
if (requiredVersion.isSatisfiedBy(pluginVersion)) {
fulfilledConstraints.add(constraint);
}
}
}
}
return fulfilledConstraints.build();
}
use of org.graylog2.contentpacks.model.constraints.Constraint in project graylog2-server by Graylog2.
the class LookupCacheFacade method exportNativeEntity.
@VisibleForTesting
Entity exportNativeEntity(CacheDto cacheDto, EntityDescriptorIds entityDescriptorIds) {
// TODO: Create independent representation of entity?
final Map<String, Object> configuration = objectMapper.convertValue(cacheDto.config(), TypeReferences.MAP_STRING_OBJECT);
final LookupCacheEntity lookupCacheEntity = LookupCacheEntity.create(ValueReference.of(cacheDto.name()), ValueReference.of(cacheDto.title()), ValueReference.of(cacheDto.description()), toReferenceMap(configuration));
final JsonNode data = objectMapper.convertValue(lookupCacheEntity, JsonNode.class);
final Set<Constraint> constraints = versionConstraints(cacheDto);
return EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(cacheDto.id(), ModelTypes.LOOKUP_CACHE_V1))).type(ModelTypes.LOOKUP_CACHE_V1).constraints(ImmutableSet.copyOf(constraints)).data(data).build();
}
use of org.graylog2.contentpacks.model.constraints.Constraint in project graylog2-server by Graylog2.
the class GraylogVersionConstraintChecker method checkConstraints.
@Override
public Set<ConstraintCheckResult> checkConstraints(Collection<Constraint> requestedConstraints) {
final ImmutableSet.Builder<ConstraintCheckResult> fulfilledConstraints = ImmutableSet.builder();
for (Constraint constraint : requestedConstraints) {
if (constraint instanceof GraylogVersionConstraint) {
final GraylogVersionConstraint versionConstraint = (GraylogVersionConstraint) constraint;
final Requirement requiredVersion = versionConstraint.version();
final ConstraintCheckResult constraintCheckResult = ConstraintCheckResult.create(versionConstraint, requiredVersion.isSatisfiedBy(graylogVersion.withClearedSuffixAndBuild()));
fulfilledConstraints.add(constraintCheckResult);
}
}
return fulfilledConstraints.build();
}
Aggregations