Example usage for java.lang Integer longValue

List of usage examples for java.lang Integer longValue

Introduction

In this page you can find the example usage for java.lang Integer longValue.

Prototype

public long longValue() 

Source Link

Document

Returns the value of this Integer as a long after a widening primitive conversion.

Usage

From source file:com.redhat.rhn.frontend.xmlrpc.system.crash.CrashHandler.java

/**
 * Get a crash file download url/*  w w w .ja  va 2 s.  c om*/
 * @param loggedInUser The current user
 * @param crashFileId Crash File ID
 * @return Return a download url string.
 *
 * @xmlrpc.doc Get a crash file download url.
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param("int", "crashFileId")
 * @xmlrpc.returntype string - The crash file download url
 */
public String getCrashFileUrl(User loggedInUser, Integer crashFileId) {
    CrashFile crashFile = CrashManager.lookupCrashFileByUserAndId(loggedInUser,
            new Long(crashFileId.longValue()));

    return RhnXmlRpcServer.getProtocol() + "://" + RhnXmlRpcServer.getServerName()
            + DownloadManager.getCrashFileDownloadPath(crashFile, loggedInUser);
}

From source file:org.mythtv.client.ui.dvr.RecordingRuleEditFragment.java

public void loadRecordingRule(Integer recordingRuleId) {
    Log.v(TAG, "loadRecordingRule : enter");

    mRule = mRecordingRuleDaoHelper.findByRecordingRuleId(getActivity(), mLocationProfile,
            recordingRuleId.longValue());
    setupForm(mRule);//  www  .j a  v a2  s  .c  o  m

    Log.v(TAG, "loadRecordingRule : exit");
}

From source file:com.ottogroup.bi.streaming.operator.json.statsd.StatsdExtractedMetricsReporter.java

/**
 * Extracts and reports a gauge value//from   w  w w.  j  a  va  2s .c o  m
 * @param metricCfg 
 *          The field configuration providing information on how to access and export content from JSON. Value is expected not to be null
 * @param json
 *          The {@link JSONObject} to extract information from. Value is expected not to be null
 */
protected void reportGauge(final StatsdMetricConfig metricCfg, final JSONObject json) {
    String path = null;
    if (metricCfg.getDynamicPathPrefix() != null) {
        try {
            String dynPathPrefix = this.jsonUtils.getTextFieldValue(json,
                    metricCfg.getDynamicPathPrefix().getPath(), false);
            if (StringUtils.isNotBlank(dynPathPrefix))
                path = dynPathPrefix + (!StringUtils.endsWith(dynPathPrefix, ".") ? "." : "")
                        + metricCfg.getPath();
            else
                path = metricCfg.getPath();
        } catch (Exception e) {
            // do nothing
            path = metricCfg.getPath();
        }
    } else {
        path = metricCfg.getPath();
    }

    if (metricCfg.getJsonRef().getContentType() == JsonContentType.INTEGER) {
        try {
            final Integer value = this.jsonUtils.getIntegerFieldValue(json, metricCfg.getJsonRef().getPath());
            if (value != null)
                this.statsdClient.gauge(path,
                        (metricCfg.getScaleFactor() != 1 ? value.longValue() * metricCfg.getScaleFactor()
                                : value.longValue()));
        } catch (Exception e) {
            // do nothing
        }
    } else if (metricCfg.getJsonRef().getContentType() == JsonContentType.DOUBLE) {
        try {
            final Double value = this.jsonUtils.getDoubleFieldValue(json, metricCfg.getJsonRef().getPath());
            if (value != null)
                this.statsdClient.gauge(path,
                        (metricCfg.getScaleFactor() != 1
                                ? (long) (value.doubleValue() * metricCfg.getScaleFactor())
                                : value.longValue()));
        } catch (Exception e) {
            // do nothing
        }
    }
}

From source file:com.ottogroup.bi.streaming.operator.json.statsd.StatsdExtractedMetricsReporter.java

/**
 * Extracts and reports a counter value// ww  w. j a v a  2s.c om
 * @param metricCfg 
 *          The field configuration providing information on how to access and export content from JSON. Value is expected not to be null
 * @param json
 *          The {@link JSONObject} to extract information from. Value is expected not to be null
 */
