Example usage for com.liferay.portal.kernel.service ServiceContext setLayoutFullURL

List of usage examples for com.liferay.portal.kernel.service ServiceContext setLayoutFullURL

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service ServiceContext setLayoutFullURL.

Prototype

public void setLayoutFullURL(String layoutFullURL) 

Source Link

Document

Sets the complete URL of the current page for this service context.

Usage

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

License:Open Source License

protected ServiceContext buildServiceContext(long companyId, long groupId, String urlTitle) throws Exception {

    ServiceContext serviceContext = new ServiceContext();

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

    serviceContext.setAttribute("pingbackUserName", pingbackUserName);

    StringBundler sb = new StringBundler(5);

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    if (Validator.isNull(portletId)) {
        return serviceContext;
    }/*from w w w .  j  a v  a2 s . co  m*/

    String layoutFullURL = PortalUtil.getLayoutFullURL(groupId, portletId);

    sb.append(layoutFullURL);

    sb.append(Portal.FRIENDLY_URL_SEPARATOR);

    Portlet portlet = _portletLocalService.getPortletById(companyId, portletId);

    sb.append(portlet.getFriendlyURLMapping());
    sb.append(StringPool.SLASH);
    sb.append(urlTitle);

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

    serviceContext.setLayoutFullURL(layoutFullURL);

    return serviceContext;
}

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

License:Open Source License

@Override
public void checkEntries() throws PortalException {
    Date now = new Date();

    int count = blogsEntryPersistence.countByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED);

    if (count == 0) {
        return;//from  w w  w  . ja va2  s  .  c o  m
    }

    List<BlogsEntry> entries = blogsEntryPersistence.findByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED);

    for (BlogsEntry entry : entries) {
        ServiceContext serviceContext = new ServiceContext();

        String[] trackbacks = StringUtil.split(entry.getTrackbacks());

        serviceContext.setAttribute("trackbacks", trackbacks);

        serviceContext.setCommand(Constants.UPDATE);

        String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
                PortletProvider.Action.VIEW);

        if (Validator.isNotNull(portletId)) {
            String layoutFullURL = PortalUtil.getLayoutFullURL(entry.getGroupId(), portletId);

            serviceContext.setLayoutFullURL(layoutFullURL);
        }

        serviceContext.setScopeGroupId(entry.getGroupId());

        blogsEntryLocalService.updateStatus(entry.getStatusByUserId(), entry.getEntryId(),
                WorkflowConstants.STATUS_APPROVED, serviceContext, new HashMap<String, Serializable>());
    }
}

From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java

License:Open Source License

protected ServiceContext getServiceContext(BlogsEntry entry) throws Exception {

    ServiceContext serviceContext = new ServiceContext();

    String[] trackbacks = StringUtil.split(entry.getTrackbacks());

    serviceContext.setAttribute("trackbacks", trackbacks);

    serviceContext.setCommand(Constants.UPDATE);

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    String layoutFullURL = PortalUtil.getLayoutFullURL(entry.getGroupId(), portletId);

    serviceContext.setLayoutFullURL(layoutFullURL);

    serviceContext.setScopeGroupId(entry.getGroupId());

    return serviceContext;
}

From source file:com.liferay.blogs.test.util.BlogsTestUtil.java

License:Open Source License

public static void populateNotificationsServiceContext(ServiceContext serviceContext, String command)
        throws Exception {

    serviceContext.setAttribute("entryURL", "http://localhost");

    if (Validator.isNotNull(command)) {
        serviceContext.setCommand(command);
    }/*from   ww w .ja  v a  2  s .com*/

    serviceContext.setLayoutFullURL("http://localhost");
}

From source file:com.liferay.bookmarks.util.test.BookmarksTestUtil.java

License:Open Source License

public static BookmarksEntry addEntry(String name, long folderId, boolean approved,
        ServiceContext serviceContext) throws Exception {

    boolean workflowEnabled = WorkflowThreadLocal.isEnabled();

    try {/*from   w  w  w. j a  v a  2  s . com*/
        WorkflowThreadLocal.setEnabled(true);

        String url = "http://www.liferay.com";
        String description = "This is a test entry.";

        serviceContext = (ServiceContext) serviceContext.clone();

        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

        BookmarksEntry entry = BookmarksEntryServiceUtil.addEntry(serviceContext.getScopeGroupId(), folderId,
                name, url, description, serviceContext);

        serviceContext.setCommand(Constants.ADD);
        serviceContext.setLayoutFullURL("http://localhost");

        if (approved) {
            entry.setStatus(WorkflowConstants.STATUS_APPROVED);

            entry = BookmarksEntryServiceUtil.updateEntry(entry.getEntryId(), serviceContext.getScopeGroupId(),
                    entry.getFolderId(), entry.getName(), entry.getUrl(), entry.getUrl(), serviceContext);
        }

        return entry;
    } finally {
        WorkflowThreadLocal.setEnabled(workflowEnabled);
    }
}

From source file:com.liferay.bookmarks.util.test.BookmarksTestUtil.java

License:Open Source License

public static BookmarksEntry updateEntry(BookmarksEntry entry, String name) throws Exception {

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(entry.getGroupId());

    serviceContext.setCommand(Constants.UPDATE);
    serviceContext.setLayoutFullURL("http://localhost");

    return BookmarksEntryLocalServiceUtil.updateEntry(TestPropsValues.getUserId(), entry.getEntryId(),
            entry.getGroupId(), entry.getFolderId(), name, entry.getUrl(), entry.getDescription(),
            serviceContext);/* w ww  .j a va2  s  .  co m*/
}

