Search in sources :

Example 1 with EndElement

use of org.exist.util.sax.event.contenthandler.EndElement in project exist by eXist-db.

the class ConfigurationDocumentTrigger method setAccountPrimaryGroupToNoGroup.

private void setAccountPrimaryGroupToNoGroup() throws SAXException {
    final SAXEvent firstEvent = deferred.peek();
    if (!(firstEvent instanceof StartElement)) {
        throw new SAXException("Unbalanced SAX Events");
    }
    StartElement start = ((StartElement) firstEvent);
    if (start.namespaceURI == null || !start.namespaceURI.equals(Configuration.NS) || !start.localName.equals(PrincipalType.ACCOUNT.getElementName())) {
        throw new SAXException("First element does not match ending '" + PrincipalType.ACCOUNT.getElementName() + "' element");
    }
    start = (StartElement) deferred.pop();
    final AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "name", "name", "CDATA", SecurityManager.UNKNOWN_GROUP);
    final StartElement startPrimaryGroup = new StartElement(start.namespaceURI, PrincipalType.GROUP.getElementName(), PrincipalType.GROUP.getElementName(), attrs);
    final EndElement endPrimaryGroup = new EndElement(startPrimaryGroup.namespaceURI, startPrimaryGroup.localName, startPrimaryGroup.qname);
    deferred.push(endPrimaryGroup);
    deferred.push(startPrimaryGroup);
    deferred.push(start);
}
Also used : StartElement(org.exist.util.sax.event.contenthandler.StartElement) AttributesImpl(org.xml.sax.helpers.AttributesImpl) SAXEvent(org.exist.util.sax.event.SAXEvent) EndElement(org.exist.util.sax.event.contenthandler.EndElement) SAXException(org.xml.sax.SAXException)

Aggregations

SAXEvent (org.exist.util.sax.event.SAXEvent)1 EndElement (org.exist.util.sax.event.contenthandler.EndElement)1 StartElement (org.exist.util.sax.event.contenthandler.StartElement)1 SAXException (org.xml.sax.SAXException)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1