[MAGNOLIA-3054] ContentWrapper requires AbstractContent to work properly Created: 02/Feb/10  Updated: 23/Jan/13  Resolved: 18/Mar/10

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 4.3
Fix Version/s: 4.3

Type: Improvement Priority: Major
Reporter: Jan Haderka Assignee: Philipp Bärfuss
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

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:

 Description   

AbstractContent defines

    abstract public NodeData getNodeData(String name, int type) throws AccessDeniedException, RepositoryException;

method that all extending classes need to implement and ContentWrapper implements this method as well, undiscriminatelly casting Content returned by

    public Content getWrappedContent();

method into AbstractContent.
Since the content wrapper is used to wrap all sorts of content in Magnolia making it actually mandatory for all Content implementations to extend AbstractContent the abstract method above should be declared in the Content interface directly or the ContentWrapper init method should be changed to accept only objects extending AbstractContent rather then those implementing Content.
For example the easymock objects created against Content interface obviously fail to be casted into AbstractContent.



 Comments   
Comment by Magnolia International [ 02/Feb/10 ]

We should come to a conclusion about this for 4.3

Comment by Philipp Bärfuss [ 04/Feb/10 ]

After overworking the InheritanceContentWrapper I have to back Jan and think we should:

  • rename AbstractContent to ContentBase or similar
  • make the wrapper type save: can only wrap ContentBase objects
  • rename getNodeData(name, type) to newNodeDataInstance() to make it more clear what this method really does
Comment by Philipp Bärfuss [ 04/Feb/10 ]

I have

  • renamed getNodeData(name, type) to newNodeDataInstance(name, type)
  • made the javadoc more explicit
  • added is instance of checks before casting, this will throw an exception having a explanatory message

In my opinion this issue can be closed. Opinions? one, two, three, ..

Generated at Mon Feb 12 03:42:43 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.