Simple example of accessing content

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2008 05:50 PM
Hi,
Would someone happen to have an example that shows how to read existing content using a web service ? The examples I have seen show how to read content after creating the content in the same program. I am looking for an example that reads content created by a user outside of my program..
So the example would be: Create Content from Web Interface, call it test.txt, and then read it and display it using a web service..
Thanks!
J
Would someone happen to have an example that shows how to read existing content using a web service ? The examples I have seen show how to read content after creating the content in the same program. I am looking for an example that reads content created by a user outside of my program..
So the example would be: Create Content from Web Interface, call it test.txt, and then read it and display it using a web service..
Thanks!
J
Labels:
- Labels:
-
Archive
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2008 06:53 PM
I managed to Google up some code from 2004 it appears
I placed foobar.txt in where SAMPLES_FOLDER was created by the supplied examples code:
Which points to:
But this above code throws an error saying it cannot find the xpath. What am I doing wrong ?
Thanks.
J
public String init() throws Exception { String downloadURL = null; try { String dir = "/app:company_home/cm:sample_folder"; String fileName = "foobar.txt"; System.out.println("dir ::" + dir); System.out.println("fileName ::" + fileName);// Start the session AuthenticationUtils.startSession("admin", "admin"); String ticket = AuthenticationUtils.getTicket();// Create a reference to the parent where we want to create content Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore"); // Create a new Reference to the node you want (variable path here). String path = dir+"*[@cm:name=\"" + fileName + "\"]"; Reference reference = new Reference(storeRef, null, path); ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();// Read the content from the respository Content[] readResult = contentService.read( new Predicate(new Reference[]{reference}, storeRef, null), Constants.PROP_CONTENT); Content contentRef = readResult[0];// Get the ticket URL as above and the downloadURL here points to the url where the content is present. System.out.println("contentRef.getUrl() : " + contentRef.getUrl()); String ticketURL = "?ticket=" + ticket; downloadURL = contentRef.getUrl() + ticketURL; System.out.println("downloadURL in webService(): " + downloadURL); } catch(Throwable e) { System.out.println(e.toString()); } finally { // End the session AuthenticationUtils.endSession(); } return downloadURL; }
I placed foobar.txt in where SAMPLES_FOLDER was created by the supplied examples code:
protected static final Reference SAMPLE_FOLDER = new Reference(STORE, null, "/app:company_home/cm:sample_folder");
Which points to:
NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, "Web Service Sample Folder")};
But this above code throws an error saying it cannot find the xpath. What am I doing wrong ?
Thanks.
J

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2008 02:20 PM
