Search in sources :

Example 1 with CacheInitialisationException

use of org.apache.stanbol.entityhub.servicesapi.yard.CacheInitialisationException in project stanbol by apache.

the class CacheUtils method loadBaseMappings.

/**
 * Loads the base mappings form the parsed Yard
 * @param yard The yard
 * @param nsPrefixService if present '{prefix}:{localname}' configurations are
 * @return The baseMappings
 * @throws YardException on any Error while getting the Representation holding
 * the Configuration from the Yard.
 * @throws CacheInitialisationException if the configuration is found but not
 * valid.
 * @throws IllegalArgumentException if <code>null</code> is parsed as {@link Yard}
 */
public static FieldMapper loadBaseMappings(Yard yard, NamespacePrefixService nsPrefixService) throws YardException, CacheInitialisationException {
    if (yard == null) {
        throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!");
    }
    Representation baseConfig = yard.getRepresentation(Cache.BASE_CONFIGURATION_URI);
    if (baseConfig != null) {
        FieldMapper mapper = readFieldConfig(yard, baseConfig, nsPrefixService);
        if (mapper == null) {
            String msg = "Invalid Base Configuration: Unable to parse FieldMappings from Field " + Cache.FIELD_MAPPING_CONFIG_FIELD;
            log.error(msg);
            if (log.isErrorEnabled()) {
                log.error(ModelUtils.getRepresentationInfo(baseConfig));
            }
            throw new CacheInitialisationException(msg);
        } else {
            return mapper;
        }
    } else {
        return null;
    // throw new CacheInitialisationException("Base Configuration not present");
    }
}
Also used : CacheInitialisationException(org.apache.stanbol.entityhub.servicesapi.yard.CacheInitialisationException) Representation(org.apache.stanbol.entityhub.servicesapi.model.Representation) FieldMapper(org.apache.stanbol.entityhub.servicesapi.mapping.FieldMapper)

Aggregations

FieldMapper (org.apache.stanbol.entityhub.servicesapi.mapping.FieldMapper)1 Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)1 CacheInitialisationException (org.apache.stanbol.entityhub.servicesapi.yard.CacheInitialisationException)1