[jboss-cvs] JBossAS SVN: r88085 - projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 30 20:24:00 EDT 2009
Author: ctomc
Date: 2009-04-30 20:24:00 -0400 (Thu, 30 Apr 2009)
New Revision: 88085
Removed:
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VanillaExe.java
Log:
removed some propertary code that would help noone
Deleted: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VanillaExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VanillaExe.java 2009-05-01 00:19:51 UTC (rev 88084)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VanillaExe.java 2009-05-01 00:24:00 UTC (rev 88085)
@@ -1,161 +0,0 @@
-package org.jboss.fresh.shell.commands;
-
-import org.jboss.fresh.io.BufferWriter;
-import org.jboss.fresh.shell.AbstractExecutable;
-import org.jboss.fresh.io.IOUtils;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-/** Execuatable for making vanilla html from Uradni-list web site
- * Created by Tomaz Cerar
- * User: cerar
- * Date: Jan 8, 2003
- * Time: 2:59:36 PM
- * www.parsek.net
- * @author Tomaz Cerar
- * @version 1.0
- */
-public class VanillaExe extends AbstractExecutable {
- private static transient org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(VanillaExe.class);
- public static final String DIR = "-dir=";
- public static final String HOST = "-host=";
-
- public void process(String exepath, String[] params) throws Exception {
- log.debug("entering");
- if (helpRequested()) {
- PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
- out.print("Usage: cd [--help] DIRECTORY\n");
- out.print(" Excutable for procesing vanilla html-s for uradni list.\n");
- out.print(" --help : this help\n");
- out.print(" -dir : specify folder to copy files in. like -dir=/usr/home\n");
- out.print(" -host : http path to page to rip. Example -host=http://www.uradni-list.si\n");
- out.print(" \n");
- out.print(" Usage:\n");
- out.print(" VanillaHtml -dir=/usr/home/ul -host=http://www.uradni-list.zrk \n");
- out.close();
- log.debug("done");
- return;
- }
-
- String ServerPath = "http://www.uradni-list.zrk";
- String stran = ServerPath + "/1/index.jsp";
- String kazalostran = ServerPath + "/1/kazalo.jsp";
- String dir = "/usr/local/web/www.uradni-list.si/Vanilla/html/1/";
-
-
- boolean direcory = false; // was out param already processed
- boolean page = false; // was out param already processed
-
- for (int i = 0; i < params.length; i++) {
-
- String param = params[i];
-
- if (!direcory && param.startsWith(DIR)) {
- dir = param.substring(DIR.length());
- if (!dir.endsWith(File.separator)) {
- dir = dir + File.separator;
- }
- direcory = true;
-
- } else if (!page && param.startsWith(HOST)) {
- ServerPath = param.substring(HOST.length());
- page = true;
-
- } else {
-
- }
- }
-
- Context ic = new InitialContext();
- DataSource ds = (DataSource) ic.lookup(getShell().getEnvProperty("PERSIST_SQL_DS"));
-
- java.sql.ResultSet urls = null;
- Connection conn = ds.getConnection();
- //PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
- try {
- Statement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- urls = st.executeQuery("SELECT URLID,Intranet FROM UradniListi WHERE (Intranet IS NULL) OR (Intranet != 1);");
-
- while (urls.next()) {
- getShell().using();
- String uid = urls.getString("URLID");
-
- String linkUL = stran + "?urlid=" + uid + "&vanilla=1";
- String fileUL = dir + uid + ".html";
- String linkULKazalo = kazalostran + "?urlid=" + uid + "&vanilla=1";
- String fileULKazalo = dir + "kazalo_" + uid + ".html";
- System.out.println("[VanillaExe] : Going for page: " + linkUL);
- SavePageToFile(linkUL, fileUL);
- System.out.println("[VanillaExe] : Page saving page to: " + fileUL);
- System.out.println("[VanillaExe] : Going for page: " + linkULKazalo);
- SavePageToFile(linkULKazalo, fileULKazalo);
- System.out.println("[VanillaExe] : Page saving page to: " + fileULKazalo);
-
- st.executeUpdate("UPDATE UradniListi SET Intranet = 1 WHERE URLID = " + uid);
- //out.print("Processed Uradni list with uid: "+uid+"\n");
- MakeIndexPage(uid, dir);
- System.out.println("[VanillaExe] :Processed Uradni list with uid: " + uid);
- }
- } catch (SQLException e) {
- log.error("SQL Exception", e);
- } finally {
- try {
- urls.close();
- } catch (SQLException e) {
- log.error("SQL Exception while closing connection", e);
- }
- conn.close();
- //out.close();
- }
-
- log.debug("done");
- }
-
- private void SavePageToFile(String link, String file) {
- try {
- URL url = new URL(link);
- File f = new File(file);
- InputStream is = url.openStream();
-
- FileOutputStream fw = new FileOutputStream(f);
- IOUtils.copy(is, fw, 50000);
- fw.close();
- is.close();
- } catch (java.io.IOException e) {
- log.error(e.getMessage(),e);
- }
- }
-
- private void MakeIndexPage(String uid, String dir) {
-
- try {
- FileWriter fw = new FileWriter(dir + "default.htm");
- fw.write("<html>\n");
- fw.write(" <head>\n");
- fw.write(" <title></title>\n");
- fw.write(" <script type=\"text\\javascript\">window.location.href = \"" + uid + ".html\"; </script> \n");
- fw.write(" </head>\n");
- fw.write(" <body> </body>\n");
- fw.write("</html>\n");
- fw.close();
- } catch (IOException e) {
- log.error(e.getMessage(),e);
- } finally {
- }
-
-
- }
-}
More information about the jboss-cvs-commits
mailing list