Example usage for com.liferay.portal.kernel.util StringPool SLASH

List of usage examples for com.liferay.portal.kernel.util StringPool SLASH

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool SLASH.

Prototype

String SLASH

To view the source code for com.liferay.portal.kernel.util StringPool SLASH.

Click Source Link

Usage

From source file:com.liferay.opensocial.shindig.util.ShindigUtil.java

License:Open Source License

public static String getFileEntryURL(String portalURL, long fileEntryId) throws PortalException {

    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);

    StringBundler sb = new StringBundler(6);

    sb.append(portalURL);/*ww  w  .  j a va2s.  c  o  m*/
    sb.append(PortalUtil.getPathContext());
    sb.append("/documents/");
    sb.append(fileEntry.getRepositoryId());
    sb.append(StringPool.SLASH);
    sb.append(fileEntry.getUuid());

    return sb.toString();
}

From source file:com.liferay.polls.util.PollsUtil.java

License:Open Source License

public static void savePollsVote(HttpServletRequest request, HttpServletResponse response,
        long pollsQuestionId) {

    Cookie cookie = new Cookie(_getCookieName(pollsQuestionId), StringPool.TRUE);

    cookie.setMaxAge((int) (Time.WEEK / 1000));
    cookie.setPath(StringPool.SLASH);

    CookieKeys.addCookie(request, response, cookie);
}

From source file:com.liferay.polls.web.internal.portlet.util.PollsUtil.java

License:Open Source License

public static void saveVote(HttpServletRequest request, HttpServletResponse response, long questionId) {

    Cookie cookie = new Cookie(_getCookieName(questionId), StringPool.TRUE);

    cookie.setMaxAge((int) (Time.WEEK / 1000));
    cookie.setPath(StringPool.SLASH);

    CookieKeys.addCookie(request, response, cookie);
}

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//  www.j  a  v  a  2s. c  o  m

    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.assetpublisher.action.RSSAction.java

License:Open Source License

protected String getAssetPublisherURL(PortletRequest portletRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    StringBundler sb = new StringBundler(7);

    String layoutFriendlyURL = GetterUtil.getString(PortalUtil.getLayoutFriendlyURL(layout, themeDisplay));

    if (!layoutFriendlyURL.startsWith(Http.HTTP_WITH_SLASH)
            && !layoutFriendlyURL.startsWith(Http.HTTPS_WITH_SLASH)) {

        sb.append(themeDisplay.getPortalURL());
    }/*from www .j a  va 2 s  .co m*/

    sb.append(layoutFriendlyURL);
    sb.append(Portal.FRIENDLY_URL_SEPARATOR);
    sb.append("asset_publisher/");
    sb.append(portletDisplay.getInstanceId());
    sb.append(StringPool.SLASH);

    return sb.toString();
}

From source file:com.liferay.portlet.blogs.lar.BlogsPortletDataHandlerImpl.java

License:Open Source License

protected String getEntryImagePath(PortletDataContext portletDataContext, BlogsEntry entry) throws Exception {

    StringBundler sb = new StringBundler(4);

    sb.append(portletDataContext.getPortletPath(PortletKeys.BLOGS));
    sb.append("/entry/");
    sb.append(entry.getUuid());/*from ww w. jav a  2 s  .co m*/
    sb.append(StringPool.SLASH);

    return sb.toString();
}

From source file:com.liferay.portlet.blogs.lar.WordPressImporter.java

License:Open Source License

protected static String getWordPressPath(PortletDataContext context, String fileName) {

    return context.getSourcePortletPath(PortletKeys.BLOGS).concat(StringPool.SLASH).concat(fileName);
}

From source file:com.liferay.portlet.blogs.service.impl.BlogsEntryLocalServiceImpl.java

License:Open Source License

