use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class AssetEntriesFacet method initFacetClause.
protected void initFacetClause() {
SearchContext searchContext = getSearchContext();
FacetConfiguration facetConfiguration = getFacetConfiguration();
JSONObject dataJSONObject = facetConfiguration.getData();
String[] entryClassNames = null;
if (dataJSONObject.has("values")) {
JSONArray valuesJSONArray = dataJSONObject.getJSONArray("values");
entryClassNames = new String[valuesJSONArray.length()];
for (int i = 0; i < valuesJSONArray.length(); i++) {
entryClassNames[i] = valuesJSONArray.getString(i);
}
}
if (ArrayUtil.isEmpty(entryClassNames)) {
entryClassNames = searchContext.getEntryClassNames();
}
if (!isStatic()) {
String[] entryClassNameParam = StringUtil.split(GetterUtil.getString(searchContext.getAttribute(getFieldName())));
if (ArrayUtil.isNotEmpty(entryClassNameParam)) {
entryClassNames = entryClassNameParam;
}
}
if (ArrayUtil.isEmpty(entryClassNames)) {
entryClassNames = SearchEngineUtil.getEntryClassNames();
if (!dataJSONObject.has("values")) {
JSONArray entriesJSONArray = JSONFactoryUtil.createJSONArray();
for (String entryClassName : entryClassNames) {
entriesJSONArray.put(entryClassName);
}
dataJSONObject.put("values", entriesJSONArray);
}
}
searchContext.setEntryClassNames(entryClassNames);
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class KnowledgeBaseUtil method getPreferredKBFolderURLTitle.
public static String getPreferredKBFolderURLTitle(PortalPreferences portalPreferences, String contentRootPrefix) throws JSONException {
String preferredKBFolderURLTitle = portalPreferences.getValue(PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderURLTitle", "{}");
JSONObject jsonObject = JSONFactoryUtil.createJSONObject(preferredKBFolderURLTitle);
return jsonObject.getString(contentRootPrefix, StringPool.BLANK);
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class KBCommentLocalServiceImpl method addKBComment.
@Override
public KBComment addKBComment(long userId, long classNameId, long classPK, String content, int userRating, ServiceContext serviceContext) throws PortalException, SystemException {
// KB comment
User user = userPersistence.findByPrimaryKey(userId);
long groupId = serviceContext.getScopeGroupId();
Date now = new Date();
validate(content);
long kbCommentId = counterLocalService.increment();
KBComment kbComment = kbCommentPersistence.create(kbCommentId);
kbComment.setUuid(serviceContext.getUuid());
kbComment.setGroupId(groupId);
kbComment.setCompanyId(user.getCompanyId());
kbComment.setUserId(user.getUserId());
kbComment.setUserName(user.getFullName());
kbComment.setCreateDate(serviceContext.getCreateDate(now));
kbComment.setModifiedDate(serviceContext.getModifiedDate(now));
kbComment.setClassNameId(classNameId);
kbComment.setClassPK(classPK);
kbComment.setContent(content);
kbComment.setUserRating(userRating);
kbComment.setStatus(KBCommentConstants.STATUS_NEW);
kbCommentPersistence.update(kbComment);
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
putTitle(extraDataJSONObject, kbComment);
socialActivityLocalService.addActivity(userId, kbComment.getGroupId(), KBComment.class.getName(), kbCommentId, AdminActivityKeys.ADD_KB_COMMENT, extraDataJSONObject.toString(), 0);
// Subscriptions
notifySubscribers(kbComment, serviceContext);
return kbComment;
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class KBTemplateLocalServiceImpl method addKBTemplate.
@Override
public KBTemplate addKBTemplate(long userId, String title, String content, ServiceContext serviceContext) throws PortalException, SystemException {
// KB template
User user = userPersistence.findByPrimaryKey(userId);
long groupId = serviceContext.getScopeGroupId();
Date now = new Date();
validate(title, content);
long kbTemplateId = counterLocalService.increment();
KBTemplate kbTemplate = kbTemplatePersistence.create(kbTemplateId);
kbTemplate.setUuid(serviceContext.getUuid());
kbTemplate.setGroupId(groupId);
kbTemplate.setCompanyId(user.getCompanyId());
kbTemplate.setUserId(user.getUserId());
kbTemplate.setUserName(user.getFullName());
kbTemplate.setCreateDate(serviceContext.getCreateDate(now));
kbTemplate.setModifiedDate(serviceContext.getModifiedDate(now));
kbTemplate.setTitle(title);
kbTemplate.setContent(content);
kbTemplatePersistence.update(kbTemplate);
// Resources
resourceLocalService.addModelResources(kbTemplate, serviceContext);
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", kbTemplate.getTitle());
socialActivityLocalService.addActivity(userId, groupId, KBTemplate.class.getName(), kbTemplateId, AdminActivityKeys.ADD_KB_TEMPLATE, extraDataJSONObject.toString(), 0);
return kbTemplate;
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class KBTemplateLocalServiceImpl method updateKBTemplate.
@Override
public KBTemplate updateKBTemplate(long kbTemplateId, String title, String content, ServiceContext serviceContext) throws PortalException, SystemException {
// KB template
validate(title, content);
KBTemplate kbTemplate = kbTemplatePersistence.findByPrimaryKey(kbTemplateId);
kbTemplate.setModifiedDate(serviceContext.getModifiedDate(null));
kbTemplate.setTitle(title);
kbTemplate.setContent(content);
kbTemplatePersistence.update(kbTemplate);
if ((serviceContext.getGroupPermissions() != null) || (serviceContext.getGuestPermissions() != null)) {
updateKBTemplateResources(kbTemplate, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
}
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", kbTemplate.getTitle());
socialActivityLocalService.addActivity(kbTemplate.getUserId(), kbTemplate.getGroupId(), KBTemplate.class.getName(), kbTemplateId, AdminActivityKeys.UPDATE_KB_TEMPLATE, extraDataJSONObject.toString(), 0);
return kbTemplate;
}
Aggregations