You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2005/02/08 19:15:35 UTC
svn commit: r152682 [8/17] - in lenya/trunk/src: java/org/apache/lenya/ac/
java/org/apache/lenya/ac/cache/ java/org/apache/lenya/ac/file/
java/org/apache/lenya/ac/impl/ java/org/apache/lenya/ac/ldap/
java/org/apache/lenya/cms/ac/ java/org/apache/lenya/cms/ac/cocoon/
java/org/apache/lenya/cms/ac/usecase/ java/org/apache/lenya/cms/ac/usecases/
java/org/apache/lenya/cms/ac/workflow/ java/org/apache/lenya/cms/ant/
java/org/apache/lenya/cms/authoring/ java/org/apache/lenya/cms/cocoon/acting/
java/org/apache/lenya/cms/cocoon/bean/
java/org/apache/lenya/cms/cocoon/components/modules/input/
java/org/apache/lenya/cms/cocoon/flow/
java/org/apache/lenya/cms/cocoon/generation/
java/org/apache/lenya/cms/cocoon/matching/
java/org/apache/lenya/cms/cocoon/scheduler/
java/org/apache/lenya/cms/cocoon/source/
java/org/apache/lenya/cms/cocoon/task/
java/org/apache/lenya/cms/cocoon/transformation/
java/org/apache/lenya/cms/cocoon/uriparameterizer/
java/org/apache/lenya/cms/metadata/dublincore/
java/org/apache/lenya/cms/metadata/usecases/
java/org/apache/lenya/cms/publication/
java/org/apache/lenya/cms/publication/file/
java/org/apache/lenya/cms/publication/task/
java/org/apache/lenya/cms/publication/templating/
java/org/apache/lenya/cms/publication/util/
java/org/apache/lenya/cms/publishing/ java/org/apache/lenya/cms/rc/
java/org/apache/lenya/cms/scheduler/ java/org/apache/lenya/cms/scheduler/xml/
java/org/apache/lenya/cms/search/usecases/ java/org/apache/lenya/cms/site/
java/org/apache/lenya/cms/site/tree/
java/org/apache/lenya/cms/site/usecases/ java/org/apache/lenya/cms/task/
java/org/apache/lenya/cms/usecase/ java/org/apache/lenya/cms/workflow/
java/org/apache/lenya/lucene/ java/org/apache/lenya/lucene/html/
java/org/apache/lenya/lucene/index/ java/org/apache/lenya/lucene/parser/
java/org/apache/lenya/net/ java/org/apache/lenya/search/
java/org/apache/lenya/search/crawler/ java/org/apache/lenya/util/
java/org/apache/lenya/workflow/ java/org/apache/lenya/workflow/impl/
java/org/apache/lenya/xml/ test/org/apache/lenya/ac/file/
test/org/apache/lenya/ac/impl/ test/org/apache/lenya/cms/
test/org/apache/lenya/cms/authoring/
test/org/apache/lenya/cms/cocoon/generation/
test/org/apache/lenya/cms/publication/
test/org/apache/lenya/cms/publication/file/ test/org/apache/lenya/cms/rc/
test/org/apache/lenya/cms/site/tree/ test/org/apache/lenya/cms/task/
test/org/apache/lenya/cms/workflow/ test/org/apache/lenya/net/
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultResourcesManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultResourcesManager.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultResourcesManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultResourcesManager.java Tue Feb 8 10:13:39 2005
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.FileFilter;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -30,10 +31,6 @@
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.excalibur.io.FileUtil;
@@ -52,121 +49,131 @@
/**
* Create a new instance of Resources.
- *
- * @param document the document for which the resources are managed
+ * @param _document the document for which the resources are managed
*/
- public DefaultResourcesManager(Document document) {
- this.document = document;
+ public DefaultResourcesManager(Document _document) {
+ this.document = _document;
}
/**
* Add the file in the Part either as a resource or content
* @param part The Part
* @param metadata Holds the metadata for the resource
- *
- * @exception Exception if an error occurs
+ * @exception IOException if an error occurs
*/
- public void addResource(Part part, Map metadata) throws Exception {
+ public void addResource(Part part, Map metadata) throws IOException {
File resourceFile;
- String fileName = part.getFileName();
- if (!fileName.matches(FILE_NAME_REGEXP)) {
- // the file name contains characters which mean trouble
- // and are therefore not allowed.
- getLogger().warn("The filename [" + fileName + "]� is not valid for an asset.");
- }
- // convert spaces in the file name to underscores
- fileName = fileName.replace(' ', '_');
- String mimeType = part.getMimeType();
- int fileSize = part.getSize();
+ try {
+ String fileName = part.getFileName();
+ if (!fileName.matches(FILE_NAME_REGEXP)) {
+ // the file name contains characters which mean trouble
+ // and are therefore not allowed.
+ getLogger().warn("The filename [" + fileName + "]� is not valid for an asset.");
+ }
+ // convert spaces in the file name to underscores
+ fileName = fileName.replace(' ', '_');
+ String mimeType = part.getMimeType();
+ int fileSize = part.getSize();
- metadata.put("format", mimeType);
- metadata.put("extent", Integer.toString(fileSize));
+ metadata.put("format", mimeType);
+ metadata.put("extent", Integer.toString(fileSize));
- /* if (type.equals("resource")) { */
- resourceFile = new File(this.getPath(), fileName);
+ /* if (type.equals("resource")) { */
+ resourceFile = new File(this.getPath(), fileName);
- if (!this.getPath().exists()) {
- this.getPath().mkdirs();
- }
+ if (!this.getPath().exists()) {
+ this.getPath().mkdirs();
+ }
- // create an extra file containing the meta description for
- // the resource.
- File metaDataFile = new File(this.getPath(), fileName + RESOURCES_META_SUFFIX);
- createMetaData(metaDataFile, metadata);
-
- /*
- * } // must be a content upload then else { resourceFile = new
- * File(document.getFile().getParent(), fileName);
- * getLogger().debug("resourceFile: " + resourceFile); }
- */
- saveResource(resourceFile, part);
+ // create an extra file containing the meta description for
+ // the resource.
+ File metaDataFile = new File(this.getPath(), fileName + RESOURCES_META_SUFFIX);
+ createMetaData(metaDataFile, metadata);
+
+ /*
+ * } // must be a content upload then else { resourceFile = new
+ * File(document.getFile().getParent(), fileName);
+ * getLogger().debug("resourceFile: " + resourceFile); }
+ */
+ saveResource(resourceFile, part);
+ } catch (final DocumentException e) {
+ getLogger().error("Document exception " +e.toString());
+ throw new IOException(e.toString());
+ } catch (final IOException e) {
+ getLogger().error("IO Error " +e.toString());
+ }
}
/**
* Saves the resource to a file.
- *
* @param resourceFile The resource file.
* @param part The part of the multipart request.
- * @throws Exception if an error occurs.
+ * @throws IOException if an error occurs.
*/
- protected void saveResource(File resourceFile, Part part) throws Exception {
+ protected void saveResource(File resourceFile, Part part) throws IOException {
if (!resourceFile.exists()) {
boolean created = resourceFile.createNewFile();
if (!created) {
- throw new RuntimeException("The file [" + resourceFile + "]�could not be created.");
+ throw new IOException("The file [" + resourceFile + "]�could not be created.");
}
}
- byte[] buf = new byte[4096];
- FileOutputStream out = new FileOutputStream(resourceFile);
- try {
- InputStream in = part.getInputStream();
- int read = in.read(buf);
-
- while (read > 0) {
- out.write(buf, 0, read);
- read = in.read(buf);
- }
- } finally {
- out.close();
+ try {
+ byte[] buf = new byte[4096];
+ FileOutputStream out = new FileOutputStream(resourceFile);
+ InputStream in = part.getInputStream();
+ int read = in.read(buf);
+
+ while (read > 0) {
+ out.write(buf, 0, read);
+ read = in.read(buf);
+ }
+ } catch (final FileNotFoundException e) {
+ getLogger().error("file not found" +e.toString());
+ throw new IOException(e.toString());
+ } catch (IOException e) {
+ getLogger().error("IO error " +e.toString());
+ throw new IOException(e.toString());
+ } catch (Exception e) {
+ getLogger().error("Exception" +e.toString());
+ throw new IOException(e.toString());
}
}
/**
* Create the meta data file given the dublin core parameters.
- *
* @param metaDataFile the file where the meta data file is to be created
* @param metadata a <code>Map</code> containing the dublin core values
- * @throws TransformerConfigurationException if an error occurs.
- * @throws TransformerException if an error occurs.
- * @throws IOException if an error occurs
- * @throws ParserConfigurationException if an error occurs.
+ * @throws DocumentException if an error occurs
*/
protected void createMetaData(File metaDataFile, Map metadata)
- throws TransformerConfigurationException, TransformerException, IOException,
- ParserConfigurationException {
+ throws DocumentException {
assert (metaDataFile.getParentFile().exists());
- try {
- dc = new DublinCoreImpl(metaDataFile);
- Iterator iter = metadata.keySet().iterator();
+ try {
+ String key;
+ String value;
+ Map.Entry entry;
+ this.dc = new DublinCoreImpl(metaDataFile);
+ Iterator iter = metadata.entrySet().iterator();
while (iter.hasNext()) {
- String key = (String) iter.next();
- String value = (String) metadata.get(key);
- dc.setValue(key, value);
+ entry = (Map.Entry)iter.next();
+ key = (String)entry.getKey();
+ value = (String)entry.getValue();
+ this.dc.setValue(key, value);
}
- dc.save();
- } catch (Exception e) {
+ this.dc.save();
+ } catch (final DocumentException e) {
getLogger().error("Saving of [" + metaDataFile + "]�failed.");
+ throw new DocumentException(e);
}
}
/**
* Get the path to the resources.
- *
* @return the path to the resources
*/
private String getPathFromPublication() {
@@ -175,7 +182,6 @@
/**
* Get the path to the resources.
- *
* @return the path to the resources
*/
public File getPath() {
@@ -187,6 +193,7 @@
/**
* Returns the path of a resource relative to the context prefix.
+ * @param resource The resource
* @return The path of a resource relative to the context prefix.
*/
public String getResourceUrl(File resource) {
@@ -196,7 +203,6 @@
/**
* Get all resources for the associated document.
- *
* @return all resources of the associated document
*/
public File[] getResources() {
@@ -243,7 +249,6 @@
/**
* Get the meta data for all resources for the associated document.
- *
* @return all meta data files for the resources for the associated
* document.
*/
@@ -296,8 +301,11 @@
}
}
+ /**
+ * @see org.apache.lenya.cms.publication.ResourcesManager#getDocument()
+ */
public Document getDocument() {
- return document;
+ return this.document;
}
/**
@@ -309,12 +317,12 @@
getLogger().debug("Copying resources of document [" + getDocument() + "]");
}
- ResourcesManager destinationManager = destinationDocument.getResourcesManager();
+ ResourcesManager _destinationManager = destinationDocument.getResourcesManager();
List resourcesList = new ArrayList(Arrays.asList(getResources()));
resourcesList.addAll(Arrays.asList(getMetaFiles()));
File[] resources = (File[]) resourcesList.toArray(new File[resourcesList.size()]);
- File destinationDirectory = destinationManager.getPath();
+ File destinationDirectory = _destinationManager.getPath();
for (int i = 0; i < resources.length; i++) {
File destinationResource = new File(destinationDirectory, resources[i].getName());
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java Tue Feb 8 10:13:39 2005
@@ -27,7 +27,6 @@
/**
* Builds a document.
- *
* @param map The identity map the document belongs to.
* @param url The URL of the form /{publication-id}/{area}/{document-id}{language-suffix}.{extension}.
* @return A document.
@@ -38,7 +37,6 @@
/**
* Checks if an URL corresponds to a CMS document.
- *
* @param publication The publication the document belongs to.
* @param url The URL of the form /{publication-id}/...
* @return A boolean value.
@@ -50,7 +48,6 @@
/**
* Builds an URL corresponding to a cms document from the publication,
* the area, the document id and the language
- *
* @param publication The publication the document belongs to.
* @param area The area the document belongs to.
* @param documentid The document id of the document.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentDoesNotExistException.java Tue Feb 8 10:13:39 2005
@@ -19,6 +19,9 @@
package org.apache.lenya.cms.publication;
+/**
+ * Document does not exist exception
+ */
public class DocumentDoesNotExistException extends DocumentException {
/**
@@ -31,7 +34,6 @@
/**
* Creates a new DocumentDoesNotExistException
- *
* @param message the exception message
*/
public DocumentDoesNotExistException(String message) {
@@ -40,7 +42,6 @@
/**
* Creates a new DocumentDoesNotExistException
- *
* @param message the exception message
* @param cause the cause of the exception
*/
@@ -50,7 +51,6 @@
/**
* Creates a new DocumentDoesNotExistException
- *
* @param cause the cause of the exception
*/
public DocumentDoesNotExistException(Throwable cause) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentException.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentException.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentException.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentException.java Tue Feb 8 10:13:39 2005
@@ -19,6 +19,9 @@
package org.apache.lenya.cms.publication;
+/**
+ * Document exception
+ */
public class DocumentException extends PublicationException {
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java Tue Feb 8 10:13:39 2005
@@ -25,10 +25,10 @@
/**
* Ctor.
- * @param identityMap The identity map.
+ * @param _identityMap The identity map.
*/
- protected DocumentFactory(DocumentIdentityMap identityMap) {
- this.identityMap = identityMap;
+ protected DocumentFactory(DocumentIdentityMap _identityMap) {
+ this.identityMap = _identityMap;
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdToPathMapper.java Tue Feb 8 10:13:39 2005
@@ -21,6 +21,9 @@
import java.io.File;
+/**
+ * Document Id to Path mapper interface
+ */
public interface DocumentIdToPathMapper {
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java Tue Feb 8 10:13:39 2005
@@ -37,10 +37,10 @@
/**
* Ctor.
- * @param publication The publication to use.
+ * @param _publication The publication to use.
*/
- public DocumentIdentityMap(Publication publication) {
- this.publication = publication;
+ public DocumentIdentityMap(Publication _publication) {
+ this.publication = _publication;
}
/**
@@ -59,7 +59,7 @@
* @return A publication.
*/
public Publication getPublication() {
- return publication;
+ return this.publication;
}
/**
@@ -73,12 +73,12 @@
protected Document get(String area, String documentId, String language)
throws DocumentBuildException {
String key = getKey(area, documentId, language);
- Document document = (Document) key2document.get(key);
+ Document document = (Document) this.key2document.get(key);
if (document == null) {
DocumentBuilder builder = getPublication().getDocumentBuilder();
String url = builder.buildCanonicalUrl(getPublication(), area, documentId, language);
document = builder.buildDocument(this, url);
- key2document.put(key, document);
+ this.key2document.put(key, document);
}
return document;
}
@@ -100,11 +100,11 @@
String key = getKey(document.getArea(), document.getId(), document.getLanguage());
Document resultDocument;
- if (key2document.containsKey(key)) {
- resultDocument = (Document) key2document.get(key);
+ if (this.key2document.containsKey(key)) {
+ resultDocument = (Document) this.key2document.get(key);
} else {
resultDocument = document;
- key2document.put(key, resultDocument);
+ this.key2document.put(key, resultDocument);
}
return resultDocument;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentType.java Tue Feb 8 10:13:39 2005
@@ -26,17 +26,23 @@
* A document type.
*/
public class DocumentType {
+ /**
+ * <code>NAMESPACE</code> The doctypes namespace
+ */
public static final String NAMESPACE = "http://apache.org/cocoon/lenya/doctypes/1.0";
+ /**
+ * <code>DEFAULT_PREFIX</code> The doctypes namespace prefix
+ */
public static final String DEFAULT_PREFIX = "dt";
/** Creates a new instance of DocumentType
*
- * @param name the name of the document type
+ * @param _name the name of the document type
*
*/
- protected DocumentType(String name) {
- assert name != null;
- this.name = name;
+ protected DocumentType(String _name) {
+ assert _name != null;
+ this.name = _name;
}
private String name;
@@ -46,46 +52,41 @@
* @return A string value.
*/
public String getName() {
- return name;
+ return this.name;
}
private ParentChildCreatorInterface creator = null;
/**
* Get the creator for this document type.
- *
* @return a <code>ParentChildCreatorInterface</code>
*/
public ParentChildCreatorInterface getCreator() {
- return creator;
+ return this.creator;
}
/**
* Set the creator
- *
- * @param creator a <code>ParentChildCreatorInterface</code>
+ * @param _creator a <code>ParentChildCreatorInterface</code>
*/
- protected void setCreator(ParentChildCreatorInterface creator) {
- assert creator != null;
- this.creator = creator;
+ protected void setCreator(ParentChildCreatorInterface _creator) {
+ assert _creator != null;
+ this.creator = _creator;
}
private String workflowFile = null;
/**
* Returns if this document type has a workflow definition.
- *
* @return A boolean value.
*/
public boolean hasWorkflow() {
- return workflowFile != null;
+ return this.workflowFile != null;
}
/**
* Get the file name of the workflow file.
- *
* @return a <code>String</code>
- *
* @throws DocumentTypeBuildException if the document type has no workflow
*/
public String getWorkflowFileName() throws DocumentTypeBuildException {
@@ -93,21 +94,19 @@
throw new DocumentTypeBuildException("The document type '" + getName() +
"' has no workflow!");
}
-
- return workflowFile;
+ return this.workflowFile;
}
/**
* Set the file name of the workflow file.
- *
* @param string the new file name
*/
public void setWorkflowFileName(String string) {
assert string != null;
- workflowFile = string;
+ this.workflowFile = string;
}
- /** (non-Javadoc)
+ /**
* @see java.lang.Object#toString()
*/
public String toString() {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuildException.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuildException.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuildException.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuildException.java Tue Feb 8 10:13:39 2005
@@ -19,9 +19,12 @@
package org.apache.lenya.cms.publication;
+/**
+ * Document type build exception
+ */
public class DocumentTypeBuildException extends Exception {
/**
- *
+ * Constructor
*/
public DocumentTypeBuildException() {
super();
@@ -29,7 +32,6 @@
/**
* Creates a new DocumentTypeBuildException.
- *
* @param message the exception message
*/
public DocumentTypeBuildException(String message) {
@@ -38,7 +40,6 @@
/**
* Creates a new DocumentTypeBuildException.
- *
* @param message the exception message
* @param cause the cause of the exception
*/
@@ -48,7 +49,6 @@
/**
* Creates a new DocumentTypeBuildException.
- *
* @param cause the cause of the exception
*/
public DocumentTypeBuildException(Throwable cause) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilder.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilder.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilder.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilder.java Tue Feb 8 10:13:39 2005
@@ -20,10 +20,13 @@
package org.apache.lenya.cms.publication;
import java.io.File;
+import java.io.IOException;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.lenya.cms.authoring.ParentChildCreatorInterface;
+import org.xml.sax.SAXException;
/**
@@ -32,6 +35,7 @@
public final class DocumentTypeBuilder {
/** Creates a new instance of DocumentTypeBuilder */
private DocumentTypeBuilder() {
+ // do nothing
}
/**
@@ -39,20 +43,37 @@
*/
public static final String DOCTYPE_DIRECTORY = "config/doctypes".replace('/', File.separatorChar);
- /*
- * The default document types configuration file, relative to the publication directory.
+ /**
+ * <code>CONFIG_FILE</code> The default document types configuration file, relative to the publication directory.
*/
public static final String CONFIG_FILE = "doctypes.xconf".replace('/', File.separatorChar);
+ /**
+ * <code>DOCTYPES_ELEMENT</code> The doctypes element
+ */
public static final String DOCTYPES_ELEMENT = "doctypes";
+ /**
+ * <code>DOCTYPE_ELEMENT</code> The doctype element
+ */
public static final String DOCTYPE_ELEMENT = "doc";
+ /**
+ * <code>TYPE_ATTRIBUTE</code> The type attribute
+ */
public static final String TYPE_ATTRIBUTE = "type";
+ /**
+ * <code>CREATOR_ELEMENT</code> The creator element
+ */
public static final String CREATOR_ELEMENT = "creator";
+ /**
+ * <code>SRC_ATTRIBUTE</code> The src attribute
+ */
public static final String SRC_ATTRIBUTE = "src";
+ /**
+ * <code>WORKFLOW_ELEMENT</code> The workflow element
+ */
public static final String WORKFLOW_ELEMENT = "workflow";
/**
* Builds a document type for a given name.
- *
* @param name A string value.
* @param publication The publication the document type belongs to.
* @return A document type object.
@@ -102,7 +123,19 @@
String workflowFileName = workflowConf.getAttribute(SRC_ATTRIBUTE);
type.setWorkflowFileName(workflowFileName);
}
- } catch (Exception e) {
+ } catch (final ConfigurationException e) {
+ throw new DocumentTypeBuildException(e);
+ } catch (final SAXException e) {
+ throw new DocumentTypeBuildException(e);
+ } catch (final IOException e) {
+ throw new DocumentTypeBuildException(e);
+ } catch (final DocumentTypeBuildException e) {
+ throw new DocumentTypeBuildException(e);
+ } catch (final ClassNotFoundException e) {
+ throw new DocumentTypeBuildException(e);
+ } catch (final InstantiationException e) {
+ throw new DocumentTypeBuildException(e);
+ } catch (final IllegalAccessException e) {
throw new DocumentTypeBuildException(e);
}
Propchange: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolver.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolverImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolverImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolverImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolverImpl.java Tue Feb 8 10:13:39 2005
@@ -47,8 +47,8 @@
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
+ public void service(ServiceManager _manager) throws ServiceException {
+ this.manager = _manager;
}
private Context context;
@@ -56,8 +56,8 @@
/**
* @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
*/
- public void contextualize(Context context) throws ContextException {
- this.context = context;
+ public void contextualize(Context _context) throws ContextException {
+ this.context = _context;
}
/**
@@ -105,10 +105,10 @@
private String filterURI(final String uri) {
final int index = uri.indexOf(";jsessionid");
- if (index >= 0)
+ if (index >= 0) {
return uri.substring(0, index);
- else
- return uri;
+ }
+ return uri;
}
}
Propchange: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolverImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeResolverImpl.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/IdentityDocumentIdToPathMapper.java Tue Feb 8 10:13:39 2005
@@ -21,6 +21,9 @@
import java.io.File;
+/**
+ * Identity Document Id to path mapper
+ */
public class IdentityDocumentIdToPathMapper implements DocumentIdToPathMapper {
/**
@@ -34,7 +37,6 @@
}
/**
- * (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) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Tue Feb 8 10:13:39 2005
@@ -31,33 +31,114 @@
* document.
*/
public class PageEnvelope {
+ /**
+ * The names of the page envelope parameters.
+ */
+ public static final String[] PARAMETER_NAMES = { PageEnvelope.AREA, PageEnvelope.CONTEXT,
+ PageEnvelope.PUBLICATION_ID, PageEnvelope.PUBLICATION,
+ PageEnvelope.PUBLICATION_LANGUAGES_CSV, PageEnvelope.DOCUMENT,
+ PageEnvelope.DOCUMENT_ID, PageEnvelope.DOCUMENT_NAME,
+ PageEnvelope.DOCUMENT_LABEL, PageEnvelope.DOCUMENT_URL,
+ PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE, PageEnvelope.DOCUMENT_PATH,
+ PageEnvelope.DOCUMENT_EXTENSION, PageEnvelope.DEFAULT_LANGUAGE,
+ PageEnvelope.DOCUMENT_LANGUAGE, PageEnvelope.DOCUMENT_LANGUAGES,
+ PageEnvelope.DOCUMENT_LANGUAGES_CSV, PageEnvelope.DOCUMENT_LASTMODIFIED,
+ PageEnvelope.BREADCRUMB_PREFIX, PageEnvelope.SSL_PREFIX };
+ /**
+ * <code>PUBLICATION_ID</code> The publication id
+ */
public static final String PUBLICATION_ID = "publication-id";
+ /**
+ * <code>PUBLICATION</code> The publication
+ */
public static final String PUBLICATION = "publication";
+ /**
+ * <code>PUBLICATION_LANGUAGES_CSV</code> A list of the publication's languages, comma-seperated
+ */
public static final String PUBLICATION_LANGUAGES_CSV = "publication-languages-csv";
+ /**
+ * <code>CONTEXT</code> The context prefix
+ */
public static final String CONTEXT = "context-prefix";
+ /**
+ * <code>AREA</code> The area
+ */
public static final String AREA = "area";
+ /**
+ * <code>DEFAULT_LANGUAGE</code> The default language of the publication
+ */
public static final String DEFAULT_LANGUAGE = "default-language";
+ /**
+ * <code>DOCUMENT</code> The current document
+ */
public static final String DOCUMENT = "document";
+ /**
+ * <code>DOCUMENT_ID</code> The document id of the current document
+ */
public static final String DOCUMENT_ID = "document-id";
+ /**
+ * <code>DOCUMENT_NAME</code> The name of the current document
+ */
public static final String DOCUMENT_NAME = "document-name";
+ /**
+ * <code>DOCUMENT_TYPE</code> The type of the current document
+ */
public static final String DOCUMENT_TYPE = "document-type";
+ /**
+ * <code>DOCUMENT_LABEL</code> The label of the current document
+ */
public static final String DOCUMENT_LABEL = "document-label";
+ /**
+ * <code>DOCUMENT_URL</code> The URL of the current document
+ */
public static final String DOCUMENT_URL = "document-url";
+ /**
+ * <code>DOCUMENT_URL_WITHOUT_LANGUAGE</code> The URL of the current document without a language extension.
+ */
public static final String DOCUMENT_URL_WITHOUT_LANGUAGE = "document-url-without-language";
+ /**
+ * <code>DOCUMENT_FILE</code> The file of the current document
+ */
public static final String DOCUMENT_FILE = "document-file";
+ /**
+ * <code>DOCUMENT_PATH</code> The path of the current document
+ */
public static final String DOCUMENT_PATH = "document-path";
+ /**
+ * <code>DOCUMENT_EXTENSION</code> The extension of the current document
+ */
public static final String DOCUMENT_EXTENSION = "document-extension";
+ /**
+ * <code>DOCUMENT_LANGUAGE</code> The language of the current document
+ */
public static final String DOCUMENT_LANGUAGE = "document-language";
+ /**
+ * <code>DOCUMENT_LANGUAGES</code> The languages the current document is available in
+ */
public static final String DOCUMENT_LANGUAGES = "document-languages";
+ /**
+ * <code>DOCUMENT_LANGUAGES_CSV</code> The languages the current document is available in, comma-seperated
+ */
public static final String DOCUMENT_LANGUAGES_CSV = "document-languages-csv";
-
+ /**
+ * <code>DOCUMENT_LASTMODIFIED</code> The last modified date of the current document
+ */
public static final String DOCUMENT_LASTMODIFIED = "document-lastmodified";
-
+ /**
+ * <code>BREADCRUMB_PREFIX</code> The breadcrumb prefix of the publication, used for navigation
+ */
public static final String BREADCRUMB_PREFIX = "breadcrumb-prefix";
-
+ /**
+ * <code>SSL_PREFIX</code> The SSL prefix of the publication
+ */
public static final String SSL_PREFIX = "ssl-prefix";
-
+ /**
+ * <code>NAMESPACE</code> The page envelope namespace
+ */
public static final String NAMESPACE = "http://apache.org/cocoon/lenya/page-envelope/1.0";
+ /**
+ * <code>DEFAULT_PREFIX</code> The default prefix
+ */
public static final String DEFAULT_PREFIX = "lenya";
private String context;
@@ -66,11 +147,11 @@
* Constructor.
*/
protected PageEnvelope() {
+ // do nothing
}
/**
* Creates a page envelope from an object model.
- *
* @param map The identity map to use.
* @param objectModel The object model.
* @throws PageEnvelopeException when something went wrong.
@@ -81,14 +162,14 @@
String webappURI;
try {
- context = request.getContextPath();
- if (context == null) {
- context = "";
+ this.context = request.getContextPath();
+ if (this.context == null) {
+ this.context = "";
}
webappURI = ServletHelper.getWebappURI(request);
- Document document = map.getFactory().getFromURL(webappURI);
- setDocument(document);
+ Document _document = map.getFactory().getFromURL(webappURI);
+ setDocument(_document);
} catch (Exception e) {
throw new PageEnvelopeException(e);
@@ -107,20 +188,18 @@
/**
* Creates the message to report when creating the envelope failed.
- *
* @param request The request.
* @return A string.
*/
protected String createExceptionMessage(Request request) {
return "Resolving page envelope failed:" + "\n URI: " + request.getRequestURI()
+ "\n Context: " + getContext() + "\n Publication ID: "
- + getPublication().getId() + "\n Area: " + document.getArea()
- + "\n Document ID: " + document.getId();
+ + getPublication().getId() + "\n Area: " + this.document.getArea()
+ + "\n Document ID: " + this.document.getId();
}
/**
* Returns the publication of this PageEnvelope.
- *
* @return a <code>Publication</code> value
*/
public Publication getPublication() {
@@ -139,63 +218,44 @@
/**
* Returns the context, e.g. "/lenya".
- *
* @return a <code>String</code> value
*/
public String getContext() {
- return context;
+ return this.context;
}
/**
* Returns the document-path.
- *
* @return a <code>File<code> value
*/
public String getDocumentPath() {
-
return getPublication().getPathMapper().getPath(getDocument().getId(),
getDocument().getLanguage());
}
/**
- * The names of the page envelope parameters.
- */
- public static final String[] PARAMETER_NAMES = { PageEnvelope.AREA, PageEnvelope.CONTEXT,
- PageEnvelope.PUBLICATION_ID, PageEnvelope.PUBLICATION,
- PageEnvelope.PUBLICATION_LANGUAGES_CSV, PageEnvelope.DOCUMENT,
- PageEnvelope.DOCUMENT_ID, PageEnvelope.DOCUMENT_NAME,
- PageEnvelope.DOCUMENT_LABEL, PageEnvelope.DOCUMENT_URL,
- PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE, PageEnvelope.DOCUMENT_PATH,
- PageEnvelope.DOCUMENT_EXTENSION, PageEnvelope.DEFAULT_LANGUAGE,
- PageEnvelope.DOCUMENT_LANGUAGE, PageEnvelope.DOCUMENT_LANGUAGES,
- PageEnvelope.DOCUMENT_LANGUAGES_CSV, PageEnvelope.DOCUMENT_LASTMODIFIED,
- PageEnvelope.BREADCRUMB_PREFIX, PageEnvelope.SSL_PREFIX };
-
- /**
* @param string The context.
*/
protected void setContext(String string) {
- context = string;
+ this.context = string;
}
private Document document;
/**
* Returns the document.
- *
* @return A document
*/
public Document getDocument() {
- return document;
+ return this.document;
}
/**
* Sets the document.
- *
- * @param document A document.
+ * @param _document A document.
*/
- public void setDocument(Document document) {
- this.document = document;
+ public void setDocument(Document _document) {
+ this.document = _document;
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeException.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeException.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeException.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeException.java Tue Feb 8 10:13:39 2005
@@ -28,11 +28,11 @@
* Creates a new PageEnvelopeException.
*/
public PageEnvelopeException() {
+ // do nothing
}
/**
* Creates a new PageEnvelopeException.
- *
* @param message the exception message
*/
public PageEnvelopeException(String message) {
@@ -41,7 +41,6 @@
/**
* Creates a new PageEnvelopeException.
- *
* @param message the exception message
* @param cause the cause of the exception
*/
@@ -51,7 +50,6 @@
/**
* Creates a new PageEnvelopeException.
- *
* @param cause the cause of the exception
*/
public PageEnvelopeException(Throwable cause) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java Tue Feb 8 10:13:39 2005
@@ -29,6 +29,7 @@
* Creates a new PageEnvelopeFactory.
*/
protected PageEnvelopeFactory() {
+ // do nothing
}
private static PageEnvelopeFactory instance;
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PathToDocumentIdMapper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PathToDocumentIdMapper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PathToDocumentIdMapper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PathToDocumentIdMapper.java Tue Feb 8 10:13:39 2005
@@ -22,20 +22,16 @@
import java.io.File;
/**
- *
* This interface is basically the reverse of DocumentIdToPathMapper.
*/
public interface PathToDocumentIdMapper {
/**
* Compute the document-id for a given file.
- *
* @param publication the publication where the file is.
* @param area the area where the file is.
* @param file the file that is associated with the document
- *
* @return the document-id of the document associated with the given file.
- *
* @throws DocumentDoesNotExistException if there is no document associated with this file.
*/
String getDocumentId(Publication publication, String area, File file)
@@ -43,9 +39,7 @@
/**
* Returns the language for a given file
- *
* @param file the document file
- *
* @return the language for the given document file or null if the file
* has no language.
*/
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Proxy.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/Proxy.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Proxy.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Proxy.java Tue Feb 8 10:13:39 2005
@@ -38,7 +38,6 @@
/**
* Returns the absolute URL of a particular document.
- *
* @param document The document.
* @return A string.
*/
@@ -56,14 +55,13 @@
/**
* Sets the proxy URL.
- * @param url The url to set.
+ * @param _url The url to set.
*/
- public void setUrl(String url) {
- this.url = url;
+ public void setUrl(String _url) {
+ this.url = _url;
}
/**
- * (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java Tue Feb 8 10:13:39 2005
@@ -30,31 +30,109 @@
*/
public interface Publication {
+ /**
+ * <code>AUTHORING_AREA</code> The authoring area
+ */
String AUTHORING_AREA = "authoring";
+ /**
+ * <code>STAGING_AREA</code> The staging area
+ */
String STAGING_AREA = "staging";
+ /**
+ * <code>LIVE_AREA</code> The live area
+ */
String LIVE_AREA = "live";
+ /**
+ * <code>ADMIN_AREA</code> The admin area
+ */
String ADMIN_AREA = "admin";
+ /**
+ * <code>ARCHIVE_AREA</code> The archive area
+ */
String ARCHIVE_AREA = "archive";
+ /**
+ * <code>TRASH_AREA</code> The trash area
+ */
String TRASH_AREA = "trash";
+ /**
+ * <code>ELEMENT_PATH_MAPPER</code> The path mapper element
+ */
String ELEMENT_PATH_MAPPER = "path-mapper";
+ /**
+ * <code>ELEMENT_DOCUMENT_BUILDER</code> The document buider element
+ */
String ELEMENT_DOCUMENT_BUILDER = "document-builder";
+ /**
+ * <code>ELEMENT_SITE_STRUCTURE</code> The site structure element
+ */
String ELEMENT_SITE_STRUCTURE = "site-structure";
+ /**
+ * <code>ATTRIBUTE_TYPE</code> The type attribute
+ */
String ATTRIBUTE_TYPE = "type";
+ /**
+ * <code>ATTRIBUTE_SRC</code> The src attribute
+ */
String ATTRIBUTE_SRC = "type";
+ /**
+ * <code>LANGUAGES</code> The languages
+ */
String LANGUAGES = "languages";
+ /**
+ * <code>LANGUAGE</code> The language
+ */
String LANGUAGE = "language";
+ /**
+ * <code>DEFAULT_LANGUAGE_ATTR</code> The default language attribute
+ */
String DEFAULT_LANGUAGE_ATTR = "default";
+ /**
+ * <code>BREADCRUMB_PREFIX</code> The breadcrumb prefix
+ */
String BREADCRUMB_PREFIX = "breadcrumb-prefix";
+ /**
+ * <code>SSL_PREFIX</code> The SSL prefix
+ */
String SSL_PREFIX = "ssl-prefix";
+ /**
+ * <code>LIVE_MOUNT_POINT</code> The live mount point
+ */
String LIVE_MOUNT_POINT = "live-mount-point";
+ /**
+ * <code>PUBLICATION_PREFIX</code> The publication prefix
+ */
String PUBLICATION_PREFIX = "lenya" + File.separator + "pubs";
+ /**
+ * <code>PUBLICATION_PREFIX_URI</code> The publication prefix URI
+ */
String PUBLICATION_PREFIX_URI = "lenya/pubs";
+ /**
+ * <code>CONFIGURATION_PATH</code> The configuration path
+ */
String CONFIGURATION_PATH = "config";
+ /**
+ * <code>CONTENT_PATH</code> The content path
+ */
String CONTENT_PATH = "content";
+ /**
+ * <code>PENDING_PATH</code> The pending path
+ */
String PENDING_PATH = "pending";
+ /**
+ * <code>DELETE_PATH</code> The delete path
+ */
String DELETE_PATH = "delete";
+ /**
+ * <code>INFO_AREA_PREFIX</code> The info area prefix
+ */
String INFO_AREA_PREFIX = "info-";
+ /**
+ * <code>SEARCH_AREA_PREFIX</code> The search area prefix
+ */
String SEARCH_AREA_PREFIX = "search-";
+ /**
+ * <code>CONFIGURATION_FILE</code> The publication configuration file
+ */
String CONFIGURATION_FILE = CONFIGURATION_PATH + File.separator + "publication.xconf";
/**
@@ -78,51 +156,43 @@
/**
* Return the directory of a specific area.
- *
* @param area a <code>File</code> representing the root of the area content directory.
- *
* @return the directory of the given content area.
*/
File getContentDirectory(String area);
/**
- * DOCUMENT ME!
- *
- * @param mapper DOCUMENT ME!
+ * Set the path mapper
+ * @param mapper The path mapper
*/
void setPathMapper(DefaultDocumentIdToPathMapper mapper);
/**
* Returns the path mapper.
- *
* @return a <code>DocumentIdToPathMapper</code>
*/
DocumentIdToPathMapper getPathMapper();
/**
* Get the default language
- *
* @return the default language
*/
String getDefaultLanguage();
/**
* Set the default language
- *
* @param language the default language
*/
void setDefaultLanguage(String language);
/**
* Get all available languages for this publication
- *
* @return an <code>Array</code> of languages
*/
String[] getLanguages();
/**
* Get the breadcrumb prefix. It can be used as a prefix if a publication is part of a larger site
- *
* @return the breadcrumb prefix
*/
String getBreadcrumbPrefix();
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationException.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationException.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationException.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationException.java Tue Feb 8 10:13:39 2005
@@ -19,11 +19,13 @@
package org.apache.lenya.cms.publication;
+/**
+ * Publication Exception
+ */
public class PublicationException extends Exception {
/**
* Creates a new PublicationException.
- *
*/
public PublicationException() {
super();
@@ -31,7 +33,6 @@
/**
* Creates a new PublicationException.
- *
* @param message the exception message
*/
public PublicationException(String message) {
@@ -40,7 +41,6 @@
/**
* Creates a new PublicationException.
- *
* @param message the exception message
* @param cause the cause of the exception
*/
@@ -50,7 +50,6 @@
/**
* Creates a new PublicationException.
- *
* @param cause the cause of the exception
*/
public PublicationException(Throwable cause) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationFactory.java Tue Feb 8 10:13:39 2005
@@ -69,11 +69,8 @@
* Creates a new publication.
* The publication ID is resolved from the request URI.
* The servlet context path is resolved from the context object.
-
* @param objectModel The object model of the Cocoon component.
- *
* @return a <code>Publication</code>
- *
* @throws PublicationException if there was a problem creating the publication.
*/
public Publication getPublication(Map objectModel) throws PublicationException {
@@ -87,12 +84,9 @@
/**
* Create a new publication with the given publication-id and servlet context path.
* These publications are cached and reused for similar requests.
- *
* @param id the publication id
* @param servletContextPath the servlet context path of the publication
- *
* @return a <code>Publication</code>
- *
* @throws PublicationException if there was a problem creating the publication.
*/
public Publication getPublication(String id, String servletContextPath)
@@ -124,7 +118,6 @@
* Generates a key to cache a publication.
* The cache key is constructed using the canonical servlet context path
* and the publication ID.
- *
* @param publicationId The publication ID.
* @param servletContextPath The servlet context path.
* @return A cache key.
@@ -146,12 +139,9 @@
/**
* Creates a new publication based on a request and a context.
- *
* @param request A request.
* @param context A context.
- *
* @return A publication.
- *
* @throws PublicationException if there was a problem creating the publication.
*/
public Publication getPublication(Request request, Context context)
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourcesManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourcesManager.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourcesManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourcesManager.java Tue Feb 8 10:13:39 2005
@@ -29,19 +29,45 @@
*/
public interface ResourcesManager {
+ /**
+ * <code>CONTENT_PREFIX</code> The content prefix
+ */
final String CONTENT_PREFIX = "content";
+ /**
+ * <code>RESOURCES_PREFIX</code> The resources prefix
+ */
final String RESOURCES_PREFIX = "resources";
+ /**
+ * <code>RESOURCES_META_SUFFIX</code> The suffix for resource meta files
+ */
final String RESOURCES_META_SUFFIX = ".meta";
-
+ /**
+ * <code>UPLOADASSET_PARAM_NAME</code> The parameter name for the uploaded asset
+ */
final String UPLOADASSET_PARAM_NAME = "properties.asset.data";
+ /**
+ * <code>UPLOADASSET_PARAM_PREFIX</code> The prefix for all asset upload parameters
+ */
final String UPLOADASSET_PARAM_PREFIX = "properties.asset.";
-
+ /**
+ * <code>UPLOADASSET_RETURN_FILESIZE</code> The file size
+ */
final String UPLOADASSET_RETURN_FILESIZE = "file-size";
+ /**
+ * <code>UPLOADASSET_RETURN_MIMETYPE</code> The mime type
+ */
final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
-
+ /**
+ * <code>FILE_NAME_REGEXP</code> The regular expression for valid asset names
+ */
final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_.]+";
+ /**
+ * <code>IMAGE_FILE_EXTENSIONS</code> The valid extensions for images
+ */
final String[] IMAGE_FILE_EXTENSIONS = { ".jpg", ".png", ".bmp", ".gif", ".svg" };
-
+ /**
+ * <code>DUBLIN_CORE_PARAMETERS</code> The known Dublin Core values
+ */
// optional parameters for meta data according to dublin core
final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject", "description",
"publisher", "contributor", "date", "type", "format", "identifier", "source",
@@ -51,12 +77,12 @@
* Add a resource to the document.
* @param part the part that contains the uploaded file
* @param metadata the metadata for the resource
+ * @throws Exception if an error occurs
*/
void addResource(Part part, Map metadata) throws Exception;
/**
* Get the path to the resources.
- *
* @return the path to the resources
* @deprecated the resource manager should not expose storage details.
*/
@@ -64,13 +90,13 @@
/**
* Returns the path of a resource relative to the context prefix.
+ * @param resource The resource
* @return The path of a resource relative to the context prefix.
*/
String getResourceUrl(File resource);
/**
* Get all resources for the associated document.
- *
* @return all resources of the associated document
*/
File[] getResources();
@@ -83,7 +109,6 @@
/**
* Get the meta data for all resources for the associated document.
- *
* @return all meta data files for the resources for the associated
* document.
*/
@@ -105,6 +130,7 @@
/**
* Gets the document this resource manager belongs to.
+ * @return The document
*/
Document getDocument();
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/SingleLanguageIdentityMapper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/SingleLanguageIdentityMapper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/SingleLanguageIdentityMapper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/SingleLanguageIdentityMapper.java Tue Feb 8 10:13:39 2005
@@ -19,6 +19,9 @@
package org.apache.lenya.cms.publication;
+/**
+ * Single Language Identity mapper
+ */
public class SingleLanguageIdentityMapper extends IdentityDocumentIdToPathMapper {
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/URLInformation.java Tue Feb 8 10:13:39 2005
@@ -34,7 +34,7 @@
* @return A string.
*/
public String getArea() {
- return area;
+ return this.area;
}
/**
@@ -42,7 +42,7 @@
* @return A string.
*/
public String getCompleteArea() {
- return completeArea;
+ return this.completeArea;
}
/**
@@ -50,7 +50,7 @@
* @return A string.
*/
public String getDocumentUrl() {
- return documentUrl;
+ return this.documentUrl;
}
/**
@@ -58,7 +58,7 @@
* @return A string.
*/
public String getPublicationId() {
- return publicationId;
+ return this.publicationId;
}
/**
@@ -76,21 +76,21 @@
if (fragments.length > 1) {
this.completeArea = fragments[1];
- if (url.length() > (this.publicationId + "/" + completeArea).length()) {
- this.documentUrl = url.substring((this.publicationId + "/" + completeArea).length());
+ if (url.length() > (this.publicationId + "/" + this.completeArea).length()) {
+ this.documentUrl = url.substring((this.publicationId + "/" + this.completeArea).length());
}
else {
this.documentUrl = "";
}
- if (completeArea.startsWith(Publication.INFO_AREA_PREFIX)) {
- this.area = completeArea.substring(Publication.INFO_AREA_PREFIX.length());
+ if (this.completeArea.startsWith(Publication.INFO_AREA_PREFIX)) {
+ this.area = this.completeArea.substring(Publication.INFO_AREA_PREFIX.length());
}
- else if (completeArea.startsWith(Publication.SEARCH_AREA_PREFIX)) {
- this.area = completeArea.substring(Publication.SEARCH_AREA_PREFIX.length());
+ else if (this.completeArea.startsWith(Publication.SEARCH_AREA_PREFIX)) {
+ this.area = this.completeArea.substring(Publication.SEARCH_AREA_PREFIX.length());
}
else {
- this.area = completeArea;
+ this.area = this.completeArea;
}
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/file/FilePublication.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/file/FilePublication.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/file/FilePublication.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/file/FilePublication.java Tue Feb 8 10:13:39 2005
@@ -45,8 +45,8 @@
/**
* Returns the directory where documents of a certain area are located.
- * @param area
- * @return
+ * @param area The area to return
+ * @return A file representing the area
*/
protected File getAreaDirectory(String area) {
File areaDirectory = new File(getDirectory(), "content" + File.separator + area);
@@ -81,7 +81,10 @@
}
/**
- * @see org.apache.lenya.cms.publication.Publication#copyDocumentSetToArea(org.apache.lenya.cms.publication.DocumentSet, java.lang.String)
+ * @param documentSet Set of documents to be copied
+ * @param destinationArea Destination area for the copy
+ * @throws PublicationException
+ * @see org.apache.lenya.cms.publication.Publication#copyDocumentSetToArea(org.apache.lenya.cms.publication.util.DocumentSet, java.lang.String)
*/
public void copyDocumentSetToArea(DocumentSet documentSet, String destinationArea)
throws PublicationException {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/task/CopyDocumentToArea.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/task/CopyDocumentToArea.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/task/CopyDocumentToArea.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/task/CopyDocumentToArea.java Tue Feb 8 10:13:39 2005
@@ -27,6 +27,9 @@
*/
public class CopyDocumentToArea extends DocumentTask {
+ /**
+ * <code>PARAMETER_DESTINATION_AREA</code> Destination area parameter
+ */
public static final String PARAMETER_DESTINATION_AREA = "destination-area";
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/task/DocumentTask.java Tue Feb 8 10:13:39 2005
@@ -28,8 +28,17 @@
*/
public abstract class DocumentTask extends PublicationTask {
+ /**
+ * <code>PARAMETER_DOCUMENT_ID</code> The document id parameter
+ */
public static final String PARAMETER_DOCUMENT_ID = "document-id";
+ /**
+ * <code>PARAMETER_DOCUMENT_AREA</code> The document area parameter
+ */
public static final String PARAMETER_DOCUMENT_AREA = "document-area";
+ /**
+ * <code>PARAMETER_DOCUMENT_LANGUAGE</code> The document language parameter
+ */
public static final String PARAMETER_DOCUMENT_LANGUAGE = "document-language";
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java Tue Feb 8 10:13:39 2005
@@ -43,15 +43,14 @@
import org.apache.lenya.workflow.Situation;
import org.apache.lenya.workflow.SynchronizedWorkflowInstances;
import org.apache.lenya.workflow.WorkflowException;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
/**
* Abstract super class for publication-based tasks.
*/
public abstract class PublicationTask extends AbstractTask {
- private static final Category log = Category.getInstance(PublicationTask.class);
-
+ private static final Logger log = Logger.getLogger(PublicationTask.class);
private DocumentIdentityMap map;
/**
@@ -120,10 +119,25 @@
}
}
+ /**
+ * <code>PARAMETER_WORKFLOW_EVENT</code> The workflow event parameter
+ */
public static final String PARAMETER_WORKFLOW_EVENT = "workflow-event";
+ /**
+ * <code>PARAMETER_USER_ID</code> The user id parameter
+ */
public static final String PARAMETER_USER_ID = "user-id";
+ /**
+ * <code>PARAMETER_IP_ADDRESS</code> The IP address parameter
+ */
public static final String PARAMETER_IP_ADDRESS = "ip-address";
+ /**
+ * <code>PARAMETER_ROLE_IDS</code> The role ids parameter
+ */
public static final String PARAMETER_ROLE_IDS = "role-ids";
+ /**
+ * <code>ROLE_SEPARATOR_REGEXP</code> The role separator regular expression
+ */
public static final String ROLE_SEPARATOR_REGEXP = ",";
/**
@@ -156,10 +170,14 @@
if (event == null) {
canFire = false;
}
-
- } catch (Exception e) {
+ } catch (final ParameterException e) {
+ throw new ExecutionException(e);
+ } catch (final ExecutionException e) {
+ throw new ExecutionException(e);
+ } catch (final WorkflowException e) {
throw new ExecutionException(e);
}
+
}
return canFire;
}
@@ -190,6 +208,7 @@
WorkflowFactory factory = WorkflowFactory.newInstance();
if (factory.hasWorkflow(document)) {
+
try {
String userId = getParameters().getParameter(PARAMETER_USER_ID);
String machineIp = getParameters().getParameter(PARAMETER_IP_ADDRESS);
@@ -213,9 +232,14 @@
if (log.isDebugEnabled()) {
log.debug("Invoking transition completed.");
}
- } catch (Exception e) {
+ } catch (final ParameterException e) {
+ throw new ExecutionException(e);
+ } catch (final ExecutionException e) {
+ throw new ExecutionException(e);
+ } catch (final WorkflowException e) {
throw new ExecutionException(e);
}
+
} else {
if (log.isDebugEnabled()) {
log.debug("No workflow associated with document.");
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingSourceResolver.java Tue Feb 8 10:13:39 2005
@@ -37,10 +37,10 @@
/**
* Returns the URI of the first existing source.
- * @return
+ * @return The URI
*/
public String getURI() {
- return uri;
+ return this.uri;
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingUsecaseResolver.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingUsecaseResolver.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingUsecaseResolver.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/ExistingUsecaseResolver.java Tue Feb 8 10:13:39 2005
@@ -34,10 +34,10 @@
/**
* Ctor.
- * @param usecase The name of the usecase to resolve.
+ * @param _usecase The name of the usecase to resolve.
*/
- public ExistingUsecaseResolver(String usecase) {
- this.usecase = usecase;
+ public ExistingUsecaseResolver(String _usecase) {
+ this.usecase = _usecase;
}
protected static final String ELEMENT_USECASES = "usecases";
@@ -47,10 +47,10 @@
/**
* @see org.apache.lenya.cms.publication.templating.PublicationVisitor#visit(org.apache.lenya.cms.publication.Publication)
*/
- public void visit(Publication publication) {
+ public void visit(Publication _publication) {
if (this.publication == null) {
- File configFile = new File(publication.getDirectory(), Publication.CONFIGURATION_FILE);
+ File configFile = new File(_publication.getDirectory(), Publication.CONFIGURATION_FILE);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
try {
@@ -61,7 +61,7 @@
for (int i = 0; i < usecaseConfigs.length; i++) {
String usecaseName = usecaseConfigs[i].getAttribute(ATTRIBUTE_NAME);
if (usecaseName.equals(this.usecase)) {
- this.publication = publication;
+ this.publication = _publication;
}
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/templating/PublicationTemplateManagerImpl.java Tue Feb 8 10:13:39 2005
@@ -52,6 +52,7 @@
* Ctor.
*/
public PublicationTemplateManagerImpl() {
+ // do nothing
}
private Publication[] templatePublications;
@@ -59,10 +60,10 @@
/**
* @see org.apache.lenya.cms.publication.templating.PublicationTemplateManager#setup(org.apache.lenya.cms.publication.Publication)
*/
- public void setup(Publication publication) throws ConfigurationException {
- this.publication = publication;
+ public void setup(Publication _publication) throws ConfigurationException {
+ this.publication = _publication;
- File configFile = new File(publication.getDirectory(), Publication.CONFIGURATION_FILE);
+ File configFile = new File(_publication.getDirectory(), Publication.CONFIGURATION_FILE);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
try {
@@ -74,7 +75,7 @@
for (int i = 0; i < templateConfigs.length; i++) {
String templateId = templateConfigs[i].getAttribute(ATTRIBUTE_ID);
PublicationFactory factory = PublicationFactory.getInstance(getLogger());
- Publication template = factory.getPublication(templateId, publication
+ Publication template = factory.getPublication(templateId, _publication
.getServletContext().getAbsolutePath());
templates.add(template);
}
@@ -101,7 +102,7 @@
SourceResolver resolver = null;
try {
- resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
String[] baseUris = getBaseURIs();
for (int i = 0; i < baseUris.length; i++) {
@@ -129,7 +130,7 @@
throw new TemplatingException("Visiting path [" + path + "] failed: ", e);
} finally {
if (resolver != null) {
- manager.release(resolver);
+ this.manager.release(resolver);
}
}
@@ -140,8 +141,8 @@
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
+ public void service(ServiceManager _manager) throws ServiceException {
+ this.manager = _manager;
}
/**
@@ -188,7 +189,7 @@
public void visit(PublicationVisitor visitor) {
SourceResolver resolver = null;
try {
- resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
Publication[] publications = getPublications();
for (int i = 0; i < publications.length; i++) {
@@ -202,7 +203,7 @@
throw new TemplatingException("Visiting publications failed: ", e);
} finally {
if (resolver != null) {
- manager.release(resolver);
+ this.manager.release(resolver);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java Tue Feb 8 10:13:39 2005
@@ -34,6 +34,7 @@
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.xpath.XPathAPI;
+import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -77,7 +78,7 @@
*/
protected List documents() throws DocumentException {
load();
- return documentsList;
+ return this.documentsList;
}
/**
@@ -123,7 +124,7 @@
* @throws DocumentException when something went wrong.
*/
protected void load() throws DocumentException {
- if (!isLoaded) {
+ if (!this.isLoaded) {
getLogger().debug("Loading: ", new DocumentException());
NamespaceHelper helper;
try {
@@ -136,14 +137,14 @@
for (int i = 0; i < documentElements.length; i++) {
Element documentElement = documentElements[i];
Document document = loadDocument(documentElement);
- documentsList.add(document);
+ this.documentsList.add(document);
}
} catch (DocumentException e) {
throw e;
} catch (Exception e) {
throw new DocumentException(e);
}
- isLoaded = true;
+ this.isLoaded = true;
}
}
@@ -209,9 +210,13 @@
*/
protected Element createDocumentElement(Document document, NamespaceHelper helper)
throws DocumentException {
- Element documentElement = helper.createElement(ELEMENT_DOCUMENT);
- documentElement.setAttributeNS(null, ATTRIBUTE_ID, document.getId());
- return documentElement;
+ try {
+ Element documentElement = helper.createElement(ELEMENT_DOCUMENT);
+ documentElement.setAttributeNS(null, ATTRIBUTE_ID, document.getId());
+ return documentElement;
+ } catch (final DOMException e) {
+ throw new DocumentException(e);
+ }
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentHelper.java Tue Feb 8 10:13:39 2005
@@ -32,6 +32,7 @@
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeException;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
@@ -50,14 +51,14 @@
/**
* Ctor.
*
- * @param objectModel The Cocoon object model.
+ * @param _objectModel The Cocoon object model.
*/
- public DocumentHelper(Map objectModel) {
- this.objectModel = objectModel;
+ public DocumentHelper(Map _objectModel) {
+ this.objectModel = _objectModel;
Publication publication;
try {
PublicationFactory factory = PublicationFactory.getInstance(new ConsoleLogger());
- publication = factory.getPublication(objectModel);
+ publication = factory.getPublication(_objectModel);
} catch (PublicationException e) {
throw new RuntimeException(e);
}
@@ -78,15 +79,16 @@
throws ProcessingException {
String url = null;
+
try {
PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(
- this.identityMap, objectModel);
+ this.identityMap, this.objectModel);
if (documentId == null) {
documentId = envelope.getDocument().getId();
}
- Request request = ObjectModelHelper.getRequest(objectModel);
+ Request request = ObjectModelHelper.getRequest(this.objectModel);
if (documentArea == null) {
String webappUrl = ServletHelper.getWebappURI(request);
@@ -109,8 +111,9 @@
}
url = contextPath + url;
-
- } catch (Exception e) {
+ } catch (final DocumentBuildException e) {
+ throw new ProcessingException(e);
+ } catch (final PageEnvelopeException e) {
throw new ProcessingException(e);
}
@@ -122,7 +125,6 @@
* Returns the complete URL of the parent document. If the document is a top-level document, the
* /index document is chosen. If the parent does not exist in the appropriate language, the
* default language is chosen.
- *
* @return A string.
* @throws ProcessingException when something went wrong.
*/
@@ -132,15 +134,17 @@
String contextPath;
try {
PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(
- this.identityMap, objectModel);
+ this.identityMap, this.objectModel);
Document document = envelope.getDocument();
- Request request = ObjectModelHelper.getRequest(objectModel);
+ Request request = ObjectModelHelper.getRequest(this.objectModel);
contextPath = request.getContextPath();
Document parent = this.identityMap.getFactory().getParent(document, "/index");
parentUrl = parent.getCanonicalWebappURL();
- } catch (Exception e) {
+ } catch (final DocumentBuildException e) {
+ throw new ProcessingException(e);
+ } catch (final PageEnvelopeException e) {
throw new ProcessingException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentLanguagesHelper.java Tue Feb 8 10:13:39 2005
@@ -55,46 +55,37 @@
/**
* Compute the URL for a given language and the parameters given in the contructor.
- *
* @param language the language
- *
* @return the url for the given language
- *
* @throws ProcessingException if the document for the given language could not be created.
*/
public String getUrl(String language) throws ProcessingException {
Document doc = getDocument(language);
- return pageEnvelope.getContext() + doc.getCanonicalWebappURL();
+ return this.pageEnvelope.getContext() + doc.getCanonicalWebappURL();
}
/**
* Compute the info area URL for a given language and the parameters given in the contructor.
- *
* @param language the language
- *
* @return the url for the given language
- *
* @throws ProcessingException if the document for the given language could not be created.
*/
public String getInfoUrl(String language) throws ProcessingException {
Document doc = getDocument(language);
- return pageEnvelope.getContext() + doc.getCompleteInfoURL();
+ return this.pageEnvelope.getContext() + doc.getCompleteInfoURL();
}
/**
* Create a document for a given language and the parameters given in the contructor.
- *
* @param language the language
- *
* @return the document with the given language
- *
* @throws ProcessingException if the document for the given language could not be created.
*/
protected Document getDocument(String language) throws ProcessingException {
Document document;
try {
document = this.identityMap.getFactory().getLanguageVersion(
- pageEnvelope.getDocument(), language);
+ this.pageEnvelope.getDocument(), language);
} catch (DocumentBuildException e) {
throw new ProcessingException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/DocumentReferencesHelper.java Tue Feb 8 10:13:39 2005
@@ -29,6 +29,7 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentDoesNotExistException;
+import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentIdToPathMapper;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.PageEnvelope;
@@ -37,14 +38,14 @@
import org.apache.lenya.cms.publication.PathToDocumentIdMapper;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.search.Grep;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
/**
* Helper class for finding references to the current document.
*/
public class DocumentReferencesHelper {
- private static final Category log = Category.getInstance(DocumentReferencesHelper.class);
+ private static final Logger log = Logger.getLogger(DocumentReferencesHelper.class);
private PageEnvelope pageEnvelope = null;
private DocumentIdentityMap identityMap;
@@ -74,9 +75,9 @@
* @return the search string
*/
protected String getReferencesSearchString() {
- return "href\\s*=\\s*\"" + pageEnvelope.getContext() + "/"
- + pageEnvelope.getPublication().getId() + "/"
- + pageEnvelope.getDocument().getArea() + pageEnvelope.getDocument().getId();
+ return "href\\s*=\\s*\"" + this.pageEnvelope.getContext() + "/"
+ + this.pageEnvelope.getPublication().getId() + "/"
+ + this.pageEnvelope.getDocument().getArea() + this.pageEnvelope.getDocument().getId();
}
/**
@@ -103,9 +104,9 @@
// looks different.
return Pattern
- .compile("href\\s*=\\s*\"" + pageEnvelope.getContext() + "/"
- + pageEnvelope.getPublication().getId() + "/"
- + pageEnvelope.getDocument().getArea()
+ .compile("href\\s*=\\s*\"" + this.pageEnvelope.getContext() + "/"
+ + this.pageEnvelope.getPublication().getId() + "/"
+ + this.pageEnvelope.getDocument().getArea()
+ "(/[-a-zA-Z0-9_/]+?)(_[a-z][a-z])?\\.html");
}
@@ -121,7 +122,7 @@
public Document[] getReferences(String area) throws ProcessingException {
ArrayList documents = new ArrayList();
- Publication publication = pageEnvelope.getPublication();
+ Publication publication = this.pageEnvelope.getPublication();
DocumentIdToPathMapper mapper = publication.getPathMapper();
if (mapper instanceof PathToDocumentIdMapper) {
PathToDocumentIdMapper fileMapper = (PathToDocumentIdMapper) mapper;
@@ -136,8 +137,8 @@
// constructed in a way such that it will catch all files which
// have a link to any language version of the current document.
// That's why we need to do some additional tests for each hit.
- String languageOfCurrentDocument = pageEnvelope.getDocument().getLanguage();
- String defaultLanguage = pageEnvelope.getPublication().getDefaultLanguage();
+ String languageOfCurrentDocument = this.pageEnvelope.getDocument().getLanguage();
+ String defaultLanguage = this.pageEnvelope.getPublication().getDefaultLanguage();
Pattern referencesSearchStringWithLanguage = Pattern
.compile(getReferencesSearchString() + "_" + languageOfCurrentDocument);
Pattern referencesSearchStringWithOutLanguage = Pattern
@@ -178,7 +179,7 @@
}
log.debug("language: " + language);
- documents.add(identityMap.getFactory().get(area, documentId, language));
+ documents.add(this.identityMap.getFactory().get(area, documentId, language));
}
} catch (IOException e) {
throw new ProcessingException(e);
@@ -203,12 +204,12 @@
public Document[] getInternalReferences() throws ProcessingException {
ArrayList unpublishedReferences = new ArrayList();
Pattern internalLinkPattern = getInternalLinkPattern();
- Publication publication = pageEnvelope.getPublication();
+ Publication publication = this.pageEnvelope.getPublication();
try {
- String[] internalLinks = Grep.findPattern(pageEnvelope.getDocument().getFile(),
+ String[] internalLinks = Grep.findPattern(this.pageEnvelope.getDocument().getFile(),
internalLinkPattern, 1);
String[] internalLinksLanguages = Grep.findPattern(
- pageEnvelope.getDocument().getFile(), internalLinkPattern, 2);
+ this.pageEnvelope.getDocument().getFile(), internalLinkPattern, 2);
for (int i = 0; i < internalLinks.length; i++) {
String docId = internalLinks[i];
@@ -225,7 +226,7 @@
}
log.debug("language: " + language);
- Document liveDocument = identityMap.getFactory().get(Publication.LIVE_AREA, docId,
+ Document liveDocument = this.identityMap.getFactory().get(Publication.LIVE_AREA, docId,
language);
if (!liveDocument.exists()) {
// the docId has not been published for the given language
@@ -233,14 +234,19 @@
if (liveLanguage == null) {
liveLanguage = publication.getDefaultLanguage();
}
- unpublishedReferences.add(identityMap.getFactory().getLanguageVersion(
+ unpublishedReferences.add(this.identityMap.getFactory().getLanguageVersion(
liveDocument, liveLanguage));
}
}
- } catch (Exception e) {
+ } catch (final DocumentBuildException e) {
+ throw new ProcessingException(e);
+ } catch (final DocumentException e) {
+ throw new ProcessingException(e);
+ } catch (final IOException e) {
throw new ProcessingException(e);
}
+
return (Document[]) unpublishedReferences
- .toArray(new Document[unpublishedReferences.size()]);
+ .toArray(new Document[unpublishedReferences.size()]);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org