Example usage for com.liferay.portal.kernel.repository.capabilities RelatedModelCapability getClassPK

List of usage examples for com.liferay.portal.kernel.repository.capabilities RelatedModelCapability getClassPK

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.capabilities RelatedModelCapability getClassPK.

Prototype

public long getClassPK(FileEntry fileEntry);

Source Link

Usage

From source file:com.liferay.wiki.search.WikiPageIndexer.java

License:Open Source License

@Override
public void addRelatedEntryFields(Document document, Object obj) throws Exception {

    long classPK = 0;

    if (obj instanceof Comment) {
        Comment comment = (Comment) obj;

        classPK = comment.getClassPK();/*from  w  w w. j a va 2 s.c  o  m*/
    } else if (obj instanceof FileEntry) {
        FileEntry fileEntry = (FileEntry) obj;

        RelatedModelCapability relatedModelCapability = fileEntry
                .getRepositoryCapability(RelatedModelCapability.class);

        classPK = relatedModelCapability.getClassPK(fileEntry);
    }

    WikiPage page = null;

    try {
        page = _wikiPageLocalService.getPage(classPK);
    } catch (Exception e) {
        return;
    }

    document.addKeyword(Field.NODE_ID, page.getNodeId());
}