Example usage for java.lang Long longValue

List of usage examples for java.lang Long longValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public long longValue() 

Source Link

Document

Returns the value of this Long as a long value.

Usage

From source file:io.sulite.SQLitePlugin.java

/**
 * Executes a batch request and sends the results via sendJavascriptCB().
 *
 * @param dbname//from w  ww.j a va2s  . c  om
 *            The name of the database.
 *
 * @param queryarr
 *            Array of query strings
 *
 * @param jsonparams
 *            Array of JSON query parameters
 *
 * @param queryIDs
 *            Array of query ids
 *
 * @param cbc
 *            Callback context from Cordova API
 *
 */
private void executeSqlBatch(String dbname, String[] queryarr, JSONArray[] jsonparams, String[] queryIDs,
        CallbackContext cbc) {
    Long db = this.getDatabase(dbname);

    if (db == null)
        return;

    long mydb = db.longValue();

    String query = "";
    String query_id = "";
    int len = queryarr.length;

    JSONArray batchResults = new JSONArray();

    for (int i = 0; i < len; i++) {
        query_id = queryIDs[i];

        JSONObject queryResult = null;
        String errorMessage = null;
        int errorCode = 0;

        try {
            query = queryarr[i];

            int step_return = 0;

            // XXX TODO bindings for UPDATE & rowsAffected for UPDATE/DELETE/INSERT
            /**
            // /* OPTIONAL changes for new Android SDK from HERE:
            if (android.os.Build.VERSION.SDK_INT >= 11 &&
                (query.toLowerCase().startsWith("update") ||
                 query.toLowerCase().startsWith("delete")))
            {
               //SQLiteStatement myStatement = mydb.compileStatement(query);
               SQLiteStatement myStatement = mydb.prepare(query);
                    
               if (jsonparams != null) {
                  for (int j = 0; j < jsonparams[i].length(); j++) {
             if (jsonparams[i].get(j) instanceof Float || jsonparams[i].get(j) instanceof Double ) {
                myStatement.bind(j + 1, jsonparams[i].getDouble(j));
             } else if (jsonparams[i].get(j) instanceof Number) {
                myStatement.bind(j + 1, jsonparams[i].getLong(j));
             } else if (jsonparams[i].isNull(j)) {
                myStatement.bindNull(j + 1);
             } else {
                myStatement.bind(j + 1, jsonparams[i].getString(j));
             }
                  }
               }
                    
               int rowsAffected = myStatement.executeUpdateDelete();
                    
               queryResult = new JSONObject();
               queryResult.put("rowsAffected", rowsAffected);
            } else // to HERE. */
            if (query.toLowerCase().startsWith("insert") && jsonparams != null) {
                /* prepare/compile statement: */
                long st = SQLiteGlue.sqlg_db_prepare_st(mydb, query);

                for (int j = 0; j < jsonparams[i].length(); j++) {
                    if (jsonparams[i].get(j) instanceof Float || jsonparams[i].get(j) instanceof Double) {
                        SQLiteGlue.sqlg_st_bind_double(st, j + 1, jsonparams[i].getDouble(j));
                    } else if (jsonparams[i].get(j) instanceof Number) {
                        SQLiteGlue.sqlg_st_bind_int64(st, j + 1, jsonparams[i].getLong(j));
                        // XXX TODO bind null:
                        //} else if (jsonparams[i].isNull(j)) {
                        //   myStatement.bindNull(j + 1);
                    } else {
                        SQLiteGlue.sqlg_st_bind_text(st, j + 1, jsonparams[i].getString(j));
                    }
                }

                step_return = SQLiteGlue.sqlg_st_step(st);

                // XXX TODO get insertId

                SQLiteGlue.sqlg_st_finish(st);

                queryResult = new JSONObject();
                // XXX TODO [insertId]:
                //queryResult.put("insertId", insertId);
                // XXX TODO [fix rowsAffected]:
                queryResult.put("rowsAffected", 1);
            } else {
                long st = SQLiteGlue.sqlg_db_prepare_st(mydb, query);

                if (jsonparams != null) {
                    for (int j = 0; j < jsonparams[i].length(); j++) {
                        //if (jsonparams[i].isNull(j))
                        //params[j] = "";
                        //myStatement.bindNull(j + 1);
                        //else
                        //params[j] = jsonparams[i].getString(j);
                        //myStatement.bind(j + 1, jsonparams[i].getString(j));
                        SQLiteGlue.sqlg_st_bind_text(st, j + 1, jsonparams[i].getString(j));
                    }
                }

                step_return = SQLiteGlue.sqlg_st_step(st);

                if ((step_return == 100) && query_id.length() > 0) {
                    queryResult = this.getRowsResultFromQuery(st);
                } else if (query_id.length() > 0) {
                    queryResult = new JSONObject();
                }

                //SQLiteGlue.sqlg_st_finish(st);
            }

            // XXX TBD ?? cleanup:
            if (step_return != 0 && step_return < 100) {
                queryResult = null;
                errorMessage = "query failure";
                // XXX TBD add mapping:
                errorCode = 0; /* UNKNOWN_ERR */
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            errorMessage = ex.getMessage();
            errorCode = 0; /* UNKNOWN_ERR */
            Log.v("executeSqlBatch", "SQLitePlugin.executeSql[Batch](): Error=" + errorMessage);
        }

        try {
            if (queryResult != null) {
                JSONObject r = new JSONObject();
                r.put("qid", query_id);

                r.put("result", queryResult);

                batchResults.put(r);
            } else if (errorMessage != null) {
                JSONObject r = new JSONObject();
                r.put("qid", query_id);

                JSONObject e = new JSONObject();
                e.put("message", errorMessage);
                e.put("code", errorCode);
                r.put("error", e);

                batchResults.put(r);
            }
        } catch (JSONException ex) {
            ex.printStackTrace();
            Log.v("executeSqlBatch", "SQLitePlugin.executeSql[Batch](): Error=" + ex.getMessage());
            // TODO what to do?
        }
    }

    cbc.success(batchResults);
}

From source file:org.ohmage.query.impl.AuditQueries.java

@Override
public List<Audit> readAuditInformation(final List<Long> auditIds) throws DataAccessException {

    if (auditIds == null) {
        return new LinkedList<Audit>();
    }//from   w  ww  .ja v  a  2s. co  m

    final List<Audit> result = new ArrayList<Audit>(auditIds.size());

    for (Long auditId : auditIds) {
        try {
            final Audit auditInformation = getJdbcTemplate().queryForObject(SQL_GET_AUDIT_INFORMATION_FROM_ID,
                    new Object[] { auditId.longValue() }, new RowMapper<Audit>() {
                        @Override
                        public Audit mapRow(final ResultSet rs, final int rowNum) throws SQLException {

                            RequestType requestType;
                            try {
                                requestType = RequestType.valueOf(rs.getString("request_type").toUpperCase());
                            } catch (IllegalArgumentException e) {
                                requestType = RequestType.UNKNOWN;
                            }

                            JSONObject response;
                            try {
                                response = new JSONObject(rs.getString("response"));
                            } catch (JSONException e) {
                                response = new JSONObject();
                            }

                            return new Audit(requestType, rs.getString("uri"), rs.getString("client"),
                                    rs.getString("device_id"), response, rs.getLong("received_millis"),
                                    rs.getLong("respond_millis"), rs.getTimestamp("db_timestamp"));
                        }
                    });

            // Micro inner class to deal with getting key-value pairs from
            // the database.
            class KeyValuePair {
                private String key;
                private String value;

                public KeyValuePair(String key, String value) {
                    this.key = key;
                    this.value = value;
                }
            }

            // Add all of the parameters.
            try {
                final List<KeyValuePair> parameters = getJdbcTemplate().query(SQL_GET_AUDIT_PARAMETERS,
                        new Object[] { auditId }, new RowMapper<KeyValuePair>() {
                            @Override
                            public KeyValuePair mapRow(final ResultSet rs, final int rowNum)
                                    throws SQLException {

                                return new KeyValuePair(rs.getString("param_key"), rs.getString("param_value"));
                            }
                        });
                for (KeyValuePair parameter : parameters) {
                    try {
                        auditInformation.addParameter(parameter.key, parameter.value);
                    } catch (DomainException e) {
                        throw new DataAccessException("The audit parameters table has a corrupt record.", e);
                    }
                }
            } catch (org.springframework.dao.DataAccessException e) {
                throw new DataAccessException(
                        "Error executing SQL '" + SQL_GET_AUDIT_PARAMETERS + "' with parameter: " + auditId, e);
            }

            // Add all of the extras.
            try {
                final List<KeyValuePair> extras = getJdbcTemplate().query(SQL_GET_AUDIT_EXTRAS,
                        new Object[] { auditId }, new RowMapper<KeyValuePair>() {
                            @Override
                            public KeyValuePair mapRow(final ResultSet rs, final int rowNum)
                                    throws SQLException {
                                return new KeyValuePair(rs.getString("extra_key"), rs.getString("extra_value"));
                            }
                        });
                for (KeyValuePair extra : extras) {
                    try {
                        auditInformation.addExtra(extra.key, extra.value);
                    } catch (DomainException e) {
                        throw new DataAccessException("The audit extras table has a corrupt record.", e);
                    }
                }
            } catch (org.springframework.dao.DataAccessException e) {
                throw new DataAccessException(
                        "Error executing SQL '" + SQL_GET_AUDIT_EXTRAS + "' with parameter: " + auditId, e);
            }

            // Add the audit information to the result.
            result.add(auditInformation);
        } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
            throw new DataAccessException("The audit ID does not exist: " + auditId, e);
        } catch (org.springframework.dao.DataAccessException e) {
            throw new DataAccessException("Error executing SQL '" + SQL_GET_AUDIT_INFORMATION_FROM_ID
                    + "' with parameter: " + auditId, e);
        }
    }

    return result;
}