From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java

License:Open Source License

@Override
public ServiceContext getServiceContext() {

    ServiceContext serviceContext = new ServiceContext();
    ThemeDisplay themeDisplay = getThemeDisplay();
    serviceContext.setCompanyId(themeDisplay.getCompanyId());
    serviceContext.setLanguageId(themeDisplay.getLanguageId());
    serviceContext.setPathMain(PortalUtil.getPathMain());
    serviceContext.setPlid(themeDisplay.getPlid());
    serviceContext.setPortalURL(PortalUtil.getPortalURL(getPortletRequest()));
    serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
    serviceContext.setUserId(themeDisplay.getUserId());

    try {//from   ww w .  j  a  v  a 2s .  c  om
        serviceContext.setLayoutFullURL(PortalUtil.getLayoutFullURL(themeDisplay));
        serviceContext.setLayoutURL(PortalUtil.getLayoutURL(themeDisplay));
        serviceContext.setUserDisplayURL(themeDisplay.getUser().getDisplayURL(themeDisplay));
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }

    return serviceContext;
}

From source file:com.liferay.journal.exportimport.data.handler.test.JournalArticleStagedModelDataHandlerTest.java

License:Open Source License

@Test
public void testArticlesWithSameResourceUUID() throws Exception {
    initExport();//from  w w  w  .j  a  va2  s . c  o  m

    JournalArticle journalArticle = JournalTestUtil.addArticle(stagingGroup.getGroupId(),
            JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(liveGroup.getGroupId());

    serviceContext.setAttribute("articleResourceUuid", journalArticle.getArticleResourceUuid());
    serviceContext.setCommand(Constants.ADD);
    serviceContext.setLayoutFullURL("http://localhost");

    JournalArticle importJournalArticle = JournalTestUtil.addArticle(liveGroup.getGroupId(),
            journalArticle.getFolderId(), serviceContext);

    Assert.assertEquals(journalArticle.getArticleResourceUuid(), importJournalArticle.getArticleResourceUuid());
    Assert.assertEquals(liveGroup.getGroupId(), importJournalArticle.getGroupId());
    Assert.assertNotEquals(journalArticle.getUuid(), importJournalArticle.getUuid());

    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, journalArticle);

    initImport();

    StagedModel exportedStagedModel = readExportedStagedModel(journalArticle);

    Assert.assertNotNull(exportedStagedModel);

    ExportImportThreadLocal.setPortletImportInProcess(true);

    try {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, exportedStagedModel);
    } finally {
        ExportImportThreadLocal.setPortletImportInProcess(false);
    }

    importJournalArticle = JournalArticleLocalServiceUtil
            .fetchJournalArticleByUuidAndGroupId(journalArticle.getUuid(), liveGroup.getGroupId());

    Assert.assertNotNull(importJournalArticle);
    Assert.assertEquals(journalArticle.getVersion(), importJournalArticle.getVersion(), 0D);
}

From source file:com.liferay.journal.exportimport.data.handler.test.JournalExportImportTest.java

License:Open Source License

@Override
protected StagedModel addStagedModel(long groupId, Date createdDate) throws Exception {

    String title = RandomTestUtil.randomString();

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(groupId);

    serviceContext.setCommand(Constants.ADD);
    serviceContext.setCreateDate(createdDate);
    serviceContext.setLayoutFullURL("http://localhost");
    serviceContext.setModifiedDate(createdDate);

    return JournalTestUtil.addArticle(groupId, JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            JournalArticleConstants.CLASSNAME_ID_DEFAULT, title, title, RandomTestUtil.randomString(),
            LocaleUtil.getSiteDefault(), false, false, serviceContext);
}

From source file:com.liferay.journal.lar.test.JournalArticleStagedModelDataHandlerTest.java

License:Open Source License

@Test
public void testArticlesWithSameResourceUUID() throws Exception {
    initExport();// w ww .j  a  va2 s.  c  om

    JournalArticle journalArticle = JournalTestUtil.addArticle(stagingGroup.getGroupId(),
            JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(liveGroup.getGroupId());

    serviceContext.setAttribute("articleResourceUuid", journalArticle.getArticleResourceUuid());
    serviceContext.setCommand(Constants.ADD);
    serviceContext.setLayoutFullURL("http://localhost");

    JournalArticle importJournalArticle = JournalTestUtil.addArticle(liveGroup.getGroupId(),
            journalArticle.getFolderId(), serviceContext);

    Assert.assertEquals(journalArticle.getArticleResourceUuid(), importJournalArticle.getArticleResourceUuid());
    Assert.assertEquals(liveGroup.getGroupId(), importJournalArticle.getGroupId());
    Assert.assertNotEquals(journalArticle.getUuid(), importJournalArticle.getUuid());

    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, journalArticle);

    initImport();

    StagedModel exportedStagedModel = readExportedStagedModel(journalArticle);

    Assert.assertNotNull(exportedStagedModel);

    ExportImportThreadLocal.setPortletImportInProcess(true);

    try {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, exportedStagedModel);
    } finally {
        ExportImportThreadLocal.setPortletImportInProcess(false);
    }

    importJournalArticle = JournalArticleLocalServiceUtil
            .fetchJournalArticleByUuidAndGroupId(journalArticle.getUuid(), liveGroup.getGroupId());

    Assert.assertNotNull(importJournalArticle);
    Assert.assertEquals(journalArticle.getVersion(), importJournalArticle.getVersion(), 0d);
}