Example usage for org.apache.commons.lang3.math NumberUtils toInt

List of usage examples for org.apache.commons.lang3.math NumberUtils toInt

Introduction

In this page you can find the example usage for org.apache.commons.lang3.math NumberUtils toInt.

Prototype

public static int toInt(final String str) 

Source Link

Document

Convert a String to an int, returning zero if the conversion fails.

If the string is null, zero is returned.

 NumberUtils.toInt(null) = 0 NumberUtils.toInt("")   = 0 NumberUtils.toInt("1")  = 1 

Usage

From source file:com.blackducksoftware.integration.hub.bamboo.tasks.HubScanTask.java

@Override
public TaskResult execute(final TaskContext taskContext) throws TaskException {
    final TaskResultBuilder resultBuilder = TaskResultBuilder.newBuilder(taskContext).success();
    TaskResult result;/*from www .  j  a va2s . c o m*/
    final HubBambooLogger logger = new HubBambooLogger(taskContext.getBuildLogger());
    final Map<String, String> envVars = HubBambooUtils.getInstance().getEnvironmentVariablesMap(
            environmentVariableAccessor.getEnvironment(),
            environmentVariableAccessor.getEnvironment(taskContext));

    final CIEnvironmentVariables commonEnvVars = new CIEnvironmentVariables();
    commonEnvVars.putAll(envVars);
    logger.setLogLevel(commonEnvVars);
    try {
        final HubBambooPluginHelper pluginHelper = new HubBambooPluginHelper(pluginAccessor);
        logger.alwaysLog("Initializing - Hub Bamboo Plugin : " + pluginHelper.getPluginVersion());
        final ConfigurationMap taskConfigMap = taskContext.getConfigurationMap();
        final HubServerConfig hubConfig = getHubServerConfig(logger);
        if (hubConfig == null) {
            logger.error("Please verify the correct dependent Hub configuration plugin is installed");
            logger.error("Please verify the configuration is correct if the plugin is installed.");
            result = resultBuilder.failedWithError().build();
            logTaskResult(logger, result);
            return result;
        }
        hubConfig.print(logger);

        final RestConnection restConnection = new CredentialsRestConnection(hubConfig);

        restConnection.connect();

        final HubServicesFactory services = new HubServicesFactory(restConnection);
        final MetaService metaService = services.createMetaService(logger);
        final CLIDataService cliDataService = services.createCLIDataService(logger);
        final File toolsDir = new File(HubBambooUtils.getInstance().getBambooHome(), CLI_FOLDER_NAME);

        final String thirdPartyVersion = BuildUtils.getCurrentVersion();
        final String pluginVersion = pluginHelper.getPluginVersion();
        final String shouldGenerateRiskReport = taskConfigMap
                .get(HubScanConfigFieldEnum.GENERATE_RISK_REPORT.getKey());
        final String maxWaitTimeForRiskReport = taskConfigMap
                .get(HubScanConfigFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE.getKey());
        boolean isRiskReportGenerated = false;
        long waitTimeForReport = DEFAULT_MAX_WAIT_TIME_MILLISEC;

        if (StringUtils.isNotBlank(shouldGenerateRiskReport)) {
            isRiskReportGenerated = Boolean.valueOf(shouldGenerateRiskReport);
        }

        if (StringUtils.isNotBlank(maxWaitTimeForRiskReport)) {
            waitTimeForReport = NumberUtils.toInt(maxWaitTimeForRiskReport);
            if (waitTimeForReport == 0) {
                // 5 minutes is the default
                waitTimeForReport = 5 * 60 * 1000;
            } else {
                waitTimeForReport = waitTimeForReport * 60 * 1000;
            }
        } else {
            waitTimeForReport = 5 * 60 * 1000;
        }
        final HubScanConfig hubScanConfig = getScanConfig(taskConfigMap, taskContext.getWorkingDirectory(),
                toolsDir, thirdPartyVersion, pluginVersion, logger);
        if (hubScanConfig == null) {
            result = resultBuilder.failedWithError().build();
            logTaskResult(logger, result);
            return result;
        }

        final boolean isFailOnPolicySelected = taskConfigMap
                .getAsBoolean(HubScanConfigFieldEnum.FAIL_ON_POLICY_VIOLATION.getKey());

        List<ScanSummaryItem> scanSummaryList = null;
        try {
            scanSummaryList = cliDataService.installAndRunScan(hubConfig, hubScanConfig);

        } catch (final ScanFailedException e) {
            if (resultBuilder.getTaskState() != TaskState.SUCCESS) {
                logger.error("Hub Scan Failed : " + e.getMessage());
                result = resultBuilder.build();
                logTaskResult(logger, result);
                return result;
            }
        }
        if (!hubScanConfig.isDryRun()) {
            final ProjectVersionItem version = getProjectVersionFromScanStatus(
                    services.createCodeLocationRequestService(),
                    services.createProjectVersionRequestService(logger), metaService, scanSummaryList.get(0));

            if (isRiskReportGenerated || isFailOnPolicySelected) {
                services.createScanStatusDataService(logger, waitTimeForReport)
                        .assertBomImportScansFinished(scanSummaryList);
            }
            if (isRiskReportGenerated) {
                final SecureToken token = SecureToken.createFromString(
                        taskContext.getRuntimeTaskContext().get(HubBambooUtils.HUB_TASK_SECURE_TOKEN));
                publishRiskReportFiles(logger, taskContext, token,
                        services.createRiskReportDataService(logger, waitTimeForReport), version);
            }
            if (isFailOnPolicySelected) {
                final TaskResultBuilder policyResult = checkPolicyFailures(resultBuilder, taskContext, logger,
                        services, metaService, version, hubScanConfig.isDryRun());

                result = policyResult.build();
            }
        } else {
            if (isRiskReportGenerated) {
                logger.warn("Will not generate the risk report because this was a dry run scan.");
            }
            if (isFailOnPolicySelected) {
                logger.warn("Will not run the Failure conditions because this was a dry run scan.");
            }
        }
    } catch (final Exception e) {
        logger.error(HUB_SCAN_TASK_ERROR, e);
        result = resultBuilder.failedWithError().build();
    }

    result = resultBuilder.build();
    logTaskResult(logger, result);
    return result;
}

