【问题标题】:Fetching articles form Liferay portal从 Liferay 门户获取文章
【发布时间】:2012-04-02 06:04:25
【问题描述】:

我们的目标是使用 Java 通过 SOAP 服务从 Liferay Portal 获取一些内容。我们现在正在使用 JournalArticleServiceSoap 成功加载文章。问题是该方法需要 group id 和 entry 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()的普通对象,您可能没有准确的查询。查看 com.liferay.portlet.asset.service.persistence.AssetEntryFinderImpl 的方法 findEntries(AssetEntryQuery entryQuery) 条目

标签: java soap service liferay portal


【解决方案1】:

通常,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 方法返回一个正数,所以它可能没有什么不同,但试一试! :)

【讨论】:

    猜你喜欢
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-16
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多