[MAGNOLIA-625] Saving without nodeCollection fails Created: 31/Jan/06  Updated: 23/Jan/13  Resolved: 03/Feb/06

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 3.0 Beta 1
Fix Version/s: 3.0 Beta 1

Type: Bug Priority: Major
Reporter: Ralf Hirning Assignee: Philipp Bärfuss
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0.5h
Time Spent: Not Specified
Original Estimate: 0.5h
Environment:

Win XP


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 info.magnolia.cms.gui.control.Save.getSaveNode(HierarchyManager hm, Content rootNode) is a check for the nodeCollectionName. The nodeCollectionName is a String which is initialized as StringUtils.EMPTY, but it is checked against null. If you want to save something directly in a page a org.apache.jackrabbit.name.MalformedPathException is thrown.

Could you please change the code snippet in getSaveNode(HierarchyManager hm, Content rootNode)

// get or create nodeCollection
Content nodeCollection = null;
if (this.getNodeCollectionName() != null) {

to something like

// get or create nodeCollection
Content nodeCollection = null;
if (this.getNodeCollectionName() != null && ! this.getNodeCollectionName().equals(StringUtils.EMPTY)) {

thanks

Ralf



 Comments   
Comment by Ralf Hirning [ 31/Jan/06 ]

Not only the nodeCollectionName is problematic, but the nodeName as well.
Both should be tested for not empty.

This method works with me:

protected Content getSaveNode(HierarchyManager hm, Content rootNode) throws AccessDeniedException,
RepositoryException {
Content node = null;

// get or create nodeCollection
Content nodeCollection = null;
if (this.getNodeCollectionName() != null && !StringUtils.isEmpty(this.getNodeCollectionName())) {
try

{ nodeCollection = rootNode.getContent(this.getNodeCollectionName()); }

catch (RepositoryException re) {
// nodeCollection does not exist -> create
nodeCollection = rootNode.createContent(this.getNodeCollectionName(), ItemType.CONTENTNODE);
if (log.isDebugEnabled())

{ log.debug("Create - " + nodeCollection.getHandle()); //$NON-NLS-1$ }

}
}
else

{ nodeCollection = rootNode; }

// get or create node
if (this.getNodeName() != null && !StringUtils.isEmpty(this.getNodeName())) {
try

{ node = nodeCollection.getContent(this.getNodeName()); }

catch (RepositoryException re) {
// node does not exist -> create
if (this.getNodeName().equals("mgnlNew"))

{ //$NON-NLS-1$ this.setNodeName(Path.getUniqueLabel(hm, nodeCollection.getHandle(), "0")); //$NON-NLS-1$ }

node = nodeCollection.createContent(this.getNodeName(), ItemType.CONTENTNODE);
node.getMetaData().setSequencePosition();
}
}
else

{ node = nodeCollection; }

return node;
}

Ralf

Comment by Philipp Bracher [ 03/Feb/06 ]

fixed

  • use StringUtils.isEmpty()
  • save the paragraph type only if not yet set
Generated at Mon Feb 12 03:19:17 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.