From source file:com.norconex.collector.http.recrawl.impl.GenericRecrawlableResolver.java

private boolean isRecrawlableFromMinFrequencies(MinFrequency f, PreviousCrawlData prevData) {
    String value = f.getValue();// w  w  w  .  j a  v  a  2s.  co m
    if (StringUtils.isBlank(value)) {
        return true;
    }

    if (NumberUtils.isDigits(value)) {
        DateTime minCrawlDate = new DateTime(prevData.getCrawlDate());
        int millis = NumberUtils.toInt(value);
        minCrawlDate = minCrawlDate.plusMillis(millis);
        if (minCrawlDate.isBeforeNow()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Recrawl suggested according to custom " + "directive (min frequency < elapsed "
                        + "time since " + prevData.getCrawlDate() + ") for: " + prevData.getReference());
            }
            return true;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("No recrawl suggested according to custom "
                    + "directive (min frequency >= elapsed time since " + prevData.getCrawlDate() + ") for: "
                    + prevData.getReference());
        }
        return false;
    }

    SitemapChangeFrequency cf = SitemapChangeFrequency.getChangeFrequency(f.getValue());
    return isRecrawlableFromFrequency(cf, prevData, "custom");
}

From source file:com.mirth.connect.plugins.datapruner.DefaultDataPrunerController.java

