Package weave.config.ConnectionConfig

Examples of weave.config.ConnectionConfig.ConnectionInfo


  }
 
  private ConnectionInfo getConnectionInfo(String user, String password) throws RemoteException
  {
    ConnectionConfig connConfig = getConnectionConfig();
    ConnectionInfo info = connConfig.getConnectionInfo(user);
    if (info == null || password == null || !password.equals(info.pass))
    {
      System.out.println(String.format("authenticate failed, name=\"%s\" pass=\"%s\"", user, password));
      throw new RemoteException("Incorrect username or password.");
    }
View Full Code Here


   * @return A list of (xml) client config files existing in the docroot folder.
   */
  public String[] getWeaveFileNames(String user, String password, Boolean showAllFiles)
    throws RemoteException
  {
    ConnectionInfo info = getConnectionInfo(user, password);
    File[] files = null;
    List<String> listOfFiles = new ArrayList<String>();
    FilenameFilter fileFilter = new FilenameFilter()
    {
      public boolean accept(File dir, String fileName)
View Full Code Here

   */
  public String saveWeaveFile(
      String user, String password, InputStream fileContent, String fileName, boolean overwriteFile)
    throws RemoteException
  {
    ConnectionInfo info = getConnectionInfo(user, password);

    try
    {
      // remove special characters
      fileName = fileName.replace("\\", "").replace("/", "");
View Full Code Here

   *
   */
  public String removeWeaveFile(String user, String password, String fileName)
    throws RemoteException, IllegalArgumentException
  {
    ConnectionInfo info = getConnectionInfo(user, password);

    if (!info.is_superuser && Strings.isEmpty(info.folderName))
      return String.format(
          "User \"%s\" does not have permission to remove configuration files.", user);

View Full Code Here

    throws RemoteException
  {
    if (newUser.equals(""))
      throw new RemoteException("Connection name cannot be empty.");

    ConnectionInfo newConnectionInfo = new ConnectionInfo();
    newConnectionInfo.name = newUser;
    newConnectionInfo.pass = newPass;
    newConnectionInfo.folderName = folderName;
    newConnectionInfo.is_superuser = true;
    newConnectionInfo.connectString = connectString;

    // if there are existing connections and DatabaseConfigInfo exists,
    // check the password. otherwise, allow anything.
    ConnectionConfig config = getConnectionConfig();
   
    if (config.getConnectionInfoNames().size() > 0 && config.getDatabaseConfigInfo() != null)
    {
      authenticate(currentUser, currentPass);

      // non-superusers can't save connection info
      if (!config.getConnectionInfo(currentUser).is_superuser)
        throw new RemoteException(String.format(
            "User \"%s\" does not have permission to modify connections.", currentUser));
      // is_superuser for the new connection will only be false if there
      // is an existing superuser connection and grantSuperuser is false.
      newConnectionInfo.is_superuser = grantSuperuser;
    }

    // test connection only - to validate parameters
    Connection conn = null;
    try
    {
      conn = newConnectionInfo.getConnection();
      SQLUtils.testConnection(conn);
    }
    catch (Exception e)
    {
      throw new RemoteException(
View Full Code Here

  // Key column uniqueness checks

  public void checkKeyColumnsForSQLImport(String connectionName, String password, String schemaName, String tableName, String[] keyColumns)
    throws RemoteException
  {
    ConnectionInfo info = getConnectionInfo(connectionName, password);
   
    if (info == null)
      throw new RemoteException(String.format("Connection named \"%s\" does not exist.", connectionName));

    Connection conn = null;
    String query = null;
    try
    {
      conn = info.getConnection();
     
      String quotedSchemaTable = SQLUtils.quoteSchemaTable(conn, schemaName, tableName);
     
      List<String> columnNames = SQLUtils.getColumns(conn, schemaName, tableName);
      for (String col : keyColumns)
View Full Code Here

      String sqlSchema, String sqlTable, boolean sqlOverwrite, String configDataTableName,
      String configKeyType, String[] nullValues,
      String[] filterColumnNames, boolean configAppend)
    throws RemoteException
  {
    ConnectionInfo connInfo = getConnectionInfo(connectionName, password);
   
    if (Strings.isEmpty(sqlSchema))
      throw new RemoteException("SQL schema must be specified.");
    if (Strings.isEmpty(sqlTable))
      throw new RemoteException("SQL table must be specified.");
   
    final int StringType = 0;
    final int IntType = 1;
    final int DoubleType = 2;
   
    if (sqlOverwrite && !connInfo.is_superuser)
      throw new RemoteException(String.format(
          "User \"%s\" does not have permission to overwrite SQL tables.", connectionName));

    Connection conn = null;
    Statement stmt = null;
    try
    {
      conn = connInfo.getConnection();

      sqlTable = sqlTable.toLowerCase(); // bug fix for MySQL running under Linux

      String[] sqlColumnNames = null;
      String[] csvColumnNames = null;
View Full Code Here

      int table_id = DataConfig.NULL; 
    DataConfig dataConfig = getDataConfig();
   
    if (sqlColumnNames == null || sqlColumnNames.length == 0)
      throw new RemoteException("No columns were found.");
    ConnectionInfo connInfo = getConnectionConfig().getConnectionInfo(connectionName);
    if (connInfo == null)
      throw new RemoteException(String.format("Connection named \"%s\" does not exist.", connectionName));
   
    String failMessage = String.format("Failed to add DataTable \"%s\" to the configuration.\n", configDataTableName);
    String query = null;
    try
    {
      Connection conn = connInfo.getStaticReadOnlyConnection();
     
      // If key column is actually the name of a column, put quotes around it.  Otherwise, don't.
      String q_sqlKeyColumn;
      if (ListUtils.findString(sqlKeyColumn, sqlColumnNames) >= 0)
        q_sqlKeyColumn = SQLUtils.quoteSymbol(conn, sqlKeyColumn);
View Full Code Here

      String configConnectionName, String password, String[] fileNameWithoutExtension, String[] keyColumns,
      String sqlSchema, String sqlTablePrefix, boolean sqlOverwrite, String configTitle,
      String configKeyType, String projectionSRS, String[] nullValues, boolean importDBFData, boolean append)
    throws RemoteException
  {
    ConnectionInfo connInfo = getConnectionInfo(configConnectionName, password);
    DataConfig dataConfig = getDataConfig();
   
    if (Strings.isEmpty(sqlSchema))
      throw new RemoteException("SQL schema must be specified.");
    if (Strings.isEmpty(sqlTablePrefix))
      throw new RemoteException("SQL table prefix must be specified.");
   
    // use lower case sql table names (fix for mysql linux problems)
    sqlTablePrefix = sqlTablePrefix.toLowerCase();

    if (sqlOverwrite && !connInfo.is_superuser)
      throw new RemoteException(String.format(
          "User \"%s\" does not have permission to overwrite SQL tables.", configConnectionName));

    String dbfTableName = sqlTablePrefix + "_dbfdata";
    Connection conn = null;
        int tableId = -1;
    try
    {
      conn = connInfo.getConnection();
      // store dbf data to database
      if (importDBFData)
      {
        importDBF(
            configConnectionName, password, fileNameWithoutExtension, sqlSchema, dbfTableName,
View Full Code Here

  public void importDBF(
      String configConnectionName, String password, String[] fileNameWithoutExtension, String sqlSchema,
      String sqlTableName, boolean sqlOverwrite, String[] nullValues)
    throws RemoteException
  {
    ConnectionInfo info = getConnectionInfo(configConnectionName, password);
   
    if (Strings.isEmpty(sqlSchema))
      throw new RemoteException("Schema must be specified.");
   
    // use lower case sql table names (fix for mysql linux problems)
    sqlTableName = sqlTableName.toLowerCase();

    if (sqlOverwrite && !info.is_superuser)
      throw new RemoteException(String.format(
          "User \"%s\" does not have permission to overwrite SQL tables.", configConnectionName));

    Connection conn = null;
    try
    {
      conn = info.getConnection();
      File[] files = new File[fileNameWithoutExtension.length];
      for (int i = 0; i < files.length; i++)
        files[i] = new File(getUploadPath() + fileNameWithoutExtension[i] + ".dbf");

      DBFUtils.storeAttributes(files, conn, sqlSchema, sqlTableName, sqlOverwrite, nullValues);
View Full Code Here

TOP

Related Classes of weave.config.ConnectionConfig.ConnectionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.