2012-03-16 120 views
3

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

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("[email protected]"); 
    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门户很陌生,但对我来说看起来很奇怪。

顺便说一句,我们显然不是在这里寻找性能,关键只是从门户远程获取一些特定的内容。如果你知道任何工作解决方案,你的帮助将不胜感激。

+0

嗨,我追溯了代码,发现通过发送AssetEntryQuery()的普通对象,您可能没有准确的查询。看看com.liferay.portlet.asset.service.persistence.AssetEntryFinderImpl的方法findEntries(AssetEntryQuery entryQuery)条目 – 2012-06-06 13:17:06

回答

0

正常情况下,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方法返回一个正数,所以它可能没有什么差别,但给它一个去! :)