removed an old dependency of commons-lang that was in conflict with the version brought by the homelibrary
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/data-analysis/tabulardata/cube-manager-parent/3.5@130323 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fe5a6f45f1
commit
fb77e1f630
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
<artifactId>cube-manager-parent</artifactId>
|
||||
<version>3.5.2-SNAPSHOT</version>
|
||||
<version>3.5.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>cube-manager-api</artifactId>
|
||||
<name>Cube Manager API</name>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
<artifactId>cube-manager-parent</artifactId>
|
||||
<version>3.5.2-SNAPSHOT</version>
|
||||
<version>3.5.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>cube-manager-data</artifactId>
|
||||
<name>Cube Manager Data</name>
|
||||
|
@ -27,12 +27,6 @@
|
|||
<version>7.0.41</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>20030203.000129</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
@ -17,7 +18,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.dbutils.DbUtils;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.gcube.data.analysis.tabulardata.cube.data.connection.DatabaseConnectionProvider;
|
||||
import org.gcube.data.analysis.tabulardata.cube.data.connection.admin.Admin;
|
||||
import org.gcube.data.analysis.tabulardata.cube.data.connection.unprivileged.Unprivileged;
|
||||
|
@ -35,6 +35,8 @@ public class SQLDatabaseWrangler implements DatabaseWrangler {
|
|||
|
||||
private static Logger log = LoggerFactory.getLogger(SQLDatabaseWrangler.class);
|
||||
|
||||
private static RandomString randomString = new RandomString(32);
|
||||
|
||||
private DatabaseConnectionProvider adminConnectionProvider;
|
||||
|
||||
private DatabaseConnectionProvider unprivilegedConnectionProvider;
|
||||
|
@ -219,7 +221,7 @@ public class SQLDatabaseWrangler implements DatabaseWrangler {
|
|||
int count = 0;
|
||||
|
||||
do {
|
||||
tableName = RandomStringUtils.random(32, true, false).toLowerCase();
|
||||
tableName = randomString.nextString().toLowerCase();
|
||||
log.debug("Generated table name: " + tableName);
|
||||
Connection connection = null;
|
||||
Statement statement = null;
|
||||
|
@ -341,4 +343,34 @@ public class SQLDatabaseWrangler implements DatabaseWrangler {
|
|||
public void createUniqueIndex(String tableName, String columnName) {
|
||||
executeQuery(String.format("CREATE UNIQUE INDEX ON %s ( %s );", tableName, columnName));
|
||||
}
|
||||
|
||||
public static class RandomString {
|
||||
|
||||
private static final char[] symbols;
|
||||
|
||||
static {
|
||||
StringBuilder tmp = new StringBuilder();
|
||||
for (char ch = '0'; ch <= '9'; ++ch)
|
||||
tmp.append(ch);
|
||||
for (char ch = 'a'; ch <= 'z'; ++ch)
|
||||
tmp.append(ch);
|
||||
symbols = tmp.toString().toCharArray();
|
||||
}
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
private final char[] buf;
|
||||
|
||||
public RandomString(int length) {
|
||||
if (length < 1)
|
||||
throw new IllegalArgumentException("length < 1: " + length);
|
||||
buf = new char[length];
|
||||
}
|
||||
|
||||
public String nextString() {
|
||||
for (int idx = 0; idx < buf.length; ++idx)
|
||||
buf[idx] = symbols[random.nextInt(symbols.length)];
|
||||
return new String(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
<artifactId>cube-manager-parent</artifactId>
|
||||
<version>3.5.2-SNAPSHOT</version>
|
||||
<version>3.5.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>cube-manager-metadata</artifactId>
|
||||
<name>Cube Manager Metadata</name>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
<artifactId>cube-manager-parent</artifactId>
|
||||
<version>3.5.2-SNAPSHOT</version>
|
||||
<version>3.5.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>cube-manager</artifactId>
|
||||
<name>Cube Manager</name>
|
||||
|
|
|
@ -10,8 +10,8 @@ import java.util.Set;
|
|||
|
||||
import javax.enterprise.event.Event;
|
||||
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.gcube.data.analysis.tabulardata.cube.data.DatabaseWrangler;
|
||||
import org.gcube.data.analysis.tabulardata.cube.data.SQLDatabaseWrangler.RandomString;
|
||||
import org.gcube.data.analysis.tabulardata.cube.events.TableCreationEvent;
|
||||
import org.gcube.data.analysis.tabulardata.cube.exceptions.NoSuchTableException;
|
||||
import org.gcube.data.analysis.tabulardata.cube.exceptions.TableCreationException;
|
||||
|
@ -40,6 +40,8 @@ public abstract class DefaultTableCreator implements TableCreator {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(DefaultTableCreator.class);
|
||||
|
||||
private static RandomString randomString = new RandomString(6);
|
||||
|
||||
protected DatabaseWrangler dbWrangler;
|
||||
protected CubeMetadataWrangler mdWrangler;
|
||||
protected TableManager tableManager;
|
||||
|
@ -354,7 +356,7 @@ public abstract class DefaultTableCreator implements TableCreator {
|
|||
public static class ColumnNameGenerator {
|
||||
|
||||
public static String generateColumnName() {
|
||||
return RandomStringUtils.random(6, true, false).toLowerCase();
|
||||
return randomString.nextString().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue