繁体   English   中英

从Liferay门户获取文章

[英]Fetching articles form Liferay portal

我们的目标是通过使用Java的SOAP服务从Liferay Portal获取一些内容。 我们正在使用JournalArticleServiceSoap成功加载文章。 问题是该方法需要组ID和条目ID,我们想要的是从特定组中获取所有文章。 因此,我们试图首先使用AssetEntryServiceSoap获取ID,但它失败了。

AssetEntryServiceSoapServiceLocator aesssLocator = new AssetEntryServiceSoapServiceLocator();
    com.liferay.client.soap.portlet.asset.service.http.AssetEntryServiceSoap assetEntryServiceSoap = null;

    URL url = null;
    try {
        url = new URL(
                "http://127.0.0.1:8080/tunnel-web/secure/axis/Portlet_Asset_AssetEntryService");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    try {
        assetEntryServiceSoap = aesssLocator
                .getPortlet_Asset_AssetEntryService(url);
    } catch (ServiceException e) {
        e.printStackTrace();
    }
    if (assetEntryServiceSoap == null) {
        return;
    }

    Portlet_Asset_AssetEntryServiceSoapBindingStub assetEntryServiceSoapBindingStub = (Portlet_Asset_AssetEntryServiceSoapBindingStub) assetEntryServiceSoap;
    assetEntryServiceSoapBindingStub.setUsername("bruno@7cogs.com");
    assetEntryServiceSoapBindingStub.setPassword("bruno");

    AssetEntrySoap[] entries;
    AssetEntryQuery query = new AssetEntryQuery();

    try {
        int count = assetEntryServiceSoap.getEntriesCount(query);
        System.out.println("Entries count: " + Integer.toString(count));
        entries = assetEntryServiceSoap.getEntries(query);
        if (entries != null) {
            System.out.println(Integer.toString(entries.length));
        }
        for (AssetEntrySoap aes : assetEntryServiceSoap.getEntries(query)) {
            System.out.println(aes.getEntryId());
        }
    } catch (RemoteException e1) {
        e1.printStackTrace();
    }

虽然getEntriesCount()返回一个像83这样的正值,但getEnries()总是返回一个空数组。 我是Liferay门户网站的新手,但对我来说这看起来很奇怪。

顺便说一句,我们显然不是在寻找性能,关键是从远程门户获取一些特定内容。 如果您知道任何有效的解决方案,我们将非常感谢您的帮助

通常,AssetEntryQuery会在其中包含更多信息,例如:

AssetEntryQuery assetEntryQuery = new AssetEntryQuery();
assetEntryQuery.setClassNameIds(new long[] { ClassNameLocalServiceUtil.getClassNameId("com.liferay.portlet.journal.model.JournalArticle") });
assetEntryQuery.setGroupIds(new long[] { groupId });

因此,这将返回您指定的groupId的所有AssetEntries,它们也是JournalArticles。

尝试这个并看看,虽然如你所说,Count方法返回一个正数,所以它可能没有区别,但是试一试! :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM