lenya/src/java/org/apache/lenya/cms/cocoon/acting RevisionControllerAction.java,1.15,1.16 RollbackAction.java,1.12,1.13

Edith Chevrier <[email protected]> Tue, 20 May 2003 18:45:22 +0200
Newsgroups gmane.comp.cms.wyona.cvs
Message-ID <[email protected]>
Update of /usr/local/repositories/lenya/src/java/org/apache/lenya/cms/cocoon/acting
In directory erbium:/tmp/cvs-serv19453/src/java/org/apache/lenya/cms/cocoon/acting

Modified Files:
	RevisionControllerAction.java RollbackAction.java 
Log Message:
Revision Controller in the usecase sitemap

Index: RevisionControllerAction.java
===================================================================
RCS file: /usr/local/repositories/lenya/src/java/org/apache/lenya/cms/cocoon/acting/RevisionControllerAction.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** RevisionControllerAction.java	30 Apr 2003 16:44:24 -0000	1.15
--- RevisionControllerAction.java	20 May 2003 16:45:19 -0000	1.16
***************
*** 55,58 ****
--- 55,63 ----
  import org.apache.lenya.cms.ac.Identity;
  import org.apache.lenya.cms.rc.RevisionController;
+ import org.apache.lenya.cms.rc.RCEnvironment;
+ 
+ import org.apache.lenya.cms.publication.PageEnvelope;
+ import org.apache.lenya.cms.publication.Publication;
+ import org.apache.lenya.cms.publication.PublicationFactory;
  
  import java.util.Map;
***************
*** 88,105 ****
          Parameters parameters) throws Exception {
  
- 
-         String publicationPath = parameters.getParameter("publicationPath");
-         getLogger().debug(".act(): publicationPath: " + publicationPath);
- 
-         // Initialize Revision Controller
-         rcmlDirectory = publicationPath + parameters.getParameter("rcmlDirectory");
-         getLogger().debug("rcmlDirectory : " + rcmlDirectory);
-         backupDirectory = publicationPath + parameters.getParameter("backupDirectory");
-         getLogger().debug("backupDirectory : " +backupDirectory );
-         rc = new RevisionController(rcmlDirectory, backupDirectory, publicationPath);
-         getLogger().debug("revision controller" + rc);
- 
-         // /Initialize Revision Controller
- 
          // Get request object
          Request request = ObjectModelHelper.getRequest(objectModel);
--- 93,96 ----
***************
*** 111,114 ****
--- 102,131 ----
          }
  
+         PageEnvelope envelope = null;
+         Publication publication = null;
+ 
+         try {
+             publication = PublicationFactory.getPublication(objectModel);
+             envelope = new PageEnvelope(publication, request);
+         }
+         catch (Exception e) {
+             getLogger().error("Resolving page envelope failed: ", e);
+         }
+ 
+         //get Parameters for RC
+         String publicationPath = publication.getEnvironment().getPublicationPath();
+         String servletContextPath = publication.getServletContext().getCanonicalPath();
+         RCEnvironment rcEnvironment = new RCEnvironment(servletContextPath);
+         rcmlDirectory = rcEnvironment.getRCMLDirectory();
+         rcmlDirectory=publicationPath+rcmlDirectory;
+         backupDirectory = rcEnvironment.getBackupDirectory();
+         backupDirectory=publicationPath+backupDirectory;
+ 
+         // Initialize Revision Controller
+         rc = new RevisionController(rcmlDirectory, backupDirectory, publicationPath);
+         getLogger().debug("revision controller" + rc);
+         // /Initialize Revision Controller
+ 
+ 
          // Get session
          Session session = request.getSession(false);
***************
*** 123,127 ****
          getLogger().debug(".act(): Identity: " + identity);
  
!         filename = request.getParameter("filename");
          username = null;
  
--- 140,146 ----
          getLogger().debug(".act(): Identity: " + identity);
  
!         String docId = request.getParameter("documentid");
!         filename =publication.getEnvironment().getAuthoringPath() + "/" +docId ;
!         getLogger().debug(".act(): publicationAuthPath + docId : " + publication.getEnvironment().getAuthoringPath() +" : " +docId );
          username = null;
  

Index: RollbackAction.java
===================================================================
RCS file: /usr/local/repositories/lenya/src/java/org/apache/lenya/cms/cocoon/acting/RollbackAction.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** RollbackAction.java	30 Apr 2003 16:44:24 -0000	1.12
--- RollbackAction.java	20 May 2003 16:45:19 -0000	1.13
***************
*** 95,142 ****
  
          // Get parameters                                                                                                                       
- //        String action = request.getParameter("action");
          String rollbackTime = request.getParameter("rollbackTime");
  
! /* FIXME
!         if (action != null) {
!             if (action.equals("rollback")) {
! */  
!               // Do the rollback to an earlier version
!                 long newtime = 0;
! 
!                 try {
!                     newtime = rc.rollback(filename, username, true,
!                             new Long(rollbackTime).longValue());
!                 } catch (FileNotFoundException e) {
!                     getLogger().error("Unable to roll back!" + e);
! 
!                     return null;
!                 } catch (Exception e) {
!                     getLogger().error("Unable to roll back!" + e);
  
!                     return null;
!                 }
  
!                 getLogger().debug("rollback complete, old (and now current) time was " +
!                     rollbackTime + " backup time is " + newtime);
  
!                 String location = request.getHeader("Referer");
  
!                 getLogger().debug("redirect to " + location);
!                 actionMap.put("location", location);
!                 return actionMap;
  
! /*
!             } else {
!                 getLogger().error("The action is no defined");
  
!                 return null;
!             }
!         } else {
!             getLogger().error("The action is null");
  
-             return null;
-         }
- */
      }
  }
--- 95,125 ----
  
          // Get parameters                                                                                                                       
          String rollbackTime = request.getParameter("rollbackTime");
  
!         // Do the rollback to an earlier version
!         long newtime = 0;
  
!         try {
!           newtime = rc.rollback(filename, username, true,
!           new Long(rollbackTime).longValue());
!         } catch (FileNotFoundException e) {
!           getLogger().error("Unable to roll back!" + e);
  
!           return null;
!         } catch (Exception e) {
!           getLogger().error("Unable to roll back!" + e);
  
!           return null;
!         }
  
!         getLogger().debug("rollback complete, old (and now current) time was " +
!              rollbackTime + " backup time is " + newtime);
  
!         String location = request.getHeader("Referer");
  
!         getLogger().debug("redirect to " + location);
!         actionMap.put("location", location);
!         return actionMap;
  
      }
  }