You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jw...@apache.org on 2005/05/12 16:00:24 UTC
svn commit: r169824 - in /lenya/trunk/src:
java/org/apache/lenya/cms/authoring/ java/org/apache/lenya/cms/publication/
java/org/apache/lenya/cms/site/usecases/
webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/
Author: jwkaltz
Date: Thu May 12 07:00:24 2005
New Revision: 169824
URL: http://svn.apache.org/viewcvs?rev=169824&view=rev
Log:
use URI instead of file for initial contents of a new document. Language version uses URI of existing document
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java?rev=169824&r1=169823&r2=169824&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java Thu May 12 07:00:24 2005
@@ -25,6 +25,9 @@
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.xml.DocumentHelper;
import org.w3c.dom.Document;
@@ -35,13 +38,15 @@
public class DefaultCreator extends AbstractLogEnabled implements ParentChildCreatorInterface {
private String sampleResourceName = null;
+ private ServiceManager manager;
/**
- * @see org.apache.lenya.cms.authoring.ParentChildCreatorInterface#init(Configuration, Logger)
+ * @see org.apache.lenya.cms.authoring.ParentChildCreatorInterface#init(Configuration, ServiceManager, Logger)
*/
- public void init(Configuration conf, Logger _logger) {
+ public void init(Configuration conf, ServiceManager _manager, Logger _logger) {
+ // parameter conf ignored: nothing to configure in current implementation
+ this.manager = _manager;
ContainerUtil.enableLogging(this, _logger);
- // nothing to configure in current implementation
}
/**
@@ -79,12 +84,13 @@
return "abstract_default";
}
+
/**
* @see org.apache.lenya.cms.authoring.ParentChildCreatorInterface#create(String, File,
* String, short, String, String, Map)
*/
public void create(
- String samplesLocation,
+ String initialContentsURI,
File parentDir,
String childId,
short childType,
@@ -98,24 +104,17 @@
String filename = getChildFileName(parentDir, id, language);
String filenameMeta = getChildMetaFileName(parentDir, id, language);
+ // Read initial contents as DOM
if (getLogger().isDebugEnabled())
- getLogger().debug("DefaultCreator.create(), ready to read sample contents, samplesLocation [" + samplesLocation + "]");
+ getLogger().debug("DefaultCreator::create(), ready to read initial contents from URI [" + initialContentsURI + "]");
- File sampleFile = null;
- if (samplesLocation != null) {
- sampleFile = new File(samplesLocation.replace('/', File.separatorChar));
- if (!sampleFile.exists())
- throw new FileNotFoundException("Sample file [" + sampleFile + "] not found, make sure you configured it within doctypes.xconf");
+ Document doc = null;
+ try {
+ doc = SourceUtil.readDOM(initialContentsURI, manager);
+ }
+ catch (Exception e) {
+ throw new DocumentException("could not read document at location [ " + initialContentsURI + "]", e);
}
- else
- throw new Exception("sample configuration setup error, samplesLocation is not set - verify your doctypes.xconf");
-
-
- // Read sample file
- Document doc = DocumentHelper.readDocument(sampleFile);
-
- if (getLogger().isDebugEnabled())
- getLogger().debug("sample document: " + doc);
if (getLogger().isDebugEnabled())
getLogger().debug("transform sample file: ");
Modified: lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java?rev=169824&r1=169823&r2=169824&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java Thu May 12 07:00:24 2005
@@ -22,6 +22,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
/**
* Interface for creation of hierarchical documents
@@ -48,9 +49,10 @@
* Configures the Creator, based on a configuration file.
*
* @param doctypeConf A configuration.
+ * @param manager the service manager
* @param logger A logger
*/
- void init(Configuration doctypeConf, Logger logger);
+ void init(Configuration doctypeConf, ServiceManager manager, Logger logger);
/**
* Return the type of node this creator will create. It can be
@@ -86,7 +88,7 @@
/**
* Create a new document.
*
- * @param samplesLocation the location where samples for this document can be found.
+ * @param initialContentsURI the URI where initial content for this document can be found.
* @param parentDir in which directory the document is to be created.
* @param childId the document id of the new document
* @param childType the type of the new document.
@@ -97,7 +99,7 @@
* @exception Exception if an error occurs
*/
void create(
- String samplesLocation,
+ String initialContentsURI,
File parentDir,
String childId,
short childType,
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java?rev=169824&r1=169823&r2=169824&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java Thu May 12 07:00:24 2005
@@ -182,7 +182,7 @@
String creatorClassName = creatorConf.getAttribute(SRC_ATTRIBUTE);
Class creatorClass = Class.forName(creatorClassName);
creator = (ParentChildCreatorInterface) creatorClass.newInstance();
- creator.init(creatorConf, getLogger());
+ creator.init(creatorConf, manager, getLogger());
} else {
creator = new DefaultBranchCreator();
}
@@ -194,7 +194,9 @@
Configuration sampleConf = creatorConf.getChild(SAMPLE_NAME, false);
if (sampleConf != null) {
String sampleLocation = sampleConf.getValue();
- type.setSampleContentLocation(publication.getDirectory() + "/" + DOCTYPE_SAMPLES + sampleLocation);
+ // FIXME: is there a cleaner way to set this ?
+ String pubBase = "lenya://lenya/pubs/" + publication.getId();
+ type.setSampleContentLocation(pubBase + "/" + DOCTYPE_SAMPLES + sampleLocation);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java?rev=169824&r1=169823&r2=169824&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java Thu May 12 07:00:24 2005
@@ -212,7 +212,7 @@
String childId = document.getName();
ParentChildCreatorInterface creator = documentType.getCreator();
creator.create(
- getInitialContentsURI(parentDocument, documentType),
+ getInitialContentsURI(usecaseDocument, documentType),
new File(publication.getContentDirectory(area), parentId),
childId,
ParentChildCreatorInterface.BRANCH_NODE,
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java?rev=169824&r1=169823&r2=169824&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/CreateLanguage.java Thu May 12 07:00:24 2005
@@ -30,7 +30,7 @@
/**
* Usecase to create a new language version of a resource.
*
- * @version $Id:$
+ * @version $Id$
*/
public class CreateLanguage extends Create {
@@ -124,12 +124,7 @@
* @see Create#getInitialContentsURI(Document, DocumentType)
*/
protected String getInitialContentsURI(Document referenceDocument, DocumentType type) {
- // FIXME: this should be
- // return referenceDocument.getSourceURI();
- // but this can only work if DefaultCreator no longer uses
- // File to read initial contents, and can work with a Lenya URI
-
- return type.getSampleContentLocation();
+ return referenceDocument.getSourceURI();
}
/**
Modified: lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java?rev=169824&r1=169823&r2=169824&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java Thu May 12 07:00:24 2005
@@ -19,6 +19,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.xpath.XPathAPI;
import org.w3c.dom.Document;
@@ -45,10 +46,10 @@
private Date date;
/**
- *
+ * @see org.apache.lenya.cms.authoring.DefaultBranchCreator#init(Configuration, ServiceManager, Logger)
*/
- public void init(Configuration conf, Logger _logger) {
- super.init(conf, _logger);
+ public void init(Configuration conf, ServiceManager _manager, Logger _logger) {
+ super.init(conf, _manager, _logger);
DateFormat fmtyyyy = new SimpleDateFormat("yyyy");
DateFormat fmtMM = new SimpleDateFormat("MM");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org