[MAGNOLIA-7606] Provide a way for Repository Exception free JCR operations Created: 20/Aug/19  Updated: 02/Dec/19  Resolved: 28/Nov/19

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2

Type: Improvement Priority: Neutral
Reporter: Roman Kovařík Assignee: Roman Kovařík
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 1d 52m
Original Estimate: Not Specified

Issue Links:
documentation
to be documented by MAGNOLIA-7621 DOC: JcrFunctions utility Closed
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)
Sprint: UI Framework 4, UI Framework 11
Story Points: 2

 Description   

We do have utilities to work with JCR such as NodeUtil or PropertyUtil.
These are quite hard to use inside of Streams/Optionals because of checked exceptions they throw.
The usual solution so far is extraction the calls to a method:

Optional.of(Node).map(getName());

String getName(Node node) {
  try {
     return node.getName();
  } catch (RE e) {
    throw new RuntimeRepositoryException(e);
  }
}

As result, such methods are duplicated all over the place.
The goal of this ticket would be introduce a utitility which would do the exception handling itself.



 Comments   
Comment by Roman Kovařík [ 20/Aug/19 ]

We've introduced info.magnolia.jcr.util.JcrFunctions which can be used as follows:

Set<Node> parents = getValueContext().get()
                .map(JcrFunctions::getParent)
                .collect(Collectors.toSet());
Comment by Roman Kovařík [ 25/Sep/19 ]

Reopened: consider using https://github.com/pivovarit/throwing-function. or https://noexception.machinezoo.com 

Comment by Roman Kovařík [ 02/Dec/19 ]

Custom JcrFunctions dropped in favour of external library.

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