[MAGNOLIA-2066] A second ContentUtil.getOrCreateContent() method mentioned in Javadoc, but missing in the class file Created: 20/Feb/08  Updated: 20/Feb/08  Resolved: 20/Feb/08

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

Type: Bug Priority: Minor
Reporter: Giancarlo Berner Assignee: Magnolia International
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Magnolia 3.5.4 EE


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)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

In the javadoc on http://dev.magnolia.info/ref/latest/apidocs/index.html there are two 'getOrCreateContent()' methods.
In the ContentUtil.java file however the method
public static Content getOrCreateContent(Content node, String name, ItemType contentType, boolean save)
is missing.

Including the following method into ContentUtil.java should do the job:

/**

  • If the node doesn't exist just create it. If the parameter save is true the parent node is saved.
  • @param node The node object to return
  • @param name The name of the node object. Will be used to create the new node
  • @param contentType The type of the node. Will be used to create the new node
  • @param save <code>true</code> Will save the new node after creation
  • @return the existing or created <code>node</code>
  • @throws AccessDeniedException
  • @throws RepositoryException
    */
    public static Content getOrCreateContent(Content node, String name, ItemType contentType, boolean save)
    throws AccessDeniedException, RepositoryException
    Unknown macro: { Content res = null; try { res = node.getContent(name); } catch (PathNotFoundException e) { res = node.createContent(name, contentType); node.save(); } return res; }


 Comments   
Comment by Magnolia International [ 20/Feb/08 ]

1) the javadoc being generated against sources at release time, this would be very unlikely to ever happen
2) the method is actually there since 3.5-rc1
3) your code does not take the extra parameter in account

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