Extracting Articles from Liferay Portal

Our goal is to get some of the content from Liferay Portal through SOAP services using Java. We are successfully uploading articles right now JournalArticleServiceSoap. The problem is that this method requires a Group ID and a Post ID and we want to get all articles from a specific group. Hence, we try to get the ids first using the AssetEntryServiceSoap, but that fails.

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 such as 83, getEnries () always returns an empty array. I am very new to Liferay portal, but it looks strange to me.

By the way, we are obviously not looking for performance here, the key is just to remotely fetch certain content from the portal. If you know of any working solution, your help would be much appreciated.

+3


source to share


1 answer


Usually the AssetEntryQuery will have a little more information in it, for example:

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

      



So this will return all AssetEntries for the groupId you specified, which are also JournalArticles.

Try this and see though, as you say, the Count method returns a positive number, so it might not have any effect, but let it go! :)

0


source







All Articles