Search in sources :

Example 46 with NotNull

use of javax.validation.constraints.NotNull in project vboard by voyages-sncf-technologies.

the class AuthenticationController method getSessionUserWithSyncFromDB.

@NotNull
public User getSessionUserWithSyncFromDB() {
    final User sessionUser = this.getSessionUser();
    if (ANONYMOUS_USER.equals(sessionUser)) {
        return ANONYMOUS_USER;
    }
    final User dbUser = this.userDAO.findByEmail(sessionUser.getEmail());
    if (dbUser == null) {
        throw new VBoardException("No user found in DB for email=" + sessionUser.getEmail());
    }
    if (!dbUser.equals(this.getSessionUser())) {
        this.logger.debug("Updating user in session cache");
        this.session.setAttribute("User", dbUser);
    }
    return dbUser;
}
Also used : User(com.vsct.vboard.models.User) VBoardException(com.vsct.vboard.models.VBoardException) NotNull(javax.validation.constraints.NotNull)

Example 47 with NotNull

use of javax.validation.constraints.NotNull in project drill by axbaretto.

the class DrillMetaImpl method drillFieldMetaData.

// Overriding fieldMetaData as Calcite version create ColumnMetaData with invalid offset
protected static ColumnMetaData.StructType drillFieldMetaData(Class<?> clazz) {
    final List<ColumnMetaData> list = new ArrayList<>();
    for (Field field : clazz.getFields()) {
        if (Modifier.isPublic(field.getModifiers()) && !Modifier.isStatic(field.getModifiers())) {
            NotNull notNull = field.getAnnotation(NotNull.class);
            boolean notNullable = (notNull != null || field.getType().isPrimitive());
            list.add(drillColumnMetaData(AvaticaUtils.camelToUpper(field.getName()), list.size(), field.getType(), notNullable));
        }
    }
    return ColumnMetaData.struct(list);
}
Also used : Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) ColumnMetaData(org.apache.calcite.avatica.ColumnMetaData) NotNull(javax.validation.constraints.NotNull)

Example 48 with NotNull

use of javax.validation.constraints.NotNull in project minijax by minijax.

the class MinijaxConstraintDescriptor method build.

@SuppressWarnings("unchecked")
public static <T extends Annotation> MinijaxConstraintDescriptor<T> build(final AnnotatedType annotatedType, final T annotation) {
    final Constraint constraint = annotation.annotationType().getAnnotation(Constraint.class);
    if (constraint == null) {
        return null;
    }
    final Class<?> valueClass = ReflectionUtils.getRawType(annotatedType);
    final Class<?> annotationClass = annotation.annotationType();
    if (constraint.validatedBy().length > 0) {
        return buildDeclaredValidator(annotation, constraint.validatedBy()[0]);
    } else if (annotationClass == AssertFalse.class) {
        return (MinijaxConstraintDescriptor<T>) buildAssertFalseValidator((AssertFalse) annotation, valueClass);
    } else if (annotationClass == AssertTrue.class) {
        return (MinijaxConstraintDescriptor<T>) buildAssertTrueValidator((AssertTrue) annotation, valueClass);
    } else if (annotationClass == Max.class) {
        return (MinijaxConstraintDescriptor<T>) buildMaxValidator((Max) annotation, valueClass);
    } else if (annotationClass == Min.class) {
        return (MinijaxConstraintDescriptor<T>) buildMinValidator((Min) annotation, valueClass);
    } else if (annotationClass == NotBlank.class) {
        return (MinijaxConstraintDescriptor<T>) buildNotBlankValidator((NotBlank) annotation, valueClass);
    } else if (annotationClass == NotEmpty.class) {
        return (MinijaxConstraintDescriptor<T>) buildNotEmptyValidator((NotEmpty) annotation, valueClass);
    } else if (annotationClass == NotNull.class) {
        return (MinijaxConstraintDescriptor<T>) buildNotNullValidator((NotNull) annotation);
    } else if (annotationClass == Pattern.class) {
        return (MinijaxConstraintDescriptor<T>) buildPatternValidator((Pattern) annotation, valueClass);
    } else if (annotationClass == Size.class) {
        return (MinijaxConstraintDescriptor<T>) buildSizeValidator((Size) annotation, valueClass);
    } else {
        throw new ValidationException("Unrecognized constraint annotation: " + annotation);
    }
}
Also used : Pattern(javax.validation.constraints.Pattern) ValidationException(javax.validation.ValidationException) Constraint(javax.validation.Constraint) Max(javax.validation.constraints.Max) Size(javax.validation.constraints.Size) AssertTrue(javax.validation.constraints.AssertTrue) NotNull(javax.validation.constraints.NotNull) Min(javax.validation.constraints.Min) NotBlank(javax.validation.constraints.NotBlank) AssertFalse(javax.validation.constraints.AssertFalse) NotEmpty(javax.validation.constraints.NotEmpty)

