Example #1
0
 @Override
 protected void doParse(final DomElement root) throws Exception {
   assertTagName(root, ROOT_TAG_NAME);
   this.appDescriptorBuilder.key(currentApplication);
   final DomElement descriptionElement = root.getChild(DESCRIPTION);
   if (descriptionElement != null) {
     this.appDescriptorBuilder.description(descriptionElement.getValue());
   }
 }
Example #2
0
  private ControllerMappingDescriptor toMappingDescriptor(final DomElement mappingElement) {
    final ControllerMappingDescriptor.Builder builder = ControllerMappingDescriptor.create();
    final String controllerPath =
        mappingElement.getAttribute(MAPPING_DESCRIPTOR_CONTROLLER_ATTRIBUTE);
    builder.controller(ResourceKey.from(this.currentApplication, controllerPath));

    final String orderValue = mappingElement.getAttribute(MAPPING_DESCRIPTOR_ORDER_ATTRIBUTE);
    if (isNotEmpty(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 (isNotEmpty(match)) {
        builder.contentConstraint(match);
      }
    }

    final DomElement patternElement = mappingElement.getChild(MAPPING_DESCRIPTOR_PATTERN_TAG_NAME);
    if (patternElement != null) {
      final String pattern = patternElement.getValue();
      if (isNotEmpty(pattern)) {
        final boolean invert =
            "true"
                .equals(patternElement.getAttribute(MAPPING_DESCRIPTOR_INVERT_ATTRIBUTE, "false"));
        builder.pattern(pattern);
        builder.invertPattern(invert);
      }
    }

    return builder.build();
  }
Example #3
0
 private FilterDescriptor toFilterDescriptor(final DomElement filterElement) {
   final FilterDescriptor.Builder builder = FilterDescriptor.create();
   final String orderValue = filterElement.getAttribute(FILTER_DESCRIPTOR_ORDER_ATTRIBUTE);
   if (isNotEmpty(orderValue)) {
     builder.order(Integer.parseInt(orderValue));
   }
   builder.name(filterElement.getAttribute(FILTER_DESCRIPTOR_NAME_ATTRIBUTE));
   builder.type(FilterType.RESPONSE);
   builder.application(this.currentApplication);
   return builder.build();
 }
Example #4
0
  @Override
  protected void doParse(final DomElement root) throws Exception {
    assertTagName(root, ROOT_TAG_NAME);

    final XmlFormMapper formMapper = new XmlFormMapper(this.currentApplication);
    this.siteDescriptorBuilder.form(formMapper.buildForm(root.getChild(CONFIG_TAG_NAME)));
    this.siteDescriptorBuilder.metaSteps(MixinNames.from(parseMetaSteps(root)));
    this.siteDescriptorBuilder.filterDescriptors(
        FilterDescriptors.from(
            parseFilterDescriptors(root.getChild(FILTER_DESCRIPTORS_PARENT_TAG_NAME))));
    this.siteDescriptorBuilder.mappingDescriptors(
        ControllerMappingDescriptors.from(
            parseMappingDescriptors(root.getChild(MAPPINGS_DESCRIPTOR_TAG_NAME))));
  }
Example #5
0
 private List<FilterDescriptor> parseFilterDescriptors(final DomElement filterDescriptorsParent) {
   if (filterDescriptorsParent != null) {
     return filterDescriptorsParent
         .getChildren(FILTER_DESCRIPTOR_TAG_NAME)
         .stream()
         .map(this::toFilterDescriptor)
         .collect(Collectors.toList());
   }
   return Collections.emptyList();
 }
Example #6
0
 private List<ControllerMappingDescriptor> parseMappingDescriptors(
     final DomElement filterDescriptorsParent) {
   if (filterDescriptorsParent != null) {
     return filterDescriptorsParent
         .getChildren(MAPPING_DESCRIPTOR_TAG_NAME)
         .stream()
         .map(this::toMappingDescriptor)
         .collect(Collectors.toList());
   }
   return Collections.emptyList();
 }
Example #7
0
 private List<MixinName> parseMetaSteps(final DomElement root) {
   return root.getChildren(META_STEP_TAG_NAME)
       .stream()
       .map(this::toMixinName)
       .collect(Collectors.toList());
 }
Example #8
0
 private MixinName toMixinName(final DomElement metaStep) {
   final ApplicationRelativeResolver resolver =
       new ApplicationRelativeResolver(this.currentApplication);
   final String name = metaStep.getAttribute(MIXIN_ATTRIBUTE_NAME);
   return resolver.toMixinName(name);
 }
 private DomElement parse(final String suffix) {
   final Document doc = DomHelper.parse(findResource(suffix));
   return DomElement.from(doc.getDocumentElement());
 }