Search in sources :

Example 11 with DomElement

use of com.enonic.xp.xml.DomElement in project xp by enonic.

the class XmlWidgetDescriptorParser method doParse.

@Override
protected void doParse(final DomElement root) throws Exception {
    assertTagName(root, "widget");
    this.builder.displayName(root.getChildValueTrimmed("display-name"));
    this.builder.description(root.getChildValue("description"));
    final DomElement interfaces = root.getChild("interfaces");
    if (interfaces != null) {
        final List<DomElement> interfaceList = interfaces.getChildren("interface");
        for (DomElement anInterface : interfaceList) {
            this.builder.addInterface(anInterface.getValue().trim());
        }
    }
    final DomElement allowedPrincipals = root.getChild("allow");
    if (allowedPrincipals != null) {
        final List<PrincipalKey> allowedPrincipalList = allowedPrincipals.getChildren("principal").stream().map(allowedPrincipal -> PrincipalKey.from(allowedPrincipal.getValue().trim())).collect(Collectors.toList());
        this.builder.setAllowedPrincipals(allowedPrincipalList);
    }
    final DomElement config = root.getChild("config");
    if (config != null) {
        final List<DomElement> properties = config.getChildren("property");
        for (DomElement property : properties) {
            this.builder.addProperty(property.getAttribute("name"), property.getAttribute("value"));
        }
    }
}
Also used : WidgetDescriptor(com.enonic.xp.admin.widget.WidgetDescriptor) List(java.util.List) PrincipalKey(com.enonic.xp.security.PrincipalKey) XmlModelParser(com.enonic.xp.xml.parser.XmlModelParser) DomElement(com.enonic.xp.xml.DomElement) Collectors(java.util.stream.Collectors) DomElement(com.enonic.xp.xml.DomElement) PrincipalKey(com.enonic.xp.security.PrincipalKey)

Aggregations

DomElement (com.enonic.xp.xml.DomElement)11 PrincipalKey (com.enonic.xp.security.PrincipalKey)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 WidgetDescriptor (com.enonic.xp.admin.widget.WidgetDescriptor)1 PublicApi (com.enonic.xp.annotation.PublicApi)1 ApplicationRelativeResolver (com.enonic.xp.app.ApplicationRelativeResolver)1 IndexConfig (com.enonic.xp.index.IndexConfig)1 PathIndexConfig (com.enonic.xp.index.PathIndexConfig)1 ContentTypeName (com.enonic.xp.schema.content.ContentTypeName)1 RelationshipType (com.enonic.xp.schema.relationship.RelationshipType)1 XDataName (com.enonic.xp.schema.xdata.XDataName)1 AccessControlList (com.enonic.xp.security.acl.AccessControlList)1 ControllerMappingDescriptor (com.enonic.xp.site.mapping.ControllerMappingDescriptor)1 GenericStyle (com.enonic.xp.style.GenericStyle)1 ImageStyle (com.enonic.xp.style.ImageStyle)1 XmlModelParser (com.enonic.xp.xml.parser.XmlModelParser)1 Collections (java.util.Collections)1