lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ed...@apache.org
Subject cvs commit: cocoon-lenya/src/webapp/lenya usecase.xmap
Date Wed, 20 Aug 2003 16:53:29 GMT
edith       2003/08/20 09:53:29

  Modified:    src/webapp/lenya usecase.xmap
  Added:       src/webapp/lenya/xslt/info restore.xsl
               src/webapp/lenya/content/info restore.xsp
  Log:
  restore usecase
  
  Revision  Changes    Path
  1.1                  cocoon-lenya/src/webapp/lenya/xslt/info/restore.xsl
  
  Index: restore.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
   $Id: restore.xsl,v 1.1 2003/08/20 16:53:29 edith Exp $
   -->
  
   <xsl:stylesheet version="1.0"
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:session="http://www.apache.org/xsp/session/2.0"
     xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
     >
    
    <xsl:output version="1.0" indent="yes" encoding="ISO-8859-1"/>
    
    <xsl:variable name="document-id"><xsl:value-of select="/page/info/document-id"/></xsl:variable>
    <xsl:variable name="dest-document-id"><xsl:value-of select="/page/info/dest-document-id"/></xsl:variable>
    <xsl:variable name="area"><xsl:value-of select="/page/info/area"/></xsl:variable>
    <xsl:variable name="task-id"><xsl:value-of select="/page/info/task-id"/></xsl:variable>
    <xsl:variable name="request-uri"><xsl:value-of select="/page/info/request-uri"/></xsl:variable>
  
    <xsl:template match="/">
      <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="page">
      <page:page>
        <page:title>Restore Document</page:title>
        <page:body>
          <xsl:apply-templates select="body"/>
  	    <xsl:apply-templates select="info"/>
        </page:body>
      </page:page>
    </xsl:template>
  
    <xsl:template match="info">
      <div class="lenya-box">
        <div class="lenya-box-title">Restore Document</div>
        <div class="lenya-box-body">
        <xsl:choose>
  		<xsl:when test="exception">		
            <p>
             The document <xsl:value-of select="document-id"/> cannot be restored because
<xsl:value-of select="exception"/>
            </p> 
            <input type="button" class="lenya-form-element" onClick="location.href='{$request-uri}';"
value="Back"/>
        	</xsl:when>
        	<xsl:otherwise>
          <form method="get">
            <xsl:attribute name="action"></xsl:attribute>
            <input type="hidden" name="lenya.usecase" value="restore"/>
            <input type="hidden" name="lenya.step" value="restore"/>
            <input type="hidden" name="task-id" value="{$task-id}"/>
            <xsl:call-template name="task-parameters">
              <xsl:with-param name="prefix" select="''"/>
            </xsl:call-template>
            <p>
   	      Do you really want to restore <xsl:value-of select="document-id"/>?
            </p>
            <input type="submit" class="lenya-form-element" value="Restore"/>
            <input type="button" class="lenya-form-element" onClick="location.href='{$request-uri}';"
value="Cancel"/>
          </form>
      	</xsl:otherwise>
  	  </xsl:choose>	
        </div>
      </div>
    </xsl:template>
    
    <xsl:template name="task-parameters">
      <xsl:param name="prefix" select="'task.'"/>
      <input type="hidden" name="{$prefix}properties.node.firstdocumentid" value="{$document-id}"/>
      <input type="hidden" name="{$prefix}properties.node.secdocumentid" value="{$dest-document-id}"/>
      <input type="hidden" name="{$prefix}properties.firstarea" value="{$area}"/>
      <input type="hidden" name="{$prefix}properties.secarea" value="authoring"/>
    </xsl:template>
  
  </xsl:stylesheet>
    
  
  
  
  1.1                  cocoon-lenya/src/webapp/lenya/content/info/restore.xsp
  
  Index: restore.xsp
  ===================================================================
  <?xml version="1.0" ?>
  
  <xsp:page 
    language="java" 
    xmlns:xsp="http://apache.org/xsp"
    xmlns:input="http://apache.org/cocoon/xsp/input/1.0"
    xmlns:xsp-request="http://apache.org/xsp/request/2.0"
    xmlns:xsp-session="http://apache.org/xsp/session/2.0"
    create-session="true">
  
    <xsp:structure>
      <xsp:include>org.apache.lenya.cms.publication.Publication</xsp:include>
      <xsp:include>org.apache.lenya.cms.publication.DublinCoreHelper</xsp:include>
      <xsp:include>org.apache.lenya.cms.publication.SiteTree</xsp:include>
      <xsp:include>org.apache.lenya.cms.publication.SiteTreeNode</xsp:include>
      <xsp:include>java.io.IOException</xsp:include>
    </xsp:structure>
  
  <page>
  <info>
     <xsp:logic>
      Publication publication = (Publication)<input:get-attribute module="page-envelope"
as="object" name="publication"/>;
      String documentid = (String) <xsp-session:get-attribute name="org.apache.lenya.cms.info.target"/>
;
      String area = (String) <xsp-session:get-attribute name="org.apache.lenya.cms.info.area"/>;
      String identifier = null;      
  	SiteTreeNode parentNode = null;
  
      try {
      	identifier = DublinCoreHelper.getDCIdentifier(publication, area, documentid);
      } catch (Exception e) {
          <exception><xsp:expr>e.toString()</xsp:expr></exception>
      }                                                                                  
                                                 
  
      if (identifier == null) {
          <exception>the identifier is null</exception>
      }     
  
  	String parentid = identifier.substring(0, identifier.length()-documentid.length());
      try {
  		SiteTree sectree = publication.getSiteTree(Publication.AUTHORING_AREA);
  		parentNode = sectree.getNode(parentid);
      } catch (Exception e) {
          <exception><xsp:expr>e.toString()</xsp:expr></exception>
      }                                                                                  
                                                 
  	if (parentNode == null) {
   		<exception> 
   		the original parent <xsp:expr>parentid</xsp:expr> doesn't exist anymore
   		</exception>
      } else {
  	   <document-id><xsp:expr>documentid</xsp:expr></document-id>
         <dest-document-id><xsp:expr>parentid</xsp:expr></dest-document-id>

  	   <area><xsp:expr>area</xsp:expr></area>
  	   <task-id>restoreDocument</task-id>
      }
  	   <request-uri><xsp-request:get-uri/></request-uri>
     </xsp:logic>
  </info>
  </page>
  </xsp:page>
  
  
  
  1.73      +19 -0     cocoon-lenya/src/webapp/lenya/usecase.xmap
  
  Index: usecase.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/usecase.xmap,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- usecase.xmap	20 Aug 2003 13:43:37 -0000	1.72
  +++ usecase.xmap	20 Aug 2003 16:53:29 -0000	1.73
  @@ -594,6 +594,25 @@
           </map:match>
           
           
  +        <map:match pattern="restore" type="usecase">
  +          
  +          <map:match pattern="showscreen" type="step">
  +            <map:generate src="content/info/restore.xsp" type="serverpages"/>
  +            <map:transform src="xslt/info/restore.xsl"/>
  +            <map:call resource="style-cms-page"/>
  +          </map:match>
  +          
  +          <map:match pattern="restore" type="step">
  +            <map:act type="task">
  +              <map:parameter name="publication-id" value="{../../1}"/>
  +              <map:parameter name="task-id" value="{request-param:task-id}"/>
  +              <map:redirect-to session="true" uri="{request:requestURI}"/>
  +            </map:act>
  +          </map:match>
  +          
  +        </map:match>
  +        
  +
           <map:match pattern="copy" type="usecase">
             
             <map:match pattern="showscreen" type="step">
  
  
  

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


Mime
View raw message