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

Java JSONException类代码示例

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

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



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

示例1: parseJSONObject

import com.liferay.portal.kernel.json.JSONException; //导入依赖的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


示例2: parseJSONObject

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * @param keyValues
 * @param jsonArray
 * @return
 * @throws JSONException
 */
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,代码行数:24,代码来源:DeliverableIndexer.java


示例3: updateOfficeSitePreferencesByKey

import com.liferay.portal.kernel.json.JSONException; //导入依赖的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


示例4: getPreferenceByKey

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
@Override
public String getPreferenceByKey(long id, long groupId, String key, ServiceContext serviceContext) {
	Preferences preferences = PreferencesLocalServiceUtil.fetchByF_userId(groupId, id);
	String result = StringPool.BLANK;
	try {
		
		JSONObject jsonObject = JSONFactoryUtil.createJSONObject(preferences.getPreferences());
		
		result = jsonObject.getString(key);
		
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	return result;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:18,代码来源:UserActions.java


示例5: updatePreferences

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
@Override
public String updatePreferences(long id, long groupId, String key, String value, ServiceContext serviceContext)
		throws NoSuchUserException, NotFoundException, UnauthenticationException, UnauthorizationException, DuplicateCategoryException {
	Preferences preferences = PreferencesLocalServiceUtil.fetchByF_userId(groupId, id);
	
	JSONObject jsonObject;
	try {
		jsonObject = JSONFactoryUtil.createJSONObject(preferences.getPreferences());
		
		jsonObject.put(key, value);
		
		preferences = PreferencesLocalServiceUtil.updatePreferences(id, preferences.getPreferencesId(), jsonObject.toJSONString(), serviceContext);
		
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	
	return preferences.getPreferences();
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:22,代码来源:UserActions.java


示例6: setTypeParam

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * Set types (asset types to search for).
 * 
 * @throws ClassNotFoundException
 * @throws PatternSyntaxException
 * @throws JSONException 
 */
protected void setTypeParam()
	throws PatternSyntaxException, ClassNotFoundException, JSONException {

	String typeFilter =
		ParamUtil.getString(_portletRequest, GSearchWebKeys.FILTER_TYPE);

	List<String> classNames = new ArrayList<String>();

	String className = parseAssetClass(typeFilter);

	if (className != null) {
		classNames.add(className);
	}
	else {
		classNames.addAll(parseDefaultAssetClasses());
	}

	_queryParams.setClassNames(classNames);
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:27,代码来源:QueryParamsBuilderImpl.java


示例7: setFacets

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setFacets(SearchContext searchContext)
	throws JSONException {
	
	JSONArray configuration = JSONFactoryUtil.createJSONArray(_gSearchConfiguration.facetConfiguration());

	for (int i = 0; i < configuration.length(); i++) {

		JSONObject item = configuration.getJSONObject(i);

		String fieldName = item.getString("fieldName");
		
		Facet facet = new MultiValueFacet(searchContext);
		facet.setFieldName(fieldName);
		facet.setStatic(false);

		searchContext.addFacet(facet);
	}
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:23,代码来源:FacetsBuilderImpl.java


示例8: jsonToMap

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
public static Map<String, Object> jsonToMap(JSONObject json) {
	Map<String, Object> retMap = new HashMap<String, Object>();

	if (Validator.isNotNull(json)) {
		try {
			retMap = toMap(json);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return retMap;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:14,代码来源:DossierFileListenner.java


示例9: toList

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
public static List<Object> toList(JSONArray array) throws JSONException {
	List<Object> list = new ArrayList<Object>();
	for (int i = 0; i < array.length(); i++) {
		Object value = array.getJSONObject(i);

		if (value instanceof JSONObject) {
			value = toMap((JSONObject) value);
		}
		list.add(value);
	}
	return list;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:13,代码来源:DossierFileListenner.java


示例10: jsonToMap

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private Map<String, Object> jsonToMap(JSONObject json) {
	Map<String, Object> retMap = new HashMap<String, Object>();

	if (Validator.isNotNull(json)) {
		try {
			retMap = toMap(json);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return retMap;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:14,代码来源:DossierFileLocalServiceImpl.java


示例11: createFromJSON

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
public static Configuracao createFromJSON(String json) throws JSONException {
	JSONObject jsonObj = JSONFactoryUtil.createJSONObject(json);

	long comunidadeSelecionada = jsonObj.getLong("comunidadeSelecionada");
	int periodoEmDias = jsonObj.getInt("periodoEmDias");
	int qtdDeRecursos = jsonObj.getInt("qtdDeRecursos");
	int modoVisualizacao = jsonObj.getInt("modoVisualizacao");
	int recurso = jsonObj.getInt("recurso");

	return new Configuracao(comunidadeSelecionada, periodoEmDias, qtdDeRecursos, modoVisualizacao, recurso);
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:12,代码来源:Configuracao.java


示例12: getConfiguracao

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * Recupera as configurações do portlet
 * 
 * Se não encontrar retorna null
 * 
 * @return
 * @throws JSONException
 */
public static Configuracao getConfiguracao() throws JSONException {
	
	PortletPreferences portletPrefs = LiferayFacesContext.getInstance().getPortletPreferences();
	String json = portletPrefs.getValue(CONFIGURACAO_KEY, null);
	
	if (json != null) {
		return Configuracao.createFromJSON(json);
	} else {
		return null;
	}
	
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:21,代码来源:ConfiguracaoManager.java


示例13: carregarConfiguracao

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private void carregarConfiguracao() {
	try {
		Configuracao config = ConfiguracaoManager.getConfiguracao();
		if (config == null) {
			this.config = Configuracao.getConfiguracaoPadrao();
		} else {
			this.config = config;
		}
	} catch (JSONException e) {
		mostrarMensagemDeErro("Erro ao carregar configuração.");
		_log.error("Ocorreu um erro ao carregar configuracao.", e);
	}
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:14,代码来源:ConfiguracaoBean.java


示例14: carregarConfiguracao

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private void carregarConfiguracao() {
	
	try {
		config = ConfiguracaoManager.getConfiguracao();

	} catch (JSONException e) {
		mostrarMensagemDeErro("Erro ao recuperar dados.");
		_log.error("Erro ao recuperar dados.",e);
	}
	
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:12,代码来源:InitBean.java


示例15: getPollerRequestDataMap

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private static Map<String, String> getPollerRequestDataMap(JSONObject dataJSON) throws JSONException {
	
	Map<String, String> dataMap = new HashMap<String, String>();
	
	Iterator<String> iterator = dataJSON.keys();
	while (iterator.hasNext()) {
		String key = iterator.next();
		dataMap.put(key, dataJSON.getString(key));
	}
	
	return dataMap;
}
 
开发者ID:saggiyogesh,项目名称:liferay-node-poller,代码行数:13,代码来源:PollerProcessorUtil.java


示例16: _doReceiveJasperRequest

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private void _doReceiveJasperRequest(Message message) {
	// TODO Auto-generated method stub
	_log.info("Jasper processing .............................");
	JSONObject msgData = (JSONObject) message.get("msgToEngine");

	File file = FileUtil.createTempFile(JRReportUtil.DocType.PDF.toString());

	try {

		long userId = msgData.getLong("userId");

		long classPK = msgData.getLong("classPK");

		String className = msgData.getString("className");
		
		JSONObject jsonData = JSONFactoryUtil.createJSONObject();
		try {
			jsonData = JSONFactoryUtil.createJSONObject(msgData.getString("formData"));
		} catch (JSONException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		String fileExport = JRReportUtil.createReportFile(msgData.getString("jrxmlTemplate"),
				jsonData.toJSONString(), null, file.getCanonicalPath());

		if (Validator.isNotNull(fileExport)) {
			
			_log.info("Jasper export success: " + fileExport);
			
			JSONObject msgDataIn = JSONFactoryUtil.createJSONObject();
			msgDataIn.put("className", className);
			msgDataIn.put("classPK", classPK);
			msgDataIn.put("userId", userId);
			msgDataIn.put("filePath", fileExport );
			
			message.put("msgToEngine", msgDataIn);
			MessageBusUtil.sendMessage("jasper/dossier/in/destination", message);
		}

	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

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


示例17: notificationByType

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
public static void notificationByType(String[] notificationTypeList) {

		List<NotificationQueue> listQueue = NotificationQueueLocalServiceUtil.getNotificationQueues(QueryUtil.ALL_POS,
				QueryUtil.ALL_POS);

		ServiceContext serviceContext = new ServiceContext();

		for (NotificationQueue notificationQueue : listQueue) {
			
			serviceContext.setCompanyId(notificationQueue.getCompanyId());
			serviceContext.setUserId(notificationQueue.getUserId());
			serviceContext.setScopeGroupId(notificationQueue.getGroupId());
			
			long groupId = notificationQueue.getGroupId();

			String queueType = notificationQueue.getNotificationType();

			try {

				JSONObject payLoadData = JSONFactoryUtil.createJSONObject(notificationQueue.getPayload());

				for (String type : notificationTypeList) {

					if (queueType.equals(type)) {

						Notificationtemplate notificationtemplate = NotificationtemplateLocalServiceUtil
								.fetchByF_NotificationtemplateByType(groupId, type);

						JSONObject payLoad = JSONFactoryUtil.createJSONObject();

						payLoad.put("toName", payLoadData.get("toName") );
						payLoad.put("toAddress", payLoadData.get("toAddress"));
						payLoad.put("subject", payLoadData.get("subject"));
						payLoad.put("body", payLoadData.get("body") );
						
//								StringUtil.replace(notificationtemplate.getEmailBody(),
//										new String[] { "[$USERNAME$]", "[$USEREMAIL$]", "[$PASSWORD$]", "[$PASSWORD_CODE$]", "[$USERSTATUS$]" },
//										new String[] { payLoadData.getString("USERNAME"),
//												payLoadData.getString("toName"),
//												payLoadData.getString("PASSWORD"),
//												payLoadData.getString("PASSWORD_CODE"),
//												payLoadData.getString("USERSTATUS") }));

						SendMailUtils.sendEmailNotification(payLoad, serviceContext);

						try {
							NotificationQueueLocalServiceUtil.deleteNotificationQueue(
									notificationQueue.getNotificationQueueId(), serviceContext);
						} catch (NoSuchNotificationQueueException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}

					}

				}

			} catch (JSONException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

		}

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


示例18: createPermissionsPatch

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
@Override
public void createPermissionsPatch(long userId, long companyId, long groupId, long id, String permissions,
		ServiceContext serviceContext) {
	try {

		JSONArray jPermissions = JSONFactoryUtil.createJSONArray(permissions);

		List<String> actionIds = new ArrayList<>();
		for (int n = 0; n < jPermissions.length(); n++) {
			JSONObject action = jPermissions.getJSONObject(n);

			actionIds.add(action.getString("actionId"));

		}

		String[] actionKey = actionIds.toArray(new String[actionIds.size()]);

		JobPosLocalServiceUtil.assignPermission(id, actionKey, serviceContext);

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

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


示例19: parseAssetClass

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * Parse asset class name corresponding the key.
 * 
 * @param key
 *            search key
 * @return corresponding class name.
 * @throws JSONException 
 */
protected String parseAssetClass(String key) throws JSONException, ClassNotFoundException {

	JSONArray configurationArray = JSONFactoryUtil.createJSONArray(_gSearchConfiguration.typeConfiguration());
	
	String className = null;

	for (int i = 0; i < configurationArray.length(); i++) {
		
		JSONObject item = configurationArray.getJSONObject(i);

		if (key.equals(item.getString("key"))) {
		
			className = item.getString("entryClassName");
			break;
		}
	}

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


示例20: parseDefaultAssetClasses

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * Parse default set of asset class names to search for.
 * 
 * @return list of class names
 * @throws JSONException 
 */
protected List<String> parseDefaultAssetClasses()
	throws ClassNotFoundException, JSONException {

	JSONArray configurationArray = JSONFactoryUtil.createJSONArray(_gSearchConfiguration.typeConfiguration());
	
	List<String> classNames = new ArrayList<String>();

	for (int i = 0; i < configurationArray.length(); i++) {
		
		JSONObject item = configurationArray.getJSONObject(i);
	
		classNames.add(item.getString("entryClassName"));
	}

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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