From source file:com.eviware.soapui.tools.SoapUISecurityTestRunner.java

@Override
public void afterStep(TestCaseRunner testRunner, SecurityTestRunContext runContext,
        SecurityTestStepResult result) {
    if (!isPrintReport())
        return;//  w  w w .  ja v  a  2 s.c om

    TestStep currentStep = runContext.getCurrentStep();

    String securityTestName = "";
    String securityScanName = "";
    if (!result.getSecurityScanResultList().isEmpty()) {
        securityTestName = result.getSecurityScanResultList().get(0).getSecurityScan().getParent().getName();
        securityScanName = result.getSecurityScanResultList().get(0).getSecurityScanName();
    }

    String countPropertyName = currentStep.getName() + " run count";
    Long count = new Long(getExportCount());// ( Long
    // )runContext.getProperty(
    // countPropertyName );
    if (count == null) {
        count = new Long(0);
    }

    runContext.setProperty(countPropertyName, new Long(count.longValue() + 1));

    if (result.getStatus() == SecurityResult.ResultStatus.FAILED || isExportAll()) {
        try {
            String exportSeparator = System.getProperty(SOAPUI_EXPORT_SEPARATOR, "-");

            TestCase tc = currentStep.getTestCase();

            String nameBase = StringUtils.createFileName(securityTestName, '_') + exportSeparator
                    + StringUtils.createFileName(securityScanName, '_') + exportSeparator
                    + StringUtils.createFileName(tc.getTestSuite().getName(), '_') + exportSeparator
                    + StringUtils.createFileName(tc.getName(), '_') + exportSeparator
                    + StringUtils.createFileName(currentStep.getName(), '_') + "-" + count.longValue() + "-"
                    + result.getStatus();

            WsdlTestCaseRunner callingTestCaseRunner = (WsdlTestCaseRunner) runContext
                    .getProperty("#CallingTestCaseRunner#");

            if (callingTestCaseRunner != null) {
                WsdlTestCase ctc = callingTestCaseRunner.getTestCase();
                WsdlRunTestCaseTestStep runTestCaseTestStep = (WsdlRunTestCaseTestStep) runContext
                        .getProperty("#CallingRunTestCaseStep#");

                nameBase = StringUtils.createFileName(securityTestName, '_') + exportSeparator
                        + StringUtils.createFileName(ctc.getTestSuite().getName(), '_') + exportSeparator
                        + StringUtils.createFileName(ctc.getName(), '_') + exportSeparator
                        + StringUtils.createFileName(runTestCaseTestStep.getName(), '_') + exportSeparator
                        + StringUtils.createFileName(tc.getTestSuite().getName(), '_') + exportSeparator
                        + StringUtils.createFileName(tc.getName(), '_') + exportSeparator
                        + StringUtils.createFileName(currentStep.getName(), '_') + "-" + count.longValue() + "-"
                        + result.getStatus();
            }

            String absoluteOutputFolder = getAbsoluteOutputFolder(ModelSupport.getModelItemProject(tc));
            String fileName = absoluteOutputFolder + File.separator + nameBase + ".txt";

            if (result.getStatus() == SecurityResult.ResultStatus.FAILED)
                log.error(currentStep.getName() + " failed, exporting to [" + fileName + "]");

            File file = new File(fileName);
            file.getParentFile().mkdirs();

            PrintWriter writer = new PrintWriter(file);
            result.writeTo(writer);
            writer.close();

            // write attachments
            if (result instanceof MessageExchange) {
                Attachment[] attachments = ((MessageExchange) result).getResponseAttachments();
                if (attachments != null && attachments.length > 0) {
                    for (int c = 0; c < attachments.length; c++) {
                        fileName = nameBase + "-attachment-" + (c + 1) + ".";

                        Attachment attachment = attachments[c];
                        String contentType = attachment.getContentType();
                        if (!"application/octet-stream".equals(contentType) && contentType != null
                                && contentType.indexOf('/') != -1) {
                            fileName += contentType.substring(contentType.lastIndexOf('/') + 1);
                        } else {
                            fileName += "dat";
                        }

                        fileName = absoluteOutputFolder + File.separator + fileName;

                        FileOutputStream outFile = new FileOutputStream(fileName);
                        Tools.writeAll(outFile, attachment.getInputStream());
                        outFile.close();
                    }
                }
            }

            setExportCount(getExportCount() + 1);
        } catch (Exception e) {
            log.error("Error saving failed result: " + e, e);
        }
    }

    setTestStepCount(getTestStepCount() + 1);

}