protected void reportCounter(final StatsdMetricConfig metricCfg, final JSONObject json) {
    String path = null;
    if (metricCfg.getDynamicPathPrefix() != null) {
        try {
            String dynPathPrefix = this.jsonUtils.getTextFieldValue(json,
                    metricCfg.getDynamicPathPrefix().getPath(), false);
            if (StringUtils.isNotBlank(dynPathPrefix))
                path = dynPathPrefix + (!StringUtils.endsWith(dynPathPrefix, ".") ? "." : "")
                        + metricCfg.getPath();
            else
                path = metricCfg.getPath();
        } catch (Exception e) {
            // do nothing
            path = metricCfg.getPath();
        }
    } else {
        path = metricCfg.getPath();
    }

    if (!metricCfg.isReportDelta()) {
        this.statsdClient.incrementCounter(path);
        return;
    }

    if (metricCfg.getJsonRef().getContentType() == JsonContentType.INTEGER) {
        try {
            final Integer value = this.jsonUtils.getIntegerFieldValue(json, metricCfg.getJsonRef().getPath());
            if (value != null)
                this.statsdClient.count(path,
                        (metricCfg.getScaleFactor() != 1 ? value.longValue() * metricCfg.getScaleFactor()
                                : value.longValue()));
        } catch (Exception e) {
            // do nothing
        }
    } else if (metricCfg.getJsonRef().getContentType() == JsonContentType.DOUBLE) {
        try {
            final Double value = this.jsonUtils.getDoubleFieldValue(json, metricCfg.getJsonRef().getPath());
            if (value != null)
                this.statsdClient.count(path,
                        (metricCfg.getScaleFactor() != 1
                                ? (long) (value.doubleValue() * metricCfg.getScaleFactor())
                                : value.longValue()));
        } catch (Exception e) {
            // do nothing
        }
    }
}

From source file:ubic.gemma.loader.genome.gene.ncbi.homology.HomologeneServiceImpl.java

@Override
public Collection<Gene> getHomologues(Gene gene) {

    Collection<Gene> genes = new HashSet<Gene>();

    if (!this.ready.get()) {
        return genes;
    }//from   w  ww .  ja  v  a 2s . c om

    Long groupId = null;

    Integer ncbiGeneId = gene.getNcbiGeneId();
    if (ncbiGeneId == null)
        return genes;
    try {
        groupId = this.getHomologeneGroup(ncbiGeneId.longValue());
    } catch (NumberFormatException e) {
        return genes;
    }

    if (groupId == null) {
        return genes;
    }

    genes = this.getGenesInGroup(groupId);

    if (genes != null)
        genes.remove(gene); // remove the given gene from the list

    return genes;

}

From source file:com.redhat.rhn.frontend.xmlrpc.packages.PackagesHandler.java

/**
 * @param user The logged in user/*  www .  ja  v a 2 s. c  o m*/
 * @param pid The id for the package
 * @return Returns the package or a fault exception
 * @throws FaultException Occurs when the package is not found
 */
private Package lookupPackage(User user, Integer pid) throws FaultException {
    Package pkg = PackageManager.lookupByIdAndUser(new Long(pid.longValue()), user);

    /*
     * PackageManager.lookupByIdAndUser() could return null, so we need to check
     * and throw a no_such_package exception if the package was not found.
     */
    if (pkg == null) {
        throw new FaultException(-208, "no_such_package", "The package '" + pid + "' cannot be found.");
    }

    return pkg;
}

From source file:com.redhat.rhn.frontend.xmlrpc.system.crash.CrashHandler.java

/**
 * Download a base64 encoded crash file.
 * @param loggedInUser The current user//from  w w w .  ja  v  a2  s .  co m
 * @param crashFileId Crash File ID
 * @return Return a byte array of the crash file.
 * @throws IOException if there is an exception
 *
 * @xmlrpc.doc Download a crash file.
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param("int", "crashFileId")
 * @xmlrpc.returntype base64 - base64 encoded crash file.
 */
