简体   繁体   English

从Liferay门户获取文章

[英]Fetching articles form Liferay portal

Our goal is to fetch some of the content from Liferay Portal via SOAP services using Java. 我们的目标是通过使用Java的SOAP服务从Liferay Portal获取一些内容。 We are successfully loading articles right now with JournalArticleServiceSoap. 我们正在使用JournalArticleServiceSoap成功加载文章。 The problem is that the method requires both group id and entry id, and what we want is to fetch all of the articles from a particular group. 问题是该方法需要组ID和条目ID,我们想要的是从特定组中获取所有文章。 Hence, we are trying to get the ids first, using AssetEntryServiceSoap but it fails. 因此,我们试图首先使用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();
    }

Although getEntriesCount() returns a positive value like 83, getEnries() always returns an empty array. 虽然getEntriesCount()返回一个像83这样的正值,但getEnries()总是返回一个空数组。 I'm very new to Liferay portal, but it looks really weird to me. 我是Liferay门户网站的新手,但对我来说这看起来很奇怪。

By the way, we are obviously not looking for performance here, the key is just to fetch some specific content from the portal remotely. 顺便说一句,我们显然不是在寻找性能,关键是从远程门户获取一些特定内容。 If you know any working solution your help would be much appreciated. 如果您知道任何有效的解决方案,我们将非常感谢您的帮助

Normally a AssetEntryQuery would have a little more information in it for example: 通常,AssetEntryQuery会在其中包含更多信息,例如:

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

So this would return all AssetEntries for the groupId you specify, that are also JournalArticles. 因此,这将返回您指定的groupId的所有AssetEntries,它们也是JournalArticles。

Try this and see, although as you say, the Count method returns a positive number so it might not make a difference, but give it a go! 尝试这个并看看,虽然如你所说,Count方法返回一个正数,所以它可能没有区别,但是试一试! :) :)

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

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