Example usage for com.liferay.portal.kernel.util PortalUtil getClassNameId

List of usage examples for com.liferay.portal.kernel.util PortalUtil getClassNameId

Introduction

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

Prototype

public static long getClassNameId(String value) 

Source Link

Document

Returns the ID of the class from its fully qualified name.

Usage

From source file:com.liferay.expando.service.test.ExpandoValueLocalServiceTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _classNameId = PortalUtil.getClassNameId(DLFileEntry.class);

    _enLocale = LocaleUtil.fromLanguageId("en_US");
    _frLocale = LocaleUtil.fromLanguageId("fr_FR");
    _ptLocale = LocaleUtil.fromLanguageId("pt_BR");

    _expandoTable = ExpandoTestUtil.addTable(_classNameId, "testExpandoTable");
}

From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java

License:Open Source License

@Override
public Object getZipEntryAsObject(Element element, String path) {
    Object object = fromXML(getZipEntryAsString(path));

    Attribute classNameAttribute = element.attribute("attached-class-name");

    if ((object != null) && (classNameAttribute != null)) {
        String className = classNameAttribute.getText();

        BeanPropertiesUtil.setProperty(object, "className", className);
        BeanPropertiesUtil.setProperty(object, "classNameId", PortalUtil.getClassNameId(className));
    }//from   w w w.j ava 2  s.c o  m

    return object;
}

From source file:com.liferay.exportimport.resources.importer.internal.util.ResourceImporter.java

License:Open Source License

@Override
protected void addDDLDisplayTemplates(String ddmStructureKey, String dirName, String fileName)
        throws Exception {

    DDMStructure ddmStructure = ddmStructureLocalService.getStructure(groupId,
            PortalUtil.getClassNameId(DDLRecordSet.class), ddmStructureKey);

    Set<String> resourcePaths = servletContext
            .getResourcePaths(_getResourcePath(dirName) + StringPool.SLASH + fileName);

    if (resourcePaths == null) {
        return;//from w  ww.  ja  v a2  s. c om
    }

    for (String resourcePath : resourcePaths) {
        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        String script = StringUtil.read(urlConnection.getInputStream());

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

        addDDMTemplate(groupId, ddmStructure.getStructureId(), resourcePath,
                getDDMTemplateLanguage(resourcePath), script, DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY,
                StringPool.BLANK);
    }
}

From source file:com.liferay.exportimport.resources.importer.internal.util.ResourceImporter.java

License:Open Source License

@Override
protected void addDDLFormTemplates(String ddmStructureKey, String dirName, String fileName) throws Exception {

    DDMStructure ddmStructure = ddmStructureLocalService.getStructure(groupId,
            PortalUtil.getClassNameId(DDLRecordSet.class), ddmStructureKey);

    Set<String> resourcePaths = servletContext
            .getResourcePaths(_getResourcePath(dirName) + StringPool.SLASH + fileName);

    if (resourcePaths == null) {
        return;/*from w  w  w.  j  av  a2  s.  c  o  m*/
    }

    for (String resourcePath : resourcePaths) {
        URL url = servletContext.getResource(resourcePath);

        URLConnection urlConnection = url.openConnection();

        String script = StringUtil.read(urlConnection.getInputStream());

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

        addDDMTemplate(groupId, ddmStructure.getStructureId(), resourcePath, "xsd", script,
                DDMTemplateConstants.TEMPLATE_TYPE_FORM, DDMTemplateConstants.TEMPLATE_MODE_CREATE);
    }
}

From source file:com.liferay.exportimport.resources.importer.test.ResourcesImporterTest.java

License:Open Source License

protected void validateJournal(Group importedGroup) throws Exception {
    List<JournalArticle> journalArticles = JournalArticleLocalServiceUtil
            .getArticles(importedGroup.getGroupId());

    Assert.assertEquals(journalArticles.toString(), 5, journalArticles.size());

    int ddmStructuresCount = DDMStructureLocalServiceUtil.getStructuresCount(importedGroup.getGroupId(),
            PortalUtil.getClassNameId(JournalArticle.class));

    Assert.assertEquals(3, ddmStructuresCount);

    int ddmTemplatesCount = DDMTemplateLocalServiceUtil.getTemplatesCount(importedGroup.getGroupId(),
            PortalUtil.getClassNameId(DDMStructure.class));

    Assert.assertEquals(3, ddmTemplatesCount);

    JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticle(importedGroup.getGroupId(),
            "BASIC-ARTICLE");

    Assert.assertTrue(journalArticle.isSmallImage());

    Map<Locale, String> descriptionMap = journalArticle.getDescriptionMap();

    Assert.assertFalse(descriptionMap.toString(), descriptionMap.isEmpty());

    AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(JournalArticle.class.getName(),
            journalArticle.getResourcePrimKey());

    List<AssetTag> assetTags = AssetTagLocalServiceUtil.getEntryTags(assetEntry.getEntryId());

    Assert.assertEquals(assetTags.toString(), 1, assetTags.size());

    JournalFolder parentJournalFolder = JournalFolderLocalServiceUtil.fetchFolder(importedGroup.getGroupId(),
            "Basic Web Content Parent Folder");

    JournalArticle parentJournalFolderJournalArticle = JournalArticleLocalServiceUtil
            .getArticle(importedGroup.getGroupId(), "BASIC-ARTICLE-IN-PARENT-FOLDER");

    Assert.assertNotNull(parentJournalFolder);

    Assert.assertEquals(parentJournalFolderJournalArticle.getFolder(), parentJournalFolder);

    JournalFolder childJournalFolder = JournalFolderLocalServiceUtil.fetchFolder(importedGroup.getGroupId(),
            "Basic Web Content Child Folder");

    Assert.assertEquals(parentJournalFolder, childJournalFolder.getParentFolder());

    JournalArticle childJournalFolderJournalArticle = JournalArticleLocalServiceUtil
            .getArticle(importedGroup.getGroupId(), "BASIC-ARTICLE-IN-CHILD-FOLDER");

    Assert.assertEquals(childJournalFolderJournalArticle.getFolder(), childJournalFolder);
}

