本文整理汇总了Java中com.liferay.portal.kernel.json.JSONException类的典型用法代码示例。如果您正苦于以下问题:Java JSONException类的具体用法?Java JSONException怎么用?Java JSONException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONException类属于com.liferay.portal.kernel.json包,在下文中一共展示了JSONException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}