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 2003/07/02 19:50:38 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/publication PublicationFactory.java

andreas     2003/07/02 10:50:38

  Modified:    src/java/org/apache/lenya/cms/publication
                        PublicationFactory.java
  Log:
  added method getPublication(request, context)
  
  Revision  Changes    Path
  1.7       +25 -16    cocoon-lenya/src/java/org/apache/lenya/cms/publication/PublicationFactory.java
  
  Index: PublicationFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/PublicationFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PublicationFactory.java	30 Jun 2003 11:52:11 -0000	1.6
  +++ PublicationFactory.java	2 Jul 2003 17:50:38 -0000	1.7
  @@ -1,5 +1,5 @@
   /*
  -$Id
  +$Id$
   <License>
   
    ============================================================================
  @@ -84,23 +84,9 @@
        */
       public static Publication getPublication(Map objectModel) {
           assert objectModel != null;
  -
           Request request = ObjectModelHelper.getRequest(objectModel);
  -        String contextPath = request.getContextPath();
  -
  -        if (contextPath == null) {
  -            contextPath = "";
  -        }
  -
  -        String webappUri = request.getRequestURI().substring(contextPath.length());
  -
  -        String publicationId = webappUri.split("/")[1];
  -        assert !"".equals(publicationId);
  -
           Context context = ObjectModelHelper.getContext(objectModel);
  -        String servletContextPath = context.getRealPath("");
  -
  -        return getPublication(publicationId, servletContextPath);
  +        return getPublication(request, context);
       }
   
       /**
  @@ -128,4 +114,27 @@
   
           return publication;
       }
  +    
  +    /**
  +     * Creates a new publication based on a request and a context.
  +     * @param request A request.
  +     * @param context A context.
  +     * @return A publication.
  +     */
  +    public static Publication getPublication(Request request, Context context) {
  +        String contextPath = request.getContextPath();
  +
  +        if (contextPath == null) {
  +            contextPath = "";
  +        }
  +
  +        String webappUri = request.getRequestURI().substring(contextPath.length());
  +
  +        String publicationId = webappUri.split("/")[1];
  +        assert !"".equals(publicationId);
  +
  +        String servletContextPath = context.getRealPath("");
  +        return getPublication(publicationId, servletContextPath);
  +    }
  +    
   }
  
  
  

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