Example usage for java.lang Long toString

List of usage examples for java.lang Long toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Long 's value.

Usage

From source file:com.facebook.ads.sdk.ProductFeedUpload.java

public static ProductFeedUpload fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:io.seldon.memcache.MemCacheKeys.java

public static String getRecommendedItemsPerAlgKey(String client, String algName, Long user, int dimensionId) {
    return "" + keys.RecommendedItems + ":" + client + ":" + algName + ":" + user.toString() + ":"
            + dimensionId;//w  ww  .  jav  a2  s . c o  m
}

From source file:com.weavers.duqhan.util.GoogleBucketFileUploader.java

public static String uploadProductImage(String url, Long productId) {
    String imgUrl = "failure";
    try {//w  ww. j ava  2 s  .  c o m
        GoogleBucketFileUploader fileUploader = new GoogleBucketFileUploader();
        Storage storage = fileUploader.authentication();
        InputStream input = new URL(url).openStream();
        if (input != null) {
            DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
            DateTime dt = DateTime.now(DateTimeZone.UTC);
            String dtString = dt.toString(dtf);
            final String fileName = "img_" + productId.toString() + dtString + ".jpg";
            // the inputstream is closed by default, so we don't need to close it here
            BlobInfo blobInfo = storage.create(
                    BlobInfo.newBuilder(PRODUCT_BUCKET_NAME, fileName).setContentType("image/jpeg")
                            // Modify access list to allow all users with link to read file
                            .setAcl(new ArrayList<>(
                                    Arrays.asList(Acl.of(Acl.User.ofAllUsers(), Acl.Role.OWNER))))
                            .build(),
                    input);
            // return the public view link
            imgUrl = "https://storage.googleapis.com/" + PRODUCT_BUCKET_NAME + "/" + blobInfo.getName();
            //                imgUrl = "https://storage.googleapis.com/duqhan-images/" + blobInfo.getName();
        }
    } catch (Exception ex) {
        Logger.getLogger(GoogleBucketFileUploader.class.getName()).log(Level.SEVERE, null, ex);
    }
    return imgUrl;
}

From source file:com.facebook.ads.sdk.AdImage.java

public static AdImage fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:com.facebook.ads.sdk.EventSourceGroup.java

public static EventSourceGroup fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:com.facebook.ads.sdk.Lead.java

public static Lead fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:kz.supershiny.core.services.ImageService.java

/**
 * Creates a filename for a photo of a good.
 * Syntax: goodId-imagesize-filename//w w  w  .j  av  a 2s.c  o m
 * 
 * @param goodId
 * @param originalFilename
 * @param type original - 0, large - 1, small - 2
 * @return 
 */
public static String getPhotoFilename(Long goodId, String originalFilename, ImageSize type) {
    if (goodId == null)
        return null;
    String prefix = "";
    switch (type) {
    case LARGE:
        prefix = ImageSize.LARGE.name();
        break;
    case SMALL:
        prefix = ImageSize.SMALL.name();
        break;
    default:
        prefix = ImageSize.ORIGINAL.name();
        break;
    }
    if (originalFilename == null || originalFilename.isEmpty()) {
        originalFilename = "photo";
    }
    return goodId.toString() + "-" + prefix + "-" + originalFilename;
}

From source file:ext.usercenter.UCClient.java

/**
 * ?helome??id?/*w  w  w . j  a  v a2  s  .c o  m*/
 * @param userId id
 * @return
 */
public static User queryUserById(Long userId) {
    long beginMillis = System.currentTimeMillis();

    String post = postNullIgnore("/remote/security/findUserInfoByPrivateId", "privateId", userId.toString(),
            "product", product);
    long endMillis = System.currentTimeMillis();
    long callTime = endMillis - beginMillis;
    callTimeLog(callTime, "queryUserById", "/remote/security/findUserInfoByPrivateId");
    return parseJsonForQueryUserById(post);
}

From source file:airlift.util.AirliftUtil.java

/**
 * Converts long to byte array.// w ww  .ja va2 s  .  c o  m
 *
 * @param _number the _number
 * @return the byte[]
 */
public static byte[] convert(java.lang.Long _number) {
    return (_number == null) ? null : convert(_number.toString());
}

From source file:com.clustercontrol.hub.util.CollectStringDataUtil.java

/**
 * /*  www  .j  av  a  2s  .c  o m*/
 * @param sampleList
 */
