You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/04/30 11:12:10 UTC
svn commit: r533638 -
/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java
Author: andreas
Date: Mon Apr 30 02:12:09 2007
New Revision: 533638
URL: http://svn.apache.org/viewvc?view=rev&rev=533638
Log:
Allow to create docs from 'Authoring' sitetree node. This fixes bug 42291.
Modified:
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java
Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java?view=diff&rev=533638&r1=533637&r2=533638
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/CreateDocument.java Mon Apr 30 02:12:09 2007
@@ -66,7 +66,11 @@
}
setParameter(LANGUAGES, languages);
- String[] relations = { RELATION_CHILD, RELATION_AFTER };
+ Document sourceDoc = getSourceDocument();
+ String[] childOnly = { RELATION_CHILD };
+ String[] childAndAfter = { RELATION_CHILD, RELATION_AFTER };
+ String[] relations = sourceDoc == null ? childOnly : childAndAfter;
+
setParameter(RELATIONS, relations);
setParameter(RELATION, RELATION_CHILD);
@@ -152,13 +156,18 @@
return getParameterAsString(PATH);
} else {
String relation = getRelation();
- DocumentLocator sourceLoc = getSourceDocument().getLocator();
- if (relation.equals(RELATION_CHILD)) {
- return sourceLoc.getChild(getNewDocumentName()).getPath();
- } else if (relation.equals(RELATION_BEFORE) || relation.equals(RELATION_AFTER)) {
- return sourceLoc.getParent().getChild(getNewDocumentName()).getPath();
+ Document sourceDoc = getSourceDocument();
+ if (sourceDoc == null) {
+ return "/" + getNewDocumentName();
} else {
- throw new IllegalStateException("unsupported relation " + relation);
+ DocumentLocator sourceLoc = getSourceDocument().getLocator();
+ if (relation.equals(RELATION_CHILD)) {
+ return sourceLoc.getChild(getNewDocumentName()).getPath();
+ } else if (relation.equals(RELATION_BEFORE) || relation.equals(RELATION_AFTER)) {
+ return sourceLoc.getParent().getChild(getNewDocumentName()).getPath();
+ } else {
+ throw new IllegalStateException("unsupported relation " + relation);
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org