Example usage for java.lang NumberFormatException getMessage

List of usage examples for java.lang NumberFormatException getMessage

Introduction

In this page you can find the example usage for java.lang NumberFormatException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.mirth.connect.connectors.smtp.SmtpSenderService.java

@Override
public Object invoke(String channelId, String method, Object object, String sessionId) throws Exception {
    if (method.equals("sendTestEmail")) {
        SmtpDispatcherProperties props = (SmtpDispatcherProperties) object;

        String host = replacer.replaceValues(props.getSmtpHost(), channelId);
        String portString = replacer.replaceValues(props.getSmtpPort(), channelId);

        int port = -1;
        try {/*from   w  w w  .  j  a v a  2  s  . c  om*/
            port = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
            return new ConnectionTestResponse(ConnectionTestResponse.Type.FAILURE,
                    "Invalid port: \"" + portString + "\"");
        }

        String secure = props.getEncryption();

        boolean authentication = props.isAuthentication();

        String username = replacer.replaceValues(props.getUsername(), channelId);
        String password = replacer.replaceValues(props.getPassword(), channelId);
        String to = replacer.replaceValues(props.getTo(), channelId);
        String from = replacer.replaceValues(props.getFrom(), channelId);

        Email email = new SimpleEmail();
        email.setDebug(true);
        email.setHostName(host);
        email.setSmtpPort(port);

        if ("SSL".equalsIgnoreCase(secure)) {
            email.setSSL(true);
        } else if ("TLS".equalsIgnoreCase(secure)) {
            email.setTLS(true);
        }

        if (authentication) {
            email.setAuthentication(username, password);
        }

        email.setSubject("Mirth Connect Test Email");

        try {
            for (String toAddress : StringUtils.split(to, ",")) {
                email.addTo(toAddress);
            }

            email.setFrom(from);
            email.setMsg(
                    "Receipt of this email confirms that mail originating from this Mirth Connect Server is capable of reaching its intended destination.\n\nSMTP Configuration:\n- Host: "
                            + host + "\n- Port: " + port);

            email.send();
            return new ConnectionTestResponse(ConnectionTestResponse.Type.SUCCESS,
                    "Sucessfully sent test email to: " + to);
        } catch (EmailException e) {
            return new ConnectionTestResponse(ConnectionTestResponse.Type.FAILURE, e.getMessage());
        }
    }

    return null;
}

From source file:com.ephesoft.gxt.systemconfig.server.SystemConfigServiceImpl.java

private PluginDetailsDTO updatePlugin(PluginDetailsDTO pluginDetailsDTO) {
    PluginService pluginService = this.getSingleBeanOfType(PluginService.class);
    String pluginIdentifier = pluginDetailsDTO.getIdentifier();
    LOGGER.info("Updating the plugin object with id: " + pluginIdentifier);

    try {//  w  w w  .j  a  va  2s  .co  m
        Long pluginId = Long.valueOf(pluginIdentifier);
        Plugin plugin = pluginService.getPluginPropertiesForPluginId(pluginId);
        LOGGER.info("Merging the changes in plugin.");
        BatchClassUtil.mergePluginFromDTO(plugin, pluginDetailsDTO, pluginService);
        LOGGER.info("updating plugin");
        pluginService.mergePlugin(plugin);
        pluginDetailsDTO = BatchClassUtil.createPluginDetailsDTO(plugin, pluginService);
    } catch (NumberFormatException e) {
        LOGGER.error("Error converting number " + e.getMessage(), e);
    }
    return pluginDetailsDTO;
}

From source file:com.ephesoft.gxt.systemconfig.server.SystemConfigServiceImpl.java

private ConnectionsDTO createNewConnection(ConnectionsDTO connectionDTO) {
    ConnectionsService connectionsService = this.getSingleBeanOfType(ConnectionsService.class);
    String connectionsIdentifier = connectionDTO.getIdentifier();
    LOGGER.info("Updating the connection object with id: " + connectionsIdentifier);

    try {//from   w  w  w .  j  av  a 2 s .c  om
        Connections connection = new Connections();
        LOGGER.info("Merging the changes in connection.");
        String encryptPassword = EphesoftEncryptionUtil.getEncryptedPasswordString(connectionDTO.getPassword());
        connectionDTO.setPassword(encryptPassword);
        BatchClassUtil.mergeConnectionFromDTO(connection, connectionDTO);
        LOGGER.info("updating connection");
        connectionsService.mergeConnection(connection);
        connectionDTO = BatchClassUtil.createConnectionDTO(connection);
        connectionDTO.setDecryptedPassword(EphesoftEncryptionUtil.getDecryptedPasswordString(encryptPassword));
    } catch (NumberFormatException e) {
        LOGGER.error("Error converting number " + e.getMessage(), e);
    }
    return connectionDTO;
}

