Uploaded image for project: 'Content Tags'
  1. Content Tags
  2. CONTTAGS-116

Allow extension of getTags method

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Neutral
    • None
    • 2.0.4

    Description

      A client would like to have a similar code structure to the getOrCreateTag method applied to the getTag methods as well:

      getOrCreateTag structure:

          public final Node getOrCreateTag(String tagName) throws RepositoryException {
              if (!isLicenseValid()) {
                  throw new IllegalStateException("License is not valid");
              }
              return getOrCreate(tagName);
          }    protected Node getOrCreate(String tagName) throws RepositoryException {
              tagName = nodeNameHelper.getValidatedName(tagName);
              final Session session = getTagsSession();
              final Node parentNode = NodeUtil.createPath(session.getRootNode(), getParentPath(tagName), NodeTypes.Folder.NAME, false);
              if (parentNode.hasNode(tagName)) {
                  return parentNode.getNode(tagName);
              } else {
                  final Node node = parentNode.addNode(tagName, TAG_NODE_TYPE);
                  session.save();
                  return node;
              }
          } 

      Current getTag structure:

          public final Optional<Node> getTag(String tagName) throws RepositoryException {
              if (!isLicenseValid()) {
                  throw new IllegalStateException("License is not valid");
              }
              tagName = nodeNameHelper.getValidatedName(tagName);
              return executeQuery(WORKSPACE, String.format("SELECT * FROM [%s] as t WHERE name(t)='%s'", TAG_NODE_TYPE, tagName)).stream().findFirst();
          }

      Suggested structure:

          public final Optional<Node> getTag(String tagName) throws RepositoryException {
              if (!isLicenseValid()) {
                  throw new IllegalStateException("License is not valid");
              }
              return getTagInternal(tagName);
          }
          protected Optional<Node> getTagInternal(String tagName) throws RepositoryException {
              tagName = nodeNameHelper.getValidatedName(tagName);
              return executeQuery(WORKSPACE, String.format("SELECT * FROM [%s] as t WHERE name(t)='%s'", TAG_NODE_TYPE, tagName)).stream().findFirst();
          } 

      This way, overriding the method would be doable by extension without modifying the class itself.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              thuy.to Thuy To
              rgaona Roberto Gaona
              Alexander Pock, Bartosz Skonieczny, Martin Gockner, Richard Uttenthaler, Siegfried Zach
              AuthorX
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Checklists

                  Task DoD