public static void store(List<StringSample> sampleList) {
    m_log.debug("store() start");

    List<CollectStringData> collectdata_entities = new ArrayList<CollectStringData>();
    JpaTransactionManager jtm = new JpaTransactionManager();
    jtm.begin();

    Map<String, MonitorInfo> monitorInfoMap = new HashMap<>();
    Map<String, CollectStringDataParser> parserMap = new HashMap<>();
    for (StringSample sample : sampleList) {
        for (StringSampleData data : sample.getStringSampleList()) {
            // for debug
            if (m_log.isDebugEnabled()) {
                m_log.debug("store() facilityId = " + data.getFacilityId() + ", dateTime = "
                        + sample.getDateTime());
                m_log.debug("store() value = " + data.getValue());
            }

            m_log.debug("persist targetName = " + data.getTargetName());

            String monitorId = sample.getMonitorId();
            String facilityId = data.getFacilityId();
            // ???512 ???
            String targetName = data.getTargetName().length() > 512 ? data.getTargetName().substring(0, 512)
                    : data.getTargetName();

            CollectStringData collectData = null;
            Long collectId = getCollectStringKeyInfoPK(monitorId, facilityId, targetName, jtm);

            Long dataId = StringDataIdGenerator.getNext();
            if (dataId == StringDataIdGenerator.getMax() / 2) {
                AplLogger.put(PriorityConstant.TYPE_WARNING, HinemosModuleConstant.HUB_TRANSFER,
                        MessageConstant.MESSAGE_HUB_COLLECT_NUMBERING_OVER_INTERMEDIATE, new String[] {},
                        String.format("current=%d, max=%d", dataId, StringDataIdGenerator.getMax()));
            }

            CollectStringDataPK pk = new CollectStringDataPK(collectId, dataId);

            String value = data.getValue() != null ? data.getValue() : "";
            collectData = new CollectStringData(pk, HinemosTime.currentTimeMillis(), value);

            if (!data.getTagList().isEmpty()) {
                Map<String, CollectDataTag> tagMap = new HashMap<>();
                for (StringSampleTag tag : data.getTagList()) {
                    tagMap.put(tag.getKey(),
                            new CollectDataTag(new CollectDataTagPK(collectId, dataId, tag.getKey()),
                                    tag.getType(), tag.getValue()));
                }
                collectData.getTagList().addAll(tagMap.values());
            }

            // 
            MonitorSettingControllerBean bean = new MonitorSettingControllerBean();
            try {
                MonitorInfo mi = monitorInfoMap.get(monitorId);
                if (mi == null) {
                    mi = bean.getMonitor(monitorId);
                    monitorInfoMap.put(monitorId, mi);
                }
                if (mi.getLogFormatId() != null) {
                    CollectStringDataParser parser = parserMap.get(mi.getLogFormatId());
                    if (parser == null) {
                        parser = new CollectStringDataParser(
                                new HubControllerBean().getLogFormat(mi.getLogFormatId()));
                        parserMap.put(mi.getLogFormatId(), parser);
                    }
                    parser.parse(collectData);

                    collectData.setLogformatId(mi.getLogFormatId());
                }

                // KEY_TIMESTAMP_IN_LOG ??????????
                CollectDataTag timestamp = null;
                for (CollectDataTag tag : collectData.getTagList()) {
                    if (tag.getKey().equals(CollectStringDataParser.KEY_TIMESTAMP_IN_LOG)) {
                        timestamp = tag;
                        break;
                    }
                }
                if (timestamp != null) {
                    try {
                        Long time = collectData.getTime();
                        collectData.setTime(Long.valueOf(timestamp.getValue()));
                        collectData.getTagList().add(new CollectDataTag(
                                new CollectDataTagPK(collectData.getCollectId(), collectData.getDataId(),
                                        CollectStringDataParser.KEY_TIMESTAMP_RECIEVED),
                                ValueType.number, time.toString()));
                    } catch (Exception e) {
                        m_log.warn("store() : fail to change to timestamp of log. time=" + timestamp.getValue(),
                                e);
                    }
                }
            } catch (MonitorNotFound | HinemosUnknown | InvalidRole e) {
                m_log.warn(String.format("failed to get a MonitorInfo : %s", sample.getMonitorId()));
            }

            collectdata_entities.add(collectData);

            m_log.debug("store() : " + collectData);
        }
    }

    jtm.commit();

    List<JdbcBatchQuery> query = new ArrayList<JdbcBatchQuery>();
    // ()?
    if (!collectdata_entities.isEmpty()) {
        query.add(new CollectStringDataJdbcBatchInsert(collectdata_entities));
        for (CollectStringData data : collectdata_entities) {
            query.add(new CollectStringTagJdbcBatchInsert(data.getTagList()));
        }
    }
    JdbcBatchExecutor.execute(query);
    jtm.close();
    m_log.debug("store() end");
}