From source file:com.ephesoft.gxt.systemconfig.server.SystemConfigServiceImpl.java

private ConnectionsDTO updateConnection(ConnectionsDTO connectionDTO) {
    ConnectionsService connectionsService = this.getSingleBeanOfType(ConnectionsService.class);
    String connectionsIdentifier = connectionDTO.getIdentifier();
    LOGGER.info("Updating the connection object with id: " + connectionsIdentifier);

    try {/* ww w . ja  v  a 2s  .  co m*/
        Long connectionId = Long.valueOf(connectionsIdentifier);
        Connections connection = connectionsService.getConnectionForId(connectionId);
        LOGGER.info("Merging the changes in connection.");
        String encryptPassword = null;
        if (!EphesoftEncryptionUtil.isPasswordStringEncrypted(connectionDTO.getPassword())) {
            encryptPassword = EphesoftEncryptionUtil.getEncryptedPasswordString(connectionDTO.getPassword());
            connectionDTO.setPassword(encryptPassword);
        } else {
            encryptPassword = connectionDTO.getPassword();
        }
        BatchClassUtil.mergeConnectionFromDTO(connection, connectionDTO);
        LOGGER.info("updating connection");
        connectionsService.mergeConnection(connection);
        connectionDTO = BatchClassUtil.createConnectionDTO(connection);
        connectionDTO.setDecryptedPassword(EphesoftEncryptionUtil.getDecryptedPasswordString(encryptPassword));
    } catch (NumberFormatException e) {
        LOGGER.error("Error converting number " + e.getMessage(), e);
    }
    return connectionDTO;
}

From source file:ml.shifu.shifu.core.processor.TrainModelProcessor.java

private List<Double> readAllValidationErrors(SourceType sourceType, FileSystem fileSystem, int k)
        throws IOException {
    List<Double> valErrs = new ArrayList<Double>();
    for (int i = 0; i < k; i++) {
        Path valErrPath = fileSystem
                .makeQualified(new Path(super.getPathFinder().getValErrorPath(sourceType), "val_error_" + i));
        if (ShifuFileUtils.isFileExists(valErrPath.toString(), sourceType)) {
            double valErr;
            BufferedReader reader = null;
            try {
                reader = ShifuFileUtils.getReader(valErrPath.toString(), sourceType);
                String line = reader.readLine();
                if (line == null) {
                    continue;
                }//from   ww w  .j a va2s .c o m
                String valErrStr = line.toString();
                LOG.debug("valErrStr is {}", valErrStr);
                valErr = Double.valueOf(valErrStr);
                valErrs.add(valErr);
            } catch (NumberFormatException e) {
                LOG.warn("Parse val error failed, ignore such error. Message: {}", e.getMessage());
                continue;
            } finally {
                if (reader != null) {
                    reader.close();
                }
            }
        }
    }
    return valErrs;
}

From source file:ml.shifu.shifu.core.processor.TrainModelProcessor.java

