lenya/src/java/org/apache/lenya/cms/cocoon/acting TaskAction.java,1.12,1.13

Andreas Hartmann <[email protected]> Fri, 16 May 2003 17:27:13 +0200
Newsgroups gmane.comp.cms.wyona.cvs
Message-ID <[email protected]>
Update of /repository/lenya/src/java/org/apache/lenya/cms/cocoon/acting
In directory erbium:/tmp/cvs-serv29817/src/java/org/apache/lenya/cms/cocoon/acting

Modified Files:
	TaskAction.java 
Log Message:
using PublicationFactory to resolve the publication

Index: TaskAction.java
===================================================================
RCS file: /repository/lenya/src/java/org/apache/lenya/cms/cocoon/acting/TaskAction.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** TaskAction.java	24 Apr 2003 13:52:38 -0000	1.12
--- TaskAction.java	16 May 2003 15:27:11 -0000	1.13
***************
*** 49,52 ****
--- 49,58 ----
  package org.apache.lenya.cms.cocoon.acting;
  
+ import java.io.File;
+ import java.io.IOException;
+ import java.net.MalformedURLException;
+ import java.net.URI;
+ import java.net.URISyntaxException;
+ import java.util.Arrays;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
***************
*** 58,66 ****
  import org.apache.cocoon.environment.Session;
  
- import org.apache.lenya.cms.publishing.PublishingEnvironment;
  import org.apache.lenya.cms.task.*;
  
  import java.util.Enumeration;
  import java.util.HashMap;
  
  
--- 64,80 ----
  import org.apache.cocoon.environment.Session;
  
  import org.apache.lenya.cms.task.*;
  
  import java.util.Enumeration;
  import java.util.HashMap;
+ import java.util.Map;
+ import org.apache.avalon.framework.parameters.ParameterException;
+ import org.apache.cocoon.environment.Context;
+ import org.apache.cocoon.environment.Redirector;
+ import org.apache.cocoon.environment.SourceResolver;
+ import org.apache.excalibur.source.Source;
+ import org.apache.lenya.cms.publication.PageEnvelope;
+ import org.apache.lenya.cms.publication.Publication;
+ import org.apache.lenya.cms.publication.PublicationFactory;
  
  
***************
*** 114,153 ****
       * @throws java.lang.Exception DOCUMENT ME!
       */
!     public java.util.Map act(org.apache.cocoon.environment.Redirector redirector,
!         org.apache.cocoon.environment.SourceResolver sourceResolver, java.util.Map objectModel,
!         String str, Parameters parameters) throws java.lang.Exception {
!         // Get Source
!         org.apache.cocoon.environment.Source inputSource = sourceResolver.resolve("");
!         String publicationPath = inputSource.getSystemId();
! 
!         // Remove "file:" protocol
!         publicationPath = publicationPath.substring(5);
! 
!         getLogger().info("######### " + publicationPath);
! 
!         if (publicationPath.endsWith("/")) {
!             publicationPath = publicationPath.substring(0, publicationPath.length() - 1);
!         }
! 
!         getLogger().info("######### " + publicationPath);
! 
!         int lastSlashIndex = publicationPath.lastIndexOf("/");
!         String publicationId = publicationPath.substring(lastSlashIndex + 1);
! 
!         getLogger().info("#######id " + publicationId);
! 
!         publicationPath = publicationPath.substring(0, lastSlashIndex + 1);
! 
!         getLogger().info("######### " + publicationPath);
! 
!         String publicationPrefix = PublishingEnvironment.PUBLICATION_PREFIX;
! 
!         String contextPath = publicationPath.substring(0,
!                 publicationPath.length() - publicationPrefix.length());
! 
!         getLogger().info("######### " + contextPath);
! 
!         publicationPath += publicationId;
  
          // Get request object
          Request request = ObjectModelHelper.getRequest(objectModel);
--- 128,137 ----
       * @throws java.lang.Exception DOCUMENT ME!
       */
!     public java.util.Map act(Redirector redirector, SourceResolver sourceResolver,
!         Map objectModel, String str, Parameters parameters) throws java.lang.Exception {
  
+         Publication publication = PublicationFactory.getPublication(objectModel);
+         File publicationDirectory = publication.getDirectory();
+         
          // Get request object
          Request request = ObjectModelHelper.getRequest(objectModel);
***************
*** 170,179 ****
          Parameters taskParameters = new Parameters();
  
!         taskParameters.setParameter(Task.PARAMETER_SERVLET_CONTEXT, contextPath);
          taskParameters.setParameter(Task.PARAMETER_CONTEXT_PREFIX, request.getContextPath() + "/");
          taskParameters.setParameter(Task.PARAMETER_SERVER_PORT,
              Integer.toString(request.getServerPort()));
          taskParameters.setParameter(Task.PARAMETER_SERVER_URI, "http://" + request.getServerName());
!         taskParameters.setParameter(Task.PARAMETER_PUBLICATION_ID, publicationId);
  
          // set parameters using the request parameters
--- 154,163 ----
          Parameters taskParameters = new Parameters();
  
!         taskParameters.setParameter(Task.PARAMETER_SERVLET_CONTEXT, publication.getServletContext().getCanonicalPath());
          taskParameters.setParameter(Task.PARAMETER_CONTEXT_PREFIX, request.getContextPath() + "/");
          taskParameters.setParameter(Task.PARAMETER_SERVER_PORT,
              Integer.toString(request.getServerPort()));
          taskParameters.setParameter(Task.PARAMETER_SERVER_URI, "http://" + request.getServerName());
!         taskParameters.setParameter(Task.PARAMETER_PUBLICATION_ID, publication.getId());
  
          // set parameters using the request parameters
***************
*** 189,197 ****
              getTaskId() + "'" + "\n-------------------------------------------------");
  
!         TaskManager manager = new TaskManager(publicationPath);
          Task task = manager.getTask(getTaskId());
  
          task.parameterize(taskParameters);
!         task.execute(contextPath);
  
          //------------------------------------------------------------
--- 173,181 ----
              getTaskId() + "'" + "\n-------------------------------------------------");
  
!         TaskManager manager = new TaskManager(publication.getDirectory().getCanonicalPath());
          Task task = manager.getTask(getTaskId());
  
          task.parameterize(taskParameters);
!         task.execute(publication.getServletContext().getCanonicalPath());
  
          //------------------------------------------------------------
***************
*** 217,219 ****
--- 201,204 ----
          return actionMap;
      }
+     
  }