Java 类com.liferay.portal.kernel.util.ArrayUtil 实例源码

项目:opencps-v2    文件:DLFolderUtil.java   
public static DLFolder getTargetFolder(
    long groupId, long parentFolderId, String destination) {

    DLFolder dlFolder = null;

    String[] folderNames =
        StringUtil.split(destination, StringPool.FORWARD_SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];
        dlFolder = getFolder(groupId, parentFolderId, name);
        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(
                groupId, dlFolder.getFolderId(),
                StringUtil.merge(folderNames, StringPool.FORWARD_SLASH));
        }

    }

    return dlFolder;
}
项目:opencps-v2    文件:DLFolderUtil.java   
public static DLFolder getTargetFolder(
    long groupId, long parentFolderId, String destination) {

    DLFolder dlFolder = null;

    String[] folderNames =
        StringUtil.split(destination, StringPool.FORWARD_SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];
        dlFolder = getFolder(groupId, parentFolderId, name);
        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(
                groupId, dlFolder.getFolderId(),
                StringUtil.merge(folderNames, StringPool.FORWARD_SLASH));
        }

    }

    return dlFolder;
}
项目:opencps-v2    文件:DLFolderUtil.java   
public static DLFolder getTargetFolder(
    long groupId, long parentFolderId, String destination) {

    DLFolder dlFolder = null;

    String[] folderNames =
        StringUtil.split(destination, StringPool.FORWARD_SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];
        dlFolder = getFolder(groupId, parentFolderId, name);
        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(
                groupId, dlFolder.getFolderId(),
                StringUtil.merge(folderNames, StringPool.FORWARD_SLASH));
        }

    }

    return dlFolder;
}
项目:index-checker    文件:DLFileEntryPermissionsHelper.java   
@Override
protected boolean isRelatedEntry(Data data) {

    long groupId = data.getGroupId();
    long repositoryId = data.get("repositoryId", -1L);

    boolean hiddenFolder = isHiddenFolder(groupId, repositoryId);

    if (!hiddenFolder) {
        return false;
    }

    long classNameId = data.get("classNameId", 0L);

    if (classNameId == 0) {
        return false;
    }

    String permissionsClassName = PortalUtil.getClassName(classNameId);

    return ArrayUtil.contains(
        validPermissionClassNames, permissionsClassName);
}
项目:index-checker    文件:MBMessagePermissionsHelper.java   
@Override
protected boolean isRelatedEntry(Data data) {

    long categoryId = data.get("categoryId", 0L);

    if (categoryId != MBCategoryConstants.DISCUSSION_CATEGORY_ID) {
        return false;
    }

    long classNameId = data.get("classNameId", 0L);

    if (classNameId == 0) {
        return false;
    }

    String permissionsClassName = PortalUtil.getClassName(classNameId);

    return ArrayUtil.contains(
        validPermissionClassNames, permissionsClassName);
}
项目:liferaylms-portlet    文件:LearningActivityAssetRendererFactory.java   
@Override
public Map<Long, String> getClassTypes(long[] groupId, Locale locale)
        throws Exception {

    Map<Long, String> classTypes = new LinkedHashMap<Long, String>();
    if(CourseLocalServiceUtil.dynamicQueryCount(CourseLocalServiceUtil.dynamicQuery().
            add(PropertyFactoryUtil.forName("groupCreatedId").in(ArrayUtil.toArray(groupId))))>0){
        LearningActivityTypeRegistry learningActivityTypeRegistry = new LearningActivityTypeRegistry();
        ResourceBundle resourceBundle = PortletBagPool.get(getPortletId()).getResourceBundle(locale);       
        long[] invisibleTypes = StringUtil.split(PropsUtil.get("lms.learningactivity.invisibles"), StringPool.COMMA,-1L);
        for(LearningActivityType learningActivityType:learningActivityTypeRegistry.getLearningActivityTypesForCreating()){
            if(learningActivityType != null && !ArrayUtil.contains(invisibleTypes, learningActivityType.getTypeId())){
                String learningActivityTypeName = learningActivityTypeRegistry.getLearningActivityType(learningActivityType.getTypeId()).getName();
                classTypes.put(learningActivityType.getTypeId(), (resourceBundle.containsKey(learningActivityTypeName)?
                        resourceBundle.getString(learningActivityTypeName):learningActivityTypeName));
            }
        }   
    }
    return classTypes;
}
项目:edemocracia    文件:LayoutImporter.java   
protected String[] appendPortletIds(
    String[] portletIds, String[] newPortletIds, String portletsMergeMode) {

    for (String portletId : newPortletIds) {
        if (ArrayUtil.contains(portletIds, portletId)) {
            continue;
        }

        if (portletsMergeMode.equals(
                PortletDataHandlerKeys.PORTLETS_MERGE_MODE_ADD_TO_BOTTOM)) {

            portletIds = ArrayUtil.append(portletIds, portletId);
        }
        else {
            portletIds = ArrayUtil.append(
                new String[] {portletId}, portletIds);
        }
    }

    return portletIds;
}
项目:liferay-evernote    文件:FileSystemImporter.java   
protected void addDLFileEntries(String fileEntriesDirName)
    throws Exception {

    File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);

    if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
        return;
    }

    File[] files = dlDocumentsDir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:liferay-evernote    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:liferay-elasticsearch-integration    文件:FileSystemImporter.java   