protected void notifySubscribers(BlogsEntry entry, ServiceContext serviceContext) throws SystemException {

    if (!entry.isApproved()) {
        return;/*from  ww  w .jav  a  2s  .  c o  m*/
    }

    String layoutFullURL = serviceContext.getLayoutFullURL();

    if (Validator.isNull(layoutFullURL)) {
        return;
    }

    PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext);

    if (preferences == null) {
        long ownerId = entry.getGroupId();
        int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP;
        long plid = PortletKeys.PREFS_PLID_SHARED;
        String portletId = PortletKeys.BLOGS;
        String defaultPreferences = null;

        preferences = portletPreferencesLocalService.getPreferences(entry.getCompanyId(), ownerId, ownerType,
                plid, portletId, defaultPreferences);
    }

    if (serviceContext.isCommandAdd() && BlogsUtil.getEmailEntryAddedEnabled(preferences)) {
    } else if (serviceContext.isCommandUpdate() && BlogsUtil.getEmailEntryUpdatedEnabled(preferences)) {
    } else {
        return;
    }

    String entryURL = layoutFullURL + Portal.FRIENDLY_URL_SEPARATOR + "blogs" + StringPool.SLASH
            + entry.getEntryId();

    String fromName = BlogsUtil.getEmailFromName(preferences, entry.getCompanyId());
    String fromAddress = BlogsUtil.getEmailFromAddress(preferences, entry.getCompanyId());

    Map<Locale, String> localizedSubjectMap = null;
    Map<Locale, String> localizedBodyMap = null;

    if (serviceContext.isCommandUpdate()) {
        localizedSubjectMap = BlogsUtil.getEmailEntryUpdatedSubjectMap(preferences);
        localizedBodyMap = BlogsUtil.getEmailEntryUpdatedBodyMap(preferences);
    } else {
        localizedSubjectMap = BlogsUtil.getEmailEntryAddedSubjectMap(preferences);
        localizedBodyMap = BlogsUtil.getEmailEntryAddedBodyMap(preferences);
    }

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setCompanyId(entry.getCompanyId());
    subscriptionSender.setContextAttributes("[$BLOGS_ENTRY_URL$]", entryURL);
    subscriptionSender.setContextUserPrefix("BLOGS_ENTRY");
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setLocalizedBodyMap(localizedBodyMap);
    subscriptionSender.setLocalizedSubjectMap(localizedSubjectMap);
    subscriptionSender.setMailId("blogs_entry", entry.getEntryId());
    subscriptionSender.setPortletId(PortletKeys.BLOGS);
    subscriptionSender.setReplyToAddress(fromAddress);
    subscriptionSender.setScopeGroupId(entry.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setUserId(entry.getUserId());

    subscriptionSender.addPersistedSubscribers(BlogsEntry.class.getName(), entry.getGroupId());

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.portlet.blogs.util.PingbackMethodImpl.java

License:Open Source License

public Response execute(long companyId) {
    if (!PropsValues.BLOGS_PINGBACK_ENABLED) {
        return XmlRpcUtil.createFault(XmlRpcConstants.REQUESTED_METHOD_NOT_FOUND, "Pingbacks are disabled");
    }//from  w  ww .  j  a v  a2 s.com

    Response response = validateSource();

    if (response != null) {
        return response;
    }

    try {
        BlogsEntry entry = getBlogsEntry(companyId);

        if (!entry.isAllowPingbacks()) {
            return XmlRpcUtil.createFault(XmlRpcConstants.REQUESTED_METHOD_NOT_FOUND, "Pingbacks are disabled");
        }

        long userId = UserLocalServiceUtil.getDefaultUserId(companyId);
        long groupId = entry.getGroupId();
        String className = BlogsEntry.class.getName();
        long classPK = entry.getEntryId();

        MBMessageDisplay messageDisplay = MBMessageLocalServiceUtil.getDiscussionMessageDisplay(userId, groupId,
                className, classPK, WorkflowConstants.STATUS_APPROVED);

        MBThread thread = messageDisplay.getThread();

        long threadId = thread.getThreadId();
        long parentMessageId = thread.getRootMessageId();
        String body = "[...] " + getExcerpt() + " [...] [url=" + _sourceUri + "]"
                + LanguageUtil.get(LocaleUtil.getDefault(), "read-more") + "[/url]";

        List<MBMessage> messages = MBMessageLocalServiceUtil.getThreadMessages(threadId,
                WorkflowConstants.STATUS_APPROVED);

        for (MBMessage message : messages) {
            if (message.getBody().equals(body)) {
                return XmlRpcUtil.createFault(PINGBACK_ALREADY_REGISTERED, "Pingback previously registered");
            }
        }

        ServiceContext serviceContext = new ServiceContext();

        String pingbackUserName = LanguageUtil.get(LocaleUtil.getDefault(), "pingback");

        serviceContext.setAttribute("pingbackUserName", pingbackUserName);

        StringBundler sb = new StringBundler(5);

        String layoutFullURL = PortalUtil.getLayoutFullURL(groupId, PortletKeys.BLOGS);

        sb.append(layoutFullURL);

        sb.append(Portal.FRIENDLY_URL_SEPARATOR);

        Portlet portlet = PortletLocalServiceUtil.getPortletById(companyId, PortletKeys.BLOGS);

        sb.append(portlet.getFriendlyURLMapping());
        sb.append(StringPool.SLASH);
        sb.append(entry.getUrlTitle());

        serviceContext.setAttribute("redirect", sb.toString());

        serviceContext.setLayoutFullURL(layoutFullURL);

        MBMessageLocalServiceUtil.addDiscussionMessage(userId, StringPool.BLANK, groupId, className, classPK,
                threadId, parentMessageId, StringPool.BLANK, body, serviceContext);

        return XmlRpcUtil.createSuccess("Pingback accepted");
    } catch (Exception e) {
        if (_log.isDebugEnabled()) {
            _log.debug(e, e);
        }

        return XmlRpcUtil.createFault(TARGET_URI_INVALID, "Error parsing target URI");
    }
}

From source file:com.liferay.portlet.documentlibrary.lar.DLPortletDataHandlerImpl.java

License:Open Source License

public static String getFileEntryPath(PortletDataContext portletDataContext, FileEntry fileEntry) {

    StringBundler sb = new StringBundler(6);

    sb.append(portletDataContext.getPortletPath(PortletKeys.DOCUMENT_LIBRARY));
    sb.append("/file-entries/");
    sb.append(fileEntry.getFileEntryId());
    sb.append(StringPool.SLASH);
    sb.append(fileEntry.getVersion());//from www. j a v a2 s.com
    sb.append(".xml");

    return sb.toString();
}