private Map<String, Object> findBestParams(SourceType sourceType, FileSystem fileSystem, GridSearch gs)
        throws IOException {
    // read validation error and find the best one update ModelConfig.
    double minValErr = Double.MAX_VALUE;
    int minIndex = -1;
    for (int i = 0; i < gs.getFlattenParams().size(); i++) {
        Path valErrPath = fileSystem
                .makeQualified(new Path(super.getPathFinder().getValErrorPath(sourceType), "val_error_" + i));
        if (ShifuFileUtils.isFileExists(valErrPath.toString(), sourceType)) {
            double valErr;
            BufferedReader reader = null;
            try {
                reader = ShifuFileUtils.getReader(valErrPath.toString(), sourceType);
                String line = reader.readLine();
                if (line == null) {
                    continue;
                }//from w  w  w. j a  v  a 2s  .  c  o  m
                String valErrStr = line.toString();
                LOG.debug("valErrStr is {}", valErrStr);
                valErr = Double.valueOf(valErrStr);
            } catch (NumberFormatException e) {
                LOG.warn("Parse val error failed, ignore such error. Message: {}", e.getMessage());
                continue;
            } finally {
                if (reader != null) {
                    reader.close();
                }
            }
            if (valErr < minValErr) {
                minValErr = valErr;
                minIndex = i;
            }
        }
    }
    Map<String, Object> params = gs.getParams(minIndex);
    LOG.info(
            "The {} params is selected by grid search with params {}, please use it and set it in ModelConfig.json.",
            minIndex, params);
    return params;
}

From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelImportServiceImpl.java

private Integer parseId(CellValueHolder id) {
    try {/* ww w. j  a v  a 2  s.com*/
        return Integer.valueOf((int) Double.parseDouble(id.getAttributeValue()));

    } catch (NumberFormatException e) {
        getProcessingLog().debug("[{0}] Could not understand Id {1}", id.getCellRef(), id.getAttributeValue());
        LOGGER.error(e.getMessage(), e);
        return null;
    }
}

From source file:com.balakrish.gpstracker.WaypointsListActivity.java

/**
 * Update waypoint in the database/*www .  j av a2s  .c  om*/
 * 
 * @param waypointId
 * @param title
 * @param lat
 * @param lng
 */
protected void updateWaypoint(long waypointId) {

    Context context = this;

    // get waypoint data from db
    final Waypoint wp = Waypoints.get(app.getDatabase(), waypointId);

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.add_waypoint_dialog,
            (ViewGroup) findViewById(R.id.add_waypoint_dialog_layout_root));

    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    builder.setTitle(R.string.edit);
    builder.setView(layout);

    // creating reference to input field in order to use it in onClick
    // handler
    final EditText wpTitle = (EditText) layout.findViewById(R.id.waypointTitleInputText);
    wpTitle.setText(wp.getTitle());

    final EditText wpDescr = (EditText) layout.findViewById(R.id.waypointDescriptionInputText);
    wpDescr.setText(wp.getDescr());

    final EditText wpLat = (EditText) layout.findViewById(R.id.waypointLatInputText);
    wpLat.setText(Double.toString(wp.getLat()));

    final EditText wpLng = (EditText) layout.findViewById(R.id.waypointLngInputText);
    wpLng.setText(Double.toString(wp.getLng()));

    // this event will be overridden in OnShowListener for validation
    builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

    final AlertDialog dialog = builder.create();

    // override setOnShowListener in order to validate dialog without closing it
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {

            Button b = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {

                    // waypoint title from input dialog

                    if (wpTitle.getText().toString().trim().equals("")) {
                        Toast.makeText(WaypointsListActivity.this, R.string.waypoint_title_required,
                                Toast.LENGTH_SHORT).show();
                        return;
                    }

                    wp.setTitle(wpTitle.getText().toString().trim());
                    wp.setDescr(wpDescr.getText().toString().trim());

                    // validate coordinates
                    try {
                        wp.setLat(Double.parseDouble(wpLat.getText().toString()));
                        wp.setLng(Double.parseDouble(wpLng.getText().toString()));
                    } catch (NumberFormatException e) {
                        Toast.makeText(WaypointsListActivity.this, R.string.incorrect_coordinates,
                                Toast.LENGTH_SHORT).show();
                        return;
                    }

                    try {

                        // update waypoint data in db
                        Waypoints.update(app.getDatabase(), wp);

                        Toast.makeText(WaypointsListActivity.this, R.string.waypoint_updated,
                                Toast.LENGTH_SHORT).show();

                        // cursor.requery();
                        updateWaypointsArray();
                        waypointsArrayAdapter.setItems(waypoints);
                        waypointsArrayAdapter.notifyDataSetChanged();

                    } catch (SQLiteException e) {
                        AppLog.e(WaypointsListActivity.this, "SQLiteException: " + e.getMessage());
                        return;
                    }

                    dialog.dismiss();

                }
            });
        }
    });

    dialog.show();

}