From source file:com.joyent.manta.client.MantaClientIT.java

private void moveDirectoryWithContents(final String source, final String destination) throws IOException {
    mantaClient.putDirectory(source);//from   ww  w  . ja v a  2s  .  co  m

    mantaClient.putDirectory(source + "dir1");
    mantaClient.putDirectory(source + "dir2");
    mantaClient.putDirectory(source + "dir3");

    mantaClient.put(source + "file1.txt", TEST_DATA);
    mantaClient.put(source + "file2.txt", TEST_DATA);
    mantaClient.put(source + "dir1/file3.txt", TEST_DATA);
    mantaClient.put(source + "dir1/file4.txt", TEST_DATA);
    mantaClient.put(source + "dir3/file5.txt", TEST_DATA);

    mantaClient.move(source, destination);
    boolean newLocationExists = mantaClient.existsAndIsAccessible(destination);
    Assert.assertTrue(newLocationExists, "Destination directory doesn't exist: " + destination);

    MantaObjectResponse headDestination = mantaClient.head(destination);

    boolean isDirectory = headDestination.isDirectory();
    Assert.assertTrue(isDirectory, "Destination wasn't created as a directory");

    Long resultSetSize = headDestination.getHttpHeaders().getResultSetSize();
    Assert.assertEquals(resultSetSize.longValue(), 5L,
            "Destination directory doesn't have the same number of entries as source");

    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "file1.txt"));
    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "file2.txt"));
    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "dir1"));
    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "dir2"));
    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "dir3"));
    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "dir1/file3.txt"));
    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "dir1/file4.txt"));
    Assert.assertTrue(mantaClient.existsAndIsAccessible(destination + "dir3/file5.txt"));

    boolean sourceIsDeleted = !mantaClient.existsAndIsAccessible(source);
    Assert.assertTrue(sourceIsDeleted, "Source directory didn't get deleted: " + source);
}

