[MAGNOLIA-6100] Make AbstractNodeBuilderTask more flexible Created: 27/Feb/15 Updated: 19/May/22 Resolved: 19/May/22 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | updatemechanism |
| Affects Version/s: | 5.3.7 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Stefan Baur | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | quickwin | ||
| Remaining Estimate: | 5m | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | 5m | ||
| Template: |
|
| Patch included: |
Yes
|
| 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: |
Michael Rauch
|
| Description |
|
Hi. Whenever I use this great class, I miss a feature that could easily be added with no harm. --> Make it possible to override the NodeOperations by a subclass. Just add a (protected?) getter for the operations field and use it in the doExecute method. Like this:
@Override
protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException {
final Node root = getRootNode(ctx);
final ErrorHandler errorHandler = newErrorHandler(ctx);
final NodeBuilder nodeBuilder = new NodeBuilder(errorHandler, root, getOperations());
try {
nodeBuilder.exec();
} catch (NodeOperationException e) {
throw new TaskExecutionException(e.getMessage(), e);
}
}
protected NodeOperation[] getOperations() {
return operations;
}
This little change enables users to override the getter an build node operations with more complex logic if needed. The problem actually is, that in constructors you cannot use instance methods yet. So if you want to generate part of your NodeOperations in a nicely separated method, you have to make that method static and break the possibility to override it again. Cheers, |
| Comments |
| Comment by Stefan Baur [ 27/Feb/15 ] |
|
HINT: This functionality could also go in a base class that has no constructor with operations but an abstract protected method. The current AbstractNodeBuilderTask could then implement that base class using the ctor arguments value. |
| Comment by Roman Kovařík [ 19/May/22 ] |
|
Hello, This ticket is now marked as closed due to one of the following reasons:
If you are still facing a problem or consider this issue still relevant, please feel free to re-open the ticket and we will reach out to you. Thank you, |