protected void addDLFileEntries(String fileEntriesDirName)
    throws Exception {

    File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);

    if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
        return;
    }

    File[] files = dlDocumentsDir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:liferay-elasticsearch-integration    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:liferay-microsite-manager    文件:FileSystemImporter.java   
protected void addDLFileEntries(String fileEntriesDirName)
    throws Exception {

    File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);

    if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
        return;
    }

    File[] files = dlDocumentsDir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:liferay-microsite-manager    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:liferay-document-and-media-treeview    文件:FileSystemImporter.java   
protected void addDLFileEntries(String fileEntriesDirName)
    throws Exception {

    File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);

    if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
        return;
    }

    File[] files = dlDocumentsDir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:liferay-document-and-media-treeview    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:hr-portal    文件:FileSystemImporter.java   
protected void addDLFileEntries(String fileEntriesDirName)
    throws Exception {

    File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);

    if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
        return;
    }

    File[] files = dlDocumentsDir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:hr-portal    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:hr-portal    文件:WebArticleHelperLocalServiceImpl.java   
public List<JournalArticle> getJournalArticlesByCategoryIds(List<Long> cIds) {
    //ServiceContext sc = ServiceContextThreadLocal.getServiceContext();

    ArrayList<JournalArticle> jaList = new ArrayList<JournalArticle>();

    if (cIds != null && cIds.size() > 0) {
        AssetEntryQuery q = new AssetEntryQuery();
        q.setAllCategoryIds(ArrayUtil.toArray(cIds.toArray(new Long[cIds.size()])));
        q.setClassName(JournalArticle.class.getName());

        try {
            List<AssetEntry> assets = AssetEntryLocalServiceUtil.getEntries(q);
            for (AssetEntry asset:assets) {
                JournalArticle ja = JournalArticleLocalServiceUtil.getLatestArticle(asset.getClassPK());
                if (!jaList.contains(ja)) {
                    jaList.add(ja);
                }
            }
        } catch (Exception e) {
            _log.error("", e);
        }
    }

    return jaList;
}
项目:liferay-voice-command    文件:FileSystemImporter.java   
protected void addDLFileEntries(String dirName) throws Exception {
    File dir = new File(_resourcesDir, dirName);

    if (!dir.isDirectory()|| !dir.canRead()) {
        return;
    }

    File[] files = dir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:liferay-voice-command    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:jukebox    文件:FileSystemImporter.java   
protected void addDLFileEntries(String fileEntriesDirName)
    throws Exception {

    File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);

    if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
        return;
    }

    File[] files = dlDocumentsDir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:jukebox    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:hr-portal    文件:FileSystemImporter.java   
