Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-14516

MirrorTemplatePlugin: the intent to differentiate between exceptions fails

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • 14.5.0
    • 14.6.0
    • None
    • Flagged

    Description

      #getMirrorPath calls #getPath and catches various types of RepositoryExceptions.
      #getPath catches RepositoryException internally so this doesn't work as intended

      result: always an error "Docbase not found" with long stack trace
      expected: different warn, info, debug loggings in case of ValueFormatException, ItemNotFoundException or PathNotFoundexception

      Full code:

          private String getMirrorPath() {
              final Node node = MirrorTemplatePlugin.this.getModelObject();
              try {
                  if (node != null && node.hasProperty(HippoNodeType.HIPPO_DOCBASE)) {
                      return getPath(node.getProperty(HippoNodeType.HIPPO_DOCBASE).getString());
                  }
              } catch (final ValueFormatException e) {
                  log.warn("Invalid value format for docbase " + e.getMessage());
                  log.debug("Invalid value format for docbase ", e);
              } catch (final PathNotFoundException e) {
                  log.warn("Docbase not found " + e.getMessage());
                  log.debug("Docbase not found ", e);
              } catch (final ItemNotFoundException e) {
                  log.info("Docbase " + e.getMessage() + " could not be dereferenced");
              } catch (final RepositoryException e) {
                  log.error("Invalid docbase " + e.getMessage(), e);
              }
              return StringUtils.EMPTY;
          }
      
          private String getPath(final String docBaseUuid) {
              String path = StringUtils.EMPTY;
              try {
                  if (StringUtils.isNotEmpty(docBaseUuid) && !docBaseUuid.equals(JcrConstants.ROOT_NODE_ID)) {
                      path = getJcrSession().getNodeByIdentifier(docBaseUuid).getPath();
                  }
              } catch (final RepositoryException e) {
                  log.error("Invalid docbase: '{}'", docBaseUuid, e);
              }
              return path;
          }
      
      

      Attachments

        Issue Links

          Activity

            People

              jhoffman Jeroen Hoffman
              jhoffman Jeroen Hoffman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: