manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1221048 - in /incubator/lcf/branches/CONNECTORS-314: build.xml framework/build.xml framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java framework/jetty-example/properties.xml
Date Tue, 20 Dec 2011 00:37:41 GMT
Author: kwright
Date: Tue Dec 20 00:37:41 2011
New Revision: 1221048

URL: http://svn.apache.org/viewvc?rev=1221048&view=rev
Log:
Fix some of the code already checked in so that it sort of works.  The index inspection is
still not right; it drops indexes that it previously created, but it almost works.

Modified:
    incubator/lcf/branches/CONNECTORS-314/build.xml
    incubator/lcf/branches/CONNECTORS-314/framework/build.xml
    incubator/lcf/branches/CONNECTORS-314/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
    incubator/lcf/branches/CONNECTORS-314/framework/jetty-example/properties.xml

Modified: incubator/lcf/branches/CONNECTORS-314/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-314/build.xml?rev=1221048&r1=1221047&r2=1221048&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-314/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-314/build.xml Tue Dec 20 00:37:41 2011
@@ -1897,7 +1897,7 @@
         <mkdir dir="build/example"/>
         <manifest file="build/example/manifest">
             <attribute name="Main-Class" value="org.apache.manifoldcf.jettyrunner.ManifoldCFJettyRunner"/>
-            <attribute name="Class-Path" value="lib/commons-codec.jar lib/commons-collections.jar
lib/commons-el.jar lib/commons-fileupload.jar lib/commons-httpclient-mcf.jar lib/commons-io.jar
lib/commons-logging.jar lib/hsqldb.jar lib/derbyclient.jar lib/derby.jar lib/derbyLocale_cs.jar
lib/derbyLocale_de_DE.jar lib/derbyLocale_es.jar lib/derbyLocale_fr.jar lib/derbyLocale_hu.jar
lib/derbyLocale_it.jar lib/derbyLocale_ja_JP.jar lib/derbyLocale_ko_KR.jar lib/derbyLocale_pl.jar
lib/derbyLocale_pt_BR.jar lib/derbyLocale_ru.jar lib/derbyLocale_zh_CN.jar lib/derbyLocale_zh_TW.jar
lib/derbynet.jar lib/derbyrun.jar lib/derbytools.jar lib/eclipse-ecj.jar lib/jasper-6.0.24.jar
lib/jasper-el-6.0.24.jar lib/jdbcpool-0.99.jar lib/jetty-6.1.26-patched-JETTY-1340.jar lib/jetty-util-6.1.26-patched-JETTY-1340.jar
lib/jsp-api-2.1-glassfish-2.1.v20091210.jar lib/json.jar lib/mcf-agents.jar lib/mcf-core.jar
lib/mcf-jetty-runner.jar lib/mcf-pull-agent.jar lib/mcf-ui-core.jar lib/log4j-1.2.jar
  lib/postgresql.jar lib/mysql-connector-java-5.1.18-bin.jar lib/serializer.jar lib/servlet-api-2.5-20081211.jar
lib/tomcat-juli-6.0.24.jar lib/xalan2.jar lib/xercesImpl-mcf.jar lib/xml-apis.jar"/>
+            <attribute name="Class-Path" value="lib/commons-codec.jar lib/commons-collections.jar
lib/commons-el.jar lib/commons-fileupload.jar lib/commons-httpclient-mcf.jar lib/commons-io.jar
lib/commons-logging.jar lib/hsqldb.jar lib/derbyclient.jar lib/derby.jar lib/derbyLocale_cs.jar
lib/derbyLocale_de_DE.jar lib/derbyLocale_es.jar lib/derbyLocale_fr.jar lib/derbyLocale_hu.jar
lib/derbyLocale_it.jar lib/derbyLocale_ja_JP.jar lib/derbyLocale_ko_KR.jar lib/derbyLocale_pl.jar
lib/derbyLocale_pt_BR.jar lib/derbyLocale_ru.jar lib/derbyLocale_zh_CN.jar lib/derbyLocale_zh_TW.jar
lib/derbynet.jar lib/derbyrun.jar lib/derbytools.jar lib/eclipse-ecj.jar lib/jasper-6.0.24.jar
lib/jasper-el-6.0.24.jar lib/jdbcpool-0.99.jar lib/jetty-6.1.26-patched-JETTY-1340.jar lib/jetty-util-6.1.26-patched-JETTY-1340.jar
lib/jsp-api-2.1-glassfish-2.1.v20091210.jar lib/json.jar lib/mcf-agents.jar lib/mcf-core.jar
lib/mcf-jetty-runner.jar lib/mcf-pull-agent.jar lib/mcf-ui-core.jar lib/log4j-1.2.jar
  lib/mysql-connector-java-5.1.18.jar lib/postgresql.jar lib/mysql-connector-java-5.1.18-bin.jar
lib/serializer.jar lib/servlet-api-2.5-20081211.jar lib/tomcat-juli-6.0.24.jar lib/xalan2.jar
lib/xercesImpl-mcf.jar lib/xml-apis.jar"/>
         </manifest>
         <jar destfile="dist/example/start.jar" manifest="build/example/manifest"/>
     </target>

Modified: incubator/lcf/branches/CONNECTORS-314/framework/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-314/framework/build.xml?rev=1221048&r1=1221047&r2=1221048&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-314/framework/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-314/framework/build.xml Tue Dec 20 00:37:41 2011
@@ -456,6 +456,7 @@
                 <include name="postgresql*.jar"/>
                 <include name="derby*.jar"/>
                 <include name="hsqldb*.jar"/>
+                <include name="mysql*.jar"/>
             </fileset>
         </copy>
         <copy todir="dist/example/lib">

Modified: incubator/lcf/branches/CONNECTORS-314/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-314/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java?rev=1221048&r1=1221047&r2=1221048&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-314/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
(original)
+++ incubator/lcf/branches/CONNECTORS-314/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java
Tue Dec 20 00:37:41 2011
@@ -26,48 +26,26 @@ public class DBInterfaceMySQL extends Da
 {
   public static final String _rcsid = "@(#)$Id: DBInterfaceMySQL.java 999670 2010-09-21 22:18:19Z
kwright $";
 
-  /** MySQL driver property */
-  public static final String mysqlDriverProperty = "org.apache.manifoldcf.mysql.database.driver";
-  /** MySQL databaseName property */
-  public static final String mysqlDatabaseNameProperty = "org.apache.manifoldcf.database.name";
-  /** MySQL url property */
-  public static final String mysqlUrlProperty = "org.apache.manifoldcf.mysql.database.url";
+  /** MySQL server property */
+  public static final String mysqlServerProperty = "org.apache.manifoldcf.mysql.server";
 
-  private static final String _url = "jdbc:mysql://localhost/";
   private static final String _driver = "com.mysql.jdbc.Driver";
+  
   protected String cacheKey;
 
   public DBInterfaceMySQL(IThreadContext tc, String databaseName, String userName, String
password)
     throws ManifoldCFException
   {
-
-    super(tc,getJdbcUrl(databaseName),getJdbcDriver(),databaseName,userName,password);
+    super(tc,getJdbcUrl(databaseName),_driver,databaseName,userName,password);
     cacheKey = CacheKeyFactory.makeDatabaseKey(this.databaseName);
   }
 
-  private static String getJdbcUrl(final String databaseName)
+  private static String getJdbcUrl(String theDatabaseName)
   {
-    String url =  ManifoldCF.getProperty(mysqlUrlProperty);
-
-    if (url == null || url.length() < 1)
-       url = "jdbc:mysql://localhost/";
-    url += databaseName;
-    return url;
-  }
-
-  private static String getJdbcDatabaseName(){
-    String databaseName =  ManifoldCF.getProperty(mysqlDatabaseNameProperty);
-
-    if (databaseName == null || databaseName.length() < 1)
-      databaseName = "manifoldfc";
-    return databaseName;
-  }
-
-  private static String getJdbcDriver(){
-    String driver =  ManifoldCF.getProperty(mysqlDriverProperty);
-    if (driver == null || driver.length() < 1)
-      driver = "com.mysql.jdbc.Driver";
-    return driver;
+    String server =  ManifoldCF.getProperty(mysqlServerProperty);
+    if (server == null || server.length() == 0)
+      server = "localhost";
+    return "jdbc:mysql://"+server+"/"+theDatabaseName;
   }
 
   /** Initialize.  This method is called once per JVM instance, in order to set up
@@ -437,7 +415,9 @@ public class DBInterfaceMySQL extends Da
   public void performRemoveIndex(String indexName)
     throws ManifoldCFException
   {
-    performModification("DROP INDEX "+indexName,null,null);
+    // MHL; we need the table name too.
+    System.out.println("Dropping index "+indexName);
+    //performModification("DROP INDEX "+indexName,null,null);
   }
 
   /** Analyze a table.
@@ -481,29 +461,30 @@ public class DBInterfaceMySQL extends Da
     Database masterDatabase = new DBInterfaceMySQL(context,"mysql",adminUserName,adminPassword);
 
     List list = new ArrayList();
-try{
-    list.add("utf8");
-    masterDatabase.executeQuery("CREATE DATABASE "+databaseName+" CHARACTER SET ?",list,
-      null,invalidateKeys,null,false,0,null,null);
-} catch (ManifoldCFException e){
-if (e.getErrorCode() != 4)
-	throw new ManifoldCFException(e.getMessage());
-}
-    if (userName != null)
+    try
     {
-try {
-      list.clear();
-      list.add(userName);
-      list.add("localhost");
-      list.add(password);
-      masterDatabase.executeQuery("GRANT ALL ON "+databaseName+".* TO ?@? IDENTIFIED BY ?",list,
+      list.add("utf8");
+      masterDatabase.executeQuery("CREATE DATABASE "+databaseName+" CHARACTER SET ?",list,
         null,invalidateKeys,null,false,0,null,null);
-} catch (ManifoldCFException e){
-if (e.getErrorCode() != 4)
+    } catch (ManifoldCFException e){
+      if (e.getErrorCode() != 4)
 	throw new ManifoldCFException(e.getMessage());
-}
-      masterDatabase.executeQuery("USE " + getJdbcDatabaseName(),null,
-        null,invalidateKeys,null,false,0,null,null);
+    }
+    if (userName != null)
+    {
+      try {
+        list.clear();
+        list.add(userName);
+        list.add("localhost");
+        list.add(password);
+        masterDatabase.executeQuery("GRANT ALL ON "+databaseName+".* TO ?@? IDENTIFIED BY
?",list,
+          null,invalidateKeys,null,false,0,null,null);
+      } catch (ManifoldCFException e){
+        if (e.getErrorCode() != 4)
+          throw new ManifoldCFException(e.getMessage());
+      }
+      //masterDatabase.executeQuery("USE " + databaseName,null,
+      //  null,invalidateKeys,null,false,0,null,null);
     }
   }
 
@@ -517,11 +498,9 @@ if (e.getErrorCode() != 4)
   {
     // Connect to super database
     Database masterDatabase = new DBInterfaceMySQL(context,"mysql",adminUserName,adminPassword);
-    //Database masterDatabase = new DBInterfaceMySQL(context,getJdbcDatabaseName(),adminUserName,adminPassword);
-
     masterDatabase.executeQuery("DROP DATABASE "+databaseName,null,null,invalidateKeys,null,false,0,null,null);
-      masterDatabase.executeQuery("USE " + getJdbcDatabaseName(),null,
-        null,invalidateKeys,null,false,0,null,null);
+    //masterDatabase.executeQuery("USE mysql",null,
+    //  null,invalidateKeys,null,false,0,null,null);
   }
 
   /** Perform a general database modification query.
@@ -532,11 +511,7 @@ if (e.getErrorCode() != 4)
   public void performModification(String query, List params, StringSet invalidateKeys)
     throws ManifoldCFException
   {
-try{
-    executeQuery("USE " + getJdbcDatabaseName(),null,null,invalidateKeys,null,false,0,null,null);
     executeQuery(query,params,null,invalidateKeys,null,false,0,null,null);
-} catch(Exception e){
-}
   }
 
   /** Get a table's schema.
@@ -548,40 +523,22 @@ try{
   public Map<String,ColumnDescription> getTableSchema(String tableName, StringSet cacheKeys,
String queryClass)
     throws ManifoldCFException
   {
-/*
-Map<String,ColumnDescription> rval = null;
-    try {
-    IResultSet set = performQuery("DESCRIBE "+tableName,null,cacheKeys,queryClass);
-    // Digest the result
-    rval = new HashMap<String,ColumnDescription>();
-    int i = 0;
-    while (i < set.getRowCount())
-    {
-      IResultRow row = set.getRow(i++);
-      String fieldName = row.getValue("Field").toString();
-      String type = row.getValue("Type").toString();
-      boolean isNull = row.getValue("Null").toString().equals("YES");
-      boolean isPrimaryKey = row.getValue("Key").toString().equals("PRI");
-      rval.put(fieldName,new ColumnDescription(type,isPrimaryKey,isNull,null,null,false));
-    }
-
-    } catch (Exception e) {
-rval = null;
-    }
-    return rval;
-*/
     StringBuilder query = new StringBuilder();
     List list = new ArrayList();
+    list.add(databaseName.toUpperCase());
     list.add(tableName.toUpperCase());
     query.append("SELECT column_name, is_nullable, data_type, character_maximum_length ")
-      .append("FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='PUBLIC' AND table_name=?");
+      .append("FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=? AND TABLE_NAME=?");
     IResultSet set = performQuery(query.toString(),list,cacheKeys,queryClass);
     if (set.getRowCount() == 0)
       return null;
 
     query = new StringBuilder();
-    query.append("SELECT column_name ")
-      .append("FROM INFORMATION_SCHEMA.SYSTEM_PRIMARYKEYS WHERE table_schem='PUBLIC' AND
table_name=?");
+    query.append("SELECT t1.column_name ")
+      .append("FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE t1, INFORMATION_SCHEMA.TABLE_CONSTRAINTS
t2 ")
+      .append("WHERE t1.CONSTRAINT_NAME=t2.CONSTRAINT_NAME AND t1.TABLE_NAME=t2.TABLE_NAME
AND ")
+      .append("t1.TABLE_SCHEMA=t2.TABLE_SCHEMA AND ")
+      .append("t1.TABLE_SCHEMA=? AND t1.TABLE_NAME=? AND t2.CONSTRAINT_TYPE='PRIMARY KEY'");
     IResultSet primarySet = performQuery(query.toString(),list,cacheKeys,queryClass);
     String primaryKey = null;
     if (primarySet.getRowCount() != 0)
@@ -625,9 +582,10 @@ rval = null;
   {
     Map<String,IndexDescription> rval = new HashMap<String,IndexDescription>();
 
-    String query = "SELECT index_name,column_name,non_unique,ordinal_position FROM INFORMATION_SCHEMA.SYSTEM_INDEXINFO
"+
-      "WHERE table_schem='PUBLIC' AND TABLE_NAME=? ORDER BY index_name,ordinal_position ASC";
+    String query = "SELECT index_name,column_name,non_unique,seq_in_index FROM INFORMATION_SCHEMA.STATISTICS
"+
+      "WHERE TABLE_SCHEMA=? AND TABLE_NAME=? ORDER BY index_name,seq_in_index ASC";
     List list = new ArrayList();
+    list.add(databaseName.toUpperCase());
     list.add(tableName.toUpperCase());
     IResultSet result = performQuery(query,list,cacheKeys,queryClass);
     String lastIndexName = null;
@@ -667,7 +625,7 @@ rval = null;
 
   protected void addIndex(Map rval, String indexName, boolean isUnique, List<String>
indexColumns)
   {
-    if (indexName.indexOf("sys_idx") != -1)
+    if (indexName.equals("primary"))
       return;
     String[] columnNames = new String[indexColumns.size()];
     int i = 0;

Modified: incubator/lcf/branches/CONNECTORS-314/framework/jetty-example/properties.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-314/framework/jetty-example/properties.xml?rev=1221048&r1=1221047&r2=1221048&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-314/framework/jetty-example/properties.xml (original)
+++ incubator/lcf/branches/CONNECTORS-314/framework/jetty-example/properties.xml Tue Dec 20
00:37:41 2011
@@ -18,19 +18,15 @@
 
 <configuration>
   <!-- Select Derby as the database implementation, and specify where the database will
be stored -->
-  <property name="org.apache.manifoldcf.databaseimplementationclass" value="org.apache.manifoldcf.core.database.DBInterfaceMySQL"/>
-  <property name="org.apache.manifoldcf.mysql.database.driver" value="com.mysql.jdbc.Driver"/>
-  <property name="org.apache.manifoldcf.database.name" value="manifoldcf"/>
-  <property name="org.apache.manifoldcf.mysql.database.url" value="jdbc:mysql://localhost/"/>
-  <property name="org.apache.manifoldcf.dbsuperusername" value="user"/>
-  <property name="org.apache.manifoldcf.dbsuperuserpassword" value="password"/>
+  <property name="org.apache.manifoldcf.databaseimplementationclass" value="org.apache.manifoldcf.core.database.DBInterfaceDerby"/>
+  <property name="org.apache.manifoldcf.derbydatabasepath" value="."/>
   <property name="org.apache.manifoldcf.database.maxhandles" value="100"/>
   <property name="org.apache.manifoldcf.crawler.threads" value="50"/>
   <!-- Point to a specific logging file -->
   <property name="org.apache.manifoldcf.logconfigfile" value="./logging.ini"/>
   <!-- Specify the connectors to be loaded -->
   <property name="org.apache.manifoldcf.connectorsconfigurationfile" value="./connectors.xml"/>
-  <!-- Tell LCF where to find the connector jars -->
+  <!-- Tell MCF where to find the connector jars -->
   <libdir path="./connector-lib"/>
   <!-- WSDD references -->
   <!-- Any additional properties go here -->



Mime
View raw message