09-12-2008 05:50 PM
09-12-2008 06:53 PM
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;
}
protected static final Reference SAMPLE_FOLDER = new Reference(STORE, null, "/app:company_home/cm:sample_folder");
NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, "Web Service Sample Folder")};
10-13-2008 02:20 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.