From source file:com.liferay.portal.configuration.easyconf.ClassLoaderAggregateProperties.java

private Configuration _addFileProperties(String fileName, CompositeConfiguration loadedCompositeConfiguration)
        throws ConfigurationException {

    try {//from  w  w w.j a va2s.c  o  m
        FileConfiguration newFileConfiguration = new PropertiesConfiguration(fileName);

        URL url = newFileConfiguration.getURL();

        if (_log.isDebugEnabled()) {
            _log.debug("Adding file " + url);
        }

        Long delay = _getReloadDelay(loadedCompositeConfiguration, newFileConfiguration);

        if (delay != null) {
            FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileConfigurationChangedReloadingStrategy();

            if (_log.isDebugEnabled()) {
                _log.debug("File " + url + " will be reloaded every " + delay + " seconds");
            }

            long milliseconds = delay.longValue() * 1000;

            fileChangedReloadingStrategy.setRefreshDelay(milliseconds);

            newFileConfiguration.setReloadingStrategy(fileChangedReloadingStrategy);
        }

        _addIncludedPropertiesSources(newFileConfiguration, loadedCompositeConfiguration);

        return newFileConfiguration;
    } catch (org.apache.commons.configuration.ConfigurationException ce) {
        if (_log.isDebugEnabled()) {
            _log.debug("Configuration source " + fileName + " ignored");
        }

        return null;
    }
}

