You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ed...@apache.org on 2005/02/09 18:27:26 UTC
svn commit: r153091 - in
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default:
java/src/org/apache/lenya/defaultpub/cms/task/Publish.java
lenya/resources/i18n/cmsui.xml lenya/resources/i18n/cmsui_de.xml
lenya/resources/i18n/cmsui_fr.xml resources/shared/css/page.css
xslt/page2xhtml.xsl
Author: edith
Date: Wed Feb 9 09:27:19 2005
New Revision: 153091
URL: http://svn.apache.org/viewcvs?view=rev&rev=153091
Log:
set the date of publication, the publisher and the date of modification when a document is published
Modified:
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/task/Publish.java
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui.xml
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_de.xml
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_fr.xml
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/resources/shared/css/page.css
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/xslt/page2xhtml.xsl
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/task/Publish.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/task/Publish.java?view=diff&r1=153090&r2=153091
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/task/Publish.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/task/Publish.java Wed Feb 9 09:27:19 2005
@@ -15,23 +15,23 @@
*
*/
-/* $Id: Publish.java,v 1.2 2004/03/20 11:46:20 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.defaultpub.cms.task;
import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.cocoon.ProcessingException;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentHelper;
+import org.apache.lenya.cms.publication.DublinCore;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
import org.apache.lenya.cms.publication.SiteTreeNode;
import org.apache.lenya.cms.publication.task.PublicationTask;
import org.apache.lenya.cms.task.ExecutionException;
@@ -47,7 +47,11 @@
public static final String PARAMETER_DOCUMENT_ID = "document-id";
public static final String PARAMETER_DOCUMENT_LANGUAGE = "document-language";
+ public static final String PARAMETER_USER_NAME = "user-name";
+ public static final String PARAMETER_USER_EMAIL = "user-email";
+ private static final String format = "yyyy-MM-dd HH:mm:ss";
+
/**
* @see org.apache.lenya.cms.task.Task#execute(java.lang.String)
*/
@@ -66,7 +70,16 @@
if (log.isDebugEnabled()) {
log.debug("Can execute task: parent is published.");
}
+ String date = new SimpleDateFormat(format).format(new Date());
+ reservedCheckOut(authoringDocument);
+ setPublicationDate(authoringDocument, date);
+ setModificationDate(authoringDocument, date);
+ setPublisher(authoringDocument);
+ authoringDocument.getDublinCore().save();
+ reservedCheckIn(authoringDocument, true);
+
publish(authoringDocument);
+
setResult(SUCCESS);
}
@@ -79,20 +92,53 @@
}
/**
+ * set the publisher (the user-id, the user-name and the user-email seperate with a |)
+ * @param document The document.
+ * @throws PublicationException When something went wrong.
+ * @throws ParameterException When something went wrong.
+ */
+ public void setPublisher(Document document) throws PublicationException, ParameterException {
+ String userId = getParameters().getParameter(PARAMETER_USER_ID);
+ String userName = getParameters().getParameter(PARAMETER_USER_NAME);
+ String userEmail = getParameters().getParameter(PARAMETER_USER_EMAIL);
+ String publisher = document.getDublinCore().getFirstValue(DublinCore.ELEMENT_PUBLISHER);
+ document.getDublinCore().setValue(DublinCore.ELEMENT_PUBLISHER, userId + "|" + userName + "|" + userEmail);
+ }
+
+ /**set the date of the publication, the date of the last change
+ * @param document The document.
+ * @param date The date in the format yyyy-MM-dd HH:mm:ss.
+ * @throws PublicationException When something went wrong
+ */
+ public void setModificationDate(Document document,String date) throws PublicationException {
+ String lastModDate = document.getDublinCore().getFirstValue(DublinCore.TERM_MODIFIED);
+ document.getDublinCore().setValue(DublinCore.TERM_MODIFIED, date);
+ }
+
+ /** set the date of the first publication
+ * @param document The document.
+ * @param date The date in the format yyyy-MM-dd HH:mm:ss.
+ * @throws PublicationException When something went wrong
+ */
+ public void setPublicationDate(Document document,String date) throws PublicationException {
+ String publicationDate = document.getDublinCore().getFirstValue(DublinCore.TERM_ISSUED);
+ if (publicationDate != null && !publicationDate.equals("")){
+ return;
+ }
+ document.getDublinCore().setValue(DublinCore.TERM_ISSUED, date);
+ }
+
+ /**
* Checks if the preconditions are complied.
* @param document The document to publish.
* @return
- * @throws PublicationException
* @throws ExecutionException
- * @throws DocumentException
+ * @throws Exception
+ * @throws IOException
*/
protected boolean checkPreconditions(Document document)
throws
- PublicationException,
- DocumentException,
- ProcessingException,
- SiteTreeException,
- ExecutionException {
+ ExecutionException, IOException, Exception {
boolean OK = true;
if (!canWorkflowFire(document)) {
@@ -111,6 +157,11 @@
}
}
+ if (!canCheckOut(document)){
+ log.error("Cannot execute task: the document is checked out by another user.");
+ OK = false;
+ }
+
return OK;
}
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui.xml?view=diff&r1=153090&r2=153091
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui.xml (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui.xml Wed Feb 9 09:27:19 2005
@@ -17,7 +17,7 @@
limitations under the License.
- $Id: cmsui.xml,v 1.2 2004/03/13 12:24:30 roku Exp $
+ $Id$
-->
@@ -29,4 +29,5 @@
<message key="New language for existing Document">New language for existing Document</message>
<message key="default.createdoc.info.all-language-versions-exists">There are already versions of this document for all languages.</message>
+ <message key="last_published">Last Published</message>
</catalogue>
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_de.xml?view=diff&r1=153090&r2=153091
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_de.xml (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_de.xml Wed Feb 9 09:27:19 2005
@@ -17,7 +17,7 @@
limitations under the License.
- $Id: cmsui_de.xml,v 1.3 2004/04/17 07:22:45 roku Exp $
+ $Id$
-->
@@ -29,5 +29,6 @@
<message key="New language for existing Document">Neue Sprachversion für existierendes Dokument anlegen</message>
<message key="default.createdoc.info.all-language-versions-exists">Das Dokument existiert bereits in allen notwendigen Sprachen.</message>
+ <message key="last_published">Letzte Aktualisierung</message>
</catalogue>
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_fr.xml
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_fr.xml?view=diff&r1=153090&r2=153091
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_fr.xml (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/resources/i18n/cmsui_fr.xml Wed Feb 9 09:27:19 2005
@@ -17,7 +17,7 @@
limitations under the License.
- $Id: cmsui_fr.xml,v 1.5 2004/04/17 07:22:46 roku Exp $
+ $Id$
@translators Olivier Lange <wire at petit-atelier dot ch>
@@ -29,5 +29,6 @@
<message key="Create new language version">Créer une nouvelle traduction</message>
<message key="New language for existing Document">Nouvelle traduction d'un document existant</message>
<message key="default.createdoc.info.all-language-versions-exists">Les traductions de ce document existent déjà dans toutes les langues.</message>
+ <message key="last_published">Mise à jour</message>
</catalogue>
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/resources/shared/css/page.css
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/resources/shared/css/page.css?view=diff&r1=153090&r2=153091
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/resources/shared/css/page.css (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/resources/shared/css/page.css Wed Feb 9 09:27:19 2005
@@ -264,3 +264,10 @@
font-size: 10px;
margin: 10px 10px 10px 5px;
}
+
+#footer {
+ padding: 5px;
+ font-size: 60%;
+ text-align: right;
+ border-top: solid 1px #BB9999;
+}
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/xslt/page2xhtml.xsl
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/xslt/page2xhtml.xsl?view=diff&r1=153090&r2=153091
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/xslt/page2xhtml.xsl (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/xslt/page2xhtml.xsl Wed Feb 9 09:27:19 2005
@@ -24,6 +24,8 @@
xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:dcterms="http://purl.org/dc/terms/"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
exclude-result-prefixes="page xhtml"
>
@@ -67,10 +69,48 @@
</div>
</td>
</tr>
+ <tr>
+ <td colspan="2" valign="top">
+ <div id="footer">
+ <xsl:apply-templates select="lenya:meta/dcterms:modified"/>
+ <xsl:apply-templates select="lenya:meta/dc:publisher"/>
+ </div>
+ </td>
+ </tr>
</table>
</div>
</body>
</html>
+</xsl:template>
+
+<xsl:template match="dcterms:modified">
+ <xsl:variable name="date"><xsl:value-of select="."/></xsl:variable>
+ <i18n:text>last_published</i18n:text>:
+ <xsl:if test="$date!=''">
+ <i18n:date-time src-pattern="yyyy-MM-dd HH:mm:ss" pattern="EEE, d MMM yyyy HH:mm:ss z" value="{$date}"/>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="dc:publisher">
+ <xsl:variable name="user"><xsl:value-of select="."/></xsl:variable>
+ <xsl:variable name="user-id"><xsl:value-of select="substring-before($user,'|')"/></xsl:variable>
+ <xsl:variable name="rest"><xsl:value-of select="substring-after($user,'|')"/></xsl:variable>
+ <xsl:variable name="user-name"><xsl:value-of select="substring-before($rest,'|')"/></xsl:variable>
+ <xsl:variable name="user-email"><xsl:value-of select="substring-after($rest,'|')"/></xsl:variable>
+
+ <xsl:if test="$user != ''">
+ <xsl:choose>
+ <xsl:when test="$user-email != ''">
+ / <a>
+ <xsl:attribute name="href"><xsl:value-of select="concat('mailto:',$user-email)"/></xsl:attribute>
+ <xsl:value-of select="$user-name"/>
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
+ / <xsl:value-of select="$user-name"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
</xsl:template>
<xsl:template match="@*|node()" priority="-1">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org