Example usage for java.lang IllegalArgumentException getCause

List of usage examples for java.lang IllegalArgumentException getCause

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.sourceforge.net.javamail4ews.util.Util.java

public static ExchangeService getExchangeService(String host, int port, String user, String password,
        Session pSession) throws MessagingException {
    if (user == null) {
        return null;
    }//from  ww w .j a v a 2  s.  co m
    if (password == null) {
        return null;
    }

    String version = getConfiguration(pSession).getString("org.sourceforge.net.javamail4ews.ExchangeVersion",
            "");
    ExchangeVersion serverVersion = null;
    if (!version.isEmpty()) {
        try {
            serverVersion = Enum.valueOf(ExchangeVersion.class, version);
        } catch (IllegalArgumentException e) {
            logger.info("Unknown version for exchange server: '" + version
                    + "' using default : no version specified");
        }
    }
    boolean enableTrace = getConfiguration(pSession)
            .getBoolean("org.sourceforge.net.javamail4ews.util.Util.EnableServiceTrace");
    ExchangeService service = null;
    if (serverVersion != null) {
        service = new ExchangeService(serverVersion);
    } else {
        service = new ExchangeService();
    }
    Integer connectionTimeout = getConnectionTimeout(pSession);
    Integer protocolTimeout = getProtocolTimeout(pSession);
    if (connectionTimeout != null) {
        logger.debug("setting timeout to {} using connection timeout value", connectionTimeout);
        service.setTimeout(connectionTimeout.intValue());
    }
    if (protocolTimeout != null) {
        logger.debug("setting protocol timeout to {} is ignored", protocolTimeout);
    }
    service.setTraceEnabled(enableTrace);

    ExchangeCredentials credentials = new WebCredentials(user, password);
    service.setCredentials(credentials);

    try {
        service.setUrl(new URI(host));
    } catch (URISyntaxException e) {
        throw new MessagingException(e.getMessage(), e);
    }

    try {
        //Bind to check if connection parameters are valid
        if (getConfiguration(pSession)
                .getBoolean("org.sourceforge.net.javamail4ews.util.Util.VerifyConnectionOnConnect")) {
            logger.debug("Connection settings : trying to verify them");
            Folder.bind(service, WellKnownFolderName.Inbox);
            logger.info("Connection settings verified.");
        } else {
            logger.info("Connection settings not verified yet.");
        }
        return service;
    } catch (Exception e) {
        Throwable cause = e.getCause();
        if (cause != null) {
            if (cause instanceof ConnectException) {
                Exception nested = (ConnectException) cause;
                throw new MessagingException(nested.getMessage(), nested);
            }
        }
        throw new AuthenticationFailedException(e.getMessage());
    }
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Gets the properties of the current graph by clicking on the property
 * button/*from  ww  w  .  j  a  va  2  s .  c  o m*/
 *
 * @param evt
 */
private void propertyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_propertyButtonActionPerformed
    try {

        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }

        if (scgc == null || !scgc.getFileName().equals(fileName)) {
            scgc = new DegreeSignalCollectGephiConnectorImpl(fileName);
        }
        propertyContentDisplay.setText(setPropertyText(scgc.getGraphProperties()));
    } catch (IllegalArgumentException exception) {

        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Gets and visualizes the chart of the Degree Distribution
 *
 * @param evt//www.  j av  a  2s . com
 */
private void degreeDistributionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_degreeDistributionButtonActionPerformed
    try {
        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }
        distributionFrame.setVisible(false);
        distributionFrame = new JFrame();

        scgc = new DegreeSignalCollectGephiConnectorImpl(fileName);
        JFreeChart chart = scgc.createDegreeDistributionChart(scgc.getDegreeDistribution());
        ChartPanel chartPanel = new ChartPanel(chart);
        Dimension dim = new Dimension(750, 450);
        distributionFrame.setMinimumSize(dim);
        distributionFrame.add(chartPanel);
        chartPanel.setVisible(true);
        chartPanel.validate();

        distributionFrame.pack();
        distributionFrame.setVisible(true);
    } catch (IllegalArgumentException exception) {

        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Gets and visualizes the chart of the Local Cluster Coefficient
 * Distribution//  www  .j  av  a  2s.c  o m
 *
 * @param evt
 */
private void clusterDistributionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clusterDistributionButtonActionPerformed

    try {
        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }
        distributionFrame.setVisible(false);
        distributionFrame = new JFrame();

        scgc = new LocalClusterCoefficientSignalCollectGephiConnectorImpl(fileName);
        JFreeChart chart = scgc.createClusterDistributionChart(scgc.getClusterDistribution());
        ChartPanel chartPanel = new ChartPanel(chart);
        Dimension dim = new Dimension(750, 450);
        distributionFrame.setMinimumSize(dim);
        chartPanel.setVisible(true);
        chartPanel.validate();

        distributionFrame.add(chartPanel);

        distributionFrame.pack();
        distributionFrame.setVisible(true);
    } catch (IllegalArgumentException exception) {

        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:com.flipzu.flipzu.Player.java

@Override
public void onPause() {
    super.onPause();
    debug.logV(TAG, "onPause()");
    try {/*from www  . j ava2s. c o m*/
        unregisterReceiver(broadcastReceiver);
    } catch (IllegalArgumentException e) {
        debug.logE(TAG, "onPause ERROR", e.getCause());
    }

    comHandler.removeCallbacks(mUpdateCommentsTask);
    liveHandler.removeCallbacks(mCheckLiveTask);
    timerHandler.removeCallbacks(mTimerTask);
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Runs a Signal/Collect SNA method when the "Run" button is clicked
 *
 * @param evt/*w  w w . ja va  2 s  . c  o m*/
 */
private void runMetricButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runMetricButtonActionPerformed

    try {

        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }
        String actualMetric = metricDropDown.getSelectedItem().toString();
        if (actualMetric.equals("Degree")) {
            scgc = new DegreeSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();
            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("PageRank")) {
            scgc = new PageRankSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();
            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Betweenness")) {
            scgc = new BetweennessSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();
            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Closeness")) {
            scgc = new ClosenessSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();

            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Local Cluster Coefficient")) {
            scgc = new LocalClusterCoefficientSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();

            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Triad Census")) {
            scgc = new TriadCensusSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();

            metricValuesTextPane.setText(setTriadCensusText(scgc.getAll()));
        } else {
            throw new IllegalArgumentException("invalid Signal/Collect metric chosen!\nPlease try again");
        }
        Dimension dim = new Dimension(750, 450);
        metricResultFrame.setMinimumSize(dim);
        metricResultFrame.pack();
        metricValuesTextPane.setVisible(true);
        metricValuesScrollPane.setVisible(true);
        metricResultFrame.setVisible(true);
    } catch (IllegalArgumentException exception) {
        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Executes the label propagation algorithm
 *
 * @param evt/*from w ww  . j a  va2 s.c  o  m*/
 */
private void labelPropagationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_labelPropagationButtonActionPerformed
    try {
        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextPane1.getText() == null) {
            throw new IllegalArgumentException("No input found!");
        }
        if (Integer.parseInt(jTextPane1.getText()) < 1) {
            throw new IllegalArgumentException("The number has to be greater than 0");
        }
        scgc = new LabelPropagationSignalCollectGephiConnectorImpl(fileName,
                scala.Option.apply(Integer.parseInt(jTextPane1.getText())));

        scgc.getLabelPropagation();
    } catch (IllegalArgumentException exception) {

        JOptionPane.showMessageDialog(messageFrame,
                "Error when parsing input " + jTextPane1.getText() + ": " + exception.getMessage(),
                "Signal/Collect Error", JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        scgc = null;
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }

}

From source file:org.apache.atlas.service.DefaultMetadataServiceTest.java

@Test
public void testTypeWithDotsCreationShouldNotBeCreated() throws AtlasException, JSONException {
    String typeName = "test_.v1_type_XXXX";
    HierarchicalTypeDefinition<ClassType> typeDef = TypesUtil.createClassTypeDef(typeName,
            ImmutableSet.<String>of(),
            TypesUtil.createUniqueRequiredAttrDef("test_type_attribute", DataTypes.STRING_TYPE));
    TypesDef typesDef = new TypesDef(typeDef, false);

    try {/*from  www  . ja  va2 s . c om*/
        metadataService.createType(TypesSerialization.toJson(typesDef));
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getCause().getMessage().contains(AtlasTypeUtil.getInvalidTypeNameErrorMessage()),
                e.getCause().getMessage());
    }
}

