Example usage for com.liferay.portal.kernel.service CompanyLocalServiceUtil fetchCompany

List of usage examples for com.liferay.portal.kernel.service CompanyLocalServiceUtil fetchCompany

Introduction

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

Prototype

public static com.liferay.portal.kernel.model.Company fetchCompany(long companyId) 

Source Link

Usage

From source file:com.liferay.document.library.internal.exportimport.data.handler.test.FileEntryStagedModelDataHandlerTest.java

License:Open Source License

protected Map<String, List<StagedModel>> addCompanyDependencies() throws Exception {

    Map<String, List<StagedModel>> dependentStagedModelsMap = new HashMap<>();

    Company company = CompanyLocalServiceUtil.fetchCompany(stagingGroup.getCompanyId());

    Group companyGroup = company.getGroup();

    DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(companyGroup.getGroupId(),
            DLFileEntryMetadata.class.getName());

    addDependentStagedModel(dependentStagedModelsMap, DDMStructureManagerUtil.getDDMStructureModelClass(),
            ddmStructure);//from w  w w. j av  a  2  s .c o m

    DLFileEntryType dlFileEntryType = addDLFileEntryType(companyGroup.getGroupId(),
            ddmStructure.getStructureId());

    addDependentStagedModel(dependentStagedModelsMap, DLFileEntryType.class, dlFileEntryType);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(stagingGroup.getGroupId(),
            TestPropsValues.getUserId());

    Folder folder = DLAppServiceUtil.addFolder(stagingGroup.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString(),
            RandomTestUtil.randomString(), serviceContext);

    addDependentStagedModel(dependentStagedModelsMap, DLFolder.class, folder);

    return dependentStagedModelsMap;
}

From source file:com.liferay.exportimport.internal.content.processor.test.DefaultExportImportContentProcessorTest.java

License:Open Source License

protected String replaceParameters(String content, FileEntry fileEntry) {
    Company company = CompanyLocalServiceUtil.fetchCompany(fileEntry.getCompanyId());

    content = replaceMultiLocaleLayoutFriendlyURLs(content);

    Map<Locale, String> livePublicLayoutFriendlyURLMap = _livePublicLayout.getFriendlyURLMap();
    Map<Locale, String> stagingPrivateLayoutFriendlyURLMap = _stagingPrivateLayout.getFriendlyURLMap();
    Map<Locale, String> stagingPublicLayoutFriendlyURLMap = _stagingPublicLayout.getFriendlyURLMap();

    content = StringUtil.replace(content, new String[] { "[$CANONICAL_URL_SEPARATOR$]",
            "[$CONTROL_PANEL_FRIENDLY_URL$]", "[$CONTROL_PANEL_LAYOUT_FRIENDLY_URL$]", "[$GROUP_FRIENDLY_URL$]",
            "[$GROUP_ID$]", "[$IMAGE_ID$]", "[$LIVE_GROUP_FRIENDLY_URL$]", "[$LIVE_GROUP_ID$]",
            "[$LIVE_PUBLIC_LAYOUT_FRIENDLY_URL$]", "[$NON_DEFAULT_LIVE_PUBLIC_LAYOUT_FRIENDLY_URL$]",
            "[$NON_DEFAULT_PRIVATE_LAYOUT_FRIENDLY_URL$]", "[$NON_DEFAULT_PUBLIC_LAYOUT_FRIENDLY_URL$]",
            "[$PATH_CONTEXT$]", "[$PATH_FRIENDLY_URL_PRIVATE_GROUP$]", "[$PATH_FRIENDLY_URL_PRIVATE_USER$]",
            "[$PATH_FRIENDLY_URL_PUBLIC$]", "[$PRIVATE_LAYOUT_FRIENDLY_URL$]", "[$PUBLIC_LAYOUT_FRIENDLY_URL$]",
            "[$TITLE$]", "[$UUID$]", "[$WEB_ID$]" },
            new String[] { VirtualLayoutConstants.CANONICAL_URL_SEPARATOR,
                    GroupConstants.CONTROL_PANEL_FRIENDLY_URL, PropsValues.CONTROL_PANEL_LAYOUT_FRIENDLY_URL,
                    _stagingGroup.getFriendlyURL(), String.valueOf(fileEntry.getGroupId()),
                    String.valueOf(fileEntry.getFileEntryId()), _liveGroup.getFriendlyURL(),
                    String.valueOf(_liveGroup.getGroupId()), _livePublicLayout.getFriendlyURL(),
                    livePublicLayoutFriendlyURLMap.get(_nonDefaultLocale),
                    stagingPrivateLayoutFriendlyURLMap.get(_nonDefaultLocale),
                    stagingPublicLayoutFriendlyURLMap.get(_nonDefaultLocale), PortalUtil.getPathContext(),
                    PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING,
                    PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING,
                    PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING,
                    _stagingPrivateLayout.getFriendlyURL(), _stagingPublicLayout.getFriendlyURL(),
                    fileEntry.getTitle(), fileEntry.getUuid(), company.getWebId() });

    if (!content.contains("[$TIMESTAMP")) {
        return content;
    }/*from www. j a  v  a  2 s. com*/

    return replaceTimestampParameters(content);
}

From source file:com.liferay.exportimport.test.BasePrototypePropagationTestCase.java

