@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) { try { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!MentionsUtil.isMentionsEnabled(themeDisplay.getSiteGroupId())) { return; } HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); JSONArray jsonArray = getJSONArray(request); HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); response.setContentType(ContentTypes.APPLICATION_JSON); ServletResponseUtil.write(response, jsonArray.toString()); } catch (Exception e) { _log.error(e, e); } return; }
public JSONArray getJSONActivityDefinitions(long groupId, String className) throws PortalException, SystemException { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); List<SocialActivityDefinition> activityDefinitions = socialActivitySettingLocalService.getActivityDefinitions(groupId, className); for (SocialActivityDefinition activityDefinition : activityDefinitions) { JSONObject activityDefinitionJSONObject = JSONFactoryUtil.createJSONObject(JSONFactoryUtil.looseSerialize(activityDefinition)); JSONArray activityCounterDefinitionsJSONArray = JSONFactoryUtil.createJSONArray(); for (SocialActivityCounterDefinition activityCounterDefinition : activityDefinition.getActivityCounterDefinitions()) { JSONObject activityCounterDefinitionJSONObject = JSONFactoryUtil.createJSONObject( JSONFactoryUtil.looseSerialize(activityCounterDefinition)); activityCounterDefinitionsJSONArray.put(activityCounterDefinitionJSONObject); } activityDefinitionJSONObject.put("counters", activityCounterDefinitionsJSONArray); jsonArray.put(activityDefinitionJSONObject); } return jsonArray; }
public void getActionMethodNames( ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException { PrintWriter printWriter = resourceResponse.getWriter(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); String contextName = ParamUtil.getString(resourceRequest, "contextName"); Map<String, Set<JSONWebServiceActionMapping>> jsonWebServiceActionMappingsMap = getServiceJSONWebServiceActionMappingsMap(contextName); String serviceClassName = ParamUtil.getString(resourceRequest, "serviceClassName"); Set<JSONWebServiceActionMapping> jsonWebServiceActionMappingsSet = jsonWebServiceActionMappingsMap.get(serviceClassName); for (JSONWebServiceActionMapping jsonWebServiceActionMapping : jsonWebServiceActionMappingsSet) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); Method method = jsonWebServiceActionMapping.getActionMethod(); String actionMethodName = method.getName(); jsonObject.put("actionMethodName", actionMethodName); jsonArray.put(jsonObject); } printWriter.write(jsonArray.toString()); }
public void transform(Object object) { JSONArray jsonArray = (JSONArray) object; JSONContext jsonContext = getContext(); jsonContext.write(jsonArray.toString()); }
protected JSONArray getPortletURLsJSONArray(Map<String, PortletURL> portletURLs) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); if (MapUtil.isEmpty(portletURLs)) { return jsonArray; } for (Map.Entry<String, PortletURL> entry : portletURLs.entrySet()) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("name", entry.getKey()); PortletURL portletURL = entry.getValue(); portletURL.setParameter("selPlid", "{selPlid}"); jsonObject.put( "value", StringUtil.replace(portletURL.toString(), HttpUtil.encodePath("{selPlid}"), "{selPlid}")); jsonArray.put(jsonObject); } return jsonArray; }
public synchronized String getNotificationEvents(long timeout) throws ChannelException { try { if (!_complete) { this.wait(timeout); } } catch (InterruptedException ie) { } try { Thread.sleep(PropsValues.POLLER_NOTIFICATIONS_TIMEOUT); } catch (InterruptedException ie) { } List<NotificationEvent> notificationEvents = ChannelHubManagerUtil.getNotificationEvents(_companyId, _userId, true); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); jsonArray.put(_pollerResponseHeaderJSONObject); for (NotificationEvent notificationEvent : notificationEvents) { jsonArray.put(notificationEvent.toJSONObject()); } return jsonArray.toString(); }
protected JSONArray getServiceClassNamesToContextNamesJSONArray() { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); Set<String> contextNames = _jsonWebServiceActionsManager.getContextNames(); for (String contextName : contextNames) { Map<String, Set<JSONWebServiceActionMapping>> jsonWebServiceActionMappingsMap = getServiceJSONWebServiceActionMappingsMap(contextName); for (Map.Entry<String, Set<JSONWebServiceActionMapping>> entry : jsonWebServiceActionMappingsMap.entrySet()) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("serviceClassName", entry.getKey()); Set<JSONWebServiceActionMapping> jsonWebServiceActionMappingsSet = entry.getValue(); Iterator<JSONWebServiceActionMapping> iterator = jsonWebServiceActionMappingsSet.iterator(); JSONWebServiceActionMapping firstJSONWebServiceActionMapping = iterator.next(); jsonObject.put("contextName", firstJSONWebServiceActionMapping.getContextName()); jsonArray.put(jsonObject); } } return jsonArray; }
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { String id = resourceRequest.getResourceID(); if (id.equalsIgnoreCase("getBrokerTopics")) { JSONArray topics = JSONFactoryUtil.createJSONArray(); long brokerId = ParamUtil.getLong(resourceRequest, "brokerId"); long brokerMessageListenerId = ParamUtil.getLong(resourceRequest, "brokerMessageListenerId"); try { Broker b = BrokerLocalServiceUtil.fetchBroker(brokerId); BrokerMessageListener bml = (brokerMessageListenerId > 0) ? BrokerMessageListenerLocalServiceUtil.fetchBrokerMessageListener( brokerMessageListenerId) : null; String[] topicsArr = b.getTopics().split(";"); for (int i = 0; i < topicsArr.length; i++) { JSONObject obj = JSONFactoryUtil.createJSONObject(); obj.put("topic", topicsArr[i]); boolean checked = false; if (bml != null) { String[] messageListenerTopcs = bml.getTopics().split(";"); for (int j = 0; j < messageListenerTopcs.length && !checked; j++) { if (messageListenerTopcs[j].equalsIgnoreCase(topicsArr[i])) checked = true; } } obj.put("checked", checked); topics.put(obj); } } catch (Exception e) { logger.error(e); } resourceResponse.getWriter().println(topics.toString()); } }
protected long[] getLayoutIds(long groupId, boolean privateLayout, String layoutIdsJSON) throws Exception { if (Validator.isNull(layoutIdsJSON)) { return new long[0]; } List<Long> layoutIds = new ArrayList<Long>(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(layoutIdsJSON); for (int i = 0; i < jsonArray.length(); ++i) { JSONObject jsonObject = jsonArray.getJSONObject(i); long layoutId = jsonObject.getLong("layoutId"); if (layoutId > 0) { layoutIds.add(layoutId); } if (jsonObject.getBoolean("includeChildren")) { addLayoutIds(layoutIds, groupId, privateLayout, layoutId); } } return ArrayUtil.toArray(layoutIds.toArray(new Long[layoutIds.size()])); }
protected void addDDMFormFieldOptions( JSONObject jsonObject, DDMFormField ddmFormField, Set<Locale> availableLocales, Locale defaultLocale) { String type = ddmFormField.getType(); if (!(type.equals(DDMImpl.TYPE_RADIO) || type.equals(DDMImpl.TYPE_SELECT))) { return; } String fieldName = ddmFormField.getName(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); DDMFormFieldOptions ddmFormFieldOptions = ddmFormField.getDDMFormFieldOptions(); for (String optionValue : ddmFormFieldOptions.getOptionsValues()) { JSONObject optionJSONObject = JSONFactoryUtil.createJSONObject(); String name = fieldName.concat(StringUtil.randomString()); optionJSONObject.put("id", name); optionJSONObject.put("name", name); optionJSONObject.put("type", "option"); optionJSONObject.put("value", optionValue); addDDMFormFieldLocalizedProperty( optionJSONObject, "label", ddmFormFieldOptions.getOptionLabels(optionValue), defaultLocale, defaultLocale, "option"); JSONObject localizationMapJSONObject = JSONFactoryUtil.createJSONObject(); for (Locale availableLocale : availableLocales) { JSONObject localeMap = JSONFactoryUtil.createJSONObject(); addDDMFormFieldLocalizedProperty( localeMap, "label", ddmFormFieldOptions.getOptionLabels(optionValue), availableLocale, defaultLocale, "option"); localizationMapJSONObject.put(LocaleUtil.toLanguageId(availableLocale), localeMap); } optionJSONObject.put("localizationMap", localizationMapJSONObject); jsonArray.put(optionJSONObject); } jsonObject.put("options", jsonArray); }
protected void updateBasicConfiguration( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { boolean displayScopeFacet = GetterUtil.getBoolean(getParameter(actionRequest, "displayScopeFacet")); boolean displayAssetCategoriesFacet = GetterUtil.getBoolean(getParameter(actionRequest, "displayAssetCategoriesFacet")); boolean displayAssetTagsFacet = GetterUtil.getBoolean(getParameter(actionRequest, "displayAssetTagsFacet")); boolean displayAssetTypeFacet = GetterUtil.getBoolean(getParameter(actionRequest, "displayAssetTypeFacet")); boolean displayFolderFacet = GetterUtil.getBoolean(getParameter(actionRequest, "displayFolderFacet")); boolean displayUserFacet = GetterUtil.getBoolean(getParameter(actionRequest, "displayUserFacet")); boolean displayModifiedRangeFacet = GetterUtil.getBoolean(getParameter(actionRequest, "displayModifiedRangeFacet")); String searchConfiguration = ContentUtil.get(SearchWebConfigurationValues.FACET_CONFIGURATION); JSONObject configurationJSONObject = JSONFactoryUtil.createJSONObject(searchConfiguration); JSONArray oldFacetsJSONArray = configurationJSONObject.getJSONArray("facets"); if (oldFacetsJSONArray == null) { if (_log.isWarnEnabled()) { _log.warn( "The resource " + SearchWebConfigurationValues.FACET_CONFIGURATION + " is missing a valid facets JSON array"); } } JSONArray newFacetsJSONArray = JSONFactoryUtil.createJSONArray(); for (int i = 0; i < oldFacetsJSONArray.length(); i++) { JSONObject oldFacetJSONObject = oldFacetsJSONArray.getJSONObject(i); String fieldName = oldFacetJSONObject.getString("fieldName"); if ((displayScopeFacet && fieldName.equals("groupId")) || (displayAssetCategoriesFacet && fieldName.equals("assetCategoryIds")) || (displayAssetTagsFacet && fieldName.equals("assetTagNames")) || (displayAssetTypeFacet && fieldName.equals("entryClassName")) || (displayFolderFacet && fieldName.equals("folderId")) || (displayUserFacet && fieldName.equals("userId")) || (displayModifiedRangeFacet && fieldName.equals("modified"))) { newFacetsJSONArray.put(oldFacetJSONObject); } } configurationJSONObject.put("facets", newFacetsJSONArray); searchConfiguration = configurationJSONObject.toString(); setPreference(actionRequest, "searchConfiguration", searchConfiguration); }
@Override public void populateConfigJSONObject( JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes, ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) { JSONObject autoCompleteConfigJSONObject = JSONFactoryUtil.createJSONObject(); autoCompleteConfigJSONObject.put("requestTemplate", "query={query}"); JSONArray triggerJSONArray = JSONFactoryUtil.createJSONArray(); JSONObject triggerJSONObject = JSONFactoryUtil.createJSONObject(); triggerJSONObject.put("resultFilters", "function(query, results) {return results;}"); triggerJSONObject.put("resultTextLocator", "title"); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); ResourceURL autoCompletePageTitleURL = (ResourceURL) requestBackedPortletURLFactory.createResourceURL(portletDisplay.getId()); Map<String, String> fileBrowserParams = (Map<String, String>) inputEditorTaglibAttributes.get("liferay-ui:input-editor:fileBrowserParams"); autoCompletePageTitleURL.setParameter("nodeId", fileBrowserParams.get("nodeId")); autoCompletePageTitleURL.setResourceID("/wiki/autocomplete_page_title"); String source = autoCompletePageTitleURL.toString() + "&" + _portal.getPortletNamespace(portletDisplay.getId()); triggerJSONObject.put("source", source); triggerJSONObject.put("term", "["); triggerJSONObject.put("tplReplace", "<a href=\"{title}\">{title}</a>"); triggerJSONObject.put("tplResults", "<span class=\"h5 truncate-text\">{title}</span>"); triggerJSONArray.put(triggerJSONObject); autoCompleteConfigJSONObject.put("trigger", triggerJSONArray); jsonObject.put("autocomplete", autoCompleteConfigJSONObject); String extraPlugins = jsonObject.getString("extraPlugins"); if (Validator.isNotNull(extraPlugins)) { extraPlugins += ",autocomplete"; } else { extraPlugins = "autocomplete,ae_placeholder,ae_selectionregion,ae_uicore"; } jsonObject.put("extraPlugins", extraPlugins); }
public static JSONArray toJSONArray(com.liferay.portal.model.Phone[][] models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (Phone[] model : models) { jsonArray.put(toJSONArray(model)); } return jsonArray; }
public static JSONArray toJSONArray(List<com.ext.portlet.reports.model.ReportsEntry> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (ReportsEntry model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray(List<com.nss.portlet.qa_chu_de.model.QAChuDeCauHoi> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (QAChuDeCauHoi model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
@Override protected BooleanClause doGetFacetClause() { SearchContext searchContext = getSearchContext(); FacetConfiguration facetConfiguration = getFacetConfiguration(); JSONObject dataJSONObject = facetConfiguration.getData(); String[] values = null; if (isStatic() && dataJSONObject.has("values")) { JSONArray valuesJSONArray = dataJSONObject.getJSONArray("values"); values = new String[valuesJSONArray.length()]; for (int i = 0; i < valuesJSONArray.length(); i++) { values[i] = valuesJSONArray.getString(i); } } String[] valuesParam = StringUtil.split(GetterUtil.getString(searchContext.getAttribute(getFieldName()))); if (!isStatic() && (valuesParam != null) && (valuesParam.length > 0)) { values = valuesParam; } if ((values == null) || (values.length == 0)) { return null; } BooleanQuery facetQuery = BooleanQueryFactoryUtil.create(searchContext); for (String value : values) { FacetValueValidator facetValueValidator = getFacetValueValidator(); if ((searchContext.getUserId() > 0) && !facetValueValidator.check(searchContext, value)) { continue; } TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, getFieldName(), value); try { facetQuery.add(termQuery, BooleanClauseOccur.SHOULD); } catch (ParseException pe) { _log.error(pe, pe); } } if (!facetQuery.hasClauses()) { return null; } return BooleanClauseFactoryUtil.create( searchContext, facetQuery, BooleanClauseOccur.MUST.getName()); }
public static JSONArray toJSONArray(com.ext.portlet.debaterevision.model.DebateItem[][] models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (DebateItem[] model : models) { jsonArray.put(toJSONArray(model)); } return jsonArray; }
public static JSONArray toJSONArray(List<com.nss.portlet.journal.model.JournalTemplate> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (JournalTemplate model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray(List<com.liferay.portal.model.Group> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (Group model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray(List<com.liferay.portlet.asset.model.AssetTag> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (AssetTag model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray(List<net.sareweb.wildtaxi.model.Request> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (Request model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray( List<com.ext.conditionaltext.model.ConditionalTextSetting> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (ConditionalTextSetting model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray( com.liferay.portlet.asset.model.AssetCategoryProperty[][] models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (AssetCategoryProperty[] model : models) { jsonArray.put(toJSONArray(model)); } return jsonArray; }
public static JSONArray toJSONArray( List<com.sgs.portlet.loaivanbannoibo.model.SoLoaiVanBanNoiBo> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (SoLoaiVanBanNoiBo model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray( List<com.sgs.portlet.receivergroup.model.ReceiverGroup> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (ReceiverGroup model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static JSONArray toJSONArray( List<com.sgs.portlet.pml_ho_so_cong_viec.model.PmlHoSoCongViec> models) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (PmlHoSoCongViec model : models) { jsonArray.put(toJSONObject(model)); } return jsonArray; }
public static java.lang.String getWARThemes() throws RemoteException { try { com.liferay.portal.kernel.json.JSONArray returnValue = ThemeServiceUtil.getWARThemes(); return returnValue.toString(); } catch (Exception e) { _log.error(e, e); throw new RemoteException(e.getMessage()); } }
protected void addLayouts(long parentLayoutId, JSONArray layoutsJSONArray) throws Exception { if (layoutsJSONArray == null) { return; } for (int i = 0; i < layoutsJSONArray.length(); i++) { JSONObject layoutJSONObject = layoutsJSONArray.getJSONObject(i); addLayout(parentLayoutId, layoutJSONObject); } }
protected void addLayoutColumns(Layout layout, JSONArray columnsJSONArray) throws Exception { if (columnsJSONArray == null) { return; } for (int i = 0; i < columnsJSONArray.length(); i++) { JSONArray columnJSONArray = columnsJSONArray.getJSONArray(i); addLayoutColumn(layout, "column-" + (i + 1), columnJSONArray); } }
protected void updateActivitySettings(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String settingsJSON = ParamUtil.getString(actionRequest, "settingsJSON"); JSONObject settingsJSONObject = JSONFactoryUtil.createJSONObject(settingsJSON); JSONArray actionsJSONArray = settingsJSONObject.getJSONArray("actions"); String modelName = settingsJSONObject.getString("modelName"); for (int i = 0; i < actionsJSONArray.length(); i++) { JSONObject actionJSONObject = actionsJSONArray.getJSONObject(i); int activityType = actionJSONObject.getInt("activityType"); SocialActivityDefinition activityDefinition = SocialActivitySettingServiceUtil.getActivityDefinition( themeDisplay.getSiteGroupIdOrLiveGroupId(), modelName, activityType); if (activityDefinition == null) { continue; } List<SocialActivityCounterDefinition> activityCounterDefinitions = new ArrayList<>(); activityCounterDefinitions.add( updateActivityCounterDefinition( actionJSONObject, activityDefinition, SocialActivityCounterConstants.NAME_CONTRIBUTION)); activityCounterDefinitions.add( updateActivityCounterDefinition( actionJSONObject, activityDefinition, SocialActivityCounterConstants.NAME_PARTICIPATION)); activityCounterDefinitions.add( updateActivityCounterDefinition( actionJSONObject, activityDefinition, SocialActivityCounterConstants.NAME_POPULARITY)); SocialActivitySettingServiceUtil.updateActivitySettings( themeDisplay.getSiteGroupIdOrLiveGroupId(), modelName, activityType, activityCounterDefinitions); } }