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 2004/12/29 18:35:05 UTC

svn commit: r123658 - /lenya/trunk/src/java/org/apache/lenya/cms/site/Overview.java /lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java /lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl /lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx

Author: gregor
Date: Wed Dec 29 09:35:03 2004
New Revision: 123658

URL: http://svn.apache.org/viewcvs?view=rev&rev=123658
Log:
Added tab.overview usecase, extended SiteUsecase to provide more values
Added:
   lenya/trunk/src/java/org/apache/lenya/cms/site/Overview.java   (contents, props changed)
Modified:
   lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java
   lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
   lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx

Added: lenya/trunk/src/java/org/apache/lenya/cms/site/Overview.java
Url: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/Overview.java?view=auto&rev=123658
==============================================================================
--- (empty file)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/Overview.java	Wed Dec 29 09:35:03 2004
@@ -0,0 +1,89 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site;
+
+import java.util.Map;
+import org.apache.cocoon.servlet.multipart.Part;
+
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.metadata.dublincore.DublinCore;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.site.SiteUsecase;
+import org.apache.lenya.cms.usecase.UsecaseException;
+
+/**
+ * Usecase to display the overview tab in the site area for a document.
+ * 
+ * @version $Id$
+ */
+public class Overview extends SiteUsecase {
+	private DublinCore dc;
+
+	/**
+     * Ctor.
+     */
+    public Overview() {
+        super();
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doInitialize()
+     */
+    protected void doInitialize() throws Exception {
+        super.doInitialize();
+        dc = getSourceDocument().getDublinCore();
+        try {
+	        setParameter("languages", getSourceDocument().getLanguages());
+	        setParameter("title", dc.getFirstValue("title"));
+	        setParameter("description", dc.getFirstValue("description"));
+	        setParameter("lastmodified", "");
+	        setParameter("resourcetype", "");
+	        setParameter("live", "");
+        } catch (Exception e) {
+        	addErrorMessage("Could not read a value.");
+        	getLogger().error("Could not read value for Overview usecase. " + e.toString());
+        }
+    }
+            
+     /**
+     * Validates the request parameters.
+     * @throws UsecaseException if an error occurs.
+     */
+    void validate() throws UsecaseException {
+   }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
+     */
+    protected void doCheckExecutionConditions() throws Exception {
+        validate();
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+     */
+    protected void doExecute() throws Exception {
+        super.doExecute();
+    }
+
+    /**
+     * @see org.apache.lenya.cms.usecase.Usecase#setParameter(java.lang.String, java.lang.Object)
+     */
+    public void setParameter(String name, Object value) {
+        super.setParameter(name, value);
+    }
+}
\ No newline at end of file

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java
Url: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java?view=diff&rev=123658&p1=lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java&r1=123657&p2=lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java&r2=123658
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java	(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteUsecase.java	Wed Dec 29 09:35:03 2004
@@ -16,9 +16,13 @@
  */
 package org.apache.lenya.cms.site;
 
+import java.util.Arrays;
+
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.usecase.DocumentUsecase;
+import org.apache.lenya.cms.workflow.WorkflowFactory;
+import org.apache.lenya.workflow.WorkflowInstance;
 
 /**
  * Super class for site related usecases.
@@ -27,9 +31,13 @@
  */
 public class SiteUsecase extends DocumentUsecase {
 
+    protected Document doc = null;
+    protected WorkflowInstance instance = null;
     protected static final String AREA = "area";
     protected static final String DOCUMENTID = "documentid";
     protected static final String LANGUAGEEXISTS = "languageexists";
+    protected static final String STATE = "state";
+    protected static final String ISLIVE = "is_live";
 
     /**
      * Ctor.
@@ -40,35 +48,37 @@
     
     /**
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#doInitialize()
-     */
+    /*TODO make common parameters available to site usecases: area, documentid, languageexists etc
+     * may need to take special areas into acccount, such as info-authoring */
     protected void doInitialize() throws Exception {
         super.doInitialize();
         doc = getSourceDocument();
+        try {
+            WorkflowFactory factory = WorkflowFactory.newInstance();
+            if (factory.hasWorkflow(getSourceDocument())) {
+                instance = factory.buildInstance(getSourceDocument());
+                setParameter(STATE, instance.getCurrentState().toString());
+                String[] variableNames = instance.getWorkflow().getVariableNames();
+                if (Arrays.asList(variableNames).contains(ISLIVE)) {
+                    setParameter("islive", Boolean.valueOf(instance.getValue(ISLIVE)));
+                }
+            } else {
+                setParameter("state", "");
+            }
+        } catch (Exception e) {
+        	getLogger().error("Could not get workflow state.");
+        	addErrorMessage("Could not get workflow state.");
+        }
+        setParameter(AREA, this.doc.getArea());
+        setParameter(DOCUMENTID, this.doc.getId());
+        setParameter(LANGUAGEEXISTS, "true");
     }
-       
-    private Document doc;
 
     /**
-     * Returns the currently edited document.
-     * @return A document.
-     */
-    protected Document getDocument() {
-        return this.doc;
-    }
-    
-    /**
      * @see org.apache.lenya.cms.usecase.Usecase#setParameter(java.lang.String, java.lang.Object)
      */
-    /*TODO make common parameters available to site usecases: area, documentid, languageexists etc */
     public void setParameter(String name, Object value) {
         super.setParameter(name, value);
-        
-        if (true) {
-            
-            setParameter(AREA, this.doc.getArea());
-            setParameter(DOCUMENTID, this.doc.getId());
-            setParameter(LANGUAGEEXISTS, "");
-        }
     }
 
     

Modified: lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
Url: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl?view=diff&rev=123658&p1=lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl&r1=123657&p2=lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl&r2=123658
==============================================================================
--- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl	(original)
+++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl	Wed Dec 29 09:35:03 2004
@@ -243,8 +243,9 @@
     <component-instance name="admin.changePassword" logger="lenya.admin" class="org.apache.lenya.cms.admin.UserPassword"/>
     <component-instance name="admin.userGroups" logger="lenya.admin" class="org.apache.lenya.cms.admin.UserGroups"/>
     <component-instance name="authoring.create" logger="lenya.authoring" class="org.apache.lenya.cms.authoring.Create"/>
-    <component-instance name="tab.meta" logger="lenya.site" class="org.apache.lenya.cms.metadata.Metadata"/>
     <component-instance name="tab.assets" logger="lenya.site" class="org.apache.lenya.cms.site.Assets"/>
+    <component-instance name="tab.meta" logger="lenya.site" class="org.apache.lenya.cms.metadata.Metadata"/>
+    <component-instance name="tab.overview" logger="lenya.site" class="org.apache.lenya.cms.site.Overview"/>
   </usecases>
       
 

Modified: lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx
Url: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx?view=diff&rev=123658&p1=lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx&r1=123657&p2=lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx&r2=123658
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx	(original)
+++ lenya/trunk/src/webapp/lenya/usecases/tab/overview.jx	Wed Dec 29 09:35:03 2004
@@ -99,6 +99,22 @@
             <tr>
               <td colspan="2">
                 <ul>
+                <jx:forEach var="message" items="${usecase.getErrorMessages()}">
+                  <li>
+                    <i18n:text><jx:out value="${message}"/></i18n:text>
+                  </li>
+                </jx:forEach>
+                <jx:forEach var="message" items="${usecase.getInfoMessages()}">
+                  <li>
+                    <i18n:text><jx:out value="${message}"/></i18n:text>
+                  </li>
+                </jx:forEach>
+                </ul>
+              </td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <ul>
                   <jx:forEach var="message" items="${usecase.getErrorMessages()}">
                     <li>
                       <i18n:text>
@@ -132,7 +148,7 @@
               <td class="lenya-entry-caption"><i18n:text>Workflow State</i18n:text>:</td>
               <td>
                 <jx:choose>
-                  <jx:when test="${not(empty(usecase.getParameter('state')))}"><jx:out select="${usecase.getParameter('state')}"/></jx:when>
+                  <jx:when test="${not(empty(usecase.getParameter('state')))}"><jx:out value="${usecase.getParameter('state')}"/></jx:when>
                   <jx:otherwise><span style="color: #999999;"><i18n:text>[no workflow]</i18n:text></span></jx:otherwise>
                 </jx:choose>
               </td>
@@ -140,7 +156,7 @@
             <tr>
               <td class="lenya-entry-caption"><i18n:text>Live</i18n:text>:</td>
               <td>
-                <jx:out value="${usecase.getParameter('live')}"/>
+                <jx:out value="${usecase.getParameter('islive')}"/>
               </td>
             </tr>
             <tr>

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