You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/05/13 10:35:35 UTC

svn commit: r169992 - /lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java /lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java

Author: andreas
Date: Fri May 13 01:35:34 2005
New Revision: 169992

URL: http://svn.apache.org/viewcvs?rev=169992&view=rev
Log:
changed Document.getResourceType() to return an object instead of a string

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?rev=169992&r1=169991&r2=169992&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Fri May 13 01:35:34 2005
@@ -80,12 +80,12 @@
      * @param _logger a logger
      */
     protected DefaultDocument(ServiceManager manager, DocumentIdentityMap map,
-            Publication publication, String _id, String _area, String _language,
-            Logger _logger) {
+            Publication publication, String _id, String _area, String _language, Logger _logger) {
 
         ContainerUtil.enableLogging(this, _logger);
         if (getLogger().isDebugEnabled())
-            getLogger().debug("DefaultDocument() creating new instance with _id [" + _id + "], _language [" + _language + "]");
+            getLogger().debug("DefaultDocument() creating new instance with _id [" + _id
+                    + "], _language [" + _language + "]");
 
         this.manager = manager;
         if (_id == null) {
@@ -102,7 +102,8 @@
         setArea(_area);
 
         if (getLogger().isDebugEnabled())
-            getLogger().debug("DefaultDocument() done building instance with _id [" + _id + "], _language [" + _language + "]");
+            getLogger().debug("DefaultDocument() done building instance with _id [" + _id
+                    + "], _language [" + _language + "]");
 
     }
 
@@ -396,7 +397,6 @@
         return metaDataManager;
     }
 
-
     private History history;
 
     /**
@@ -407,8 +407,8 @@
             try {
                 final String path = getPublication().getPathMapper()
                         .getPath(getId(), getLanguage());
-                final String uri = getPublication().getSourceURI()
-                        + "/content/workflow/history/" + path;
+                final String uri = getPublication().getSourceURI() + "/content/workflow/history/"
+                        + path;
                 this.history = new CMSHistory(uri, this.manager);
             } catch (WorkflowException e) {
                 throw new RuntimeException(e);
@@ -519,13 +519,29 @@
         return nodes;
     }
 
+    private DocumentType resourceType;
+
     /**
-     * Convenience method to read the document's resource type from
-     * the meta-data.
+     * Convenience method to read the document's resource type from the meta-data.
      * @see Document#getResourceType()
      */
-    public String getResourceType() throws DocumentException {
-        return getMetaDataManager().getLenyaMetaData().getFirstValue(LenyaMetaData.ELEMENT_RESOURCE_TYPE);
+    public DocumentType getResourceType() throws DocumentException {
+        if (this.resourceType == null) {
+            String name = getMetaDataManager().getLenyaMetaData()
+                    .getFirstValue(LenyaMetaData.ELEMENT_RESOURCE_TYPE);
+            DocumentTypeBuilder builder = null;
+            try {
+                builder = (DocumentTypeBuilder) this.manager.lookup(DocumentTypeBuilder.ROLE);
+                this.resourceType = builder.buildDocumentType(name, getPublication());
+            } catch (Exception e) {
+                throw new DocumentException(e);
+            } finally {
+                if (builder != null) {
+                    this.manager.release(builder);
+                }
+            }
+        }
+        return this.resourceType;
     }
 
-}
+}
\ No newline at end of file

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?rev=169992&r1=169991&r2=169992&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java Fri May 13 01:35:34 2005
@@ -198,5 +198,5 @@
      * @return The resource type of this document (formerly known as doctype)
      * @throws DocumentException if an error occurs.
      */
-    String getResourceType() throws DocumentException;
+    DocumentType getResourceType() throws DocumentException;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org