[CONTTAGS-116] Allow extension of getTags method Created: 24/Jan/22  Updated: 26/Aug/22

Status: Open
Project: Content Tags
Component/s: None
Affects Version/s: 2.0.4
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Roberto Gaona Assignee: Thuy To
Resolution: Unresolved Votes: 0
Labels: quickwin
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Visible to:
Alexander Pock, Bartosz Skonieczny, Martin Gockner, Richard Uttenthaler, Siegfried Zach
Epic Link: AuthorX Support
Team: AuthorX

 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.



 Comments   
Comment by Philipp Kronberger [ 24/Feb/22 ]

Hello, could you maybe address this request? It would provide us a way to implement some extensions to the TagManager. Regards, Philipp

Comment by Philipp Kronberger [ 28/Mar/22 ]

In a lack of any feedback i find ourself in the situation to copy the TagManagers 1:1 and extend my logic myself.
Are there any possibilities that you could add an extension point any time? Regards Philipp

Comment by Roberto Gaona [ 29/Mar/22 ]

Hello Philipp,

The extension will be added once the development team gets some time to deal with this ticket. In the meantime, you can implement it on your side following the proposed structure to cover your issue.

Also, the Pull Requests are checked by the Product team rather, so they will check the PR you submitted about this ticket.

Kind regards,

Roberto Gaona

Generated at Mon Feb 12 00:25:07 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.