Example 49 with NotNull

use of javax.validation.constraints.NotNull in project rpki-validator-3 by RIPE-NCC.

the class ValidatedRpkiObjects method initialize.

@PostConstruct
private synchronized void initialize() {
    new TransactionTemplate(transactionManager).execute((status) -> {
        Map<@NotNull @Valid TrustAnchor, List<RpkiObject>> grouped = Stream.concat(rpkiObjects.findCurrentlyValidated(RpkiObject.Type.ROA), rpkiObjects.findCurrentlyValidated(RpkiObject.Type.ROUTER_CER)).collect(Collectors.groupingBy(pair -> pair.getLeft().getTrustAnchor(), Collectors.mapping(pair -> pair.getRight(), Collectors.toList())));
        grouped.forEach(this::update);
        return null;
    });
}
Also used : X509RouterCertificate(net.ripe.rpki.commons.crypto.x509cert.X509RouterCertificate) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Value(lombok.Value) ArrayList(java.util.ArrayList) Sorting(net.ripe.rpki.validator3.api.Sorting) Valid(javax.validation.Valid) Asn(net.ripe.ipresource.Asn) Paging(net.ripe.rpki.validator3.api.Paging) ImmutableList(com.google.common.collect.ImmutableList) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) Transactions(net.ripe.rpki.validator3.util.Transactions) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) ImmutableSet(com.google.common.collect.ImmutableSet) Transactional(javax.transaction.Transactional) IpRange(net.ripe.ipresource.IpRange) Collection(java.util.Collection) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) Slf4j(lombok.extern.slf4j.Slf4j) Component(org.springframework.stereotype.Component) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) PostConstruct(javax.annotation.PostConstruct) ValidationResult(net.ripe.rpki.commons.validation.ValidationResult) SearchTerm(net.ripe.rpki.validator3.api.SearchTerm) Optional(java.util.Optional) X509CertificateUtil(net.ripe.rpki.commons.crypto.x509cert.X509CertificateUtil) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PostConstruct(javax.annotation.PostConstruct)

Example 50 with NotNull

use of javax.validation.constraints.NotNull in project solr-document-store by DBCDK.

the class EEConfig method getValue.

private String getValue(InjectionPoint ip) throws EJBException {
    String name = getName(ip);
    String value = props.getProperty(name);
    if (value == null) {
        Default def = ip.getAnnotated().getAnnotation(Default.class);
        if (def != null) {
            value = def.value();
        }
    }
    NotNull notNull = ip.getAnnotated().getAnnotation(NotNull.class);
    if (notNull != null && value == null) {
        throw new EJBException("Cannot resolve value for: " + name + " null is not allowed");
    }
    log.info("Configuration value {}:{}", name, value);
    return value;
}
Also used : EJBException(javax.ejb.EJBException) NotNull(javax.validation.constraints.NotNull)

Aggregations

NotNull (javax.validation.constraints.NotNull)77 List (java.util.List)24 Map (java.util.Map)18 Collectors (java.util.stream.Collectors)16 Inject (javax.inject.Inject)16 Logger (org.slf4j.Logger)14 ArrayList (java.util.ArrayList)13 LoggerFactory (org.slf4j.LoggerFactory)13 HashMap (java.util.HashMap)11 Response (javax.ws.rs.core.Response)10 Optional (java.util.Optional)9 Strings (com.google.common.base.Strings)8 Lists (com.google.common.collect.Lists)8 Set (java.util.Set)8 Valid (javax.validation.Valid)8 Api (io.swagger.annotations.Api)7 ApiParam (io.swagger.annotations.ApiParam)7 IOException (java.io.IOException)7 Collection (java.util.Collection)7 Nullable (javax.annotation.Nullable)7