public byte[] getCrashFile(User loggedInUser, Integer crashFileId) throws IOException {
    CrashFile crashFile = CrashManager.lookupCrashFileByUserAndId(loggedInUser,
            new Long(crashFileId.longValue()));
    String path = Config.get().getString(ConfigDefaults.MOUNT_POINT) + "/"
            + crashFile.getCrash().getStoragePath() + "/" + crashFile.getFilename();
    File file = new File(path);

    if (file.length() > freeMemCoeff * Runtime.getRuntime().freeMemory()) {
        throw new CrashFileDownloadException("api.crashfile.download.toolarge");
    }

    byte[] plainFile = new byte[(int) file.length()];
    FileInputStream fis = new FileInputStream(file);
    BufferedInputStream br = new BufferedInputStream(fis);
    if (br.read(plainFile) != file.length()) {
        throw new CrashFileDownloadException("api.package.download.ioerror");
    }

    fis.close();
    br.close();

    return Base64.encodeBase64(plainFile);
}

From source file:org.oscarehr.PMmodule.dao.ProgramProviderDAO.java

public List<ProgramProvider> getProgramProvidersInTeam(Integer programId, Integer teamId) {
    if (programId == null || programId <= 0) {
        throw new IllegalArgumentException();
    }/*w ww.  j a v a2 s.com*/
    if (teamId == null || teamId <= 0) {
        throw new IllegalArgumentException();
    }
    Long pId = programId.longValue();

    List<ProgramProvider> results = this.getHibernateTemplate().find(
            "select pp from ProgramProvider pp left join pp.teams as team where pp.ProgramId = ? and team.id = ?",
            new Object[] { pId, teamId });

    if (log.isDebugEnabled()) {
        log.debug("getProgramProvidersInTeam: programId=" + programId + ",teamId=" + teamId + ",# of results="
                + results.size());
    }

    return results;
}

From source file:org.jenkinsci.plugins.skytap.ConnectToVPNTunnelStep.java

private String connectVPNToConfiguration(String confId, String networkId, String vpnId) {

    // build url//from w  w  w .j av  a  2 s. c  om
    String reqUrl = this.buildConnectRequestURL(confId, networkId, vpnId);

    // create request
    HttpPut hp = SkytapUtils.buildHttpPutRequest(reqUrl, this.authCredentials);

    // add content to request - vpn identifier
    BasicHttpEntity he = new BasicHttpEntity();
    he.setContentEncoding("gzip");
    he.setContentType("application/json");

    // json string for connected attribute
    String jsonString = "{\"connected\" :true}";

    InputStream stream;
    try {
        stream = new ByteArrayInputStream(jsonString.getBytes("UTF-8"));
        Integer len = jsonString.getBytes("UTF-8").length;
        long llen = len.longValue();

        he.setContent(stream);
        he.setContentLength(llen);

    } catch (UnsupportedEncodingException e) {
        JenkinsLogger.error("Error encoding json string for connected attribute: " + e.getMessage());

    }

    hp.setEntity(he);
    String response = "";

    try {
        response = SkytapUtils.executeHttpRequest(hp);
    } catch (SkytapException e) {
        JenkinsLogger.error("Skytap Exception: " + e.getMessage());
    }

    return response;

}

From source file:org.jenkinsci.plugins.skytap.ConnectToVPNTunnelStep.java

private String attachVPNToConfiguration(String confId, String networkId, String vpnId) {

    // build url// ww  w  .  ja v  a  2s.  co  m
    String requestUrl = this.buildRequestURL(confId, networkId);

    // create request
    HttpPost hp = SkytapUtils.buildHttpPostRequest(requestUrl, this.authCredentials);

    // add content to request - vpn identifier
    BasicHttpEntity he = new BasicHttpEntity();
    he.setContentEncoding("gzip");
    he.setContentType("application/json");

    // json string for vpn id
    String jsonString = "{\"id\":\"" + vpnId + "\"}";

    InputStream stream;
    try {
        stream = new ByteArrayInputStream(jsonString.getBytes("UTF-8"));
        Integer len = jsonString.getBytes("UTF-8").length;
        long llen = len.longValue();

        he.setContent(stream);
        he.setContentLength(llen);

    } catch (UnsupportedEncodingException e) {
        JenkinsLogger.error("Error encoding json string for vpn id: " + e.getMessage());

    }

    hp.setEntity(he);

    JenkinsLogger.log("HTTP POST request: " + hp.toString());

    // execute request
    String httpRespBody = "";

    try {
        httpRespBody = SkytapUtils.executeHttpRequest(hp);
    } catch (SkytapException e) {
        JenkinsLogger.error("Skytap Exception: " + e.getMessage());
    }

    // return response
    return httpRespBody;

}