portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/content-server/src/java/org/apache/jetspeed/contentserver ContentFilter.java SimpleContentLocator.java ContentLocator.java
Date Fri, 07 May 2004 02:41:15 GMT
taylor      2004/05/06 19:41:15

  Modified:    content-server/src/java/org/apache/jetspeed/contentserver
                        ContentFilter.java SimpleContentLocator.java
                        ContentLocator.java
  Log:
  added licensing information
  
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.8       +43 -42    jakarta-jetspeed-2/content-server/src/java/org/apache/jetspeed/contentserver/ContentFilter.java
  
  Index: ContentFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/content-server/src/java/org/apache/jetspeed/contentserver/ContentFilter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ContentFilter.java	25 Mar 2004 21:39:56 -0000	1.7
  +++ ContentFilter.java	7 May 2004 02:41:15 -0000	1.8
  @@ -1,3 +1,18 @@
  +/*
  + * Copyright 2000-2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
   package org.apache.jetspeed.contentserver;
   
   import java.io.File;
  @@ -18,12 +33,6 @@
   import org.apache.commons.logging.LogFactory;
   
   /**
  - * Created on Dec 30, 2003
  - * 
  - * @author
  - */
  -
  -/**
    * <p>
    * ContentFilter
    * </p>
  @@ -34,7 +43,6 @@
    */
   public class ContentFilter implements Filter
   {
  -
       public static final String SESSION_CONTENT_PATH_ATTR = "org.apache.jetspeed.content.pathes";
   
       private FilterConfig config;
  @@ -43,7 +51,7 @@
   
       // private String themesDir;
       private File contentDirFile;
  -    
  +
       private static final Log log = LogFactory.getLog(ContentFilter.class);
   
       private String urlHint;
  @@ -55,44 +63,46 @@
        */
       public void init(FilterConfig config) throws ServletException
       {
  -        this.config = config;        
  +        this.config = config;
           String dir = config.getInitParameter("content.directory");
           urlHint = config.getInitParameter("url.hint");
           this.contentDir = config.getServletContext().getRealPath(dir);
           // this.themesDir = this.contentDir + "/themes";
           this.contentDirFile = new File(this.contentDir);
  -        if (!contentDirFile.exists()) { throw new ServletException(
  -                "The specified content directory "
  -                        + contentDirFile.getAbsolutePath() + " does not exist!"); }
  -
  +        if (!contentDirFile.exists())
  +        {
  +            throw new ServletException(
  +            "The specified content directory "
  +            + contentDirFile.getAbsolutePath() + " does not exist!");
  +        }
       }
   
       /**
        * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
        *      javax.servlet.ServletResponse, javax.servlet.FilterChain)
        */
  -    public void doFilter(ServletRequest request, ServletResponse response,
  -            FilterChain chain) throws IOException, ServletException
  +    public void doFilter(ServletRequest request, ServletResponse response, 
  +    FilterChain chain) throws IOException, ServletException
       {
           if (request instanceof HttpServletRequest)
           {
  -            
               HttpServletRequest httpRequest = (HttpServletRequest) request;
               HttpServletResponse httpResponse = (HttpServletResponse) response;
  -            String requestURI = httpRequest.getRequestURI();            
  -            String mimeType = config.getServletContext()
  -            .getMimeType(requestURI);
  -            
  -            if (mimeType == null) { throw new NullPointerException(
  -                    "MIME-TYPE for "
  -                    + requestURI
  -                    + " could not be located.  Make sure your container is properly configured
to detect MIME types."); }
  -            
  +            String requestURI = httpRequest.getRequestURI();
  +            String mimeType = config.getServletContext().getMimeType(requestURI);
  +            if (mimeType == null)
  +            {
  +                throw new NullPointerException(
  +                        "MIME-TYPE for "
  +                                + requestURI
  +                                + " could not be located.  Make sure your container is
properly configured to detect MIME types.");
  +            }
               log.debug(mimeType + " detected: " + requestURI);
  -            
  -            SimpleContentLocator contentLocator = new SimpleContentLocator(this.contentDir,
urlHint, true);
  -            long contentLength = contentLocator.mergeContent(requestURI, getContentSearchPathes(httpRequest),
response.getOutputStream());
  -            
  +            SimpleContentLocator contentLocator = new SimpleContentLocator(
  +                    this.contentDir, urlHint, true);
  +            long contentLength = contentLocator.mergeContent(requestURI,
  +                    getContentSearchPathes(httpRequest), response
  +                            .getOutputStream());
               if (contentLength > -1)
               {
                   response.setContentType(mimeType);
  @@ -103,12 +113,8 @@
               {
                   chain.doFilter(request, response);
               }
  -            
               return;
  -            
           }
  -        
  -
           chain.doFilter(request, response);
       }
   
  @@ -117,22 +123,17 @@
        */
       public void destroy()
       {
  -
       }
   
  -
       protected List getContentSearchPathes(HttpServletRequest request)
       {
  -        List contentPathes = (List) request.getSession().getAttribute(
  -                SESSION_CONTENT_PATH_ATTR);
  +        List contentPathes = (List) request.getSession().getAttribute(SESSION_CONTENT_PATH_ATTR);
           if (contentPathes == null)
           {
  -            contentPathes = new ArrayList();            
  +            contentPathes = new ArrayList();
               //request.getSession()
  -            //        .setAttribute(SESSION_THEME_ATTR, contentPathes);            
  +            //        .setAttribute(SESSION_THEME_ATTR, contentPathes);
           }
  -
           return contentPathes;
       }
  -
   }
  
  
  
  1.3       +15 -6     jakarta-jetspeed-2/content-server/src/java/org/apache/jetspeed/contentserver/SimpleContentLocator.java
  
  Index: SimpleContentLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/content-server/src/java/org/apache/jetspeed/contentserver/SimpleContentLocator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleContentLocator.java	13 Mar 2004 23:57:41 -0000	1.2
  +++ SimpleContentLocator.java	7 May 2004 02:41:15 -0000	1.3
  @@ -1,8 +1,17 @@
   /*
  - * Created on Mar 12, 2004
  - *
  - * To change the template for this generated file go to
  - * Window - Preferences - Java - Code Generation - Code and Comments
  + * Copyright 2000-2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
    */
   package org.apache.jetspeed.contentserver;
   
  @@ -24,7 +33,7 @@
    * </p>
    * 
    * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
  - * @version $ $
  + * @version $Id $
    *  
    */
   public class SimpleContentLocator implements ContentLocator
  @@ -126,7 +135,7 @@
           BufferedInputStream bis = null;
           try
           {
  -
  +            // DST: TODO: optimize using larger blocks with Streams helper utility
               bis = new BufferedInputStream(new FileInputStream(fqFile));
               for (int j = bis.read(); j != -1; j = bis.read())
               {
  
  
  
  1.3       +14 -5     jakarta-jetspeed-2/content-server/src/java/org/apache/jetspeed/contentserver/ContentLocator.java
  
  Index: ContentLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/content-server/src/java/org/apache/jetspeed/contentserver/ContentLocator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContentLocator.java	13 Mar 2004 23:57:41 -0000	1.2
  +++ ContentLocator.java	7 May 2004 02:41:15 -0000	1.3
  @@ -1,8 +1,17 @@
   /*
  - * Created on Mar 12, 2004
  - *
  - * To change the template for this generated file go to
  - * Window - Preferences - Java - Code Generation - Code and Comments
  + * Copyright 2000-2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
    */
   package org.apache.jetspeed.contentserver;
   
  @@ -16,7 +25,7 @@
    * </p>
    *
    * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
  - * @version $ $
  + * @version $Id $
    *
    */
   public interface ContentLocator
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message