License:Open Source License

@Before
public void setUp() throws Exception {
    ServiceContextThreadLocal.pushServiceContext(ServiceContextTestUtil.getServiceContext());

    ServiceTestUtil.setUser(TestPropsValues.getUser());

    // Group/*from   w w  w .  j a va  2 s  .  c o m*/

    group = GroupTestUtil.addGroup();

    // Global scope article

    Company company = CompanyLocalServiceUtil.fetchCompany(group.getCompanyId());

    globalGroupId = company.getGroupId();

    globalJournalArticle = JournalTestUtil.addArticle(globalGroupId, "Global Article", "Global Content");

    // Layout prototype

    layoutPrototype = LayoutTestUtil.addLayoutPrototype(RandomTestUtil.randomString());

    layoutPrototypeLayout = layoutPrototype.getLayout();

    LayoutTestUtil.updateLayoutTemplateId(layoutPrototypeLayout, initialLayoutTemplateId);

    doSetUp();
}

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

License:Open Source License

protected Map<String, List<StagedModel>> addCompanyDependencies() throws Exception {

    Map<String, List<StagedModel>> dependentStagedModelsMap = new HashMap<>();

    Company company = CompanyLocalServiceUtil.fetchCompany(stagingGroup.getCompanyId());

    Group companyGroup = company.getGroup();

    DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(companyGroup.getGroupId(),
            JournalArticle.class.getName());

    addDependentStagedModel(dependentStagedModelsMap, DDMStructure.class, ddmStructure);

    DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(companyGroup.getGroupId(),
            ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class));

    addDependentStagedModel(dependentStagedModelsMap, DDMTemplate.class, ddmTemplate);

    JournalFolder folder = JournalTestUtil.addFolder(stagingGroup.getGroupId(), RandomTestUtil.randomString());

    addDependentStagedModel(dependentStagedModelsMap, JournalFolder.class, folder);

    return dependentStagedModelsMap;
}

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

License:Open Source License

protected void exportImportJournalArticle(boolean companyScopeDependencies) throws Exception {

    JournalArticle article = null;//  w  w w.  ja  v  a 2 s. co m
    DDMStructure ddmStructure = null;
    DDMTemplate ddmTemplate = null;

    long groupId = group.getGroupId();

    Company company = CompanyLocalServiceUtil.fetchCompany(group.getCompanyId());

    Group companyGroup = company.getGroup();

    if (companyScopeDependencies) {
        groupId = companyGroup.getGroupId();
    }

    ddmStructure = DDMStructureTestUtil.addStructure(groupId, JournalArticle.class.getName());

    ddmTemplate = DDMTemplateTestUtil.addTemplate(groupId, ddmStructure.getStructureId(),
            PortalUtil.getClassNameId(JournalArticle.class));

    String content = DDMStructureTestUtil.getSampleStructuredContent();

    article = JournalTestUtil.addArticleWithXMLContent(group.getGroupId(), content,
            ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey());

    exportImportPortlet(JournalPortletKeys.JOURNAL);

    int articlesCount = JournalArticleLocalServiceUtil.getArticlesCount(importedGroup.getGroupId());

    Assert.assertEquals(1, articlesCount);

    JournalArticle groupArticle = JournalArticleLocalServiceUtil
            .fetchJournalArticleByUuidAndGroupId(article.getUuid(), importedGroup.getGroupId());

    Assert.assertNotNull(groupArticle);

    groupId = importedGroup.getGroupId();

    if (companyScopeDependencies) {
        DDMStructure importedDDMStructure = DDMStructureLocalServiceUtil
                .fetchDDMStructureByUuidAndGroupId(ddmStructure.getUuid(), groupId);

        Assert.assertNull(importedDDMStructure);

        DDMTemplate importedDDMTemplate = DDMTemplateLocalServiceUtil
                .fetchDDMTemplateByUuidAndGroupId(ddmTemplate.getUuid(), groupId);

        Assert.assertNull(importedDDMTemplate);

        groupId = companyGroup.getGroupId();
    }

    DDMStructure dependentDDMStructure = DDMStructureLocalServiceUtil
            .fetchDDMStructureByUuidAndGroupId(ddmStructure.getUuid(), groupId);

    Assert.assertNotNull(dependentDDMStructure);

    DDMTemplate dependentDDMTemplate = DDMTemplateLocalServiceUtil
            .fetchDDMTemplateByUuidAndGroupId(ddmTemplate.getUuid(), groupId);

    Assert.assertNotNull(dependentDDMTemplate);

    Assert.assertEquals(article.getDDMStructureKey(), dependentDDMStructure.getStructureKey());
    Assert.assertEquals(article.getDDMTemplateKey(), dependentDDMTemplate.getTemplateKey());
    Assert.assertEquals(dependentDDMTemplate.getClassPK(), dependentDDMStructure.getStructureId());
}

From source file:com.liferay.layout.type.controller.test.LayoutTypeURLTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _company = CompanyLocalServiceUtil.fetchCompany(TestPropsValues.getCompanyId());

    _group = GroupTestUtil.addGroup();// w  w  w .  j a  v a  2s.c  om

    _publicLayout = LayoutTestUtil.addLayout(_group);

    setUpVirtualHostName();
}