Validate single attribute of an entity.

@param entity - Entity.
@param attribute - Name of attribute to be validated.
@return true, if attribute value is valid; false, otherwise.
@throws OidException
@throws ConnectionException
@throws APIException
197900
public boolean validate(Entity entity, String attribute) throws APIException, ConnectionException, OidException {
        Asset asset = v1Instance.getAsset(entity.getInstanceKey()) != null ? v1Instance.getAsset(entity.getInstanceKey()) : v1Instance.getAsset(entity.getID());
        IAttributeDefinition attributeDefinition = asset.getAssetType().getAttributeDefinition(attribute);
        return validator.validate(asset, attributeDefinition);
    }
573196
public Map<Entity, List<String>> validate(Entity[] entities) throws APIException, ConnectionException, OidException {
        Map<Entity, List<String>> results = new HashMap<Entity, List<String>>();

        for (Entity entity : entities) {
            results.put(entity, validate(entity));
        }

        return results;
    }
234066
public boolean isValidEntityObject(Object entity, EntityMetadata metadata)
    {
        if (entity == null)
        {
            log.error("Entity to be persisted must not be null, operation failed");
            return false;
        }

        Object id = PropertyAccessorHelper.getId(entity, metadata);
        if (id == null)
        {
            log.error("Entity to be persisted can't have Primary key set to null.");
            throw new IllegalArgumentException("Entity to be persisted can't have Primary key set to null.");
            // return false;
        }
        return true;
    }
1073594
public Response getEntityDefinitionByAttribute(String entityType, String attribute, String value) {
        try {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Fetching entity definition for type={}, qualified name={}", entityType, value);
            }

            entityType = ParamChecker.notEmpty(entityType, "Entity type cannot be null");
            attribute  = ParamChecker.notEmpty(attribute, "attribute name cannot be null");
            value      = ParamChecker.notEmpty(value, "attribute value cannot be null");

            Map<String, Object> attributes = new HashMap<>();
            attributes.put(attribute, value);

            AtlasEntityWithExtInfo entityInfo;

            try {
                entityInfo = entitiesStore.getByUniqueAttributes(getEntityType(entityType), attributes);
            } catch (AtlasBaseException e) {
                LOG.error("Cannot find entity with type: {}, attribute: {} and value: {}", entityType, attribute, value);
                throw toWebApplicationException(e);
            }

            String entityDefinition = null;

            if (entityInfo != null) {
                AtlasEntity entity = entityInfo.getEntity();
                final ITypedReferenceableInstance instance = restAdapters.getITypedReferenceable(entity);

                entityDefinition = InstanceSerialization.toJson(instance, true);
            }

            JSONObject response = new JSONObject();
            response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());

            Response.Status status = Response.Status.NOT_FOUND;
            if (entityDefinition != null) {
                response.put(AtlasClient.DEFINITION, new JSONObject(entityDefinition));
                status = Response.Status.OK;
            } else {
                response.put(AtlasClient.ERROR, Servlets.escapeJsonString(String.format("An entity with type={%s}, " +
                        "qualifiedName={%s} does not exist", entityType, value)));
            }

            return Response.status(status).entity(response).build();

        } catch (AtlasBaseException e) {
            LOG.error("Unable to get instance definition for type={}, qualifiedName={}", entityType, value, e);
            throw toWebApplicationException(e);
        } catch (IllegalArgumentException e) {
            LOG.error("Bad type={}, qualifiedName={}", entityType, value, e);
            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
        } catch (WebApplicationException e) {
            LOG.error("Unable to get instance definition for type={}, qualifiedName={}", entityType, value, e);
            throw e;
        } catch (Throwable e) {
            LOG.error("Unable to get instance definition for type={}, qualifiedName={}", entityType, value, e);
            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
        }
    }
192025
@Override
    public void validateDefault(InputProblemReporter rep, boolean normalize)
        throws XMLStreamException
    {
        String normStr = validateDefaultName(rep, normalize);
        if (normalize) {
            mDefValue.setValue(normStr);
        }

        // Ok, but was it declared?

        /* 03-Dec-2004, TSa: This is rather ugly -- need to know we
         *   actually really get a DTD reader, and DTD reader needs
         *   to expose a special method... but it gets things done.
         */
        EntityDecl ent = ((MinimalDTDReader) rep).findEntity(normStr);
        checkEntity(rep, normStr, ent);
    }
959460
public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) {
        validateStereotypes(attributes, manager);
        validateQualifiers(attributes, manager);
        validateTypes(attributes, manager);
        validateScope(attributes, manager);
    }
