• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JSONObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.liferay.portal.kernel.json.JSONObject的典型用法代码示例。如果您正苦于以下问题:Java JSONObject类的具体用法?Java JSONObject怎么用?Java JSONObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSONObject类属于com.liferay.portal.kernel.json包,在下文中一共展示了JSONObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateOfficeSitePreferencesByKey

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
@Override
public OfficeSite updateOfficeSitePreferencesByKey(long userId, long companyId, long groupId, long id, String key,
		String value, ServiceContext serviceContext)
		throws NoSuchUserException, NotFoundException, UnauthenticationException, UnauthorizationException {
	OfficeSite officeSite = OfficeSiteLocalServiceUtil.fetchOfficeSite(id);

	try {
		JSONObject jsonObject = JSONFactoryUtil.createJSONObject(officeSite.getPreferences());
		
		jsonObject.put(key, value);
		
		officeSite = OfficeSiteLocalServiceUtil.updateOfficeSite(userId, officeSite.getOfficeSiteId(), officeSite.getName(),
				officeSite.getEnName(), officeSite.getGovAgencyCode(), officeSite.getAddress(), officeSite.getTelNo(),
				officeSite.getFaxNo(), officeSite.getEmail(), officeSite.getWebsite(), officeSite.getLogoFileEntryId(),
				officeSite.getSiteGroupId(), officeSite.getAdminUserId(), jsonObject.toJSONString(), serviceContext);
		
		
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	return officeSite;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:25,代码来源:OfficeSiteActions.java


示例2: actionSaveFacetConfig

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
/**
 * This action saves the Liferay facet configuration for a given tab
 *
 * @param request The request
 * @param response The response
 * @throws PortletException If something goes wrong
 * @throws IOException If something goes wrong
 */
@ProcessAction(name = ACTION_NAME_SAVE_FACET_CONFIG)
public void actionSaveFacetConfig(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK);
    String facetClassName = ParamUtil.get(request, FORM_FIELD_FACET_CLASS_NAME, StringPool.BLANK);
    String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK);
    PortletPreferences preferences = request.getPreferences();
    FlashlightSearchConfiguration configuration = this.searchService.readConfiguration(preferences);
    SearchFacet targetFacet = this.getSearchFacetFromRequest(tabId, facetClassName, configuration);

    if(targetFacet != null) {
        JSONObject facetConfiguration = targetFacet.getJSONData(request);
        targetFacet.getFacetConfiguration().setDataJSONObject(facetConfiguration);
        this.searchService.saveSearchFacetConfig(configuration.getTabs().get(tabId), targetFacet, preferences);
        SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED);
        response.sendRedirect(redirectUrl);
    }
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:26,代码来源:FlashlightSearchPortlet.java


示例3: createReturnJson

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
/**
 * Create Return json value 
 * 
 * @param resourceRequest
 * @param resourceResponse
 * @param urls URL string list
 * @return json URL strings
 */
protected String createReturnJson(ResourceRequest resourceRequest, ResourceResponse resourceResponse, List<String> urls) {

	JSONObject rootJSONObject = JSONFactoryUtil.createJSONObject();
	
	//Add plain text with line breaks for textarea
	rootJSONObject.put("urlstr", String.join(LDFPortletKeys.EOL, urls));
	
	JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

	for ( String url : urls) {
		JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject();

		curUserJSONObject.put("url", url);
		jsonArray.put(curUserJSONObject);
	}
	rootJSONObject.put("urllist", jsonArray);

	return rootJSONObject.toJSONString();
}
 
开发者ID:yasuflatland-lf,项目名称:liferay-dummy-factory,代码行数:28,代码来源:ImageLinksMVCResourceCommand.java