private void applyPrunerSettings(Properties properties) {
    if (StringUtils.isNotEmpty(properties.getProperty("pruningBlockSize"))) {
        int blockSize = NumberUtils.toInt(properties.getProperty("pruningBlockSize"));
        if (blockSize < MIN_PRUNING_BLOCK_SIZE) {
            blockSize = MIN_PRUNING_BLOCK_SIZE;
        } else if (blockSize > MAX_PRUNING_BLOCK_SIZE) {
            blockSize = DataPruner.DEFAULT_PRUNING_BLOCK_SIZE;
        }//from   ww  w  .  j  a  va2 s  .c  om
        pruner.setPrunerBlockSize(blockSize);
    } else {
        pruner.setPrunerBlockSize(DataPruner.DEFAULT_PRUNING_BLOCK_SIZE);
    }

    isEnabled = Boolean.parseBoolean(properties.getProperty("enabled"));
    if (properties.containsKey("pollingProperties")) {
        pruner.setPollingProperties(serializer.deserialize(properties.getProperty("pollingProperties"),
                PollConnectorProperties.class));
    } else {
        PollConnectorProperties defaultProperties = new PollConnectorProperties();
        defaultProperties.setPollingFrequency(3600000);
        pruner.setPollingProperties(defaultProperties);
    }

    pruner.setArchiveEnabled(
            Boolean.parseBoolean(properties.getProperty("archiveEnabled", Boolean.FALSE.toString())));

    if (pruner.isArchiveEnabled()) {
        if (properties.contains("archiverOptions")) {
            pruner.setArchiverOptions(new MessageWriterOptions());
        } else {
            pruner.setArchiverOptions(serializer.deserialize(properties.getProperty("archiverOptions"),
                    MessageWriterOptions.class));
        }
    }

    if (Boolean.parseBoolean(properties.getProperty("pruneEvents", Boolean.FALSE.toString()))) {
        pruner.setPruneEvents(true);
        pruner.setMaxEventAge(Integer.parseInt(properties.getProperty("maxEventAge")));
    } else {
        pruner.setPruneEvents(false);
        pruner.setMaxEventAge(null);
    }

    if (StringUtils.isNotEmpty(properties.getProperty("archiverBlockSize"))) {
        int blockSize = NumberUtils.toInt(properties.getProperty("archiverBlockSize"));
        if (blockSize <= 0 || blockSize > MAX_ARCHIVING_BLOCK_SIZE) {
            blockSize = DataPruner.DEFAULT_ARCHIVING_BLOCK_SIZE;
        }
        pruner.setArchiverBlockSize(blockSize);
    } else {
        pruner.setArchiverBlockSize(DataPruner.DEFAULT_ARCHIVING_BLOCK_SIZE);
    }
}

From source file:com.blackducksoftware.integration.hub.builder.HubScanJobConfigBuilder.java

private void validateMaxWaitTimeForBomUpdate(
        final ValidationResults<HubScanJobFieldEnum, HubScanJobConfig> result,
        final Integer defaultMaxWaitTime) {
    if (dryRun) {
        result.addResult(HubScanJobFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE,
                new ValidationResult(ValidationResultEnum.OK, ""));
    } else {/*ww  w  . j  av  a 2s .com*/
        if (shouldUseDefaultValues() && defaultMaxWaitTime != null) {
            final int maxWaitTime = NumberUtils.toInt(maxWaitTimeForBomUpdate);
            if (maxWaitTime <= 0) {
                maxWaitTimeForBomUpdate = String.valueOf(defaultMaxWaitTime);
            }
            return;
        }
        if (StringUtils.isBlank(maxWaitTimeForBomUpdate)) {
            result.addResult(HubScanJobFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE, new ValidationResult(
                    ValidationResultEnum.ERROR, "No maximum wait time for the Bom Update found."));
            return;
        }
        int maxWaitTime = -1;
        try {
            maxWaitTime = stringToInteger(maxWaitTimeForBomUpdate);
        } catch (final IllegalArgumentException e) {
            result.addResult(HubScanJobFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE,
                    new ValidationResult(ValidationResultEnum.ERROR, e.getMessage(), e));
            return;
        }
        if (maxWaitTime <= 0) {
            result.addResult(HubScanJobFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE,
                    new ValidationResult(ValidationResultEnum.ERROR,
                            "The maximum wait time for the BOM Update must be greater than 0."));
        } else if (maxWaitTime < 2) {
            result.addResult(HubScanJobFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE,
                    new ValidationResult(ValidationResultEnum.WARN, "This wait time may be too short."));
        } else {
            result.addResult(HubScanJobFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE,
                    new ValidationResult(ValidationResultEnum.OK, ""));
        }
    }
}

