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/07/12 15:47:41 UTC
svn commit: r215950 - in /lenya/trunk/src/webapp/lenya/pubs/blog: config/
config/menus/ config/workflow/ java/src/org/apache/lenya/cms/workflow/
java/src/org/apache/lenya/cms/workflow/usecases/ lenya/usecases/workflow/
lenya/xslt/publishing/
Author: andreas
Date: Tue Jul 12 06:47:38 2005
New Revision: 215950
URL: http://svn.apache.org/viewcvs?rev=215950&view=rev
Log:
Blog pub: Implemented publishing using the usecase framework
Added:
lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/workflow/
lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/workflow/usecases/
lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java
lenya/trunk/src/webapp/lenya/pubs/blog/lenya/usecases/workflow/
lenya/trunk/src/webapp/lenya/pubs/blog/lenya/usecases/workflow/publish.jx
Removed:
lenya/trunk/src/webapp/lenya/pubs/blog/lenya/xslt/publishing/
Modified:
lenya/trunk/src/webapp/lenya/pubs/blog/config/menus/entry.xsp
lenya/trunk/src/webapp/lenya/pubs/blog/config/usecases.xconf
lenya/trunk/src/webapp/lenya/pubs/blog/config/workflow/workflow.xml
Modified: lenya/trunk/src/webapp/lenya/pubs/blog/config/menus/entry.xsp
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/config/menus/entry.xsp?rev=215950&r1=215949&r2=215950&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/config/menus/entry.xsp (original)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/config/menus/entry.xsp Tue Jul 12 06:47:38 2005
@@ -44,9 +44,9 @@
<menus>
<menu i18n:attr="name" name="File">
<block>
- <item wf:event="edit" uc:usecase="edit.forms" href="?&form=entry">Edit with Forms</item>
- <item wf:event="edit" href="index-bxe.html">Edit with BXE</item>
- <item wf:event="edit" uc:usecase="1formedit" uc:step="open">Edit with one Form</item>
+ <item uc:usecase="edit.forms" href="?&form=entry">Edit with Forms</item>
+ <item href="index-bxe.html">Edit with BXE</item>
+ <item uc:usecase="edit.oneform" href="?">Edit with one Form</item>
</block>
<block>
<item uc:usecase="workflow.publish" href="?"><i18n:text>Publish</i18n:text></item>
Modified: lenya/trunk/src/webapp/lenya/pubs/blog/config/usecases.xconf
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/config/usecases.xconf?rev=215950&r1=215949&r2=215950&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/config/usecases.xconf (original)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/config/usecases.xconf Tue Jul 12 06:47:38 2005
@@ -18,9 +18,14 @@
<!-- $Id$ -->
<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'blog/site.create']">
- <component-instance name="blog/site.create"
- logger="lenya.site"
- class="org.apache.lenya.cms.site.usecases.CreateBlogEntry">
- <view template="site/create"/>
- </component-instance>
+ <component-instance name="blog/site.create"
+ logger="lenya.site"
+ class="org.apache.lenya.cms.site.usecases.CreateBlogEntry">
+ <view template="site/create"/>
+ </component-instance>
+ <component-instance name="blog/workflow.publish"
+ logger="lenya.workflow"
+ class="org.apache.lenya.cms.workflow.usecases.Publish">
+ <view template="workflow/publish"/>
+ </component-instance>
</xconf>
Modified: lenya/trunk/src/webapp/lenya/pubs/blog/config/workflow/workflow.xml
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/config/workflow/workflow.xml?rev=215950&r1=215949&r2=215950&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/config/workflow/workflow.xml (original)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/config/workflow/workflow.xml Tue Jul 12 06:47:38 2005
@@ -34,68 +34,20 @@
<!-- edit: authoring -> authoring -->
<transition source="authoring" destination="authoring">
<event id="edit"/>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit, review, organize</condition>
+ <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit</condition>
</transition>
<!-- publish: authoring -> live -->
<transition source="authoring" destination="live">
<event id="publish"/>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">review, organize</condition>
+ <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit</condition>
<assign variable="is_live" value="true"/>
</transition>
- <!-- deactivate: authoring -> authoring -->
- <transition source="authoring" destination="authoring">
- <event id="deactivate"/>
- <condition class="org.apache.lenya.workflow.impl.BooleanVariableCondition">is_live = true</condition>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">review, organize</condition>
- <assign variable="is_live" value="false"/>
- </transition>
-
- <!-- delete: authoring -> trash -->
- <transition source="authoring" destination="trash" synchronized="true">
- <event id="delete"/>
- <condition class="org.apache.lenya.workflow.impl.BooleanVariableCondition">is_live = false</condition>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit, review, organize</condition>
- </transition>
-
- <!-- archive: authoring -> archive -->
- <transition source="authoring" destination="archive" synchronized="true">
- <event id="archive"/>
- <condition class="org.apache.lenya.workflow.impl.BooleanVariableCondition">is_live = false</condition>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit, review, organize</condition>
- </transition>
-
- <!-- LIVE -->
-
<!-- edit: live -> authoring -->
<transition source="live" destination="authoring">
<event id="edit"/>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit, review, organize</condition>
- </transition>
-
- <!-- deactivate: live -> authoring -->
- <transition source="live" destination="authoring">
- <event id="deactivate"/>
- <condition class="org.apache.lenya.workflow.impl.BooleanVariableCondition">is_live = true</condition>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">review, organize</condition>
- <assign variable="is_live" value="false"/>
- </transition>
-
- <!-- TRASH -->
-
- <!-- restore: trash -> authoring -->
- <transition source="trash" destination="authoring" synchronized="true">
- <event id="restore"/>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit, review, organize</condition>
+ <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit</condition>
</transition>
-
- <!-- ARCHIVE -->
- <!-- restore: archive -> authoring -->
- <transition source="archive" destination="authoring" synchronized="true">
- <event id="restore"/>
- <condition class="org.apache.lenya.cms.workflow.RoleCondition">edit, review, organize</condition>
- </transition>
-
</workflow>
Added: lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java?rev=215950&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java (added)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/workflow/usecases/Publish.java Tue Jul 12 06:47:38 2005
@@ -0,0 +1,125 @@
+/*
+ * Copyright 1999-2005 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.workflow.usecases;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentManager;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.util.DocumentSet;
+import org.apache.lenya.cms.site.SiteUtil;
+import org.apache.lenya.cms.usecase.DocumentUsecase;
+import org.apache.lenya.cms.usecase.UsecaseException;
+import org.apache.lenya.cms.workflow.WorkflowUtil;
+import org.apache.lenya.transaction.Transactionable;
+
+/**
+ * Publish usecase handler.
+ *
+ * @version $Id: Publish.java 209612 2005-07-07 16:52:44Z chestnut $
+ */
+public class Publish extends DocumentUsecase {
+
+ protected static final String MISSING_DOCUMENTS = "missingDocuments";
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#getObjectsToLock()
+ */
+ protected Transactionable[] getObjectsToLock() throws UsecaseException {
+ try {
+ List nodes = new ArrayList();
+ DocumentSet set = new DocumentSet();
+
+ Document doc = getSourceDocument();
+ set.addAll(SiteUtil.getSubSite(this.manager, doc));
+
+ Document liveDoc = doc.getIdentityMap().getAreaVersion(doc, Publication.LIVE_AREA);
+ if(liveDoc.exists())
+ set.addAll(SiteUtil.getSubSite(this.manager, liveDoc));
+ else
+ set.add(liveDoc);
+
+
+ Document[] documents = set.getDocuments();
+ for (int i = 0; i < documents.length; i++) {
+ nodes.addAll(Arrays.asList(documents[i].getRepositoryNodes()));
+ }
+
+ nodes.add(SiteUtil.getSiteStructure(this.manager, liveDoc).getRepositoryNode());
+ return (Transactionable[]) nodes.toArray(new Transactionable[nodes.size()]);
+
+ } catch (Exception e) {
+ throw new UsecaseException(e);
+ }
+ }
+
+ /**
+ * Checks if the workflow event is supported and the parent of the document exists in the live
+ * area.
+ *
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
+ */
+ protected void doCheckPreconditions() throws Exception {
+ super.doCheckPreconditions();
+ if (!hasErrors()) {
+
+ String event = getEvent();
+ Document document = getSourceDocument();
+
+ if (!document.getArea().equals(Publication.AUTHORING_AREA)) {
+ addErrorMessage("This usecase can only be invoked from the authoring area.");
+ return;
+ }
+
+ if (!WorkflowUtil.canInvoke(this.manager, getLogger(), getSourceDocument(), event)) {
+ addErrorMessage("error-workflow-document", new String[] { getEvent(),
+ getSourceDocument().getId() });
+ }
+
+ }
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+ */
+ protected void doExecute() throws Exception {
+ DocumentManager documentManager = null;
+ try {
+ Document authoringDocument = getSourceDocument();
+ documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+ documentManager.copyToArea(authoringDocument, Publication.LIVE_AREA);
+ WorkflowUtil.invoke(this.manager, getLogger(), authoringDocument, getEvent());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (documentManager != null) {
+ this.manager.release(documentManager);
+ }
+ }
+ }
+
+ /**
+ * @return The event to invoke.
+ */
+ private String getEvent() {
+ return "publish";
+ }
+
+}
\ No newline at end of file
Added: lenya/trunk/src/webapp/lenya/pubs/blog/lenya/usecases/workflow/publish.jx
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/lenya/usecases/workflow/publish.jx?rev=215950&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/lenya/usecases/workflow/publish.jx (added)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/lenya/usecases/workflow/publish.jx Tue Jul 12 06:47:38 2005
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2005 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.
+-->
+
+<!-- $Id: publish.jx 164785 2005-04-26 13:19:24Z jwkaltz $ -->
+
+<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+ xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
+
+ <page:title><i18n:text>Publish</i18n:text></page:title>
+ <page:body>
+ <div class="lenya-box">
+ <div class="lenya-box-title">
+ <i18n:text>Publish</i18n:text>
+ </div>
+ <div class="lenya-box-body">
+ <form>
+ <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+ <input type="hidden" name="lenya.usecase" value="${request.getParameter('lenya.usecase')}"/>
+ <table class="lenya-table-noborder">
+ <tr>
+ <td class="lenya-entry-caption" valign="top"><i18n:text>Document</i18n:text>:</td>
+ <td valign="top">
+ <jx:out value="${usecase.getParameter('document').getId()}"/>
+ </td>
+ </tr>
+ <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/>
+ <td>
+ <input i18n:attr="value" type="submit" name="submit" value="Publish"/>
+  
+ <input i18n:attr="value" type="submit" name="cancel" value="Cancel"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </div>
+ </page:body>
+</page:page>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org