cancel
Showing results for 
Search instead for 
Did you mean: 

Web Content type: content or avmplaincontent?

nathan
Champ in-the-making
Champ in-the-making
Hi all,

I need some help clarifying issues I'm seeing in a Web Services application. I am trying to access content in an XML file, and largely followed the examples in the SDK.

I've tried two methods of accessing this content, each with its own issue. First, I tried querying for the content using the normal alfresco content type:


Store storeRef = new Store("avm", "myWebProject");

Query query = new Query(
                Constants.QUERY_LANG_LUCENE,
                "+PATH:\"/www/avm_webapps/ROOT/content/*\"");

Predicate predicate = new Predicate(null, storeRef, query);

Content[] readResult = contentService.read(
    predicate,
    "{http://www.alfresco.org/model/content/1.0}content");

if (readResult == null) {
               System.out.println("No content gotten!");
            }
            else {
               for (Content content : readResult) {
                   InputStream contentStream = ContentUtils.getContentAsInputStream(content);

}

This seems to work without errors, but the readResult contains each piece of retrieved content six times, and continues to receive results from content that has been deleted.

After checking the node browser, I noticed that all the web content files are listed as type "{http://www.alfresco.org/model/wcmmodel/1.0}avmplaincontent". Replacing the type in the read method, however, gives me this error:


org.alfresco.webservice.util.WebServiceException: Unable to get content as inputStream.
   at org.alfresco.webservice.util.ContentUtils.getContentAsInputStream(ContentUtils.java:128)
   at com.bigbad.utils.HeadlineGrabber.getHeadlineList(TestApp.java:91)
   at com.bigbad.utils.HeadlineGrabber.getHeadlines(TestApp.java:46)
   at com.bigbad.utils.HeadlineGrabber.main(TestApp.java:26)
Caused by: java.net.MalformedURLException: no protocol: null?ticket=TICKET_861ad1ef84ccfc8e68ad51787c1e5812ff219e41
   at java.net.URL.<init>(Unknown Source)
   at java.net.URL.<init>(Unknown Source)Error during query
[]
   at java.net.URL.<init>(Unknown Source)
   at org.alfresco.webservice.util.ContentUtils.getContentAsInputStream(ContentUtils.java:122)
   … 3 more

After digging into the ContentUtils code, I tracked the problem down to a call to content.getURL(), which returns null and, in turn, the MalformedURLException above.

Any suggestions how I could make this work?
1 REPLY 1

robertoroberto
Champ in-the-making
Champ in-the-making
Hi,Have Anyone resolved the problem? I have the same problem.
Can you help me?