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();
}
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();
}
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();
}
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();
}
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()));
}
}
}
Aggregations