You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by mi...@apache.org on 2005/11/02 11:49:48 UTC
svn commit: r330231 - in
/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms: authoring/
publication/
Author: michi
Date: Wed Nov 2 02:49:40 2005
New Revision: 330231
URL: http://svn.apache.org/viewcvs?rev=330231&view=rev
Log:
bug re hardcoded filename generation fixed. DocumentIdToPathMapper is now being used
Modified:
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java?rev=330231&r1=330230&r2=330231&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultBranchCreator.java Wed Nov 2 02:49:40 2005
@@ -15,13 +15,17 @@
*
*/
-/* $Id: DefaultBranchCreator.java,v 1.15 2004/03/01 16:18:27 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.authoring;
+import org.apache.log4j.Category;
+
import java.io.File;
public class DefaultBranchCreator extends DefaultCreator {
+ private Category log = Category.getInstance(DefaultBranchCreator.class);
+
/**
* Return the child type.
*
@@ -36,12 +40,16 @@
}
/** (non-Javadoc)
+ * @depracted because it does not the DocumentIdToPathMapper
* @see org.apache.lenya.cms.authoring.DefaultCreator#getChildFileName(java.io.File, java.lang.String)
*/
protected String getChildFileName(
File parentDir,
String childId,
String language) {
+
+ log.warn("This method has the filename creation hardcoded, resp. the DocumentIdToPathMapper should be used!");
+
return parentDir
+ File.separator
+ childId
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java?rev=330231&r1=330230&r2=330231&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java Wed Nov 2 02:49:40 2005
@@ -24,6 +24,7 @@
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.xml.DocumentHelper;
import org.apache.log4j.Category;
import org.w3c.dom.Document;
@@ -130,8 +131,10 @@
* @throws Exception DOCUMENT ME!
*/
public void create(
+ Publication publication,
File samplesDir,
File parentDir,
+ String parentId,
String childId,
short childType,
String childName,
@@ -140,7 +143,8 @@
throws Exception {
// Set filenames
String id = generateTreeId(childId, childType);
- String filename = getChildFileName(parentDir, id, language);
+ String filename = publication.getPathMapper().getFile(publication, "authoring", parentId + "/" + id, language).getAbsolutePath();
+ log.debug("Filename: " + filename);
String filenameMeta = getChildMetaFileName(parentDir, id, language);
String doctypeSample = samplesDir + File.separator + sampleResourceName;
@@ -169,10 +173,11 @@
if (!parent.exists()) {
parent.mkdirs();
+ log.warn("Directory has been created: " + parent);
}
// Write file
- log.debug("write file: " + filename);
+ log.debug("Write file: " + filename);
DocumentHelper.writeDocument(doc, new File(filename));
// now do the same thing for the meta document if the
@@ -193,6 +198,33 @@
}
/**
+ * @deprecated replaced by create method with access to publication context
+ *
+ * @param samplesDir DOCUMENT ME!
+ * @param parentDir DOCUMENT ME!
+ * @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,
+ String language,
+ Map parameters)
+ throws Exception {
+
+ log.warn("Deprecated!");
+ }
+
+ /**
* Apply some transformation on the newly created child.
*
* @param doc the xml document
@@ -231,6 +263,7 @@
throws Exception {}
/**
+ * @deprecated because it implies not to use the DocumentIdToPathMapper
* Get the file name of the child
*
* @param parentDir the parent directory
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java?rev=330231&r1=330230&r2=330231&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java Wed Nov 2 02:49:40 2005
@@ -23,6 +23,7 @@
import java.util.Collections;
import org.apache.lenya.cms.publication.SiteTree;
+import org.apache.lenya.cms.publication.DocumentIdToPathMapper;
import org.apache.lenya.cms.publication.DocumentType;
import org.apache.lenya.cms.publication.DocumentTypeBuildException;
import org.apache.lenya.cms.publication.DocumentTypeBuilder;
@@ -126,9 +127,14 @@
DocumentTypeBuilder.DOCTYPE_DIRECTORY);
try {
+ DocumentIdToPathMapper mapper = publication.getPathMapper();
+ log.debug("Parent directory: " + mapper.getFile(publication, "authoring", parentId, language));
creator.create(
+ publication,
new File(doctypesDirectory, "samples"),
- new File(authoringDirectory, parentId),
+ mapper.getDirectory(publication, "authoring", parentId, language),
+ //new File(authoringDirectory, parentId),
+ parentId,
childId,
childType,
childName,
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java?rev=330231&r1=330230&r2=330231&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java Wed Nov 2 02:49:40 2005
@@ -15,7 +15,7 @@
*
*/
-/* $Id: ParentChildCreatorInterface.java,v 1.14 2004/03/03 12:56:32 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.authoring;
@@ -24,6 +24,8 @@
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.lenya.cms.publication.Publication;
+
public interface ParentChildCreatorInterface {
/**
* Constant for a branch node. Branch nodes are somewhat related
@@ -80,6 +82,35 @@
String generateTreeId(String childId, short childType) throws Exception;
/**
+ * Create a new document.
+ *
+ * @param publication the publication context.
+ * @param samplesDir the directory where the template file is located.
+ * @param parentDir in which directory the document is to be created.
+ * @param parentId the parent id of the new document
+ * @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(
+ Publication publication,
+ File samplesDir,
+ File parentDir,
+ String parentId,
+ String childId,
+ short childType,
+ String childName,
+ String language,
+ Map parameters)
+ throws Exception;
+
+ /**
+ * @deprecated replaced by create method with access to publication context
+ *
* Create a new document.
*
* @param samplesDir the directory where the template file is located.
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java?rev=330231&r1=330230&r2=330231&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java Wed Nov 2 02:49:40 2005
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DefaultDocumentIdToPathMapper.java,v 1.22 2004/03/01 16:18:17 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.publication;
@@ -37,11 +37,22 @@
}
/**
- * (non-Javadoc)
- *
- * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication,
- * java.lang.String, java.lang.String)
- */
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication,
+ * java.lang.String, java.lang.String)
+ */
+ public File getDirectory(Publication publication, String area, String documentId, String language) {
+ return getDirectory(publication, area, documentId);
+ }
+
+ /**
+ * @deprecated because language is missing
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication,
+ * java.lang.String, java.lang.String)
+ */
public File getDirectory(Publication publication, String area, String documentId) {
assert documentId.startsWith("/");
// remove leading slash
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java?rev=330231&r1=330230&r2=330231&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java Wed Nov 2 02:49:40 2005
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DocumentIdToPathMapper.java,v 1.10 2004/03/01 16:18:16 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.publication;
@@ -49,6 +49,23 @@
String language);
/**
+ * Compute the document-path for a given publication, area and
+ * document-id. As there are possibly multiple files for the same
+ * document-id (for different languages) the return value is a directory.
+ *
+ * @param publication The publication.
+ * @param area The area.
+ * @param documentId The document id.
+ * @param language The language of the document.
+ *
+ * @return The directory where all the files with the same
+ * document-id are located
+ */
+ File getDirectory(Publication publication, String area, String documentId, String language);
+
+ /**
+ * @deprecated replaced by getDirectory with access to the language
+ *
* Compute the document-path for a given publication, area and
* document-id. As there are possibly multiple files for the same
* document-id (for different languages) the return value is a directory.
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java?rev=330231&r1=330230&r2=330231&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java Wed Nov 2 02:49:40 2005
@@ -15,7 +15,7 @@
*
*/
-/* $Id: IdentityDocumentIdToPathMapper.java,v 1.3 2004/03/01 16:18:17 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.publication;
@@ -34,6 +34,16 @@
}
/**
+ * (non-Javadoc)
+ * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String)
+ */
+ public File getDirectory(Publication publication, String area, String documentId, String language) {
+ return getDirectory(publication, area, documentId);
+ }
+
+ /**
+ * @deprecated because language is missing
+ *
* (non-Javadoc)
* @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String)
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org