/**
  * Get the cause of an I/O exception if caused by a possible disk error
  *
  * @param ioe an I/O exception
  * @return cause if the I/O exception is caused by a possible disk error; null otherwise.
  */
 static IOException getCauseIfDiskError(IOException ioe) {
   if (ioe.getMessage() != null && ioe.getMessage().startsWith(DISK_ERROR)) {
     return (IOException) ioe.getCause();
   } else {
     return null;
   }
 }
Esempio n. 2
0
 private GdcNotification(CommandLine ln, Properties defaults) {
   try {
     cliParams = parse(ln, defaults);
     cliParams.setHttpConfig(
         new NamePasswordConfiguration(
             "https",
             cliParams.get(CLI_PARAM_GDC_HOST[0]),
             cliParams.get(CLI_PARAM_GDC_USERNAME[0]),
             cliParams.get(CLI_PARAM_GDC_PASSWORD[0])));
     String config = cliParams.get(CLI_PARAM_CONFIG);
     if (config != null && config.length() > 0) {
       execute(config);
     } else {
       l.error("No config file given.");
       commandsHelp();
       System.exit(1);
     }
     finishedSucessfuly = true;
   } catch (ConnectionException e) {
     l.error("Can't connect to SFDC: " + e.getMessage());
     Throwable c = e.getCause();
     while (c != null) {
       l.error("Caused by: " + c.getMessage());
       c = c.getCause();
     }
     l.debug("Can't connect to SFDC:", e);
   } catch (InvalidArgumentException e) {
     l.error("Invalid command line argument: " + e.getMessage());
     Throwable c = e.getCause();
     while (c != null) {
       l.error("Caused by: " + c.getMessage());
       c = c.getCause();
     }
     l.debug("Invalid command line argument:", e);
     l.info(commandsHelp());
   } catch (SfdcException e) {
     l.error("Error communicating with SalesForce: " + e.getMessage());
     Throwable c = e.getCause();
     while (c != null) {
       l.error("Caused by: " + c.getMessage());
       c = c.getCause();
     }
     l.debug("Error communicating with SalesForce.", e);
   } catch (IOException e) {
     l.error(
         "Encountered an IO problem. Please check that all files that you use in your command line arguments and commands exist. More info: '"
             + e.getMessage()
             + "'");
     Throwable c = e.getCause();
     while (c != null) {
       l.error("Caused by: " + c.getMessage());
       c = c.getCause();
     }
     l.debug(
         "Encountered an IO problem. Please check that all files that you use in your command line arguments and commands exist. More info: '"
             + e.getMessage()
             + "'",
         e);
   } catch (InternalErrorException e) {
     Throwable c = e.getCause();
     if (c != null && c instanceof SQLException) {
       l.error(
           "Error extracting data. Can't process the incoming data. Please check the CSV file "
               + "separator and consistency (same number of columns in each row). Also, please make sure "
               + "that the number of columns in your XML config file matches the number of rows in your "
               + "data source. Make sure that your file is readable by other users (particularly the mysql user). "
               + "More info: '"
               + c.getMessage()
               + "'");
       l.debug(
           "Error extracting data. Can't process the incoming data. Please check the CSV file "
               + "separator and consistency (same number of columns in each row). Also, please make sure "
               + "that the number of columns in your XML config file matches the number of rows in your "
               + "data source. Make sure that your file is readable by other users (particularly the mysql user). "
               + "More info: '"
               + c.getMessage()
               + "'",
           c);
     } else {
       l.error("Internal error: " + e.getMessage());
       c = e.getCause();
       while (c != null) {
         l.error("Caused by: " + c.getMessage());
         c = c.getCause();
       }
       l.debug("REST API invocation error: ", e);
     }
   } catch (HttpMethodException e) {
     l.error("Error executing GoodData REST API: " + e.getMessage());
     Throwable c = e.getCause();
     while (c != null) {
       l.error("Caused by: " + c.getMessage());
       c = c.getCause();
     }
     l.debug("Error executing GoodData REST API.", e);
   } catch (GdcRestApiException e) {
     l.error("REST API invocation error: " + e.getMessage());
     Throwable c = e.getCause();
     while (c != null) {
       if (c instanceof HttpMethodException) {
         HttpMethodException ex = (HttpMethodException) c;
         String msg = ex.getMessage();
         if (msg != null && msg.length() > 0 && msg.indexOf("/ldm/manage") > 0) {
           l.error("Error creating/updating logical data model (executing MAQL DDL).");
           if (msg.indexOf(".date") > 0) {
             l.error("Bad time dimension schemaReference.");
           } else {
             l.error(
                 "You are either trying to create a data object that already exists "
                     + "(executing the same MAQL multiple times) or providing a wrong reference "
                     + "or schemaReference in your XML configuration.");
           }
         }
       }
       l.error("Caused by: " + c.getMessage());
       c = c.getCause();
     }
     l.debug("REST API invocation error: ", e);
   } catch (GdcException e) {
     l.error("Unrecognized error: " + e.getMessage());
     Throwable c = e.getCause();
     while (c != null) {
       l.error("Caused by: " + c.getMessage());
       c = c.getCause();
     }
     l.debug("Unrecognized error: ", e);
   }
 }