Search in sources :

Example 1 with QNameFilter

use of org.alfresco.opencmis.dictionary.QNameFilter in project SearchServices by Alfresco.

the class AlfrescoSolrDataModel method getQNameFilter.

/**
 * TODO: Fix to load type filter/exclusions from somewhere sensible
 * @return QNameFilter
 */
private QNameFilter getQNameFilter() {
    QNameFilter qnameFilter = null;
    FileSystemXmlApplicationContext ctx = null;
    File resourceDirectory = getResourceDirectory();
    // If we ever need to filter out models in the future, then we must put a filter somewhere.
    // Currently, we do not need to filter any models, so this filter does not exist.
    File filterContext = new File(resourceDirectory, "opencmis-qnamefilter-context.xml");
    if (!filterContext.exists()) {
        log.info("No type filter context found at " + filterContext.getAbsolutePath() + ", no type filtering");
        return qnameFilter;
    }
    try {
        ctx = new FileSystemXmlApplicationContext(new String[] { "file:" + filterContext.getAbsolutePath() }, false);
        ctx.setClassLoader(this.getClass().getClassLoader());
        ctx.refresh();
        qnameFilter = (QNameFilter) ctx.getBean("cmisTypeExclusions");
        if (qnameFilter == null) {
            log.warn("Unable to find type filter at " + filterContext.getAbsolutePath() + ", no type filtering");
        }
    } catch (BeansException e) {
        log.warn("Unable to parse type filter at " + filterContext.getAbsolutePath() + ", no type filtering");
    } finally {
        if (ctx != null && ctx.getBeanFactory() != null && ctx.isActive()) {
            ctx.close();
        }
    }
    return qnameFilter;
}
Also used : FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) QNameFilter(org.alfresco.opencmis.dictionary.QNameFilter) File(java.io.File) BeansException(org.springframework.beans.BeansException)

Aggregations

File (java.io.File)1 QNameFilter (org.alfresco.opencmis.dictionary.QNameFilter)1 BeansException (org.springframework.beans.BeansException)1 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)1