/*
* This software and supporting documentation were developed by
*
* Siemens Corporate Technology
* Competence Center Knowledge Management and Business Transformation
* D-81730 Munich, Germany
*
* Authors (representing a really great team ;-) )
* Stefan B. Augustin, Thorbj�rn Hansen, Manfred Langen
*
* This software is Open Source under GNU General Public License (GPL).
* Read the text of this license in LICENSE.TXT
* or look at www.opensource.org/licenses/
*
* Once more we emphasize, that:
* THIS SOFTWARE IS MADE AVAILABLE, AS IS, WITHOUT ANY WARRANTY
* REGARDING THE SOFTWARE, ITS PERFORMANCE OR
* FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
* ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
* PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
*/
package KFM.preprocessor.Precompile;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import com.oroinc.text.regex.*;
import KFM.preprocessor.MakePortalFileWorker;
public class PrecompileServlet extends HttpServlet
{
private final String mPatternString = "/SIPF_([a-zA-Z]*)-([a-zA-Z]*)-([a-zA-Z]*)(.*)";
private PatternMatcher mMatcher;
private Pattern mPattern;
private MakePortalFileWorker mWorker;
public void init(ServletConfig config) throws ServletException
{
super.init(config);
// to do: code goes here.
mMatcher = new Perl5Matcher();
PatternCompiler tCompiler = new Perl5Compiler();
mPattern = null;
try {
mPattern = tCompiler.compile(mPatternString);
} catch(MalformedPatternException e) {
System.out.println(e);
}
Properties tProps = new Properties();
tProps.put("fileDir", "");
tProps.put("host", "localhost");
tProps.put("port", "84");
String tHttpParams =
"pre_Dir=dev/seehund/ReplaceHostBean.properties&lang=all/Languages.inc";
mWorker = new MakePortalFileWorker(tHttpParams, tProps);
}
public String getServletInfo()
{
return "Precompiles missing static pages";
}
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
// to do: code goes here.
synchronized(this) {
// example: /SIPF_http-NS-de/PortalUI/SIP2.index.html
String tURI = req.getQueryString();
tURI = tURI.substring("request=".length());
if(tURI.startsWith("/SIPF/")) {
tURI = "/SIPF_http-IE-de/" + tURI.substring("/SIPF/".length());
}
System.out.println(tURI);
PatternMatcherInput tInput = new PatternMatcherInput(tURI);
if(mMatcher.contains(tInput, mPattern)) {
MatchResult tResult = mMatcher.getMatch();
mWorker.setChannel(tResult.group(1));
mWorker.setBrowser(tResult.group(2));
mWorker.setLanguage(tResult.group(3));
String tFilename =
"o:/kfm/www-docs/public/portal/portal.v9" + tResult.group(4);
File tFile = new File(tFilename);
if(!tFile.exists()) {
tFilename += ".jsp";
tFile = new File(tFilename);
}
System.out.println(tFile);
mWorker.workFile(tFile);
System.out.println("done");
resp.sendRedirect("http://seehund.sip.siemens.net" + tURI);
} else {
System.out.println("no match!");
resp.getWriter().println("no match!");
}
}
}
}