com.liferay.portal.kernel.json.JSONObject.getLong()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(12.8k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中com.liferay.portal.kernel.json.JSONObject.getLong()方法的一些代码示例,展示了JSONObject.getLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.getLong()方法的具体详情如下:
包路径:com.liferay.portal.kernel.json.JSONObject
类名称:JSONObject
方法名:getLong

JSONObject.getLong介绍

暂无

代码示例

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

public static Set<Long> toLongSet(
  JSONArray jsonArray, String jsonObjectKey) {
  if (jsonArray == null) {
    return Collections.emptySet();
  }
  Set<Long> values = new HashSet<>(jsonArray.length());
  for (int i = 0; i < jsonArray.length(); i++) {
    JSONObject jsonObject = jsonArray.getJSONObject(i);
    values.add(jsonObject.getLong(jsonObjectKey));
  }
  return values;
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

protected AssetRenderer<?> getAssetRenderer(JSONObject jsonObject) {
  String className = jsonObject.getString("className");
  long classPK = jsonObject.getLong("classPK");
  return getAssetRenderer(className, classPK);
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

public static long[] toLongArray(
  JSONArray jsonArray, String jsonObjectKey) {
  if (jsonArray == null) {
    return new long[0];
  }
  long[] values = new long[jsonArray.length()];
  for (int i = 0; i < jsonArray.length(); i++) {
    JSONObject jsonObject = jsonArray.getJSONObject(i);
    values[i] = jsonObject.getLong(jsonObjectKey);
  }
  return values;
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

private String _getUserFullName(JSONObject jsonObject) {
  String fullName = jsonObject.getString("fullName");
  if (Validator.isNotNull(fullName)) {
    return fullName;
  }
  return PortalUtil.getUserName(
    jsonObject.getLong("userId"), StringPool.BLANK);
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

long groupId = jsonObject.getLong("groupId");

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

serviceContext.setCompanyId(jsonObject.getLong("companyId"));
serviceContext.setLayoutFullURL(jsonObject.getString("layoutFullURL"));
serviceContext.setLayoutURL(jsonObject.getString("layoutURL"));
serviceContext.setPathMain(jsonObject.getString("pathMain"));
serviceContext.setPlid(jsonObject.getLong("plid"));
serviceContext.setPortalURL(jsonObject.getString("portalURL"));
serviceContext.setScopeGroupId(jsonObject.getLong("scopeGroupId"));
serviceContext.setUserDisplayURL(
  jsonObject.getString("userDisplayURL"));
serviceContext.setUserId(jsonObject.getLong("userId"));

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

public AuditMessage(String message) throws JSONException {
  JSONObject jsonObject = JSONFactoryUtil.createJSONObject(message);
  _additionalInfoJSONObject = jsonObject.getJSONObject(_ADDITIONAL_INFO);
  _className = jsonObject.getString(_CLASS_NAME);
  _classPK = jsonObject.getString(_CLASS_PK);
  if (jsonObject.has(_CLIENT_HOST)) {
    _clientHost = jsonObject.getString(_CLIENT_HOST);
  }
  if (jsonObject.has(_CLIENT_IP)) {
    _clientIP = jsonObject.getString(_CLIENT_IP);
  }
  _companyId = jsonObject.getLong(_COMPANY_ID);
  _eventType = jsonObject.getString(_EVENT_TYPE);
  _message = jsonObject.getString(_MESSAGE);
  if (jsonObject.has(_SERVER_NAME)) {
    _serverName = jsonObject.getString(_SERVER_NAME);
  }
  if (jsonObject.has(_SERVER_PORT)) {
    _serverPort = jsonObject.getInt(_SERVER_PORT);
  }
  if (jsonObject.has(_SESSION_ID)) {
    _sessionID = jsonObject.getString(_SESSION_ID);
  }
  _timestamp = GetterUtil.getDate(
    jsonObject.getString(_TIMESTAMP), _getDateFormat());
  _userId = jsonObject.getLong(_USER_ID);
  _userName = jsonObject.getString(_USER_NAME);
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.service

protected Layout fetchImportedLayout(
  PortletDataContext portletDataContext, JSONObject jsonObject) {
  Map<Long, Layout> layouts =
    (Map<Long, Layout>)portletDataContext.getNewPrimaryKeysMap(
      Layout.class + ".layout");
  long layoutId = jsonObject.getLong("layoutId");
  Layout layout = layouts.get(layoutId);
  if (layout == null) {
    if (_log.isWarnEnabled()) {
      _log.warn("Unable to find layout with ID " + layoutId);
    }
  }
  return layout;
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.form.field.type

protected FileEntry getFileEntry(JSONObject valueJSONObject) {
  try {
    return dlAppService.getFileEntryByUuidAndGroupId(
      valueJSONObject.getString("uuid"),
      valueJSONObject.getLong("groupId"));
  }
  catch (PortalException pe) {
    _log.error("Unable to retrieve file entry ", pe);
    return null;
  }
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.service

protected String handleJSON(String value, Locale locale) {
  JSONObject jsonObject = null;
  try {
    jsonObject = JSONFactoryUtil.createJSONObject(value);
  }
  catch (JSONException jsone) {
    if (_log.isDebugEnabled()) {
      _log.debug("Unable to parse JSON", jsone);
    }
    return StringPool.BLANK;
  }
  long groupId = jsonObject.getLong("groupId");
  boolean privateLayout = jsonObject.getBoolean("privateLayout");
  long layoutId = jsonObject.getLong("layoutId");
  try {
    return LayoutServiceUtil.getLayoutName(
      groupId, privateLayout, layoutId,
      LanguageUtil.getLanguageId(locale));
  }
  catch (Exception e) {
    if (e instanceof NoSuchLayoutException ||
      e instanceof PrincipalException) {
      return LanguageUtil.format(
        locale, "is-temporarily-unavailable", "content");
    }
  }
  return StringPool.BLANK;
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.api

protected FileEntry fetchTempFileEntry(String value)
  throws PortalException {
  if (Validator.isNull(value)) {
    return null;
  }
  JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value);
  boolean tempFile = jsonObject.getBoolean("tempFile");
  if (!tempFile) {
    return null;
  }
  return DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(
    jsonObject.getString("uuid"), jsonObject.getLong("groupId"));
}

代码示例来源:origin: com.liferay/com.liferay.exportimport.service

@Override
public Map<Long, Boolean> getLayoutIdMap(PortletRequest portletRequest)
  throws PortalException {
  Map<Long, Boolean> layoutIdMap = new LinkedHashMap<>();
  String layoutIdsJSON = GetterUtil.getString(
    portletRequest.getAttribute("layoutIdMap"));
  if (Validator.isNull(layoutIdsJSON)) {
    return layoutIdMap;
  }
  JSONArray jsonArray = JSONFactoryUtil.createJSONArray(layoutIdsJSON);
  for (int i = 0; i < jsonArray.length(); ++i) {
    JSONObject jsonObject = jsonArray.getJSONObject(i);
    long plid = jsonObject.getLong("plid");
    boolean includeChildren = jsonObject.getBoolean("includeChildren");
    layoutIdMap.put(plid, includeChildren);
  }
  return layoutIdMap;
}

代码示例来源:origin: com.liferay/com.liferay.exportimport.service

@Override
protected String getLink(
    UserNotificationEvent userNotificationEvent,
    ServiceContext serviceContext)
  throws Exception {
  PortletURL renderURL = PortletURLFactoryUtil.create(
    serviceContext.getRequest(), ExportImportPortletKeys.EXPORT_IMPORT,
    PortletRequest.RENDER_PHASE);
  renderURL.setParameter("mvcPath", "/view_export_import.jsp");
  JSONObject jsonObject = JSONFactoryUtil.createJSONObject(
    userNotificationEvent.getPayload());
  long backgroundTaskId = jsonObject.getLong("backgroundTaskId");
  BackgroundTask backgroundTask =
    _backgroundTaskLocalService.fetchBackgroundTask(backgroundTaskId);
  if (backgroundTask == null) {
    return StringPool.BLANK;
  }
  renderURL.setParameter(
    "backgroundTaskId", String.valueOf(backgroundTaskId));
  renderURL.setParameter("backURL", serviceContext.getCurrentURL());
  return renderURL.toString();
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.form.field.type

@Override
public String render(DDMFormFieldValue ddmFormFieldValue, Locale locale) {
  JSONObject jsonObject =
    documentLibraryDDMFormFieldValueAccessor.getValue(
      ddmFormFieldValue, locale);
  String uuid = jsonObject.getString("uuid");
  long groupId = jsonObject.getLong("groupId");
  if (Validator.isNull(uuid) || (groupId == 0)) {
    return StringPool.BLANK;
  }
  try {
    FileEntry fileEntry = dlAppService.getFileEntryByUuidAndGroupId(
      uuid, groupId);
    return fileEntry.getTitle();
  }
  catch (Exception e) {
    return LanguageUtil.format(
      locale, "is-temporarily-unavailable", "content");
  }
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.service

@Override
public String get(DDMFormFieldValue ddmFormFieldValue) {
  Value value = ddmFormFieldValue.getValue();
  JSONObject jsonObject = createJSONObject(
    value.getString(locale));
  String className = jsonObject.getString("className");
  long classPK = jsonObject.getLong("classPK");
  if (Validator.isNull(className) && (classPK == 0)) {
    return StringPool.BLANK;
  }
  try {
    AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(
      className, classPK);
    return assetEntry.getTitle(locale);
  }
  catch (Exception e) {
    return LanguageUtil.format(
      locale, "is-temporarily-unavailable", "content");
  }
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.service

@Override
public String get(DDMFormFieldValue ddmFormFieldValue) {
  Value value = ddmFormFieldValue.getValue();
  JSONObject jsonObject = createJSONObject(
    value.getString(locale));
  String uuid = jsonObject.getString("uuid");
  long groupId = jsonObject.getLong("groupId");
  if (Validator.isNull(uuid) && (groupId == 0)) {
    return StringPool.BLANK;
  }
  try {
    FileEntry fileEntry =
      DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(
        uuid, groupId);
    return fileEntry.getTitle();
  }
  catch (Exception e) {
    return LanguageUtil.format(
      locale, "is-temporarily-unavailable", "content");
  }
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.service

protected FileEntry fetchImportedFileEntry(
    PortletDataContext portletDataContext, JSONObject jsonObject)
  throws PortalException {
  Map<Long, Long> groupIds =
    (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap(
      Group.class);
  long groupId = jsonObject.getLong("groupId");
  String uuid = jsonObject.getString("uuid");
  groupId = MapUtil.getLong(groupIds, groupId, groupId);
  if ((groupId > 0) && Validator.isNotNull(uuid)) {
    try {
      return _dlAppService.getFileEntryByUuidAndGroupId(
        uuid, groupId);
    }
    catch (NoSuchFileEntryException nsfee) {
      if (_log.isWarnEnabled()) {
        _log.warn(
          StringBundler.concat(
            "Unable to find file entry with uuid ", uuid,
            " and groupId ", groupId),
          nsfee);
      }
    }
  }
  return null;
}

代码示例来源:origin: com.liferay/com.liferay.dynamic.data.mapping.service

@Override
public void transform(DDMFormFieldValue ddmFormFieldValue)
  throws PortalException {
  Value value = ddmFormFieldValue.getValue();
  for (Locale locale : value.getAvailableLocales()) {
    String valueString = value.getString(locale);
    if (Validator.isNull(valueString)) {
      return;
    }
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject(
      valueString);
    long groupId = GetterUtil.getLong(jsonObject.get("groupId"));
    long layoutId = GetterUtil.getLong(
      jsonObject.getLong("layoutId"));
    boolean privateLayout = jsonObject.getBoolean("privateLayout");
    Layout layout = _layoutLocalService.fetchLayout(
      groupId, privateLayout, layoutId);
    if (layout == null) {
      continue;
    }
    Element entityElement =
      _portletDataContext.getExportDataElement(_stagedModel);
    _portletDataContext.addReferenceElement(
      _stagedModel, entityElement, layout,
      PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true);
  }
}

代码示例来源:origin: com.liferay/com.liferay.message.boards.web

protected void deleteDiscussionSocialActivities(
    String className, MBMessage message)
  throws PortalException {
  MBDiscussion discussion = _mbDiscussionLocalService.getThreadDiscussion(
    message.getThreadId());
  long classNameId = _classNameLocalService.getClassNameId(className);
  if (discussion.getClassNameId() != classNameId) {
    return;
  }
  long classPK = discussion.getClassPK();
  List<SocialActivity> socialActivities =
    _socialActivityLocalService.getActivities(
      0, className, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
  for (SocialActivity socialActivity : socialActivities) {
    if (Validator.isNull(socialActivity.getExtraData())) {
      continue;
    }
    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(
      socialActivity.getExtraData());
    long extraDataMessageId = extraDataJSONObject.getLong("messageId");
    if (message.getMessageId() == extraDataMessageId) {
      _socialActivityLocalService.deleteActivity(
        socialActivity.getActivityId());
    }
  }
}

代码示例来源:origin: com.liferay/com.liferay.journal.service

protected void addDocumentLibraryFileEntries(Element dynamicElementElement)
  throws PortalException {
  if (ExportImportThreadLocal.isImportInProcess()) {
    return;
  }
  for (Element dynamicContentElement :
      dynamicElementElement.elements("dynamic-content")) {
    String value = dynamicContentElement.getText();
    if (Validator.isNull(value)) {
      continue;
    }
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value);
    boolean tempFile = jsonObject.getBoolean("tempFile");
    if (!tempFile) {
      continue;
    }
    String uuid = jsonObject.getString("uuid");
    long groupId = jsonObject.getLong("groupId");
    FileEntry fileEntry =
      dlAppLocalService.getFileEntryByUuidAndGroupId(uuid, groupId);
    String fileEntryName = DLUtil.getUniqueFileName(
      fileEntry.getGroupId(), fileEntry.getFolderId(),
      fileEntry.getFileName());
    dlAppLocalService.addFileEntry(
      fileEntry.getUserId(), fileEntry.getGroupId(), 0, fileEntryName,
      fileEntry.getMimeType(), fileEntryName, StringPool.BLANK,
      StringPool.BLANK, fileEntry.getContentStream(),
      fileEntry.getSize(), new ServiceContext());
  }
}

相关文章