From source file:com.liferay.portal.configuration.easyconf.ClassLoaderAggregateProperties.java

private Configuration _addURLProperties(URL url, CompositeConfiguration loadedCompositeConfiguration)
        throws ConfigurationException {

    try {/*from   www  .j a  va2s .  c  om*/
        FileConfiguration newFileConfiguration = new PropertiesConfiguration(url);

        if (_log.isDebugEnabled()) {
            _log.debug("Adding resource " + url);
        }

        Long delay = _getReloadDelay(loadedCompositeConfiguration, newFileConfiguration);

        if (delay != null) {
            FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileConfigurationChangedReloadingStrategy();

            if (_log.isDebugEnabled()) {
                _log.debug("Resource " + url + " will be reloaded every " + delay + " seconds");
            }

            long milliseconds = delay.longValue() * 1000;

            fileChangedReloadingStrategy.setRefreshDelay(milliseconds);

            newFileConfiguration.setReloadingStrategy(fileChangedReloadingStrategy);
        }

        _addIncludedPropertiesSources(newFileConfiguration, loadedCompositeConfiguration);

        return newFileConfiguration;
    } catch (org.apache.commons.configuration.ConfigurationException ce) {
        if (_log.isDebugEnabled()) {
            _log.debug("Configuration source " + url + " ignored");
        }

        return null;
    }
}

From source file:com.centurylink.mdw.workflow.activity.process.ProcessStartActivity.java

