[GitHub] [maven-site-plugin] qualitesys commented on a change in pull request #48: [MSITE-872] Set the Content-Type header

2021-05-02 Thread GitBox


qualitesys commented on a change in pull request #48:
URL: https://github.com/apache/maven-site-plugin/pull/48#discussion_r624727891



##
File path: src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java
##
@@ -114,6 +117,16 @@ public void doFilter( ServletRequest servletRequest, 
ServletResponse servletResp
 path = path.substring( languageWanted.length() + 1 );
 }
 }
+// Set the contentType for the response
+Path aPath =  Paths.get( path );
+if ( null != aPath ) 

Review comment:
   corrected




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org



[GitHub] [maven-site-plugin] qualitesys commented on a change in pull request #48: [MSITE-872] Set the Content-Type header

2021-04-27 Thread GitBox


qualitesys commented on a change in pull request #48:
URL: https://github.com/apache/maven-site-plugin/pull/48#discussion_r621483341



##
File path: 
src/test/java/org/apache/maven/plugins/site/run/SiteRunMSITE872Test.java
##
@@ -0,0 +1,1009 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.maven.plugins.site.run;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.FilterRegistration;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRegistration;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpUpgradeHandler;
+import javax.servlet.http.Part;
+import junit.framework.Assert;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.doxia.site.decoration.DecorationModel;
+import org.apache.maven.doxia.siterenderer.DocumentContent;
+import org.apache.maven.doxia.siterenderer.DocumentRenderer;
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.doxia.siterenderer.RendererException;
+import org.apache.maven.doxia.siterenderer.RenderingContext;
+import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
+import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
+import static 
org.apache.maven.plugins.site.run.DoxiaFilter.I18N_DOXIA_CONTEXTS_KEY;
+import static org.apache.maven.plugins.site.run.DoxiaFilter.LOCALES_LIST_KEY;
+import static org.apache.maven.plugins.site.run.DoxiaFilter.SITE_RENDERER_KEY;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author D. CRUETTE / QualiteSys 2021 04 26
+ * Check that the response contenttype is set according to the request 
ressource type
+ *
+ */
+public class SiteRunMSITE872Test {
+
+public SiteRunMSITE872Test() {
+}
+
+@BeforeClass
+public static void setUpClass() {
+}
+
+@AfterClass
+public static void tearDownClass() {
+}
+
+@Before
+public void setUp() {
+}
+
+@After
+public void tearDown() {
+}
+
+final String MYLOCALE = "default";
+
+@Test
+public void testCall() 
+{
+
+SiteRenderingContext  leContext  = new 
SiteRenderingContext();
+Map leDocuments= new 
HashMap();
+SiteRenderingContext  leGeneratedSiteContext = new 
SiteRenderingContext();
+DoxiaBean leDoxiaBean = new DoxiaBean ( leContext, leDocuments, 
leGeneratedSiteContext );
+
+Map leI18nDoxiaContexts = new HashMap();
+leI18nDoxiaContexts.put(MYLOCALE, leDoxiaBean);
+DoxiaFilter  leDoxiaFilter  = new DoxiaFilter();
+
+try {
+try {
+// Force ServletPath
+String[][] ltTests = new String[][] {
+{"./rrr/bb/index.html" , "text/html"}
+,
+  

[GitHub] [maven-site-plugin] qualitesys commented on a change in pull request #48: [MSITE-872] Set the Content-Type header

2021-04-26 Thread GitBox


qualitesys commented on a change in pull request #48:
URL: https://github.com/apache/maven-site-plugin/pull/48#discussion_r620608861



##
File path: src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java
##
@@ -118,8 +118,7 @@ public void doFilter( ServletRequest servletRequest, 
ServletResponse servletResp
 }
 }
 // Set the contentType for the response
-File file  = new File ( path );
-Path aPath = file.toPath();
+Path aPath =  (new File ( path ) ).toPath();

Review comment:
   If you want




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org



[GitHub] [maven-site-plugin] qualitesys commented on a change in pull request #48: [MSITE-872] Set the Content-Type header

2021-04-26 Thread GitBox


qualitesys commented on a change in pull request #48:
URL: https://github.com/apache/maven-site-plugin/pull/48#discussion_r619859807



##
File path: src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java
##
@@ -114,6 +116,8 @@ public void doFilter( ServletRequest servletRequest, 
ServletResponse servletResp
 path = path.substring( languageWanted.length() + 1 );
 }
 }
+// Set the contentType for the response
+servletResponse.setContentType( Files.probeContentType( ( new File ( 
path ) ).toPath( ) ) );

Review comment:
   I have added NPE checks




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org



[GitHub] [maven-site-plugin] qualitesys commented on a change in pull request #48: [MSITE-872] Set the Content-Type header

2021-04-25 Thread GitBox


qualitesys commented on a change in pull request #48:
URL: https://github.com/apache/maven-site-plugin/pull/48#discussion_r619859807



##
File path: src/main/java/org/apache/maven/plugins/site/run/DoxiaFilter.java
##
@@ -114,6 +116,8 @@ public void doFilter( ServletRequest servletRequest, 
ServletResponse servletResp
 path = path.substring( languageWanted.length() + 1 );
 }
 }
+// Set the contentType for the response
+servletResponse.setContentType( Files.probeContentType( ( new File ( 
path ) ).toPath( ) ) );

Review comment:
   I have added NPE checks




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org