protected List<DLFileEntry> doFindBy_G_U_R_F_M_NewRepository( long userId, String mimeType, QueryDefinition<DLFileEntry> queryDefinition) throws Exception { List<Long> repositoryIds = ListUtil.toList(new long[] {_newRepositoryFolder.getRepositoryId()}); List<Long> folderIds = ListUtil.toList(new long[] {_newRepositoryFolder.getFolderId()}); return doFindBy_G_U_R_F_M(userId, repositoryIds, folderIds, mimeType, queryDefinition); }
public static com.liferay.portlet.documentlibrary.model.DLFolderSoap updateFolder( long folderId, java.lang.String name, java.lang.String description, long defaultFileEntryTypeId, Long[] fileEntryTypeIds, boolean overrideFileEntryTypes, com.liferay.portal.service.ServiceContext serviceContext) throws RemoteException { try { com.liferay.portlet.documentlibrary.model.DLFolder returnValue = DLFolderServiceUtil.updateFolder( folderId, name, description, defaultFileEntryTypeId, ListUtil.toList(fileEntryTypeIds), overrideFileEntryTypes, serviceContext); return com.liferay.portlet.documentlibrary.model.DLFolderSoap.toSoapModel(returnValue); } catch (Exception e) { _log.error(e, e); throw new RemoteException(e.getMessage()); } }
protected long getFolderId(String type) throws SystemException { Locale[] locales = LanguageUtil.getAvailableLocales(); List<String> words = new ArrayList<String>(); for (Locale locale : locales) { String translation = LanguageUtil.get(locale, type).toLowerCase(); words.addAll(ListUtil.toList(translation.split(StringPool.SPACE))); } List<Folder> folders = FolderLocalServiceUtil.getFolders(account.getAccountId()); for (String word : words) { for (Folder folder : folders) { String folderName = folder.getDisplayName().toLowerCase(); if (folderName.contains(word)) { return folder.getFolderId(); } } } return 0; }
protected int doCountBy_G_U_R_F_M_BothRepositories( long userId, String mimeType, QueryDefinition<DLFileEntry> queryDefinition) throws Exception { List<Long> repositoryIds = ListUtil.toList( new long[] { _defaultRepositoryFolder.getRepositoryId(), _newRepositoryFolder.getRepositoryId() }); List<Long> folderIds = ListUtil.toList( new long[] { _defaultRepositoryFolder.getFolderId(), _newRepositoryFolder.getFolderId() }); return doCountBy_G_U_R_F_M(userId, repositoryIds, folderIds, mimeType, queryDefinition); }
protected List<String> getPortalDependencyJars(Properties properties) { String[] dependencyJars = StringUtil.split( properties.getProperty( "portal-dependency-jars", properties.getProperty("portal.dependency.jars"))); return ListUtil.toList(dependencyJars); }
private <T, V extends T> List<T> _subList( List<V> list, int start, int end, OrderByComparator<T> obc) { if (obc != null) { list = ListUtil.sort(list, obc); } return (List<T>) ListUtil.toList(ListUtil.subList(list, start, end)); }
@Override public List<Long> getSubcategoryIds(long parentCategoryId) { AssetCategory parentAssetCategory = assetCategoryPersistence.fetchByPrimaryKey(parentCategoryId); if (parentAssetCategory == null) { return Collections.emptyList(); } return ListUtil.toList( assetCategoryPersistence.getDescendants(parentAssetCategory), AssetCategory.CATEGORY_ID_ACCESSOR); }
protected int doCountBy_G_U_F_M( long userId, String mimeType, QueryDefinition<DLFileEntry> queryDefinition) throws Exception { List<Long> folderIds = ListUtil.toList(new long[] {_defaultRepositoryFolder.getFolderId()}); String[] mimeTypes = null; if (mimeType != null) { mimeTypes = new String[] {mimeType}; } return DLFileEntryLocalServiceUtil.getFileEntriesCount( _group.getGroupId(), userId, folderIds, mimeTypes, queryDefinition); }
public static int getFoldersFileEntriesCount(long repositoryId, Long[] folderIds, int status) throws RemoteException { try { int returnValue = DLAppServiceUtil.getFoldersFileEntriesCount( repositoryId, ListUtil.toList(folderIds), status); return returnValue; } catch (Exception e) { _log.error(e, e); throw new RemoteException(e.getMessage()); } }
protected String replaceTimestampParameters(String content) { List<String> urls = ListUtil.toList(StringUtil.splitLines(content)); String timestampParameter = "t=123456789"; String parameters1 = timestampParameter + "&width=100&height=100"; String parameters2 = "width=100&" + timestampParameter + "&height=100"; String parameters3 = "width=100&height=100&" + timestampParameter; String parameters4 = timestampParameter + "?" + timestampParameter + "&width=100&height=100"; List<String> outURLs = new ArrayList<>(); for (String url : urls) { if (!url.contains("[$TIMESTAMP")) { continue; } outURLs.add( StringUtil.replace( url, new String[] {"[$TIMESTAMP$]", "[$TIMESTAMP_ONLY$]"}, new String[] {"&" + parameters1, "?" + parameters1})); outURLs.add( StringUtil.replace( url, new String[] {"[$TIMESTAMP$]", "[$TIMESTAMP_ONLY$]"}, new String[] {"&" + parameters2, "?" + parameters2})); outURLs.add( StringUtil.replace( url, new String[] {"[$TIMESTAMP$]", "[$TIMESTAMP_ONLY$]"}, new String[] {"&" + parameters3, "?" + parameters3})); outURLs.add( StringUtil.replace( url, new String[] {"[$TIMESTAMP$]", "[$TIMESTAMP_ONLY$]"}, new String[] {StringPool.BLANK, "?" + parameters4})); } return StringUtil.merge(outURLs, StringPool.NEW_LINE); }
@Override public List<XStreamAlias> getXStreamAliases() { return ListUtil.toList(_xStreamAliases); }
@Override public List<XStreamType> getAllowedXStreamTypes() { return ListUtil.toList(_xStreamTypes); }
public DDMFormLayoutColumn(int size, String... ddmFormFieldNames) { _size = size; _ddmFormFieldNames = ListUtil.toList(ddmFormFieldNames); }
public void setHeaderNames(String headerNames) { _headerNames = ListUtil.toList(StringUtil.split(headerNames)); }
@Test public void testFileEntryTypeRestrictions() throws Exception { // Configure folder DLFolderLocalServiceUtil.updateFolder( _folder.getFolderId(), _folder.getParentFolderId(), _folder.getName(), _folder.getDescription(), _contractDLFileEntryType.getPrimaryKey(), ListUtil.toList( new long[] { _contractDLFileEntryType.getPrimaryKey(), _marketingBannerDLFileEntryType.getPrimaryKey() }), true, ServiceContextTestUtil.getServiceContext(_group.getGroupId())); // Add file to folder String name = "Test.txt"; byte[] bytes = _CONTENT.getBytes(); FileEntry fileEntry = DLAppServiceUtil.addFileEntry( _group.getGroupId(), _folder.getFolderId(), name, ContentTypes.TEXT_PLAIN, name, "", "", bytes, ServiceContextTestUtil.getServiceContext(_group.getGroupId())); assertFileEntryType(fileEntry, _contractDLFileEntryType); // Add file to subfolder fileEntry = DLAppServiceUtil.addFileEntry( _group.getGroupId(), _subfolder.getFolderId(), name, ContentTypes.TEXT_PLAIN, name, "", "", bytes, ServiceContextTestUtil.getServiceContext(_group.getGroupId())); assertFileEntryType(fileEntry, _contractDLFileEntryType); // Configure subfolder DLFolderLocalServiceUtil.updateFolder( _subfolder.getFolderId(), _subfolder.getParentFolderId(), _subfolder.getName(), _subfolder.getDescription(), _basicDocumentDLFileEntryType.getPrimaryKey(), ListUtil.toList(new long[] {_basicDocumentDLFileEntryType.getPrimaryKey()}), true, ServiceContextTestUtil.getServiceContext(_group.getGroupId())); fileEntry = DLAppServiceUtil.getFileEntry(fileEntry.getFileEntryId()); assertFileEntryType(fileEntry, _basicDocumentDLFileEntryType); }
protected void writeClasspathFile( File libDir, List<String> dependencyJars, String projectDirName, String projectName, boolean javaProject) throws Exception { File classpathFile = new File(projectDirName + "/.classpath"); if (!javaProject) { classpathFile.delete(); return; } Set<String> globalJars = new LinkedHashSet<String>(); List<String> portalJars = new ArrayList<String>(); Set<String> extGlobalJars = new LinkedHashSet<String>(); Set<String> extPortalJars = new LinkedHashSet<String>(); String libDirPath = StringUtil.replace(libDir.getPath(), StringPool.BACK_SLASH, StringPool.SLASH); if (libDirPath.contains("/ext/")) { FilenameFilter filenameFilter = new GlobFilenameFilter("*.jar"); for (String dirName : new String[] {"global", "portal"}) { File file = new File(libDirPath + "/../ext-lib/" + dirName); List<String> jars = ListUtil.toList(file.list(filenameFilter)); if (dirName.equals("global")) { extGlobalJars.addAll(ListUtil.sort(jars)); File dir = new File(PropsValues.LIFERAY_LIB_GLOBAL_DIR); String[] fileNames = dir.list(filenameFilter); globalJars.addAll(ListUtil.sort(ListUtil.toList(fileNames))); globalJars.removeAll(extGlobalJars); } else if (dirName.equals("portal")) { extPortalJars.addAll(ListUtil.sort(jars)); File dir = new File(PropsValues.LIFERAY_LIB_PORTAL_DIR); String[] fileNames = dir.list(filenameFilter); portalJars.addAll(ListUtil.sort(ListUtil.toList(fileNames))); portalJars.removeAll(extPortalJars); } } } else { globalJars.add("portlet.jar"); portalJars.addAll(dependencyJars); portalJars.add("commons-logging.jar"); portalJars.add("log4j.jar"); portalJars = ListUtil.unique(portalJars); Collections.sort(portalJars); } String[] customJarsArray = libDir.list(new GlobFilenameFilter("*.jar")); List<String> customJars = null; if (customJarsArray != null) { customJars = ListUtil.toList(customJarsArray); for (String jar : portalJars) { customJars.remove(jar); } customJars.remove(projectName + "-service.jar"); customJars.remove("util-bridges.jar"); customJars.remove("util-java.jar"); customJars.remove("util-taglib.jar"); Collections.sort(customJars); } else { customJars = new ArrayList<String>(); } StringBundler sb = new StringBundler(); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"); sb.append("<classpath>\n"); for (String sourceDirName : _SOURCE_DIR_NAMES) { if (_fileUtil.exists(projectDirName + "/" + sourceDirName)) { sb.append("\t<classpathentry excluding=\"**/.svn/**|.svn/\" "); sb.append("kind=\"src\" path=\""); sb.append(sourceDirName); sb.append("\" />\n"); } } sb.append("\t<classpathentry kind=\"src\" path=\"/portal\" />\n"); sb.append("\t<classpathentry kind=\"con\" "); sb.append("path=\"org.eclipse.jdt.launching.JRE_CONTAINER\" />\n"); boolean addJunitJars = false; for (String testType : _TEST_TYPES) { String testFolder = "test/" + testType; if (_fileUtil.exists(projectDirName + "/" + testFolder)) { addJunitJars = true; sb.append("\t<classpathentry excluding=\"**/.svn/**|.svn/\" "); sb.append("kind=\"src\" path=\""); sb.append(testFolder); sb.append("\" />\n"); } } if (addJunitJars) { addClasspathEntry(sb, "/portal/lib/development/junit.jar"); addClasspathEntry(sb, "/portal/lib/development/mockito.jar"); addClasspathEntry(sb, "/portal/lib/development/powermock-mockito.jar"); addClasspathEntry(sb, "/portal/lib/development/spring-test.jar"); portalJars.add("commons-io.jar"); portalJars.add("commons-lang.jar"); } addClasspathEntry(sb, "/portal/lib/development/activation.jar"); addClasspathEntry(sb, "/portal/lib/development/annotations.jar"); addClasspathEntry(sb, "/portal/lib/development/jsp-api.jar"); addClasspathEntry(sb, "/portal/lib/development/mail.jar"); addClasspathEntry(sb, "/portal/lib/development/servlet-api.jar"); Map<String, String> attributes = new HashMap<String, String>(); if (libDirPath.contains("/ext/")) { attributes.put("optional", "true"); } for (String jar : globalJars) { addClasspathEntry(sb, "/portal/lib/global/" + jar, attributes); } portalJars = ListUtil.unique(portalJars); Collections.sort(portalJars); for (String jar : portalJars) { if (!jar.equals("util-slf4j.jar")) { addClasspathEntry(sb, "/portal/lib/portal/" + jar, attributes); } } addClasspathEntry(sb, "/portal/portal-service/portal-service.jar"); addClasspathEntry(sb, "/portal/util-bridges/util-bridges.jar"); addClasspathEntry(sb, "/portal/util-java/util-java.jar"); if (portalJars.contains("util-slf4j.jar")) { addClasspathEntry(sb, "/portal/util-slf4j/util-slf4j.jar"); } addClasspathEntry(sb, "/portal/util-taglib/util-taglib.jar"); for (String jar : extGlobalJars) { addClasspathEntry(sb, "docroot/WEB-INF/ext-lib/global/" + jar); } for (String jar : extPortalJars) { addClasspathEntry(sb, "docroot/WEB-INF/ext-lib/portal/" + jar); } for (String jar : customJars) { if (libDirPath.contains("/tmp/WEB-INF/lib")) { addClasspathEntry(sb, "tmp/WEB-INF/lib/" + jar); } else if (libDirPath.contains("/docroot/WEB-INF/lib")) { addClasspathEntry(sb, "docroot/WEB-INF/lib/" + jar); } else { addClasspathEntry(sb, "lib/" + jar); } } File ivyXmlFile = new File(projectDirName, "ivy.xml"); if (ivyXmlFile.exists()) { String content = _fileUtil.read(ivyXmlFile); if (content.contains("arquillian-junit-container")) { String ivyDirName = ".ivy"; for (int i = 0; i < 10; i++) { if (_fileUtil.exists(ivyDirName)) { break; } ivyDirName = "../" + ivyDirName; } addIvyCacheJar(sb, ivyDirName, "org.apache.felix/org.apache.felix.framework"); addIvyCacheJar(sb, ivyDirName, "org.jboss.arquillian.junit/arquillian-junit-core"); addIvyCacheJar(sb, ivyDirName, "org.jboss.arquillian.test/arquillian-test-api"); } } sb.append("\t<classpathentry kind=\"output\" path=\"bin\" />\n"); sb.append("</classpath>"); System.out.println("Updating " + classpathFile); String content = StringUtil.replace(sb.toString(), "\"/portal", "\"/portal-" + _BRANCH); _fileUtil.write(classpathFile, content); }