protected void addDocumentAttachment(XmlObject msgdoc) throws ActivityException {

    try {/*from   ww w  .j  av  a2  s. co  m*/
        if (msgdoc instanceof MessageDocument) {
            TaskManager taskMgr = ServiceLocator.getTaskManager();
            EventManager eventMgr = ServiceLocator.getEventManager();
            Long documentId = this.getProcessInstanceOwnerId();
            Message emailMessage = ((MessageDocument) msgdoc).getMessage();
            FileOutputStream outputFile = null;
            List<Attachment> attachments = emailMessage.getAttachmentList();
            String filePath = getAttachmentLocation();
            if (filePath.equals(MiscConstants.DEFAULT_ATTACHMENT_LOCATION)) {
                for (Attachment attachment : attachments) {
                    taskMgr.addAttachment(attachment.getFileName(),
                            MiscConstants.ATTACHMENT_LOCATION_PREFIX + getMasterRequestId(),
                            attachment.getContentType(), "SYSTEM", OwnerType.DOCUMENT, documentId);
                }
            } else { // download file to directory location
                if (getMasterRequestId() != null) {
                    filePath += getMasterRequestId() + "/";
                }
                File ownerDir = new File(filePath);
                ownerDir.mkdirs();
                Long attachmentId = null;
                for (Attachment attachment : attachments) {
                    outputFile = new FileOutputStream(filePath + attachment.getFileName());
                    outputFile.write(Base64.decodeBase64(attachment.getAttachment()));
                    outputFile.close();
                    attachmentId = taskMgr.addAttachment(attachment.getFileName(), filePath,
                            attachment.getContentType(), "SYSTEM", OwnerType.DOCUMENT, documentId);
                    attachment.unsetAttachment();
                    attachment.setAttachmentId(attachmentId.longValue());
                }
                eventMgr.updateDocumentContent(documentId, msgdoc.xmlText(), XmlObject.class.getName());
            }
        }
    } catch (Exception e) {
        logger.severeException("Exception occured to while adding attachment", e);
        throw new ActivityException("Exception occured to while adding attachment" + e.getMessage());
    }
}

From source file:com.edgenius.wiki.webapp.admin.action.SpaceAdminAction.java

public String filter() {
    User viewer = WikiUtil.getUser();/* w  w  w .  ja  v a  2  s.co m*/

    //page 0(null) or 1 is same
    page = page == 0 ? 1 : page;

    //minus one is for system space
    int total = spaceService.getSpaceCount(filter) - 1;
    Map<Integer, Long> totalPageSummary = spaceService.getAllSpacePagesCount();

    List<SpaceDTO> list = new ArrayList<SpaceDTO>();
    List<Space> spaces;

    if (sortBy == Space.SORT_BY_PAGE_COUNT) {
        int cs = CompareToComparator.TYPE_KEEP_SAME_VALUE | CompareToComparator.DESCEND;
        //a little tracker here - normally, user want to see maximum pages of space then descend to less
        //but default, if users click sort link, the initial is sort by Ascend. So here is special for page_count 
        //which sortByDesc means sortByAsc...
        if (sortByDesc) {
            cs = CompareToComparator.TYPE_KEEP_SAME_VALUE | CompareToComparator.ASCEND;
        }
        Map<Long, Integer> sortedPageCount = new TreeMap<Long, Integer>(new CompareToComparator<Long>(cs));
        for (Entry<Integer, Long> e : totalPageSummary.entrySet()) {
            sortedPageCount.put(e.getValue(), e.getKey());
        }
        List<Integer> sortedUid = new ArrayList<Integer>(sortedPageCount.values());

        spaces = new ArrayList<Space>();
        if (StringUtils.isBlank(filter)) {
            //SortBy PageCount won't as sub-prime search keyword - it is hard to implemented, so only it is primary keyword, sort them

            //now, sort totalPageSummary, then get space one by one
            int from = (page - 1) * PAGE_SIZE;
            if (from < sortedUid.size()) {
                //get sub-list 
                int end = Math.min(sortedUid.size(), from + PAGE_SIZE);
                sortedUid = sortedUid.subList(from, end);
                for (Integer spaceUid : sortedUid) {
                    spaces.add(spaceService.getSpace(spaceUid));
                }

            }
        } else {
            //if filter has some value. It is possible retrieve all spaces one by one if filter doesn't actually
            //match any spaces! It is disaster! So we try to find out all spaces with that filter first. then 
            //sub list it.
            Map<Integer, Space> uidMap = new HashMap<Integer, Space>();
            List<Space> fitlerOutSpaces = spaceService.getSpaces(viewer, 0, -1, null, filter, false);
            //we save spaces with uid, so it is easier to find out it by uid
            for (Space space : fitlerOutSpaces) {
                uidMap.put(space.getUid(), space);
            }
            for (Integer spaceUid : sortedUid) {
                Space space = uidMap.get(spaceUid);
                if (space != null) {
                    spaces.add(space);
                    if (spaces.size() > PAGE_SIZE)
                        break;
                }
            }

        }
    } else {
        String sortSeq = getSortBySequence(WikiConstants.SESSION_NAME_SPACE_SORTBY, sortBy);
        //don't input Space.SORT_BY_PAGE_COUNT! it is not valid sort parameter for this method, cause unexpected sort result
        spaces = spaceService.getSpaces(viewer, (page - 1) * PAGE_SIZE, PAGE_SIZE, sortSeq, filter, sortByDesc);
    }

    for (Space space : spaces) {
        //skip system DAO
        if (SharedConstants.SYSTEM_SPACEUNAME.equals(space.getUnixName())) {
            continue;
        }
        SpaceDTO dto = getSpaceDTO(space);

        dto.setCreatedDate(DateUtil.toDisplayDate(viewer, space.getCreatedDate(), messageService));

        dto.setSmallLogoUrl(SpaceUtil.getSpaceLogoUrl(space, themeService, space.getLogoSmall(), false));
        Long totalP = totalPageSummary.get(space.getUid());
        if (totalP == null) {
            AuditLogger.error("Unexpected : space " + space.getUnixName() + " cannot get page count");
            dto.setTotalPages(0);
        } else {
            dto.setTotalPages(totalP.longValue());
        }

        list.add(dto);
    }

    PageInfo pInfo = new PageInfo();
    pInfo.setCurrentPage(page);
    pInfo.setTotalPage(total / PAGE_SIZE + (total % PAGE_SIZE > 0 ? 1 : 0));

    getRequest().setAttribute("total", total);
    getRequest().setAttribute("spaces", list);
    getRequest().setAttribute("pagination", pInfo);

    return "list";
}