From source file:com.ephesoft.gxt.systemconfig.server.SystemConfigServiceImpl.java

@Override
public ConnectionsResult removeSelectedConnection(List<ConnectionsDTO> selectedConnection) {
    Results returnValue = Results.FAILURE;
    int failedDeletions = 0;
    int totalDeletions = 0;
    ConnectionsService connectionsService = this.getSingleBeanOfType(ConnectionsService.class);
    List<ConnectionsDTO> allConnections = null;
    ConnectionsResult connectionsResult = new ConnectionsResult();
    try {/*from w ww  .j ava  2  s.c  o m*/
        if (!CollectionUtil.isEmpty(selectedConnection)) {
            totalDeletions = selectedConnection.size();
            for (ConnectionsDTO connectionDTO : selectedConnection) {
                final String identifier = connectionDTO.getIdentifier();
                if (!StringUtil.isNullOrEmpty(identifier)) {
                    long id = Long.valueOf(connectionDTO.getIdentifier());
                    Connections connection = connectionsService.getConnectionForId(id);
                    if (null != connection) {
                        boolean isConnectionInUse = connectionsService.isConnectionInUse(connection.getId());
                        if (!isConnectionInUse) {
                            connection.setDeleted(true);
                            connectionsService.mergeConnection(connection);
                        } else {
                            failedDeletions++;
                        }
                    }
                }
            }
        }
        if (failedDeletions == totalDeletions) {
            returnValue = Results.FAILURE;
        } else if (failedDeletions == 0) {
            returnValue = Results.SUCCESSFUL;
        } else {
            returnValue = Results.PARTIAL_SUCCESS;
        }
        allConnections = getAllConnectionsDTO();
        connectionsResult.setAllConnections(allConnections);
        connectionsResult.setConnectionResult(returnValue);
    } catch (NumberFormatException noFormatException) {
        LOGGER.error(StringUtil.concatenate("Error converting id into long ", noFormatException.getMessage()));
    }
    return connectionsResult;
}

From source file:com.flexive.ejb.mbeans.FxCache.java

/**
 * {@inheritDoc}/*from w ww .  j av  a2s  .co  m*/
 */
@Override
@SuppressWarnings("unchecked")
public synchronized void create() throws Exception {
    if (server != null)
        return;

    //switch to UTF-8 encoding
    if (!"UTF-8".equals(System.getProperty("file.encoding"))) {
        // set default charset to UTF-8
        LOG.warn("Changing system character encoding from " + System.getProperty("file.encoding")
                + " to UTF-8.");
        System.setProperty("file.encoding", "UTF-8");
    }
    //start streamserver
    try {
        int port = DEFAULT_STREAMING_PORT;
        if (System.getProperty(STREAMING_PORT_PROPERTY) != null) {
            String _port = System.getProperty(STREAMING_PORT_PROPERTY);
            try {
                port = Integer.parseInt(_port);
            } catch (NumberFormatException e) {
                //ignore port
                LOG.error("Invalid streaming server port provided: [" + _port + "], using default port [" + port
                        + "]");
            }
        }
        server = new StreamServer(FxStreamUtils.probeNetworkInterfaces(), port);
        server.addProtocol(new BinaryUploadProtocol());
        server.addProtocol(new BinaryDownloadProtocol());
        server.start();

        // update streaming server list in shared cache.
        // NOTE! Since we are operating directly on the backing cache, we have to do the actions
        // provided by FxCacheProxy (mapping paths, serializing values) manually

        final List<ServerLocation> servers = getCachedServerList();
        serverLocation = new ServerLocation(server.getAddress().getAddress(), server.getPort());
        if ((serverLocation.getAddress().isLinkLocalAddress() || serverLocation.getAddress().isAnyLocalAddress()
                || serverLocation.getAddress().isLoopbackAddress()))
            FxStreamUtils.addLocalServer(serverLocation);
        else if (!servers.contains(serverLocation)) //only add if not contained already and not bound to a local address
            servers.add(serverLocation);
        updateCachedServerList(servers);

        LOG.info("Added " + serverLocation + " to available StreamServers (" + servers.size()
                + " total) for cache " + getBackingCache().toString());
    } catch (Exception e) {
        LOG.error("Failed to start StreamServer. Error: " + e.getMessage(), e);
    }
}