gpt4 book ai didi

java - 从 Liferay 门户获取文章

转载 作者:行者123 更新时间:2023-12-02 09:39:34 25 4
gpt4 key购买 nike

我们的目标是使用 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 方法返回一个正数,所以它可能没有什么区别,但试一试! :)

关于java - 从 Liferay 门户获取文章,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9741619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com