From source file:org.zeroturnaround.jenkins.LiveRebelProxy.java

public boolean perform(FilePath[] wars, String contextPath, List<String> deployableServers, Strategy strategy,
        boolean useFallbackIfCompatibleWithWarnings, boolean uploadOnly, OverrideForm override, File meta)
        throws IOException, InterruptedException {
    if (wars.length == 0) {
        listener.getLogger()//w  ww. ja  v a  2s.c  o m
                .println("Could not find any artifact to deploy. Please, specify it in job configuration.");
        return false;
    }

    if (deployableServers.isEmpty()) {
        listener.getLogger().println("No servers specified in LiveRebel configuration.");
        return false;
    }

    this.strategy = strategy;
    this.useFallbackIfCompatibleWithWarnings = useFallbackIfCompatibleWithWarnings;

    if (!initCommandCenter()) {
        return false;
    }

    listener.getLogger().println("Deploying artifacts.");
    for (FilePath warFile : wars) {
        boolean result = false;
        Boolean tempFileCreated = false;
        ArrayList<File> filestToDelete = new ArrayList<File>();
        try {
            listener.getLogger().printf("Processing artifact: %s\n", warFile);

            if (override != null && (override.getApp() != null || override.getVer() != null)) {
                String app = noramlizeString(override.getApp());
                String ver = noramlizeString(override.getVer());
                warFile = overrideOrCreateXML(new File(warFile.getRemote()), app, ver);
                filestToDelete.add(new File(warFile.getRemote()));
                tempFileCreated = true;
            }

            if (meta != null) {
                warFile = addMetadataIntoArchive(new File(warFile.getRemote()), meta);
                filestToDelete.add(new File(warFile.getRemote()));
                tempFileCreated = true;
            }

            LiveRebelXml lrXml = getLiveRebelXml(warFile);
            ApplicationInfo applicationInfo = getCommandCenter().getApplication(lrXml.getApplicationId());
            uploadIfNeeded(applicationInfo, lrXml.getVersionId(), warFile);
            if (!uploadOnly) {
                update(lrXml, applicationInfo, warFile, deployableServers, contextPath);
                listener.getLogger().printf(ARTIFACT_DEPLOYED_AND_UPDATED, deployableServers, warFile);
            }
            result = true;
        } catch (IllegalArgumentException e) {
            listener.getLogger().println("ERROR!");
            e.printStackTrace(listener.getLogger());
        } catch (Error e) {
            listener.getLogger().println("ERROR! Unexpected error received from server.");
            listener.getLogger().println();
            listener.getLogger().println("URL: " + e.getURL());
            listener.getLogger().println("Status code: " + e.getStatus());
            listener.getLogger().println("Message: " + e.getMessage());
        } catch (ParseException e) {
            listener.getLogger().println("ERROR! Unable to read server response.");
            listener.getLogger().println();
            listener.getLogger().println("Response: " + e.getResponse());
            listener.getLogger().println("Reason: " + e.getMessage());
        } catch (RuntimeException e) {
            if (e.getCause() instanceof ZipException) {
                listener.getLogger().printf(
                        "ERROR! Unable to read artifact (%s). The file you trying to deploy is not an artifact or may be corrupted.\n",
                        warFile);
            } else {
                listener.getLogger().println("ERROR! Unexpected error occured:");
                listener.getLogger().println();
                e.printStackTrace(listener.getLogger());
            }
        } catch (Throwable t) {
            listener.getLogger().println("ERROR! Unexpected error occured:");
            listener.getLogger().println();
            t.printStackTrace(listener.getLogger());
        } finally {
            if (tempFileCreated) {
                for (File file : filestToDelete) {
                    FileUtils.deleteQuietly(file);
                }
            }
        }
        if (!result)
            return result;
    }
    return true;
}

From source file:org.apache.pulsar.broker.service.BrokerService.java

public CompletableFuture<Topic> getTopic(final String topic) {
    try {/*from  ww w  .jav  a 2 s.c  o m*/
        CompletableFuture<Topic> topicFuture = topics.get(topic);
        if (topicFuture != null) {
            if (topicFuture.isCompletedExceptionally()) {
                // Exceptional topics should be recreated.
                topics.remove(topic, topicFuture);
            } else {
                return topicFuture;
            }
        }
        return topics.computeIfAbsent(topic, this::createPersistentTopic);
    } catch (IllegalArgumentException e) {
        log.warn("[{}] Illegalargument exception when loading topic", topic, e);
        return failedFuture(e);
    } catch (RuntimeException e) {
        Throwable cause = e.getCause();
        if (cause instanceof ServiceUnitNotReadyException) {
            log.warn("[{}] Service unit is not ready when loading the topic", topic);
        } else {
            log.warn("[{}] Unexpected exception when loading topic: {}", topic, cause);
        }

        return failedFuture(cause);
    }
}