示例4: getServiceProcesses

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
@Override
public JSONObject getServiceProcesses(long userId, long companyId, long groupId, LinkedHashMap<String, Object> params,
		Sort[] sorts, int start, int end, ServiceContext serviceContext) throws PortalException {
	JSONObject result = JSONFactoryUtil.createJSONObject();

	Hits hits = null;
	long count = 0;

	SearchContext searchContext = new SearchContext();
	searchContext.setCompanyId(companyId);

	hits = ServiceProcessLocalServiceUtil.searchLucene(params, sorts, start, end, searchContext);
	count = ServiceProcessLocalServiceUtil.countLucene(params, searchContext);

	result.put("total", count);
	result.put("data", hits.toList());

	return result;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:20,代码来源:ServiceProcessActionsImpl.java


示例5: getValueFormData

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
private JSONObject getValueFormData(String fileTemplateNo, long dossierId) {
	DossierFile dossierFile = null;
	JSONObject formValue = JSONFactoryUtil.createJSONObject();

	try {
		_log.info("fileTemplateNo" + fileTemplateNo);

		dossierFile = DossierFileLocalServiceUtil.getDossierFileByDID_FTNO_DPT_First(dossierId, fileTemplateNo, 2,
				false, new DossierFileComparator(false, "createDate", Date.class));

		_log.info("dossierFile_____" + Validator.isNotNull(dossierFile));

		if (Validator.isNotNull(dossierFile)) {
			formValue = JSONFactoryUtil.createJSONObject(dossierFile.getFormData());
		}

	} catch (Exception e) {
		_log.error(e);
	}

	return formValue;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:23,代码来源:DossierFileListenner.java


示例6: parseJSONObject

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
protected List<Object[]> parseJSONObject(
    List<Object[]> keyValues, JSONArray jsonArray)
    throws JSONException {

    if (jsonArray != null && jsonArray.length() > 0) {
        for (int i = 0; i < jsonArray.length(); i++) {
            Object tempObject = jsonArray.get(i);
            if (tempObject instanceof JSONObject) {
                parseJSONObject(keyValues, (JSONObject) tempObject);
            }
            else if (tempObject instanceof JSONArray) {
                parseJSONObject(keyValues, (JSONArray) tempObject);
            }
            else {
                // Tinh chung cho key cha.
            }
        }
    }

    return keyValues;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:22,代码来源:RegistrationFormIndexer.java


示例7: translateValues

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public JSONArray translateValues(
	QueryParams queryParams, FacetCollector facetCollector,
	JSONObject configuration)
	throws Exception {

	JSONArray facetArray = JSONFactoryUtil.createJSONArray();

	List<TermCollector> termCollectors = facetCollector.getTermCollectors();

	for (TermCollector tc : termCollectors) {

		JSONObject item = parseStructureData(tc, queryParams.getLocale());
		facetArray.put(item);
	}

	return facetArray;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:22,代码来源:WebContentStructureFacetTranslator.java


示例8: addMeasurement

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
private int addMeasurement(ServiceContext serviceContext, long userId,
        JSONObject data, String id, String name, Date timestamp,
        String unit, String value) throws Exception {

    Hits hits = _measurementLocalService.search(userId,
            serviceContext.getScopeGroupId(), null, id, null, null,
            timestamp, null, null, null, true, 0, 1, null);

    if (hits.getLength() == 0) {

        _measurementLocalService.addMeasurement(userId, data.toString(), id,
                name, timestamp, unit, value, serviceContext);

        return IMPORTED;

    } else {

        return IGNORED;
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-data-manager,代码行数:21,代码来源:MeasurementImportController.java


示例9: generalUserInfo

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
private JSONObject generalUserInfo(long userId) {
	ApplicantActions applicantActions = new ApplicantActionsImpl();
	String applicantName = StringPool.BLANK;
	try {
		Applicant applicant = applicantActions.getApplicantByMappingUserId(userId);
		if (applicant != null) {
			applicantName = applicant.getApplicantName();
		}
	} catch (PortalException e) {
		_log.error(e);
	}
	JSONObject userInfo = JSONFactoryUtil.createJSONObject();
	userInfo.put("actionUser", applicantName);

	return userInfo;

}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:18,代码来源:FrontendWebCustomerPortlet.java


示例10: pullPaymentFile

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
private void pullPaymentFile(String requestURL, String charset, long desGroupId, long dossierId,
		String authStringEnc, File file, String confirmNote, String paymentMethod, String confirmPayload,
		ServiceContext serviceContext) {

	try {
		MultipartUtility multipart = new MultipartUtility(requestURL, charset, desGroupId, authStringEnc,
				HttpMethod.PUT);
		// TODO; check logic here, if ref fileId in SERVER equal CLIENT

		multipart.addFilePart("file", file);
		multipart.addFormField("confirmNote", confirmNote);
		multipart.addFormField("paymentMethod", paymentMethod);
		multipart.addFormField("confirmPayload", confirmPayload);

		JSONObject object = JSONFactoryUtil.createJSONObject();

		List<String> response = multipart.finish();

		// resetDossier(desGroupId, dossierRef, false, serviceContext);

	} catch (Exception e) {
		_log.error(e);
	}

}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:26,代码来源:DossierPullScheduler.java


示例11: getRegistrationTemplates

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
@Override
public JSONObject getRegistrationTemplates(long groupId, String formNo, String govAgencyCode) {

	JSONObject result = JSONFactoryUtil.createJSONObject();
	List<RegistrationTemplates> lstRegistrationTemplates = null;
	try {
		if(formNo != null){
			lstRegistrationTemplates = RegistrationTemplatesLocalServiceUtil
					.getRegistrationTemplatesbyFormNo(groupId, formNo);
		}else{
			lstRegistrationTemplates = RegistrationTemplatesLocalServiceUtil
					.getRegistrationTemplatesbyGOVCODE(groupId, govAgencyCode);
		}

		result.put("total", lstRegistrationTemplates.size());
		result.put("lstRegistrationTemplate", lstRegistrationTemplates);

	} catch (Exception e) {
		_log.error(e);
	}

	return result;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:24,代码来源:RegistrationTemplatesActionsImpl.java


示例12: getGroupId

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
private long getGroupId(JSONObject response) {
	long groupId = 0l;

	try {

		if (response.getInt(RESTFulConfiguration.STATUS) == 200) {

			JSONObject jsData = JSONFactoryUtil.createJSONObject(response.getString(RESTFulConfiguration.MESSAGE));
			groupId = jsData.getLong("groupId");
		}

	} catch (Exception e) {
		// TODO: handle exception
	}

	return groupId;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:18,代码来源:RegistrationSyncScheduler.java


示例13: getDeliverableTypes

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
@Override
public JSONObject getDeliverableTypes(long groupId, int start, int end) {

	JSONObject result = JSONFactoryUtil.createJSONObject();

	try {
		if (start == 0) {
			start = -1;
			end = -1;
		}

		List<DeliverableType> lstDeliverableType = DeliverableTypeLocalServiceUtil.getDeliverableTypes(start, end);

		int total = DeliverableTypeLocalServiceUtil.getDeliverableTypesCount();

		result.put("total", total);
		result.put("lstDeliverableType", lstDeliverableType);

	} catch (Exception e) {
		_log.error(e);
	}

	return result;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:25,代码来源:DeliverableTypesActionsImpl.java


示例14: getPayload

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
public static JSONObject getPayload(String notiType, JSONObject object, long groupId) {
	JSONObject payload = JSONFactoryUtil.createJSONObject();

	try {
		
		_log.info("notiType"+notiType);
		_log.info("groupId"+groupId);
		
		Notificationtemplate notificationtemplate = NotificationtemplateLocalServiceUtil
				.fetchByF_NotificationtemplateByType(groupId, notiType);
		String body = getEmailBody(notificationtemplate, object);
		String subject = notificationtemplate.getEmailSubject();
		
		payload.put("toName", object.get("toName"));
		payload.put("toAddress", object.get("toAddress"));
		payload.put("subject", subject);
		payload.put("body", body);
	} catch (Exception e) {
		_log.error(e);
	}
	
	return payload;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:24,代码来源:ApplicantListenerUtils.java


示例15: getFormDataById

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
@Override
	public JSONObject getFormDataById(long companyId, LinkedHashMap<String, Object> params, Sort[] sorts, int start, int end,
			ServiceContext serviceContext) {
		JSONObject result = JSONFactoryUtil.createJSONObject();
		
		Hits hits = null;
		
		SearchContext searchContext = new SearchContext();
		searchContext.setCompanyId(companyId);
		
		try {
			
			hits = DeliverableLocalServiceUtil.searchLucene(params, sorts, start, end, searchContext);
			
			result.put("data", hits.toList());
			
//			long total = DeliverableLocalServiceUtil.countLucene(params, searchContext);
//			
//			result.put("total", total);
			
		} catch (Exception e) {
			_log.error(e);
		}
		
		return result;
	}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:27,代码来源:DeliverableActionsImpl.java


示例16: getStatisticByDomain

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
@Override
public Response getStatisticByDomain(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
		User user, ServiceContext serviceContext) {
	ServiceInfoActions actions = new ServiceInfoActionsImpl();
	
	long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
	
	JSONObject results = JSONFactoryUtil.createJSONObject();
	
	try {
		results = actions.getStatisticByDomain(serviceContext, groupId);
		
		_log.info(results);
		
		return Response.status(200).entity(JSONFactoryUtil.looseSerialize(results)).build();

	} catch (Exception e) {
		ErrorMsg error = new ErrorMsg();

			error.setMessage("Forbidden.");
			error.setCode(HttpURLConnection.HTTP_FORBIDDEN);
			error.setDescription("Forbidden.");
			
			return Response.status(HttpURLConnection.HTTP_FORBIDDEN).entity(error).build();
	}
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:27,代码来源:ServiceInfoManagementImpl.java


示例17: translateValues

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public JSONArray translateValues(
	QueryParams queryParams, FacetCollector facetCollector,
	JSONObject configuration)
	throws Exception {

	JSONArray facetArray = JSONFactoryUtil.createJSONArray();

	List<TermCollector> termCollectors = facetCollector.getTermCollectors();

	for (TermCollector tc : termCollectors) {

		JSONObject item = parseDocumentTypeData(tc, queryParams.getLocale());
		
		if (item != null) {
			facetArray.put(item);
		}
	}

	return facetArray;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:25,代码来源:DocumentTypeFacetTranslator.java


示例18: validateFile

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
protected void validateFile(ActionRequest actionRequest, ActionResponse actionResponse, String folderName)
        throws Exception {

    _log.info("validateFile()");

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    FileEntry fileEntry = ExportImportHelperUtil.getTempFileEntry(groupId, themeDisplay.getUserId(), folderName);

    InputStream inputStream = null;

    try {
        inputStream = _dlFileEntryLocalService.getFileAsStream(fileEntry.getFileEntryId(), fileEntry.getVersion(),
                false);

        // TODO: validate uploaded file

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
        //
        // if ((weakMissingReferences != null) &&
        // !weakMissingReferences.isEmpty()) {
        //
        // jsonObject.put("warningMessages",
        // StagingUtil.getWarningMessagesJSONArray(themeDisplay.getLocale(),
        // weakMissingReferences));
        // }

        JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);
    } finally {
        StreamUtil.cleanUp(inputStream);
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:35,代码来源:ImportTaskRecordsMVCActionCommand.java


示例19: generateServiceConfigs

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
private List<JSONObject> generateServiceConfigs(List<ServiceInfoServiceConfig> serviceConfigList) {

		List<JSONObject> serviceConfigs = new ArrayList<>();

		for (ServiceInfoServiceConfig cf : serviceConfigList) {
			JSONObject cfJson = JSONFactoryUtil.createJSONObject();

			cfJson.put("level", cf.getServiceLevel());
			cfJson.put("govAgencyCode", cf.getGovAgencyCode());
			cfJson.put("govAgencyName", cf.getGovAgencyName());
			// cfJson.put("serviceConfigId", cf.) // TODO need serviceConfigId
		}

		return serviceConfigs;
	}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:16,代码来源:ServiceConfigManagementImpl.java


示例20: getCategoryList

import com.liferay.portal.kernel.json.JSONObject; //导入依赖的package包/类
/**
 * Get Category list
 * 
 * @param resourceRequest
 * @param resourceResponse
 * @return
 * @throws PortalException 
 */
private String getCategoryList(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortalException {
	ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
	
	JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
	 
	String[] groupsStrIds = ParamUtil.getStringValues(resourceRequest, "groupIds",
			new String[] { String.valueOf(themeDisplay.getScopeGroupId()) });
	long[] groupIds = CommonUtil.convertStringToLongArray(groupsStrIds);		
	long siteGroupId = groupIds[0];

	if(_log.isDebugEnabled()) {
		_log.debug("SiteGroup Id <" + String.valueOf(siteGroupId) + ">");
	}
	
	List<MBCategory> categories = _mbCategoryLocalService.getCategories(
			siteGroupId, 
			MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, 
			WorkflowConstants.STATUS_APPROVED, 
			QueryUtil.ALL_POS, 
			QueryUtil.ALL_POS);
	
	for(MBCategory category : categories ) {
		JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject();
		
		if(_log.isDebugEnabled()) {
			_log.debug("Category name <" + category.getName() + ">");
			_log.debug(category.toString());
			_log.debug("----------");
		}
		
		curUserJSONObject.put("categoryId" , category.getCategoryId());
		curUserJSONObject.put("categoryName" , category.getName());
		
		jsonArray.put(curUserJSONObject);
	}
	
	return jsonArray.toJSONString();
}
 
开发者ID:yasuflatland-lf,项目名称:liferay-dummy-factory,代码行数:47,代码来源:MBMVCResourceCommand.java



注:本文中的com.liferay.portal.kernel.json.JSONObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IResourceServiceProvider类代码示例发布时间:2022-05-21
下一篇:
Java Yaml类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap