Example usage for java.lang NullPointerException getMessage

List of usage examples for java.lang NullPointerException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.gbif.harvest.tapir.TapirMetadataHandler.java

/**
 * Load supported namespaces into list.//  ww w. java2s. c o m
 * If there is a problem loading the file, or no match exists for the
 * contentNamespace, list will remain empty
 *
 * @throws HarvesterException thrown if method fails
 */
private void loadSupportedNamespaces() throws HarvesterException {

    Properties mapping = new Properties();
    String mappingFilePath = fileUtils.constructMappingFilePath(BASE_LOCATION, MAPPING_DIRECTORY_NAME,
            CONCEPTUAL_MAPPING_FILENAME);
    InputStream is = null;
    try {
        is = TapirMetadataHandler.class.getResourceAsStream(mappingFilePath);
        mapping.load(is);
        for (Object key : mapping.keySet()) {
            // add content namespace to list of supported namespaces
            supported_namespaces.add((String) key);
        }
    } catch (NullPointerException e) {
        log.info("error.mappingFileExists", new String[] { mappingFilePath, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } catch (IOException e) {
        log.error("tapirmetadatahandler.error.loadSupportedNamespaces", e.getMessage(), e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                log.error(
                        "An error occurred closing input stream on " + mappingFilePath + ": " + e.getMessage(),
                        e);
            }
        }
    }
}

From source file:org.ensembl.healthcheck.DatabaseRegistryEntry.java

/**
 * <p>/*w ww.  j  a v a  2  s  . c om*/
 * Returns information about a database. Queries the meta table to determine
 * the type and schema version of the database.
 * </p>
 * 
 * @param server
 * @param name
 * @return DatabaseInfo
 */
public static DatabaseInfo getInfoFromDatabase(DatabaseServer server, final String name) throws SQLException {
    SqlTemplate template = null;

    try {
        template = new ConnectionBasedSqlTemplateImpl(server.getDatabaseConnection(name));
    } catch (NullPointerException e) {

        // This exception can be thrown, if a database name has hashes in
        // it like this one:
        //
        // #mysql50#jhv_gadus_morhua_57_merged_projection_build.bak
        // or
        // #mysql50#jhv_gadus_morhua_57_ref_1.3_asm_buggy
        //
        // A database like this can exist on a MySql server, but
        // connecting to it will cause a NullPointerException to be
        // thrown.
        //
        logger.warning("Unable to connect to " + name + " on " + server);

        // No info will be available for this database.
        //
        return null;
    }

    DatabaseInfo info = null;

    boolean dbHasAMetaTable = template.queryForDefaultObjectList("show tables like 'meta'", String.class)
            .size() == 1;

    if (dbHasAMetaTable) {

        try {
            List<DatabaseInfo> dbInfos = template.queryForList(

                    // Will return something like ("core", 63)
                    //
                    "select m1.meta_value, m2.meta_value from meta m1 join meta m2 where m1.meta_key='schema_type' and m2.meta_key='schema_version'",

                    new RowMapper<DatabaseInfo>() {

                        public DatabaseInfo mapRow(ResultSet resultSet, int position) throws SQLException {

                            String schemaType = resultSet.getString(1);
                            String schemaVersion = resultSet.getString(2);

                            return new DatabaseInfo(name, null, Species.UNKNOWN,
                                    DatabaseType.resolveAlias(schemaType), schemaVersion, null);
                        }
                    });

            info = CollectionUtils.getFirstElement(dbInfos, info);

        } catch (SqlUncheckedException e) {

            logger.warning("Can't determine database type and version from " + name + " on " + server + ": "
                    + e.getMessage());

            // No info will be available for this database.
            //
            return null;
        } finally {

        }
    }
    return info;
}

From source file:org.gbif.harvest.tapir.TapirMetadataHandler.java

/**
 * Determine the index mapping file./*from w  w w  .  jav a2  s.c o  m*/
 * If there is a problem loading the file, or no match exists for the
 * contentNamespace, the default is used.
 *
 * @param contentNamespace contentNamespace
 *
 * @return mapping file name
 *
 * @throws HarvesterException thrown if method fails
 */
private String getMappingFile(String contentNamespace) throws HarvesterException {

    // Initially, set the mapping file to the default
    String mappingFile = DEFAULT_MAPPING_FILE;

    Properties mapping = new Properties();
    String mappingFilePath = fileUtils.constructMappingFilePath(BASE_LOCATION, MAPPING_DIRECTORY_NAME,
            CONCEPTUAL_MAPPING_FILENAME);
    InputStream is = null;
    try {
        is = TapirMetadataHandler.class.getResourceAsStream(mappingFilePath);
        mapping.load(is);
        for (Object key : mapping.keySet()) {
            // match on contentnamespace determines mapping file
            if (StringUtils.equals(contentNamespace, (String) key)) {
                mappingFile = mapping.getProperty((String) key);
            }
        }
    } catch (NullPointerException e) {
        log.info("error.mappingFileExists", new String[] { mappingFilePath, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } catch (IOException e) {
        log.error("tapirmetadatahandler.error.getMappingFile", e.getMessage(), e);
        log.debug("tapirmetadatahandler.default.getMappingFile", mappingFile);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                log.error(
                        "An error occurred closing input stream on " + mappingFilePath + ": " + e.getMessage(),
                        e);
            }
        }
    }

    return mappingFile;
}

From source file:org.gbif.harvest.tapir.TapirMetadataHandler.java

/**
 * Determine the outputModel from the appropriate mapping file.
 * If there is a problem loading the file, or no match exists for the
 * contentNamespace, the default is used.
 *
 * @param contentNamespace contentNamespace
 *
 * @return mapping file name//from www .ja  va  2s.  com
 *
 * @throws HarvesterException thrown if method fails
 */
private String getOutputModel(String contentNamespace) throws HarvesterException {

    // Initially, set the outputModel to the default
    String outputModel = DEFAULT_OUTPUT_MODEL;

    Properties mapping = new Properties();
    String mappingFilePath = fileUtils.constructMappingFilePath(BASE_LOCATION, MAPPING_DIRECTORY_NAME,
            OUTPUT_MODEL_MAPPING_FILENAME);
    boolean found = false;
    InputStream is = null;
    try {
        is = TapirMetadataHandler.class.getResourceAsStream(mappingFilePath);
        mapping.load(is);
        for (Object key : mapping.keySet()) {
            if (StringUtils.equals(contentNamespace, (String) key)) {
                outputModel = mapping.getProperty((String) key);
                found = true;
            }
        }
        // if not found, alert operator
        if (!found) {
            log.error("digirmetadatahandler.default.outputModelMappingNotFound", contentNamespace);
        }
    } catch (NullPointerException e) {
        log.info("error.mappingFileExists", new String[] { mappingFilePath, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } catch (IOException e) {
        log.error("tapirmetadatahandler.error.getOutputModel", e.getMessage(), e);
        log.debug("tapirmetadatahandler.default.getOutputModel", outputModel);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                log.error(
                        "An error occurred closing input stream on " + mappingFilePath + ": " + e.getMessage(),
                        e);
            }
        }
    }

    return outputModel;
}

From source file:org.apache.lens.cube.parse.TestCubeRewriter.java

@Test
public void testAliasNameSameAsColumnName() throws Exception {
    String query = "SELECT msr2 as msr2 from testCube WHERE " + TWO_DAYS_RANGE;
    try {//from w  w  w. jav a 2s.c om
        String hql = rewrite(query, getConf());
        assertNotNull(hql);
        System.out.println("@@HQL " + hql);
    } catch (NullPointerException npe) {
        fail(npe.getMessage());
        log.error("Not expecting null pointer exception", npe);
    }
}

From source file:org.geoserver.gwc.GWCTest.java

@Test
public void testAddGridset() throws Exception {
    try {//  w w  w . ja  v a 2  s .com
        mediator.addGridSet(null);
        fail();
    } catch (NullPointerException e) {
        assertTrue(true);
    }
    GridSet gset = mock(GridSet.class);
    GridSet gset2 = mock(GridSet.class);
    doThrow(new IOException("fake")).when(tld).addGridSet(same(gset));
    try {
        mediator.addGridSet(gset);
        fail();
    } catch (IOException e) {
        assertEquals("fake", e.getMessage());
    }
    mediator.addGridSet(gset2);
    verify(tld, times(1)).addGridSet(same(gset2));
}

From source file:dentex.youtube.downloader.ShareActivity.java

private void callDownloadManager(String link) {
    videoUri = Uri.parse(path.toURI() + composedVideoFilename);
    Utils.logger("d", "videoUri: " + videoUri, DEBUG_TAG);

    dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    Request request = null;// ww  w  . j ava  2 s . c o m
    try {
        request = new Request(Uri.parse(link));
        request.setDestinationUri(videoUri);
        request.allowScanningByMediaScanner();
        request.setVisibleInDownloadsUi(false);

        String visValue = settings.getString("download_manager_notification", "VISIBLE");
        int vis;
        if (visValue.equals("VISIBLE_NOTIFY_COMPLETED")) {
            vis = DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED;
        } else if (visValue.equals("HIDDEN")) {
            vis = DownloadManager.Request.VISIBILITY_HIDDEN;
        } else {
            vis = DownloadManager.Request.VISIBILITY_VISIBLE;
        }
        request.setNotificationVisibility(vis);
        request.setTitle(videoFilename);
        request.setDescription(getString(R.string.ytd_video));
    } catch (IllegalArgumentException e) {
        Log.e(DEBUG_TAG, "callDownloadManager: " + e.getMessage());
        YTD.NoDownProvPopUp(this);
        BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadManager: ", e.getMessage(), e);
    }

    Intent intent1 = new Intent(ShareActivity.this, DownloadsService.class);
    intent1.putExtra("COPY", false);

    audioExtrEnabled = settings.getBoolean("enable_audio_extraction", false);
    if (audioExtractionEnabled && audioConfirm.isChecked()) {
        intent1.putExtra("AUDIO", extrType);
    } else {
        intent1.putExtra("AUDIO", "none");
    }

    try {
        try {
            enqueue = dm.enqueue(request);
        } catch (IllegalArgumentException e) {
            Log.e(DEBUG_TAG, "callDownloadManager: " + e.getMessage());
            YTD.NoDownProvPopUp(this);
            BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadManager: ", e.getMessage(), e);
        } catch (NullPointerException ne) {
            Log.e(DEBUG_TAG, "callDownloadApk: " + ne.getMessage());
            BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadApk: ", ne.getMessage(), ne);
            Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
        }
        Utils.logger("d", "_ID " + enqueue + " enqueued", DEBUG_TAG);
    } catch (SecurityException e) {
        // handle path on etxSdCard:
        Utils.logger("w", e.getMessage(), DEBUG_TAG);
        showExtsdcardInfo();
        intent1.putExtra("COPY", true);
        videoOnExt = true;
        tempDownloadToSdcard(request);
    }

    startService(intent1);

    settings.edit().putString(String.valueOf(enqueue), composedVideoFilename).apply();

    if (settings.getBoolean("enable_own_notification", true) == true) {
        Utils.logger("i", "enable_own_notification: true", DEBUG_TAG);
        sequence.add(enqueue);
        settings.edit().putLong(composedVideoFilename, enqueue).apply();

        if (videoOnExt == true) {
            videoFileObserver = new Observer.YtdFileObserver(dir_Downloads.getAbsolutePath());
        } else {
            videoFileObserver = new Observer.YtdFileObserver(path.getAbsolutePath());
        }
        videoFileObserver.startWatching();

        //NotificationHelper();
    }
}

From source file:com.becapps.easydownloader.ShareActivity.java

private void callDownloadManager(String link) {
    videoUri = Uri.parse(path.toURI() + composedVideoFilename);
    Utils.logger("d", "videoUri: " + videoUri, DEBUG_TAG);

    dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    Request request = null;//from w w w  .ja v a2s. co  m
    try {
        request = new Request(Uri.parse(link));
        request.setDestinationUri(videoUri);
        request.allowScanningByMediaScanner();
        //request.setVisibleInDownloadsUi(false);

        String visValue = settings.getString("download_manager_notification", "VISIBLE");
        int vis;
        if (visValue.equals("VISIBLE_NOTIFY_COMPLETED")) {
            vis = DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED;
        } else if (visValue.equals("HIDDEN")) {
            vis = DownloadManager.Request.VISIBILITY_HIDDEN;
        } else {
            vis = DownloadManager.Request.VISIBILITY_VISIBLE;
        }
        request.setNotificationVisibility(vis);
        request.setTitle(videoFilename);
        request.setDescription(getString(R.string.ytd_video));
    } catch (IllegalArgumentException e) {
        Log.e(DEBUG_TAG, "callDownloadManager: " + e.getMessage());
        YTD.NoDownProvPopUp(this);
        BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadManager: ", e.getMessage(), e);
    }

    Intent intent1 = new Intent(ShareActivity.this, DownloadsService.class);
    intent1.putExtra("COPY", false);

    audioExtrEnabled = settings.getBoolean("enable_audio_extraction", false);
    if (audioExtractionEnabled && (audioConfirm.isChecked() && audioConfirm != null)) {
        intent1.putExtra("AUDIO", extrType);
    } else {
        intent1.putExtra("AUDIO", "none");
    }

    try {
        try {
            enqueue = dm.enqueue(request);
        } catch (IllegalArgumentException e) {
            Log.e(DEBUG_TAG, "callDownloadManager: " + e.getMessage());
            YTD.NoDownProvPopUp(this);
            BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadManager: ", e.getMessage(), e);
        } catch (NullPointerException ne) {
            Log.e(DEBUG_TAG, "callDownloadApk: " + ne.getMessage());
            BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadApk: ", ne.getMessage(), ne);
            Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
        }
        Utils.logger("d", "_ID " + enqueue + " enqueued", DEBUG_TAG);
    } catch (SecurityException e) {
        // handle path on etxSdCard:
        Utils.logger("w", e.getMessage(), DEBUG_TAG);
        showExtsdcardInfo();
        intent1.putExtra("COPY", true);
        videoOnExt = true;
        tempDownloadToSdcard(request);
    }

    startService(intent1);

    settings.edit().putString(String.valueOf(enqueue), composedVideoFilename).apply();

    if (settings.getBoolean("enable_own_notification", true) == true) {
        Utils.logger("i", "enable_own_notification: true", DEBUG_TAG);
        sequence.add(enqueue);
        settings.edit().putLong(composedVideoFilename, enqueue).apply();

        if (videoOnExt == true) {
            videoFileObserver = new Observer.YtdFileObserver(dir_Downloads.getAbsolutePath());
        } else {
            videoFileObserver = new Observer.YtdFileObserver(path.getAbsolutePath());
        }
        videoFileObserver.startWatching();

        //NotificationHelper();
    }
}

From source file:org.gbif.harvest.tapir.TapirMetadataHandler.java

/**
 * Iterates over the metadata mapping file (properties file), populating the
 * various elements-of-interest maps.//from www .j  a va 2s.  c o m
 * In most cases, regular expressions divide the mapping file's properties
 * into the appropriate element-of-interest map.
 * Where some properties actually represent repeating elements in a metadata
 * xml response, the standardised set of repeating element names are
 * located in a static list. Each repeating element name matches a key name
 * in the indexMapping properties file and is used to get at its XPath
 * expression.
 * Note: The mapping file's properties are in the following format:
 * [element-of-interest categoriser] + [property name] = [XPath expresson]
 * The regular expression matches according to the [element-of-interest
 * categoriser]
 * The corresponding element-of-interest map is then populated with: key =
 * [property name] & value = [XPath expression]
 *
 * @param mappingFile name
 * @param protocol    name
 *
 * @throws HarvesterException thrown if method fails
 */
private void populateElementOfInterestsMapsFromMappingFile(String mappingFile, String protocol)
        throws HarvesterException {

    // Create regex patterns
    // contact-related patterns
    Pattern relatedEntityKeyPattern = Pattern.compile("relatedEntity([\\S]*)");
    Pattern hasContactKeyPattern = Pattern.compile("hasContact([\\S]*)");

    // non-contact, metadata related pattern
    Pattern metadataKeyPattern = Pattern.compile("metadata([\\S]*)");

    // non-contact, non-metadata, settings related pattern
    Pattern settingKeyPattern = Pattern.compile("setting([\\S]*)");

    // properties we harvest are read from file
    Properties mapping = new Properties();
    String mappingFilePath = fileUtils.constructMappingFilePath(BASE_LOCATION, protocol, MAPPING_DIRECTORY_NAME,
            mappingFile);
    InputStream is = null;
    try {
        is = TapirMetadataHandler.class.getResourceAsStream(mappingFilePath);
        mapping.load(is);

        // Divide the mapping properties into various element-of-interest maps
        for (Object key : mapping.keySet()) {
            Boolean matched = false;
            // Matchers matching keys belonging to repeating element groups
            Matcher relatedEntityKeyMatcher = relatedEntityKeyPattern.matcher((String) key);

            if (relatedEntityKeyMatcher.matches()) {
                String property = relatedEntityKeyMatcher.group(1);
                harvestedRelatedEntityElementsOfInterest.put(property, mapping.getProperty((String) key));
                matched = true;
            }
            if (!matched) {
                Matcher hasContactKeyMatcher = hasContactKeyPattern.matcher((String) key);
                if (hasContactKeyMatcher.matches()) {
                    String property = hasContactKeyMatcher.group(1);
                    harvestedHasContactElementsOfInterest.put(property, mapping.getProperty((String) key));
                    matched = true;
                }
                if (!matched) {
                    Matcher contactKeyMatcher = metadataKeyPattern.matcher((String) key);
                    if (contactKeyMatcher.matches()) {
                        String property = contactKeyMatcher.group(1);
                        metadataElementsOfInterest.put(property, mapping.getProperty((String) key));
                        matched = true;
                    }
                    if (!matched) {
                        Matcher settingKeyMatcher = settingKeyPattern.matcher((String) key);
                        if (settingKeyMatcher.matches()) {
                            String property = settingKeyMatcher.group(1);
                            settingsElementsOfInterest.put(property, mapping.getProperty((String) key));
                            matched = true;
                        }
                        if (!matched) {
                            // Determines the XPath expressions used to isolate repeating elements in a
                            // metadata xml response.
                            if (metadataRepeatingElementsXpath.keySet().contains(key)) {
                                // construct an XPath expression for repeating Element
                                DefaultXPath xpath = new DefaultXPath(mapping.getProperty((String) key));
                                xpath.setNamespaceURIs(namespaceMap);
                                metadataRepeatingElementsXpath.put((String) key, xpath);
                            }
                        }
                    }
                }
            }
        }
    } catch (NullPointerException e) {
        log.info("error.mappingFileExists", new String[] { mappingFilePath, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } catch (Exception e) {
        log.error("error.populateElementOfInterestsMapsFromMappingFile",
                new String[] { mappingFile, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                log.error(
                        "An error occurred closing input stream on " + mappingFilePath + ": " + e.getMessage(),
                        e);
            }
        }
    }
}

From source file:com.openbravo.pos.sales.restaurant.JRetailTicketsBagRestaurantMap.java

public int getTableCovers(String tableId, String splitId) {
    int noOfCovers = 0;
    try {/*from  w  w  w.  j a  va2s . co m*/
        try {
            noOfCovers = dlReceipts.getTableCovers(tableId, splitId);
        } catch (NullPointerException ex) {
            noOfCovers = 2;
        }
    } catch (BasicException ex) {
        logger.info("getTableCovers in map class exception " + ex.getMessage());
        Logger.getLogger(JTableCover.class.getName()).log(Level.SEVERE, null, ex);
    }

    return noOfCovers;
}