Search in sources :

Example 1 with GsaConfigException

use of org.codelibs.fess.exception.GsaConfigException in project fess by codelibs.

the class GsaConfigParser method parse.

public void parse(final InputSource is) {
    try {
        final SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setFeature(org.codelibs.fess.crawler.Constants.FEATURE_SECURE_PROCESSING, true);
        factory.setFeature(org.codelibs.fess.crawler.Constants.FEATURE_EXTERNAL_GENERAL_ENTITIES, false);
        factory.setFeature(org.codelibs.fess.crawler.Constants.FEATURE_EXTERNAL_PARAMETER_ENTITIES, false);
        final SAXParser parser = factory.newSAXParser();
        parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, StringUtil.EMPTY);
        parser.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, StringUtil.EMPTY);
        parser.parse(is, this);
    } catch (final Exception e) {
        throw new GsaConfigException("Failed to parse XML file.", e);
    }
}
Also used : SAXParser(javax.xml.parsers.SAXParser) GsaConfigException(org.codelibs.fess.exception.GsaConfigException) GsaConfigException(org.codelibs.fess.exception.GsaConfigException) SAXException(org.xml.sax.SAXException) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 2 with GsaConfigException

use of org.codelibs.fess.exception.GsaConfigException in project fess by codelibs.

the class GsaConfigParser method startElement.

@Override
public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
    if (logger.isDebugEnabled()) {
        logger.debug("Start Element: {}", qName);
    }
    if (tagQueue.isEmpty() && !"eef".equalsIgnoreCase(qName)) {
        throw new GsaConfigException("Invalid format.");
    }
    if (COLLECTION.equalsIgnoreCase(qName) && COLLECTIONS.equalsIgnoreCase(tagQueue.peekLast())) {
        final long now = System.currentTimeMillis();
        final String name = attributes.getValue("Name");
        labelType = new LabelType();
        labelType.setName(name);
        labelType.setValue(name);
        labelType.setPermissions(new String[] { "Rguest" });
        labelType.setCreatedBy(Constants.SYSTEM_USER);
        labelType.setCreatedTime(now);
        labelType.setUpdatedBy(Constants.SYSTEM_USER);
        labelType.setUpdatedTime(now);
    }
    tagQueue.offer(qName);
}
Also used : LabelType(org.codelibs.fess.es.config.exentity.LabelType) GsaConfigException(org.codelibs.fess.exception.GsaConfigException)

Aggregations

GsaConfigException (org.codelibs.fess.exception.GsaConfigException)2 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 LabelType (org.codelibs.fess.es.config.exentity.LabelType)1 SAXException (org.xml.sax.SAXException)1