Пример #1
0
  /**
   * Create an Archival Unit
   *
   * @return true If successful
   */
  private boolean createAu() {

    Configuration config = getAuConfigFromForm();

    AuProxy au;
    Element element;

    try {
      au = getRemoteApi().createAndSaveAuConfiguration(getPlugin(), config);

    } catch (ArchivalUnit.ConfigurationException exception) {
      return error("Configuration failed: " + exception.getMessage());

    } catch (IOException exception) {
      return error("Unable to save configuration: " + exception.getMessage());
    }
    /*
     * Successful creation - add the AU name and ID to the response document
     */
    element = getXmlUtils().createElement(getResponseRoot(), AP_E_AU);
    XmlUtils.addText(element, au.getName());

    element = getXmlUtils().createElement(getResponseRoot(), AP_E_AUID);
    XmlUtils.addText(element, au.getAuId());

    return true;
  }
Пример #2
0
    private ViewDefinition readViewDefinition(Element element) {
      String name = element.getAttribute("name");
      Assert.ifEmpty(name, "can`t read view without name");

      String extend = element.getAttribute("extend");
      String file = element.getAttribute("file");

      if (isNoneEmpty(file)) file = fileScope.getRelativePath(file);

      ViewDefinition viewDef = new ViewDefinition(name, file);
      viewDef.setExtend(extend);

      fragmentRefExpressions.forEach(
          x -> {
            XmlUtils.iterateSubElements(
                element, x, e -> viewDef.addFragment(readFragmentReference(e)));
          });

      resourcesRefExpressions.forEach(
          x -> {
            XmlUtils.iterateSubElements(
                element, x, e -> viewDef.addResources(readResourcesReference(e)));
          });

      return viewDef;
    }
Пример #3
0
    private void readFragmentInnerContent(Element element, FragmentDef fragmentDef) {
      fragmentRefExpressions.forEach(
          x -> {
            XmlUtils.iterateSubElements(
                element, x, e -> fragmentDef.addInnerFragment(readFragmentReference(e)));
          });

      resourcesRefExpressions.forEach(
          x -> {
            XmlUtils.iterateSubElements(
                element, x, e -> fragmentDef.addResources(readResourcesReference(e)));
          });
    }
Пример #4
0
    public PageManifestDef read(FileScope fileScope, Document document, PageManifestDef pmd)
        throws XPathExpressionException {
      this.fileScope = fileScope;
      XmlUtils.iterateSubElements(
          document, resourcesExpr, e -> pmd.addResourceSet(readResourcesDefinition(e)));
      XmlUtils.iterateSubElements(
          document, fragmentsExpr, e -> pmd.addFragments(readFragmentDefinition(e)));
      XmlUtils.iterateSubElements(document, viewsExpr, e -> pmd.addView(readViewDefinition(e)));

      List<String> imports =
          XmlUtils.getSingleAttrNodes(
              document, importsExpr, "file", "import tag must contain file attribute");

      imports
          .stream()
          .forEach(
              i ->
                  XMLPageManifestLoader.this.readPageDefinitionFile(
                      fileScope.getRelativePath(i), pmd));

      return pmd;
    }
Пример #5
0
    private void readResources(Element resourcesElement, ResourcesDef resDef) {
      XmlUtils.iterateSubElements(
          resourcesElement,
          element -> {
            XmlManifestResourceElement resourceElement = new XmlManifestResourceElement(element);

            Optional<ResourceReader> optional =
                resourcesReaders
                    .stream()
                    .filter(reader -> reader.accept(resourceElement))
                    .findFirst();

            try {
              if (optional.isPresent())
                resDef.addResource(optional.get().read(resourceElement, fileScope));
            } catch (Exception e) {
              throw new JumbleException("Fail to load resource: " + element.getTagName(), e);
            }
          });
    }