Search in sources :

Example 1 with JSONObject

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);
}
Also used : FacetConfiguration(com.liferay.portal.kernel.search.facet.config.FacetConfiguration) JSONObject(com.liferay.portal.kernel.json.JSONObject) JSONArray(com.liferay.portal.kernel.json.JSONArray) SearchContext(com.liferay.portal.kernel.search.SearchContext)

Example 2 with JSONObject

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);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject)

Example 3 with JSONObject

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;
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment) User(com.liferay.portal.model.User) JSONObject(com.liferay.portal.kernel.json.JSONObject) Date(java.util.Date)

Example 4 with JSONObject

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;
}
Also used : User(com.liferay.portal.model.User) JSONObject(com.liferay.portal.kernel.json.JSONObject) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) Date(java.util.Date)

Example 5 with JSONObject

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;
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) KBTemplate(com.liferay.knowledgebase.model.KBTemplate)

Aggregations

JSONObject (com.liferay.portal.kernel.json.JSONObject)54 JSONArray (com.liferay.portal.kernel.json.JSONArray)13 IOException (java.io.IOException)10 TException (org.apache.thrift.TException)9 PrintWriter (java.io.PrintWriter)7 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)5 ServiceContext (com.liferay.portal.service.ServiceContext)5 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)5 PortalException (com.liferay.portal.kernel.exception.PortalException)4 JSONException (com.liferay.portal.kernel.json.JSONException)4 Folder (com.liferay.portal.kernel.repository.model.Folder)4 Date (java.util.Date)4 CveSearchService (org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService)4 VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)4 User (org.eclipse.sw360.datahandler.thrift.users.User)4 JSONFactoryUtil.createJSONObject (com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject)3 Role (com.liferay.portal.kernel.model.Role)3 User (com.liferay.portal.kernel.model.User)3 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)3 User (com.liferay.portal.model.User)3