From source file:es.tid.fiware.rss.service.SettlementManager.java

/**
 * Create RS Model.//  w ww . j av  a  2  s .c  om
 * 
 * @param providerId
 * @param productClass
 * @param revenue
 * @throws IOException
 */
public void runCreateRSModel(String providerId, String productClass, Long revenue) throws IOException {
    logger.debug("Creating RsModel. Provider: {} productClass {}  revenue:", providerId, productClass,
            revenue.toString());
    SetRevenueShareConf rsModel = new SetRevenueShareConf();
    SetRevenueShareConfId id = new SetRevenueShareConfId();
    rsModel.setId(id);
    rsModel.setNuPercRevenueShare(BigDecimal.valueOf(revenue.longValue()));
    id.setTxAppProviderId(providerId);
    id.setProductClass(productClass);
    id.setNuObId(Long.valueOf(1));
    id.setCountryId(Long.valueOf(1));
    revenueShareConfDao.create(rsModel);
}

From source file:com.brightcove.com.uploader.verifier.ExistenceCheck.java

/**
 * Asserts that a video is retrievable via Media api.
 * This wraps  JUnit asserts and will behave accordingly.
 * @param videoID video to find//from w ww.j ava  2  s .  co m
 * @param token api read token the video belongs to
 * @throws MediaAPIError
 * @throws URISyntaxException
 * @throws JSONException
 */
public void assertVideoExists(Long videoID, String token)
        throws MediaAPIError, URISyntaxException, JSONException {

    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("command", "find_video_by_id"));
    parameters.add(new BasicNameValuePair("video_id", "" + videoID));
    parameters.add(new BasicNameValuePair("token", token));
    // Build up URL from the parameters provided
    JsonNode jsonObject = mMediaAPIHelper.executeRead(mEnvironment, parameters);
    mLog.info("response to find by ID (" + videoID + "): " + jsonObject);

    assertNotNull(jsonObject);
    assertEquals(videoID.longValue(), jsonObject.get("id").getLongValue());

}