From source file:com.netsteadfast.greenstep.bsc.service.logic.impl.StrategyMapLogicServiceImpl.java

@SuppressWarnings("unchecked")
private void saveNodesAndConnections(StrategyMapVO strategyMap, Map<String, Object> jsonData)
        throws ServiceException, Exception {

    List<Map<String, Object>> connections = (List<Map<String, Object>>) jsonData.get("connections");
    List<Map<String, Object>> nodes = (List<Map<String, Object>>) jsonData.get("nodes");

    for (int i = 0; connections != null && i < connections.size(); i++) {
        Map<String, Object> data = connections.get(i);
        String connectionId = (String) data.get("connectionId");
        String sourceId = (String) data.get("sourceId");
        String targetId = (String) data.get("targetId");
        if (StringUtils.isBlank(connectionId) || StringUtils.isBlank(sourceId)
                || StringUtils.isBlank(targetId)) {
            continue;
        }//from w  ww  .j a  va  2 s .co  m
        StrategyMapConnsVO mapConns = new StrategyMapConnsVO();
        mapConns.setMasterOid(strategyMap.getOid());
        mapConns.setConnectionId(connectionId);
        mapConns.setSourceId(sourceId);
        mapConns.setTargetId(targetId);
        this.strategyMapConnsService.saveIgnoreUK(mapConns);
    }

    for (int i = 0; nodes != null && i < nodes.size(); i++) {
        Map<String, Object> data = nodes.get(i);
        String id = (String) data.get("id");
        String text = (String) data.get("text");
        String positionX = String.valueOf(data.get("positionX"));
        String positionY = String.valueOf(data.get("positionY"));
        if (StringUtils.isBlank(id) || StringUtils.isBlank(text) || !NumberUtils.isNumber(positionX)
                || !NumberUtils.isNumber(positionY)) {
            continue;
        }
        StrategyMapNodesVO mapNodes = new StrategyMapNodesVO();
        mapNodes.setMasterOid(strategyMap.getOid());
        mapNodes.setId(id);
        mapNodes.setText(text);
        mapNodes.setPositionX(NumberUtils.toInt(positionX));
        mapNodes.setPositionY(NumberUtils.toInt(positionY));
        this.strategyMapNodesService.saveIgnoreUK(mapNodes);
    }

}

From source file:fr.mailjet.rest.impl.AbstractServiceTestBase.java

private void doMinimumInteger(String parRegExp, String parResult, Integer parMinimum, String parFirstIndexOf,
        String parLastIndexOf, int parAddToStart, boolean parUseLastIndexOf) {
    Pattern locPattern = Pattern.compile(parRegExp);
    Matcher locMatcher = locPattern.matcher(parResult);
    while (locMatcher.find()) {
        String locValue = locMatcher.group();
        int locStart = locValue.indexOf(parFirstIndexOf) + parAddToStart;
        int locEnd = parUseLastIndexOf ? locValue.lastIndexOf(parLastIndexOf) : locValue.length();
        int locRealIntegerValue = NumberUtils.toInt(locValue.substring(locStart, locEnd));
        assertTrue(parMinimum.intValue() <= locRealIntegerValue);
        return;//from  w w  w. j  av a 2 s . c om
    }
    // Si la valeur n'a pas t trouv on lve une erreur
    assertFalse("La regexp " + parRegExp + " n'a rien trouv pour la valeur : \n" + parResult, true);
}

From source file:com.mirth.connect.connectors.ws.WebServiceConnectorServlet.java

private WsdlInterface[] getWsdlInterfaces(String wsdlUrl, WebServiceDispatcherProperties props,
        String channelId) throws Exception {
    WsdlProject wsdlProject = new WsdlProjectFactory().createNew();
    WsdlLoader wsdlLoader = new UrlWsdlLoader(wsdlUrl);
    int timeout = NumberUtils.toInt(props.getSocketTimeout());
    return importWsdlInterfaces(wsdlProject, wsdlUrl, wsdlLoader, timeout);
}

From source file:io.gromit.geolite2.geonames.SubdivisionFinder.java

/**
 * Read level two.//www .j a  v a2  s  .  co m
 *
 * @param subdivisionTwoLocationUrl the subdivision two location url
 * @return the subdivision finder
 */
public SubdivisionFinder readLevelTwo(String subdivisionTwoLocationUrl) {
    ZipInputStream zipis = null;
    try {
        zipis = new ZipInputStream(new URL(subdivisionTwoLocationUrl).openStream(), Charset.forName("UTF-8"));
        ZipEntry zipEntry = zipis.getNextEntry();
        logger.info("reading " + zipEntry.getName());
        if (crc2 == zipEntry.getCrc()) {
            logger.info("skipp, same CRC");
            return this;
        }
        CsvParserSettings settings = new CsvParserSettings();
        settings.setSkipEmptyLines(true);
        settings.trimValues(true);
        CsvFormat format = new CsvFormat();
        format.setDelimiter('\t');
        format.setLineSeparator("\n");
        format.setCharToEscapeQuoteEscaping('\0');
        format.setQuote('\0');
        settings.setFormat(format);
        CsvParser parser = new CsvParser(settings);

        List<String[]> lines = parser.parseAll(new InputStreamReader(zipis, "UTF-8"));

        for (String[] entry : lines) {
            Subdivision subdivision = new Subdivision();
            subdivision.setId(entry[0]);
            subdivision.setName(entry[1]);
            subdivision.setGeonameId(NumberUtils.toInt(entry[2]));
            idTowMap.put(subdivision.getId(), subdivision);
            geonameIdMap.put(subdivision.getGeonameId(), subdivision);
        }
        logger.info("loaded " + lines.size() + " subdivisions level 2");
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    } finally {
        try {
            zipis.close();
        } catch (Exception e) {
        }
        ;
    }
    return this;
}

From source file:com.moviejukebox.plugin.TheMovieDbPlugin.java

