You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by eg...@apache.org on 2003/07/30 17:30:06 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting DefaultCreatorAction.java ParentChildCreatorAction.java
egli 2003/07/30 08:30:06
Modified: src/java/org/apache/lenya/cms/authoring
ParentChildCreatorInterface.java
DefaultLeafCreator.java DocumentCreator.java
DefaultCreator.java DefaultBranchCreator.java
src/java/org/apache/lenya/cms/cocoon/acting
DefaultCreatorAction.java
ParentChildCreatorAction.java
Log:
Added provisions so that the create process now creates
files with a language suffix according to the language.
Revision Changes Path
1.11 +12 -6 cocoon-lenya/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
Index: ParentChildCreatorInterface.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ParentChildCreatorInterface.java 23 Jul 2003 13:21:20 -0000 1.10
+++ ParentChildCreatorInterface.java 30 Jul 2003 15:30:06 -0000 1.11
@@ -61,7 +61,6 @@
import java.util.Map;
-
/**
* DOCUMENT ME!
*
@@ -120,8 +119,7 @@
* @return a <code>String</code> value
* @exception Exception if an error occurs
*/
- String generateTreeId(String childId, short childType)
- throws Exception;
+ String generateTreeId(String childId, short childType) throws Exception;
/**
* Create a new document.
@@ -131,10 +129,18 @@
* @param childId the document id of the new document
* @param childType the type of the new document.
* @param childName the name of the new document.
+ * @param language for which the document is created.
* @param parameters additional parameters that can be used when creating the child
*
* @exception Exception if an error occurs
*/
- void create(File samplesDir, File parentDir, String childId, short childType, String childName,
- Map parameters) throws Exception;
+ void create(
+ File samplesDir,
+ File parentDir,
+ String childId,
+ short childType,
+ String childName,
+ String language,
+ Map parameters)
+ throws Exception;
}
1.11 +13 -7 cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DefaultLeafCreator.java
Index: DefaultLeafCreator.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DefaultLeafCreator.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultLeafCreator.java 23 Jul 2003 13:21:20 -0000 1.10
+++ DefaultLeafCreator.java 30 Jul 2003 15:30:06 -0000 1.11
@@ -59,14 +59,14 @@
import java.io.File;
-
/**
* DOCUMENT ME!
*
* @author Christian Egli
*/
public class DefaultLeafCreator extends DefaultCreator {
- private static Category log = Category.getInstance(DefaultLeafCreator.class);
+ private static Category log =
+ Category.getInstance(DefaultLeafCreator.class);
/**
* Return the child type.
@@ -84,14 +84,20 @@
/** (non-Javadoc)
* @see org.apache.lenya.cms.authoring.DefaultCreator#getChildFileName(java.io.File, java.lang.String)
*/
- protected String getChildFileName(File parentDir, String childId) {
- return parentDir + File.separator + childId + ".xml";
+ protected String getChildFileName(
+ File parentDir,
+ String childId,
+ String language) {
+ return parentDir + File.separator + childId + "_" + language + ".xml";
}
/** (non-Javadoc)
* @see org.apache.lenya.cms.authoring.DefaultCreator#getChildMetaFileName(java.io.File, java.lang.String)
*/
- protected String getChildMetaFileName(File parentDir, String childId) {
- return parentDir + File.separator + childId + "-meta.xml";
+ protected String getChildMetaFileName(
+ File parentDir,
+ String childId,
+ String language) {
+ return parentDir + File.separator + childId + "-meta" + "_" + language + ".xml";
}
}
1.4 +47 -15 cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java
Index: DocumentCreator.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DocumentCreator.java 15 Jul 2003 13:45:15 -0000 1.3
+++ DocumentCreator.java 30 Jul 2003 15:30:06 -0000 1.4
@@ -66,7 +66,6 @@
import java.util.Collections;
-
/**
* @author andreas
*
@@ -87,9 +86,17 @@
*
* @throws CreatorException DOCUMENT ME!
*/
- public void create(Publication publication, File authoringDirectory, String treeFileName,
- String parentId, String childId, String childName, String childTypeString,
- String documentTypeName, String language) throws CreatorException {
+ public void create(
+ Publication publication,
+ File authoringDirectory,
+ String treeFileName,
+ String parentId,
+ String childId,
+ String childName,
+ String childTypeString,
+ String documentTypeName,
+ String language)
+ throws CreatorException {
short childType;
if (childTypeString.equals("branch")) {
@@ -97,10 +104,15 @@
} else if (childTypeString.equals("leaf")) {
childType = ParentChildCreatorInterface.LEAF_NODE;
} else {
- throw new CreatorException("No such child type: " + childTypeString);
+ throw new CreatorException(
+ "No such child type: " + childTypeString);
}
- if (!validate(parentId, childId, childName, childTypeString, documentTypeName)) {
+ if (!validate(parentId,
+ childId,
+ childName,
+ childTypeString,
+ documentTypeName)) {
throw new CreatorException("Exception: Validation of parameters failed");
}
@@ -108,7 +120,10 @@
DocumentType type;
try {
- type = DocumentTypeBuilder.buildDocumentType(documentTypeName, publication);
+ type =
+ DocumentTypeBuilder.buildDocumentType(
+ documentTypeName,
+ publication);
} catch (DocumentTypeBuildException e) {
throw new CreatorException(e);
}
@@ -118,7 +133,8 @@
DefaultSiteTree siteTree;
try {
- siteTree = new DefaultSiteTree(new File(authoringDirectory, treeFileName));
+ siteTree =
+ new DefaultSiteTree(new File(authoringDirectory, treeFileName));
} catch (Exception e) {
throw new CreatorException(e);
}
@@ -127,17 +143,27 @@
labels[0] = new Label(childName, language);
try {
- siteTree.addNode(parentId, creator.generateTreeId(childId, childType), labels);
+ siteTree.addNode(
+ parentId,
+ creator.generateTreeId(childId, childType),
+ labels);
} catch (Exception e) {
throw new CreatorException(e);
}
- File doctypesDirectory = new File(publication.getDirectory(),
+ File doctypesDirectory =
+ new File(
+ publication.getDirectory(),
DocumentTypeBuilder.DOCTYPE_DIRECTORY);
try {
- creator.create(new File(doctypesDirectory, "samples"),
- new File(authoringDirectory, parentId), childId, childType, childName,
+ creator.create(
+ new File(doctypesDirectory, "samples"),
+ new File(authoringDirectory, parentId),
+ childId,
+ childType,
+ childName,
+ language,
Collections.EMPTY_MAP);
} catch (Exception e) {
throw new CreatorException(e);
@@ -162,8 +188,14 @@
*
* @return DOCUMENT ME!
*/
- public boolean validate(String parentid, String childid, String childname, String childtype,
+ public boolean validate(
+ String parentid,
+ String childid,
+ String childname,
+ String childtype,
String doctype) {
- return (childid.indexOf(" ") == -1) && (childid.length() > 0) && (childname.length() > 0);
+ return (childid.indexOf(" ") == -1)
+ && (childid.length() > 0)
+ && (childname.length() > 0);
}
}
1.22 +82 -56 cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
Index: DefaultCreator.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- DefaultCreator.java 23 Jul 2003 13:21:20 -0000 1.21
+++ DefaultCreator.java 30 Jul 2003 15:30:06 -0000 1.22
@@ -67,7 +67,6 @@
import java.util.Map;
-
/**
* DOCUMENT ME!
*
@@ -79,7 +78,7 @@
public static final String RESOURCE_META_NAME = "resource-meta-name";
public static final String SAMPLE_NAME = "sample-name";
public static final String SAMPLE_META_NAME = "sample-meta-name";
-
+
private String resourceName = null;
private String resourceMetaName = null;
private String sampleResourceName = null;
@@ -100,15 +99,18 @@
}
if (conf.getChild(RESOURCE_META_NAME, false) != null) {
- resourceMetaName = conf.getChild(RESOURCE_META_NAME).getValue("index-meta.xml");
+ resourceMetaName =
+ conf.getChild(RESOURCE_META_NAME).getValue("index-meta.xml");
}
if (conf.getChild(SAMPLE_NAME, false) != null) {
- sampleResourceName = conf.getChild(SAMPLE_NAME).getValue("sampleindex.xml");
+ sampleResourceName =
+ conf.getChild(SAMPLE_NAME).getValue("sampleindex.xml");
}
if (conf.getChild(SAMPLE_META_NAME, false) != null) {
- sampleMetaName = conf.getChild(SAMPLE_META_NAME).getValue("samplemeta.xml");
+ sampleMetaName =
+ conf.getChild(SAMPLE_META_NAME).getValue("samplemeta.xml");
}
}
@@ -165,17 +167,25 @@
* @param childId DOCUMENT ME!
* @param childType DOCUMENT ME!
* @param childName the name of the child
+ * @param language for which the document is created
* @param parameters additional parameters that can be considered when
* creating the child
*
* @throws Exception DOCUMENT ME!
*/
- public void create(File samplesDir, File parentDir, String childId, short childType,
- String childName, Map parameters) throws Exception {
+ public void create(
+ File samplesDir,
+ File parentDir,
+ String childId,
+ short childType,
+ String childName,
+ String language,
+ Map parameters)
+ throws Exception {
// Set filenames
String id = generateTreeId(childId, childType);
- String filename = getChildFileName(parentDir, id);
- String filenameMeta = getChildMetaFileName(parentDir, id);
+ String filename = getChildFileName(parentDir, id, language);
+ String filenameMeta = getChildMetaFileName(parentDir, id, language);
String doctypeSample = samplesDir + File.separator + sampleResourceName;
String doctypeMeta = samplesDir + File.separator + sampleMetaName;
@@ -220,57 +230,73 @@
}
}
- /**
- * Apply some transformation on the newly created child.
- *
- * @param doc the xml document
- * @param childId the id of the child
- * @param childType the type of child
- * @param childName the name of the child
- * @param parameters additional parameters that can be used in the transformation
- *
- * @throws Exception if the transformation fails
- */
- protected void transformXML(Document doc, String childId, short childType, String childName,
- Map parameters) throws Exception {
- }
-
- /**
- * Apply some transformation on the meta file of newly created child.
- *
- * @param doc the xml document
- * @param childId the id of the child
- * @param childType the type of child
- * @param childName the name of the child
- * @param parameters additional parameters that can be used in the transformation
- *
- * @throws Exception if the transformation fails
- */
- protected void transformMetaXML(Document doc, String childId, short childType,
- String childName, Map parameters) throws Exception {
- }
-
- /**
- * Get the file name of the child
- *
- * @param parentDir the parent directory
- * @param childId the id of the child
- *
- * @return the file name of the child
- */
- protected String getChildFileName(File parentDir, String childId) {
+ /**
+ * Apply some transformation on the newly created child.
+ *
+ * @param doc the xml document
+ * @param childId the id of the child
+ * @param childType the type of child
+ * @param childName the name of the child
+ * @param parameters additional parameters that can be used in the transformation
+ *
+ * @throws Exception if the transformation fails
+ */
+ protected void transformXML(
+ Document doc,
+ String childId,
+ short childType,
+ String childName,
+ Map parameters)
+ throws Exception {}
+
+ /**
+ * Apply some transformation on the meta file of newly created child.
+ *
+ * @param doc the xml document
+ * @param childId the id of the child
+ * @param childType the type of child
+ * @param childName the name of the child
+ * @param parameters additional parameters that can be used in the transformation
+ *
+ * @throws Exception if the transformation fails
+ */
+ protected void transformMetaXML(
+ Document doc,
+ String childId,
+ short childType,
+ String childName,
+ Map parameters)
+ throws Exception {}
+
+ /**
+ * Get the file name of the child
+ *
+ * @param parentDir the parent directory
+ * @param childId the id of the child
+ * @param language for which the document is created
+ *
+ * @return the file name of the child
+ */
+ protected String getChildFileName(
+ File parentDir,
+ String childId,
+ String language) {
return null;
}
- /**
- * Get the file name of the meta file
- *
- * @param parentDir the parent directory
- * @param childId the id of the child
- *
- * @return the name of the meta file
- */
- protected String getChildMetaFileName(File parentDir, String childId) {
+ /**
+ * Get the file name of the meta file
+ *
+ * @param parentDir the parent directory
+ * @param childId the id of the child
+ * @param language for which the document is created
+ *
+ * @return the name of the meta file
+ */
+ protected String getChildMetaFileName(
+ File parentDir,
+ String childId,
+ String language) {
return null;
}
}
1.11 +25 -7 cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java
Index: DefaultBranchCreator.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultBranchCreator.java 23 Jul 2003 13:21:20 -0000 1.10
+++ DefaultBranchCreator.java 30 Jul 2003 15:30:06 -0000 1.11
@@ -59,14 +59,14 @@
import java.io.File;
-
/**
* DOCUMENT ME!
*
* @author Michael Wechner
*/
public class DefaultBranchCreator extends DefaultCreator {
- private static Category log = Category.getInstance(DefaultBranchCreator.class);
+ private static Category log =
+ Category.getInstance(DefaultBranchCreator.class);
/**
* Return the child type.
@@ -84,14 +84,32 @@
/** (non-Javadoc)
* @see org.apache.lenya.cms.authoring.DefaultCreator#getChildFileName(java.io.File, java.lang.String)
*/
- protected String getChildFileName(File parentDir, String childId) {
- return parentDir + File.separator + childId + File.separator + "index.xml";
+ protected String getChildFileName(
+ File parentDir,
+ String childId,
+ String language) {
+ return parentDir
+ + File.separator
+ + childId
+ + File.separator
+ + "index_"
+ + language
+ + ".xml";
}
/** (non-Javadoc)
* @see org.apache.lenya.cms.authoring.DefaultCreator#getChildMetaFileName(java.io.File, java.lang.String)
*/
- protected String getChildMetaFileName(File parentDir, String childId) {
- return parentDir + File.separator + childId + File.separator + "indexmeta.xml";
+ protected String getChildMetaFileName(
+ File parentDir,
+ String childId,
+ String language) {
+ return parentDir
+ + File.separator
+ + childId
+ + File.separator
+ + "indexmeta_"
+ + language
+ + ".xml";
}
}
1.9 +5 -4 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java
Index: DefaultCreatorAction.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultCreatorAction.java 23 Jul 2003 13:21:30 -0000 1.8
+++ DefaultCreatorAction.java 30 Jul 2003 15:30:06 -0000 1.9
@@ -162,7 +162,8 @@
}
String doctype = request.getParameter("doctype");
-
+ String language = request.getParameter("language");
+
if (!validate(parentid, childid, childname, childtype, doctype)) {
getLogger().error("Exception: Validation of parameters failed");
@@ -280,7 +281,7 @@
try {
creator.create(new File(absoluteDoctypesPath + "samples"),
new File(publication.getDirectory(), docsPath + parentid), childid, childType,
- childname, allParameters);
+ childname, language, allParameters);
} catch (Exception e) {
getLogger().error(".act(): Creator threw exception: " + e);
}
1.33 +3 -2 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/ParentChildCreatorAction.java
Index: ParentChildCreatorAction.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/acting/ParentChildCreatorAction.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- ParentChildCreatorAction.java 23 Jul 2003 13:21:30 -0000 1.32
+++ ParentChildCreatorAction.java 30 Jul 2003 15:30:06 -0000 1.33
@@ -167,6 +167,7 @@
}
String doctype = request.getParameter("doctype");
+ String language = request.getParameter("language");
if (!validate(parentid, childid, childname, childtype, doctype)) {
getLogger().error("Exception: Validation of parameters failed");
@@ -344,7 +345,7 @@
try {
creator.create(new File(absoluteDoctypesPath + "samples"),
- new File(sitemapParentPath + docsPath + parentid), childid, childType, childname,
+ new File(sitemapParentPath + docsPath + parentid), childid, childType, childname, language,
allParameters);
} catch (Exception e) {
getLogger().error(".act(): Creator threw exception: " + e);
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org