From source file:com.liferay.exportimport.system.event.test.SystemEventCheckTest.java

License:Open Source License

protected void validate(List<SystemEvent> systemEvents, boolean missing) {
    for (SystemEvent systemEvent : systemEvents) {
        SystemEvent actualSystemEvent = SystemEventLocalServiceUtil.fetchSystemEvent(_group.getGroupId(),
                PortalUtil.getClassNameId(Group.class), systemEvent.getClassPK(),
                SystemEventConstants.TYPE_DELETE);

        if (missing) {
            Assert.assertEquals(null, actualSystemEvent);
        } else {//from  w ww .  j a va  2  s. c  o  m
            Assert.assertEquals(systemEvent, actualSystemEvent);
        }
    }
}

From source file:com.liferay.exportimport.test.util.lar.BasePortletExportImportTestCase.java

License:Open Source License

protected void testExportImportDisplayStyle(long displayStyleGroupId, String scopeType) throws Exception {

    Portlet portlet = PortletLocalServiceUtil.getPortletById(group.getCompanyId(), getPortletId());

    if (portlet == null) {
        return;/*from   w w w .  ja  va2 s . c  o  m*/
    }

    if (scopeType.equals("layout") && !portlet.isScopeable()) {
        Assert.assertTrue("This test does not apply", true);

        return;
    }

    TemplateHandler templateHandler = portlet.getTemplateHandlerInstance();

    if ((templateHandler == null) || !templateHandler.isDisplayTemplateHandler()) {

        Assert.assertTrue("This test does not apply", true);

        return;
    }

    String className = templateHandler.getClassName();
    long resourceClassNameId = PortalUtil
            .getClassNameId("com.liferay.portlet.display.template.PortletDisplayTemplate");

    DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(displayStyleGroupId,
            PortalUtil.getClassNameId(className), 0, resourceClassNameId);

    Map<String, String[]> preferenceMap = new HashMap<>();

    String displayStyle = PortletDisplayTemplateManager.DISPLAY_STYLE_PREFIX + ddmTemplate.getTemplateKey();

    preferenceMap.put("displayStyle", new String[] { displayStyle });

    preferenceMap.put("displayStyleGroupId", new String[] { String.valueOf(ddmTemplate.getGroupId()) });

    if (scopeType.equals("layout")) {
        preferenceMap.put("lfrScopeLayoutUuid", new String[] { this.layout.getUuid() });
    }

    preferenceMap.put("lfrScopeType", new String[] { scopeType });

    PortletPreferences portletPreferences = getImportedPortletPreferences(preferenceMap);

    String importedDisplayStyle = portletPreferences.getValue("displayStyle", StringPool.BLANK);

    Assert.assertEquals(displayStyle, importedDisplayStyle);

    long importedDisplayStyleGroupId = GetterUtil
            .getLong(portletPreferences.getValue("displayStyleGroupId", null));

    long expectedDisplayStyleGroupId = importedGroup.getGroupId();

    if (scopeType.equals("company")) {
        Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(importedGroup.getCompanyId());

        expectedDisplayStyleGroupId = companyGroup.getGroupId();
    } else if (displayStyleGroupId != group.getGroupId()) {
        expectedDisplayStyleGroupId = displayStyleGroupId;
    }

    Assert.assertEquals(expectedDisplayStyleGroupId, importedDisplayStyleGroupId);
}

From source file:com.liferay.gs.hack.model.impl.ClientModelImpl.java

License:Open Source License

@Override
public StagedModelType getStagedModelType() {
    return new StagedModelType(PortalUtil.getClassNameId(Client.class.getName()));
}

From source file:com.liferay.gs.hack.model.impl.ProjectModelImpl.java

License:Open Source License

@Override
public StagedModelType getStagedModelType() {
    return new StagedModelType(PortalUtil.getClassNameId(Project.class.getName()));
}

From source file:com.liferay.gs.hack.model.impl.ProjectTaskModelImpl.java

License:Open Source License

@Override
public StagedModelType getStagedModelType() {
    return new StagedModelType(PortalUtil.getClassNameId(ProjectTask.class.getName()));
}