List of usage examples for com.liferay.portal.kernel.util StringPool PERCENT
String PERCENT
To view the source code for com.liferay.portal.kernel.util StringPool PERCENT.
Click Source Link
From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java
License:Open Source License
@Override public AssetEntry updateEntry(long userId, long groupId, Date createDate, Date modifiedDate, String className, long classPK, String classUuid, long classTypeId, long[] categoryIds, String[] tagNames, boolean visible, Date startDate, Date endDate, Date expirationDate, String mimeType, String title, String description, String summary, String url, String layoutUuid, int height, int width, Integer priority, boolean sync) throws PortalException, SystemException { // Entry/*from ww w . ja va 2 s .c om*/ User user = userPersistence.findByPrimaryKey(userId); long classNameId = PortalUtil.getClassNameId(className); List<String> newTagsList = new ArrayList<String>(); if (!Validator.isNull(tagNames) && className.equalsIgnoreCase(JournalArticle.class.getName())) { for (String tag : tagNames) { if (PropsUtil.get("stoxx-contentmanagement-all-region").equalsIgnoreCase(tag)) { ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil .locate(ClpSerializer.getServletContextName(), "portletClassLoader"); DynamicQuery query = DynamicQueryFactoryUtil.forClass(IndexDB.class, classLoader); query.setProjection( ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("superRegion"))); query.addOrder(OrderFactoryUtil.asc("superRegion")); query.add(RestrictionsFactoryUtil.eq("data1", "1")); newTagsList.addAll(new ArrayList<String>(IndexDBLocalServiceUtil.dynamicQuery(query))); } else if (PropsUtil.get("stoxx-contentmanagement-all-type").equalsIgnoreCase(tag)) { ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil .locate(ClpSerializer.getServletContextName(), "portletClassLoader"); DynamicQuery query = DynamicQueryFactoryUtil.forClass(IndexDB.class, classLoader); query.setProjection( ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("superType"))); query.addOrder(OrderFactoryUtil.asc("superType")); query.add(RestrictionsFactoryUtil.eq("data1", "1")); newTagsList.addAll(new ArrayList<String>(IndexDBLocalServiceUtil.dynamicQuery(query))); } else { List<String> regionSuperTypeList = getRegionandTypeList(tag); if (regionSuperTypeList.size() > 0) { newTagsList.addAll(regionSuperTypeList); } } } } if (newTagsList.size() > 0) { int arraySize = newTagsList.size() + tagNames.length; String[] newTagNames = new String[arraySize]; int count = 0; for (String tag : newTagsList) { tag = tag.replace(StringPool.SLASH, StringPool.BLANK); tag = tag.replace(StringPool.AMPERSAND, StringPool.BLANK); tag = tag.replace(StringPool.PERCENT, StringPool.BLANK); newTagNames[count] = tag; count++; } for (String tag : tagNames) { if (!PropsUtil.get("stoxx-contentmanagement-all-type").equalsIgnoreCase(tag) && !PropsUtil.get("stoxx-contentmanagement-all-region").equalsIgnoreCase(tag)) { newTagNames[count] = tag; count++; } } List<String> tagList = new ArrayList<String>(Arrays.asList(newTagNames)); tagList.removeAll(Collections.singleton(null)); tagNames = tagList.toArray(new String[tagList.size()]); } validate(groupId, className, categoryIds, tagNames); AssetEntry entry = assetEntryPersistence.fetchByC_C(classNameId, classPK); boolean oldVisible = false; if (entry != null) { oldVisible = entry.isVisible(); } if (modifiedDate == null) { modifiedDate = new Date(); } if (entry == null) { long entryId = counterLocalService.increment(); entry = assetEntryPersistence.create(entryId); entry.setCompanyId(user.getCompanyId()); entry.setUserId(user.getUserId()); entry.setUserName(user.getFullName()); if (createDate == null) { createDate = new Date(); } entry.setCreateDate(createDate); entry.setModifiedDate(modifiedDate); entry.setClassNameId(classNameId); entry.setClassPK(classPK); entry.setClassUuid(classUuid); entry.setVisible(visible); entry.setExpirationDate(expirationDate); if (priority == null) { entry.setPriority(0); } entry.setViewCount(0); } entry.setGroupId(groupId); entry.setModifiedDate(modifiedDate); entry.setClassTypeId(classTypeId); entry.setVisible(visible); entry.setStartDate(startDate); entry.setEndDate(endDate); entry.setExpirationDate(expirationDate); entry.setMimeType(mimeType); entry.setTitle(title); entry.setDescription(description); entry.setSummary(summary); entry.setUrl(url); entry.setLayoutUuid(layoutUuid); entry.setHeight(height); entry.setWidth(width); if (priority != null) { entry.setPriority(priority.intValue()); } // Categories if (categoryIds != null) { assetEntryPersistence.setAssetCategories(entry.getEntryId(), categoryIds); } // Tags if (tagNames != null) { long siteGroupId = PortalUtil.getSiteGroupId(groupId); Group siteGroup = groupLocalService.getGroup(siteGroupId); List<AssetTag> tags = assetTagLocalService.checkTags(userId, siteGroup, tagNames); List<AssetTag> oldTags = assetEntryPersistence.getAssetTags(entry.getEntryId()); assetEntryPersistence.setAssetTags(entry.getEntryId(), tags); if (entry.isVisible()) { boolean isNew = entry.isNew(); assetEntryPersistence.updateImpl(entry); if (isNew) { for (AssetTag tag : tags) { assetTagLocalService.incrementAssetCount(tag.getTagId(), classNameId); } } else { for (AssetTag oldTag : oldTags) { if (!tags.contains(oldTag)) { assetTagLocalService.decrementAssetCount(oldTag.getTagId(), classNameId); } } for (AssetTag tag : tags) { if (!oldTags.contains(tag)) { assetTagLocalService.incrementAssetCount(tag.getTagId(), classNameId); } } } } else if (oldVisible) { for (AssetTag oldTag : oldTags) { assetTagLocalService.decrementAssetCount(oldTag.getTagId(), classNameId); } } } // Update entry after tags so that entry listeners have access to the // saved categories and tags log.info("AssetEntryLocalServiceImpl.updateEntry() inside updateEntry"); if (entry.getClassName().equals(JournalArticle.class.getName())) { List<AssetCategory> assetCategory = entry.getCategories(); for (AssetCategory ae : assetCategory) { log.info("AssetEntryLocalServiceImpl.updateEntry() the asset category is " + ae.getName()); if (STOXXConstants.CATEGORY_STOXX_NEWS_PRESS_RELEASE.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_NEWS_MARKET_NEWS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_MARKET_TRENDS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_WEBINARS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_EXPERT_SPEAK.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_EVENTS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_PULSE.equalsIgnoreCase(ae.getName())) { JournalArticle journalArticle = null; try { journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(entry.getClassPK()); } catch (Exception e) { log.info("The exception in getting journalArticle " + e.getMessage()); break; } String strDate = getXmlDocument(journalArticle, "Date"); log.info("AssetEntryLocalServiceImpl.updateEntry() Date is strDate" + strDate); if (!Validator.isBlank(strDate)) { log.info("AssetEntryLocalServiceImpl.updateEntry() date is not null"); Date date = new Date(Long.parseLong(strDate)); entry.setModifiedDate(date); break; } } } } log.info("AssetEntryLocalServiceImpl.updateEntry() processing finished"); assetEntryPersistence.update(entry); // Synchronize if (!sync) { return entry; } if (className.equals(BlogsEntry.class.getName())) { BlogsEntry blogsEntry = blogsEntryPersistence.findByPrimaryKey(classPK); blogsEntry.setTitle(title); blogsEntryPersistence.update(blogsEntry); } else if (className.equals(BookmarksEntry.class.getName())) { BookmarksEntry bookmarksEntry = bookmarksEntryPersistence.findByPrimaryKey(classPK); bookmarksEntry.setName(title); bookmarksEntry.setDescription(description); bookmarksEntry.setUrl(url); bookmarksEntryPersistence.update(bookmarksEntry); } else if (className.equals(DLFileEntry.class.getName())) { DLFileEntry dlFileEntry = dlFileEntryPersistence.findByPrimaryKey(classPK); dlFileEntry.setTitle(title); dlFileEntry.setDescription(description); dlFileEntryPersistence.update(dlFileEntry); } else if (className.equals(JournalArticle.class.getName())) { JournalArticle journalArticle = journalArticlePersistence.findByPrimaryKey(classPK); journalArticle.setTitle(title); journalArticle.setDescription(description); journalArticlePersistence.update(journalArticle); } else if (className.equals(MBMessage.class.getName())) { MBMessage mbMessage = mbMessagePersistence.findByPrimaryKey(classPK); mbMessage.setSubject(title); mbMessagePersistence.update(mbMessage); } else if (className.equals(WikiPage.class.getName())) { WikiPage wikiPage = wikiPagePersistence.findByPrimaryKey(classPK); wikiPage.setTitle(title); wikiPagePersistence.update(wikiPage); } return entry; }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLContentLocalServiceImpl.java
License:Open Source License
public void deleteContentsByDirectory(long companyId, long repositoryId, String dirName) throws SystemException { if (!dirName.endsWith(StringPool.SLASH)) { dirName = dirName.concat(StringPool.SLASH); }//from w w w. java 2 s . co m dirName = dirName.concat(StringPool.PERCENT); dlContentPersistence.removeByC_R_LikeP(companyId, repositoryId, dirName); }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLContentLocalServiceImpl.java
License:Open Source License
public List<DLContent> getContentsByDirectory(long companyId, long repositoryId, String dirName) throws SystemException { if (!dirName.endsWith(StringPool.SLASH)) { dirName = dirName.concat(StringPool.SLASH); }/*from w w w . j a v a 2s . co m*/ dirName = dirName.concat(StringPool.PERCENT); return dlContentPersistence.findByC_R_LikeP(companyId, repositoryId, dirName); }
From source file:com.liferay.salesforce.service.impl.SalesforceAccountLocalServiceImpl.java
License:Open Source License
public MessageBatch getAccountsByName(long companyId, String name, List<String> fieldNames, long ownerId) throws SystemException { Condition condition = ConditionImpl.LIKE("Name", StringUtil.quote(name, StringPool.PERCENT)); return executeQuery(companyId, fieldNames, condition, ownerId); }
From source file:com.liferay.so.service.impl.FavoriteSiteLocalServiceImpl.java
License:Open Source License
protected String getGroupRealName(long companyId, String name) { if (Validator.isNull(name)) { return name; }//from w ww.j av a 2 s. c o m String groupRealName = name; try { Company company = companyPersistence.findByPrimaryKey(companyId); Account account = company.getAccount(); String companyName = account.getName(); name = StringUtil.replace(name, StringPool.PERCENT, StringPool.BLANK); if (companyName.indexOf(name) != -1) { groupRealName = StringUtil.quote(GroupConstants.GUEST, StringPool.PERCENT); } } catch (PortalException pe) { } return groupRealName; }
From source file:com.liferay.so.service.persistence.FavoriteSiteFinderImpl.java
License:Open Source License
public int countByU_N(long userId, String name, String groupRealName) throws SystemException { Session session = null;//from ww w . j av a 2 s . c o m try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_U_N); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(StringPool.PERCENT + name + StringPool.PERCENT); qPos.add(groupRealName); qPos.add(name); Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.so.service.persistence.FavoriteSiteFinderImpl.java
License:Open Source License
public List<Object[]> findByU_N(long userId, String name, String groupRealName, int start, int end) throws SystemException { name = StringUtil.lowerCase(name);/*from w w w . j a va 2 s. co m*/ Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_U_N); SQLQuery q = session.createSQLQuery(sql); q.addScalar("userId", Type.LONG); q.addScalar("groupId", Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(StringPool.PERCENT + name + StringPool.PERCENT); qPos.add(groupRealName); qPos.add(name); return (List<Object[]>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.sync.service.impl.SyncDeviceLocalServiceImpl.java
License:Open Source License
@Override public List<SyncDevice> search(long companyId, String keywords, int start, int end, OrderByComparator<SyncDevice> orderByComparator) { return syncDevicePersistence.findByC_U(companyId, StringUtil.quote(keywords, StringPool.PERCENT), start, end, orderByComparator);/* w w w. j a v a2 s . c o m*/ }
From source file:com.liferay.util.dao.orm.CustomSQL.java
License:Open Source License
public String[] keywords(String keywords, boolean lowerCase) { if (Validator.isNull(keywords)) { return new String[] { null }; }/*from www. j a va 2s .c o m*/ if (lowerCase) { keywords = keywords.toLowerCase(); } keywords = keywords.trim(); String[] keywordsArray = keywords.split("\\s+"); for (int i = 0; i < keywordsArray.length; i++) { String keyword = keywordsArray[i]; keywordsArray[i] = StringPool.PERCENT + keyword + StringPool.PERCENT; } return keywordsArray; }
From source file:com.liferay.wsrp.hook.upgrade.v1_1_0.UpgradeUuid.java
License:Open Source License
protected void updateLayout(String oldPortletId, String newPortletId) throws Exception { Connection con = null;/* w w w. j a va2s . co m*/ PreparedStatement ps = null; ResultSet rs = null; try { con = DataAccess.getConnection(); ps = con.prepareStatement("select plid, typeSettings from Layout where typeSettings " + "like ?"); ps.setString(1, StringPool.PERCENT + oldPortletId + StringPool.PERCENT); rs = ps.executeQuery(); while (rs.next()) { long plid = rs.getLong("plid"); String typeSettings = rs.getString("typeSettings"); typeSettings = StringUtil.replace(typeSettings, oldPortletId, newPortletId); updateLayout(plid, typeSettings); } } finally { DataAccess.cleanUp(con, ps, rs); } }