Search in sources :

Example 6 with DomElement

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

the class XmlSiteParser method toMappingDescriptor.

private ControllerMappingDescriptor toMappingDescriptor(final DomElement mappingElement) {
    final ControllerMappingDescriptor.Builder builder = ControllerMappingDescriptor.create();
    final String controllerPath = mappingElement.getAttribute(MAPPING_DESCRIPTOR_CONTROLLER_ATTRIBUTE);
    if (!nullToEmpty(controllerPath).isBlank()) {
        builder.controller(ResourceKey.from(this.currentApplication, controllerPath));
    }
    final String filterPath = mappingElement.getAttribute(MAPPING_DESCRIPTOR_FILTER_ATTRIBUTE);
    if (!nullToEmpty(filterPath).isBlank()) {
        builder.filter(ResourceKey.from(this.currentApplication, filterPath));
    }
    final String orderValue = mappingElement.getAttribute(MAPPING_DESCRIPTOR_ORDER_ATTRIBUTE);
    if (!isNullOrEmpty(orderValue)) {
        builder.order(Integer.parseInt(orderValue));
    }
    final DomElement matchElement = mappingElement.getChild(MAPPING_DESCRIPTOR_MATCH_TAG_NAME);
    if (matchElement != null) {
        final String match = matchElement.getValue();
        if (!isNullOrEmpty(match)) {
            builder.contentConstraint(match);
        }
    }
    final DomElement patternElement = mappingElement.getChild(MAPPING_DESCRIPTOR_PATTERN_TAG_NAME);
    if (patternElement != null) {
        final String pattern = patternElement.getValue();
        if (!isNullOrEmpty(pattern)) {
            final boolean invert = "true".equals(patternElement.getAttribute(MAPPING_DESCRIPTOR_INVERT_ATTRIBUTE, "false"));
            builder.pattern(pattern);
            builder.invertPattern(invert);
        }
    }
    return builder.build();
}
Also used : DomElement(com.enonic.xp.xml.DomElement) ControllerMappingDescriptor(com.enonic.xp.site.mapping.ControllerMappingDescriptor)

Example 7 with DomElement

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

the class XmlStyleDescriptorParser method toGenericStyle.

private GenericStyle toGenericStyle(final DomElement styleElement) {
    final GenericStyle.Builder builder = GenericStyle.create();
    builder.name(styleElement.getAttribute(ELEMENT_NAME_ATTRIBUTE_NAME));
    final DomElement displayName = styleElement.getChild(DISPLAY_NAME_TAG_NAME);
    if (displayName != null) {
        builder.displayName(displayName.getValue());
        builder.displayNameI18nKey(displayName.getAttribute(I18N_ATTRIBUTE_NAME));
    }
    return builder.build();
}
Also used : GenericStyle(com.enonic.xp.style.GenericStyle) DomElement(com.enonic.xp.xml.DomElement)

Example 8 with DomElement

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

the class XmlStyleDescriptorParser method toImageStyle.

private ImageStyle toImageStyle(final DomElement styleElement) {
    final ImageStyle.Builder builder = ImageStyle.create();
    builder.name(styleElement.getAttribute(ELEMENT_NAME_ATTRIBUTE_NAME));
    final DomElement displayName = styleElement.getChild(DISPLAY_NAME_TAG_NAME);
    if (displayName != null) {
        builder.displayName(displayName.getValue());
        builder.displayNameI18nKey(displayName.getAttribute(I18N_ATTRIBUTE_NAME));
    }
    final DomElement aspectRatio = styleElement.getChild(ASPECT_RATIO_TAG_NAME);
    if (aspectRatio != null) {
        builder.aspectRatio(aspectRatio.getValue().trim());
    }
    final DomElement filter = styleElement.getChild(FILTER_TAG_NAME);
    if (filter != null) {
        builder.filter(filter.getValue().trim());
    }
    return builder.build();
}
Also used : DomElement(com.enonic.xp.xml.DomElement) ImageStyle(com.enonic.xp.style.ImageStyle)

Example 9 with DomElement

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

the class XmlPermissionsParser method parse.

public static AccessControlList parse(final DomElement root) {
    final AccessControlList.Builder builder = AccessControlList.create();
    final List<DomElement> aclEntries = root.getChildren("principal");
    for (final DomElement aclEntry : aclEntries) {
        builder.add(parseACLEntry(aclEntry));
    }
    return builder.build();
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) DomElement(com.enonic.xp.xml.DomElement)

Example 10 with DomElement

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

the class XmlAdminToolDescriptorParser method doParse.

@Override
protected void doParse(final DomElement root) throws Exception {
    assertTagName(root, "tool");
    this.builder.displayName(root.getChildValueTrimmed("display-name"));
    this.builder.displayNameI18nKey(root.getChild("display-name") != null ? root.getChild("display-name").getAttribute("i18n") : null);
    this.builder.description(root.getChildValue("description"));
    this.builder.descriptionI18nKey(root.getChild("description") != null ? root.getChild("description").getAttribute("i18n") : null);
    final DomElement allowedPrincipals = root.getChild("allow");
    if (allowedPrincipals != null) {
        final List<DomElement> allowedPrincipalList = allowedPrincipals.getChildren("principal");
        for (DomElement allowedPrincipal : allowedPrincipalList) {
            this.builder.addAllowedPrincipals(PrincipalKey.from(allowedPrincipal.getValue().trim()));
        }
    }
}
Also used : DomElement(com.enonic.xp.xml.DomElement)

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