@Override
public boolean scan(Movie movie) {
    String imdbID = movie.getId(IMDB_PLUGIN_ID);
    String tmdbID = movie.getId(TMDB_PLUGIN_ID);
    List<ReleaseInfo> movieReleaseInfo = new ArrayList<>();
    MediaCreditList moviePeople = null;//from   ww  w  .  j a va 2 s.co  m
    MovieInfo moviedb = null;
    boolean retval;

    // First look to see if we have a TMDb ID as this will make looking the film up easier
    if (StringTools.isValidString(tmdbID)) {
        // Search based on TMdb ID
        LOG.debug("{}: Using TMDb ID ({}) for {}", movie.getBaseName(), tmdbID, movie.getBaseName());
        try {
            moviedb = tmdb.getMovieInfo(NumberUtils.toInt(tmdbID), languageCode);
        } catch (MovieDbException ex) {
            LOG.debug("{}: Failed to get movie info using TMDB ID: {} - {}", movie.getBaseName(), tmdbID,
                    ex.getMessage());
        }
    }

    if (moviedb == null && StringTools.isValidString(imdbID)) {
        // Search based on IMDb ID
        LOG.debug("{}: Using IMDb ID ({}) for {}", movie.getBaseName(), imdbID, movie.getBaseName());
        try {
            moviedb = tmdb.getMovieInfoImdb(imdbID, languageCode);
            tmdbID = String.valueOf(moviedb.getId());
            if (StringTools.isNotValidString(tmdbID)) {
                LOG.debug("{}: No TMDb ID found for movie!", movie.getBaseName());
            }
        } catch (MovieDbException ex) {
            LOG.debug("{}: Failed to get movie info using IMDB ID: {} - {}", movie.getBaseName(), imdbID,
                    ex.getMessage());
        }
    }

    if (moviedb == null) {
        LOG.debug("{}: No IDs provided for movie, search using title & year", movie.getBaseName());

        // Search using movie name
        int movieYear = NumberUtils.toInt(movie.getYear(), 0);

        // Check with the title
        LOG.debug(LOG_LOCATE_MOVIE_INFORMATION, movie.getBaseName(), movie.getTitle(), movieYear);
        moviedb = searchMovieTitle(movie, movieYear, movie.getTitle());

        if (moviedb == null) {
            // Check with the original title
            LOG.debug(LOG_LOCATE_MOVIE_INFORMATION, movie.getBaseName(), movie.getOriginalTitle(), movieYear);
            moviedb = searchMovieTitle(movie, movieYear, movie.getOriginalTitle());
        }

        // If still no matches try with a shorter title
        if (moviedb == null) {
            for (int words = 3; words > 0; words--) {
                String shortTitle = StringTools.getWords(movie.getTitle(), words);
                LOG.debug("{}: Using shorter title '{}'", movie.getBaseName(), shortTitle);
                moviedb = searchMovieTitle(movie, movieYear, shortTitle);
                if (moviedb != null) {
                    LOG.debug("{}: Movie found", movie.getBaseName());
                    break;
                }
            }

            if (moviedb == null) {
                for (int words = 3; words > 0; words--) {
                    String shortTitle = StringTools.getWords(movie.getOriginalTitle(), words);
                    LOG.debug("{}: Using shorter title '{}'", movie.getBaseName(), shortTitle);
                    moviedb = searchMovieTitle(movie, movieYear, shortTitle);
                    if (moviedb != null) {
                        LOG.debug("{}: Movie found", movie.getBaseName());
                        break;
                    }
                }
            }
        }
    }

    if (moviedb == null) {
        LOG.debug("Movie {} not found!", movie.getBaseName());
        LOG.debug("Try using a NFO file to specify the movie");
        return false;
    }

    try {
        // Get the full information on the film
        moviedb = tmdb.getMovieInfo(moviedb.getId(), languageCode);
    } catch (MovieDbException ex) {
        LOG.debug("Failed to download remaining information for {}", movie.getBaseName());
    }
    LOG.debug("Found id ({}) for {}", moviedb.getId(), moviedb.getTitle());

    try {
        // Get the release information
        movieReleaseInfo = tmdb.getMovieReleaseInfo(moviedb.getId(), countryCode).getResults();
    } catch (MovieDbException ex) {
        LOG.debug("Failed to get release information: {}", ex.getMessage(), ex);
    }

    try {
        // Get the cast information
        moviePeople = tmdb.getMovieCredits(moviedb.getId());
    } catch (MovieDbException ex) {
        LOG.debug("Failed to get cast information: {}", ex.getMessage(), ex);
    }

    retval = true;
    if (moviedb.getId() > 0) {
        movie.setMovieType(Movie.TYPE_MOVIE);
    }

    if (StringTools.isValidString(moviedb.getTitle())) {
        copyMovieInfo(moviedb, movie);
    }

    // Set the release information
    if (!movieReleaseInfo.isEmpty() && OverrideTools.checkOverwriteCertification(movie, TMDB_PLUGIN_ID)) {
        // Default to the first one
        ReleaseInfo ri = movieReleaseInfo.get(0);
        for (ReleaseInfo release : movieReleaseInfo) {
            if (release.isPrimary()) {
                ri = release;
                break;
            }
        }

        LOG.trace("Using release information: {}", ri.toString());
        movie.setCertification(ri.getCertification(), TMDB_PLUGIN_ID);
    }

    // Add the cast information
    // TODO: Add the people to the cast/crew
    if (moviePeople != null) {
        List<String> newActors = new ArrayList<>();
        List<String> newDirectors = new ArrayList<>();
        List<String> newWriters = new ArrayList<>();

        LOG.debug("Adding {} people to the cast list", Math.min(moviePeople.getCast().size(), actorMax));
        for (MediaCreditCast person : moviePeople.getCast()) {
            LOG.trace("Adding cast member {}", person.toString());
            newActors.add(person.getName());
        }

        LOG.debug("Adding {} people to the crew list", Math.min(moviePeople.getCrew().size(), 2));
        for (MediaCreditCrew person : moviePeople.getCrew()) {
            LOG.trace("Adding crew member {}", person.toString());
            if ("Directing".equalsIgnoreCase(person.getDepartment())) {
                LOG.trace("{} is a Director", person.getName());
                newDirectors.add(person.getName());
            } else if ("Writing".equalsIgnoreCase(person.getDepartment())) {
                LOG.trace("{} is a Writer", person.getName());
                newWriters.add(person.getName());
            } else {
                LOG.trace("Unknown job {} for {}", person.getJob(), person.toString());
            }
        }

        if (OverrideTools.checkOverwriteDirectors(movie, TMDB_PLUGIN_ID)) {
            movie.setDirectors(newDirectors, TMDB_PLUGIN_ID);
        }
        if (OverrideTools.checkOverwritePeopleDirectors(movie, TMDB_PLUGIN_ID)) {
            movie.setPeopleDirectors(newDirectors, TMDB_PLUGIN_ID);
        }
        if (OverrideTools.checkOverwriteWriters(movie, TMDB_PLUGIN_ID)) {
            movie.setWriters(newWriters, TMDB_PLUGIN_ID);
        }
        if (OverrideTools.checkOverwritePeopleWriters(movie, TMDB_PLUGIN_ID)) {
            movie.setPeopleWriters(newWriters, TMDB_PLUGIN_ID);
        }
        if (OverrideTools.checkOverwriteActors(movie, TMDB_PLUGIN_ID)) {
            movie.setCast(newActors, TMDB_PLUGIN_ID);
        }
        if (OverrideTools.checkOverwritePeopleActors(movie, TMDB_PLUGIN_ID)) {
            movie.setPeopleCast(newActors, TMDB_PLUGIN_ID);
        }
    } else {
        LOG.debug("No cast or crew members found");
    }

    // Update TheMovieDb Id if needed
    if (StringTools.isNotValidString(movie.getId(TMDB_PLUGIN_ID))) {
        movie.setId(TMDB_PLUGIN_ID, moviedb.getId());
    }

    // Update IMDb Id if needed
    if (StringTools.isNotValidString(movie.getId(IMDB_PLUGIN_ID))) {
        movie.setId(IMDB_PLUGIN_ID, moviedb.getImdbID());
    }

    // Create the auto sets for movies and not extras
    if (AUTO_COLLECTION && !movie.isExtra()) {
        Collection coll = moviedb.getBelongsToCollection();
        if (coll != null) {
            LOG.debug("{} belongs to a collection: '{}'", movie.getTitle(), coll.getName());
            CollectionInfo collInfo = getCollectionInfo(coll.getId(), languageCode);
            if (collInfo != null) {
                movie.addSet(collInfo.getName());
                movie.setId(CACHE_COLLECTION, coll.getId());
            } else {
                LOG.debug("Failed to get collection information!");
            }
        }
    }

    if (downloadFanart && StringTools.isNotValidString(movie.getFanartURL())) {
        movie.setFanartURL(getFanartURL(movie));
        if (StringTools.isValidString(movie.getFanartURL())) {
            movie.setFanartFilename(movie.getBaseName() + FANART_TOKEN + "." + fanartExtension);
        }
    }
    return retval;
}

From source file:com.blackducksoftware.integration.hub.bamboo.config.HubConfigController.java

private int getIntFromObject(final String value) {
    if (StringUtils.isNotBlank(value)) {
        return NumberUtils.toInt(value);
    }//from ww  w . j a v  a 2s. c o  m
    return 0;
}