protected void addDLFileEntries(String fileEntriesDirName)
    throws Exception {

    File dlDocumentsDir = new File(_resourcesDir, fileEntriesDirName);

    if (!dlDocumentsDir.isDirectory()|| !dlDocumentsDir.canRead()) {
        return;
    }

    File[] files = dlDocumentsDir.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
        else {
            addDLFileEntry(
                DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, file);
        }
    }
}
项目:hr-portal    文件:FileSystemImporter.java   
protected long addDLFolder(long parentFolderId, File folder)
    throws Exception {

    long folderId = addDLFolder(parentFolderId, folder.getName());

    File[] files = folder.listFiles();

    if (ArrayUtil.isEmpty(files)) {
        return folderId;
    }

    for (File file : files) {
        if (file.isDirectory()) {
            addDLFolder(folderId, file);
        }
        else {
            addDLFileEntry(folderId, file);
        }
    }

    return folderId;
}
项目:hr-portal    文件:WebArticleHelperLocalServiceImpl.java   
public List<JournalArticle> getJournalArticlesByCategoryIds(List<Long> cIds) {
    //ServiceContext sc = ServiceContextThreadLocal.getServiceContext();

    ArrayList<JournalArticle> jaList = new ArrayList<JournalArticle>();

    if (cIds != null && cIds.size() > 0) {
        AssetEntryQuery q = new AssetEntryQuery();
        q.setAllCategoryIds(ArrayUtil.toArray(cIds.toArray(new Long[cIds.size()])));
        q.setClassName(JournalArticle.class.getName());

        try {
            List<AssetEntry> assets = AssetEntryLocalServiceUtil.getEntries(q);
            for (AssetEntry asset:assets) {
                JournalArticle ja = JournalArticleLocalServiceUtil.getLatestArticle(asset.getClassPK());
                if (!jaList.contains(ja)) {
                    jaList.add(ja);
                }
            }
        } catch (Exception e) {
            _log.error("", e);
        }
    }

    return jaList;
}
项目:opencps-v2    文件:DLFolderUtil.java   
public static DLFolder getTargetFolder(
    long userId, long groupId, long repositoryId, boolean mountPoint,
    long parentFolderId, String destination, String description,
    boolean hidden, ServiceContext serviceContext) throws Exception {

    DLFolder dlFolder = null;

    String[] folderNames = StringUtil.split(destination, StringPool.SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];

        dlFolder = makeFolder(
            userId, groupId, repositoryId, mountPoint, parentFolderId, name,
            description, hidden, serviceContext);

        setFolderPermissions(dlFolder);

        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(
                userId, groupId, repositoryId, mountPoint,
                dlFolder.getFolderId(),
                StringUtil.merge(folderNames, StringPool.FORWARD_SLASH),
                description, hidden, serviceContext);
        }

    }

    return dlFolder;
}
项目:opencps-v2    文件:DLFolderUtil.java   
public static DLFolder getTargetFolder(
    long userId, long groupId, long repositoryId, boolean mountPoint,
    long parentFolderId, String destination, String description,
    boolean hidden, ServiceContext serviceContext) throws Exception {

    DLFolder dlFolder = null;

    String[] folderNames = StringUtil.split(destination, StringPool.SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];

        dlFolder = makeFolder(
            userId, groupId, repositoryId, mountPoint, parentFolderId, name,
            description, hidden, serviceContext);

        setFolderPermissions(dlFolder);

        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(
                userId, groupId, repositoryId, mountPoint,
                dlFolder.getFolderId(),
                StringUtil.merge(folderNames, StringPool.FORWARD_SLASH),
                description, hidden, serviceContext);
        }

    }

    return dlFolder;
}
项目:opencps-v2    文件:DLFolderUtil.java   
public static DLFolder getTargetFolder(
    long userId, long groupId, long repositoryId, boolean mountPoint,
    long parentFolderId, String destination, String description,
    boolean hidden, ServiceContext serviceContext) throws Exception {

    DLFolder dlFolder = null;

    String[] folderNames = StringUtil.split(destination, StringPool.SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];

        dlFolder = makeFolder(
            userId, groupId, repositoryId, mountPoint, parentFolderId, name,
            description, hidden, serviceContext);

        setFolderPermissions(dlFolder);

        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(
                userId, groupId, repositoryId, mountPoint,
                dlFolder.getFolderId(),
                StringUtil.merge(folderNames, StringPool.FORWARD_SLASH),
                description, hidden, serviceContext);
        }

    }

    return dlFolder;
}
项目:liferaylms-portlet    文件:CourseServiceImpl.java   
private long [] getGruposFromExpando(Long companyId, String [] userGroupNames) throws PortalException, SystemException
{
    List<Long> userGroupIds = new ArrayList<Long>();
    if (userGroupNames != null) {
        for (String ugn : userGroupNames) {
            UserGroup ug = UserGroupLocalServiceUtil.getUserGroup(companyId, ugn);
            userGroupIds.add(ug.getUserGroupId());
        }
    }
    return ArrayUtil.toArray(userGroupIds.toArray(new Long[0]));
}
项目:liferay-evernote    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:liferay-elasticsearch-integration    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:liferay-microsite-manager    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:liferay-document-and-media-treeview    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:hr-portal    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:liferay-voice-command    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:jukebox    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:hr-portal    文件:FileSystemImporter.java   
protected String[] getJSONArrayAsStringArray(
    JSONObject jsonObject, String key) {

    JSONArray jsonArray = jsonObject.getJSONArray(key);

    if (jsonArray != null) {
        return ArrayUtil.toStringArray(jsonArray);
    }

    return new String[0];
}
项目:opencps-v2    文件:CommentLocalServiceImpl.java   
@Indexable(type = IndexableType.REINDEX)
@Override
public Comment updateComment(long commentId, String className, String classPK, String email, int upvoteCount,
        ServiceContext serviceContext)
        throws UnauthenticationException, UnauthorizationException, NotFoundException, NoSuchUserException {

    // // authen
    // BackendAuthImpl authImpl = new BackendAuthImpl();
    //
    // boolean isAuth = authImpl.isAuth(serviceContext, StringPool.BLANK,
    // StringPool.BLANK);
    //
    // if (!isAuth) {
    // throw new UnauthenticationException();
    // }
    //
    // boolean hasPermission = authImpl.hasResource(serviceContext,
    // ModelNameKeys.WORKINGUNIT_MGT_CENTER,
    // ActionKeys.EDIT_DATA);
    //
    // if (!hasPermission) {
    // throw new UnauthorizationException();
    // }

    Date now = new Date();

    Comment comment = commentPersistence.fetchByPrimaryKey(commentId);

    if (Validator.isNull(comment)) {
        throw new NotFoundException();
    }

    comment.setModifiedDate(serviceContext.getCreateDate(now));

    // Other fields
    int counter = comment.getUpvoteCount();

    String userHasUpvoted = Validator.isNotNull(comment.getUserHasUpvoted()) ? comment.getUserHasUpvoted()
            : StringPool.BLANK;

    if ((!StringUtil.contains(userHasUpvoted, email) || Validator.isNull(comment.getUserHasUpvoted()))
            && upvoteCount >= 0) {

        userHasUpvoted += Validator.isNotNull(userHasUpvoted) ? StringPool.COMMA + email : email;

        String[] userVoteds = StringUtil.split(userHasUpvoted);

        counter = userVoteds.length;

    } else if (StringUtil.contains(userHasUpvoted, email) && upvoteCount < 0) {

        String[] emails = StringUtil.split(userHasUpvoted);
        emails = ArrayUtil.remove(emails, email);
        userHasUpvoted = StringUtil.merge(emails);

        counter = emails.length;

    }

    comment.setUserHasUpvoted(userHasUpvoted);
    // comment.setClassName(className);
    // comment.setClassPK(classPK);
    comment.setUpvoteCount(counter);
    comment.setExpandoBridgeAttributes(serviceContext);

    commentPersistence.update(comment);

    return comment;
}
项目:liferay-db-setup-core    文件:SetupCategorization.java   
private static String composeVocabularySettings(Vocabulary vocabulary, final long groupId) {
    AssetVocabularySettingsHelper assetVocabularySettingsHelper = new AssetVocabularySettingsHelper();
    assetVocabularySettingsHelper.setMultiValued(vocabulary.isMultiValued());
    List<AssociatedAssetType> types = vocabulary.getAssociatedAssetType();

    if (Objects.isNull(types) || types.isEmpty()) {
        assetVocabularySettingsHelper.setClassNameIdsAndClassTypePKs(new long[] {AssetCategoryConstants.ALL_CLASS_NAME_ID},
            new long[] {AssetCategoryConstants.ALL_CLASS_TYPE_PK}, new boolean[] {false});
        return assetVocabularySettingsHelper.toString();
    }

    List<Long> classNameIds = new LinkedList<>();
    List<Long> classTypePKs = new LinkedList<>();
    List<Boolean> requireds = new LinkedList<>();

    for (AssociatedAssetType type : types) {
        ClassName className = ClassNameLocalServiceUtil.fetchClassName(type.getClassName());
        if (className.getValue().isEmpty()) {
            continue;
        }

        long subtypePK = -1;
        if ( Objects.nonNull(type.getSubtypeStructureKey()) && !type.getSubtypeStructureKey().isEmpty()) { // has subtype
            try {
                subtypePK = ResolverUtil.getStructureId(type.getSubtypeStructureKey(), groupId, Class.forName(type.getClassName()), true);
            } catch (ClassNotFoundException | PortalException e) {
                LOG.error("Class can not be be resolved for classname: " + type.getClassName(), e);
                continue;
            }
        }

        classNameIds.add(className.getClassNameId());
        classTypePKs.add(subtypePK);
        requireds.add(type.isRequired());
    }

    // no valid associated types case
    if (classNameIds.isEmpty()) {
        assetVocabularySettingsHelper.setClassNameIdsAndClassTypePKs(new long[] {AssetCategoryConstants.ALL_CLASS_NAME_ID},
            new long[] {AssetCategoryConstants.ALL_CLASS_TYPE_PK}, new boolean[] {false});
        return assetVocabularySettingsHelper.toString();
    }


    // when associated types exists
    boolean[] requiredsArray = new boolean[requireds.size()];
    for (int i = 0; i < requireds.size(); i++) {
        requiredsArray[i] = requireds.get(i);
    }

    assetVocabularySettingsHelper.setClassNameIdsAndClassTypePKs(ArrayUtil.toLongArray(classNameIds), ArrayUtil.toLongArray(classTypePKs), requiredsArray);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Vocabulary settings composed for vocabulary:" + vocabulary.getName() + ". Content: " + assetVocabularySettingsHelper.toString());
    }

    return assetVocabularySettingsHelper.toString();
}
项目:liferay-elasticsearch-integration    文件:ElasticsearchHelper.java   
/**
  * Gets the documents.
  *
  * @param searchHits the search hits
  * @param searchContext the search context
  * @return the documents
  */
 private Document[] getDocuments(SearchHits searchHits, SearchContext searchContext) {
     if (_log.isInfoEnabled()) {
         _log.info("Getting document objects from SearchHits");
     }

     String[] types = searchContext.getEntryClassNames();
     int total = Integer.parseInt((searchHits != null)? String.valueOf(searchHits.getTotalHits()) : "0");
     int failedJsonCount = 0;
     String className = null;
     if (total > 0) {
         List<Document> documentsList = new ArrayList<Document>(total);
         @SuppressWarnings("rawtypes")
Iterator itr = searchHits.iterator();
         while (itr.hasNext()) {
             Document document = new DocumentImpl();
             SearchHit hit = (SearchHit) itr.next();

             JSONObject json;
             try {
                 json = JSONFactoryUtil.createJSONObject(hit.getSourceAsString());
                 @SuppressWarnings("rawtypes")
        Iterator jsonItr = json.keys();
                 while (jsonItr.hasNext()) {
                     String key = (String) jsonItr.next();
                     String value = (String) json.getString(key);
                     if (_log.isDebugEnabled()) {
                         _log.debug(">>>>>>>>>> " + key + " : " + value);
                     }
                     document.add(new Field(key, value));
                     if (key.equalsIgnoreCase("entryClassName")) {
                         className = value;
                     }
                 }
                 if (ArrayUtil.contains(types, className)) {
                     documentsList.add(document);
                 }
             } catch (JSONException e) {
                 failedJsonCount++;
                 _log.error("Error while processing the search result json objects", e);
             }               
         }
         if (_log.isInfoEnabled()) {
             _log.info("Total size of the search results: " + documentsList.size());
         }
         return documentsList.toArray(new Document[documentsList.size()-failedJsonCount]);
     } else {
         if (_log.isInfoEnabled()) {
             _log.info("No search results found");
         }
         return new Document[0];
     }   
 }