709838
public boolean getAttributeAsBoolean(AnnotationAttributeType attribute) {
		String temp = attributes.get(attribute.getValue());

		return Boolean.parseBoolean(temp);
	}
149315
private void validate(Entity entity) {
    MailSettingsImpl mailSettings = new MailSettingsImpl(entity);
    if (mailSettings.isTestConnection()
        && mailSettings.getUsername() != null
        && mailSettings.getPassword() != null) {
      mailSenderFactory.validateConnection(mailSettings);
    }
  }
718062
public void validateAttributes(Collection<String> attributes) throws CompatibilityException {
                Validate.notNull(attributes);
                for (String attribute : attributes) {
                        validateAttribute(attribute);
                }
        }
930053
public static void addAttribute(String name, String oid, Class<?> clazz)
            throws CertificateException {
        ObjectIdentifier objId;
        try {
            objId = new ObjectIdentifier(oid);
        } catch (IOException ioe) {
            throw new CertificateException
                                ("Invalid Object identifier: " + oid);
        }
        OIDInfo info = new OIDInfo(name, objId, clazz);
        if (oidMap.put(objId, info) != null) {
            throw new CertificateException
                                ("Object identifier already exists: " + oid);
        }
        if (nameMap.put(name, info) != null) {
            throw new CertificateException("Name already exists: " + name);
        }
    }
904783
protected function validateAttribute($object, $attribute)
    {
        $value = $object->{$attribute};
        if ($this->isEmpty($value)) {
            $this->addError($object, $attribute, $this->message);
        }
    }
238754
protected void validateProperties(final Object entity, final EntityDataModel edm)
            throws ODataException {
        final Type type = edm.getType(entity.getClass());
        // No validation needed if it is not a structured type
        if (!(type instanceof StructuredType)) {
            return;
        }

        visitProperties(edm, (StructuredType) type, property -> {
            Object value = getPropertyValue(property, entity);
            if (value == null) {
                if (!property.isNullable()) {
                    throw new ODataBadRequestException("The property '" + property.getName() +
                            "' is required to be non-empty in an entity of type: " + type.getFullyQualifiedName());
                }
            } else if (!(property instanceof NavigationProperty)) {
                // Validate contained properties, but not if the property is a navigation property.
                // Navigation properties in a request are only links, they don't contain the entity that the
                // navigation property points to itself.
                validateProperties(value, edm);
            }
        });
    }
45472
protected function validateAttribute($object, $attribute)
    {
        $value = $object->{$attribute};
        if ($this->isEmpty($value)) {
            $this->validateEmpty($object, $attribute);
            return;
        }
        if (!$this->validateValue($value)) {
            $this->addError($object, $attribute, $this->message);
        }
    }
780211
public void setState(Attribute<E, ?> attribute, PropertyState state) {
        if (!stateless) {
            attribute.getPropertyState().set(entity, state);
        }
    }
440505
public boolean validate(E entity)
    {
        if (entity != null)
        {
            // entity metadata could be null.
            if (entityMetadata == null)
            {
                throw new IllegalArgumentException(
                        "Entity object is invalid, operation failed. Please check previous log message for details");
            }

            return false;

        }

        // will return false if entity is null.
        return true;
    }
1112441
public void setEntity_attributes(int i, EntityAttribute v) { 
    if (Entity_Type.featOkTst && ((Entity_Type)jcasType).casFeat_entity_attributes == null)
      jcasType.jcas.throwFeatMissing("entity_attributes", "de.julielab.jules.types.ace.Entity");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Entity_Type)jcasType).casFeatCode_entity_attributes), i);
    jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Entity_Type)jcasType).casFeatCode_entity_attributes), i, jcasType.ll_cas.ll_getFSRef(v));}
159322
static void validateLabelAttribute(EntityType entityType) {
    if (entityType.getLabelAttribute() != null && !entityType.getLabelAttribute().isVisible()) {
      throw new MolgenisValidationException(
          new ConstraintViolation(
              format(
                  "Label attribute [%s] of EntityType [%s] must be visible.",
                  entityType.getLabelAttribute().getName(), entityType.getId())));
    }

    if (!entityType.isAbstract()
        && !entityType.getIdAttribute().isVisible()
        && (entityType.getLabelAttribute() == null)) {
      throw new MolgenisValidationException(
          new ConstraintViolation(
              format(
                  "EntityType [%s] must define a label attribute because the identifier is hidden",
                  entityType.getId())));
    }
  }