当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtil类代码示例

本文整理汇总了Java中com.liferay.portal.kernel.util.ArrayUtil的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil类的具体用法?Java ArrayUtil怎么用?Java ArrayUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ArrayUtil类属于com.liferay.portal.kernel.util包,在下文中一共展示了ArrayUtil类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTargetFolder

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:23,代码来源:DLFolderUtil.java

示例2: isRelatedEntry

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
@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);
}
 
开发者ID:jorgediaz-lr,项目名称:index-checker,代码行数:24,代码来源:DLFileEntryPermissionsHelper.java

示例3: isRelatedEntry

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
@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);
}
 
开发者ID:jorgediaz-lr,项目名称:index-checker,代码行数:21,代码来源:MBMessagePermissionsHelper.java

示例4: getClassTypes

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
@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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:21,代码来源:LearningActivityAssetRendererFactory.java

示例5: appendPortletIds

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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;
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:22,代码来源:LayoutImporter.java

示例6: addDLFileEntries

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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);
		}
	}
}
 
开发者ID:rivetlogic,项目名称:liferay-evernote,代码行数:26,代码来源:FileSystemImporter.java

示例7: addDLFolder

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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;
}
 
开发者ID:rivetlogic,项目名称:liferay-evernote,代码行数:23,代码来源:FileSystemImporter.java

示例8: getJournalArticlesByCategoryIds

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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;
}
 
开发者ID:rivetlogic,项目名称:hr-portal,代码行数:26,代码来源:WebArticleHelperLocalServiceImpl.java

示例9: addDLFileEntries

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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);
		}
	}
}
 
开发者ID:rivetlogic,项目名称:liferay-voice-command,代码行数:24,代码来源:FileSystemImporter.java

示例10: getGruposFromExpando

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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]));
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:12,代码来源:CourseServiceImpl.java

示例11: getJSONArrayAsStringArray

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
protected String[] getJSONArrayAsStringArray(
	JSONObject jsonObject, String key) {

	JSONArray jsonArray = jsonObject.getJSONArray(key);

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

	return new String[0];
}
 
开发者ID:rivetlogic,项目名称:liferay-evernote,代码行数:12,代码来源:FileSystemImporter.java

示例12: updateComment

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
@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;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:70,代码来源:CommentLocalServiceImpl.java

示例13: composeVocabularySettings

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
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();
}
 
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:58,代码来源:SetupCategorization.java

示例14: getDocuments

import com.liferay.portal.kernel.util.ArrayUtil; //导入依赖的package包/类
/**
  * 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];
     }   
 }
 
开发者ID:rivetlogic,项目名称:liferay-elasticsearch-integration,代码行数:60,代码来源:ElasticsearchHelper.java


注:本文中的com.liferay.portal.kernel.util.ArrayUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。