02-28-2007 07:19 PM
protected static final String USERNAME = ""
protected static final String PASSWORD = "";
protected static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
protected static final Reference SAMPLE_FOLDER = new Reference(STORE, null, "/app:company_home/cm:guest_home");
// node ref 9b2469fe-ba26-11db-8e3a-43f788d364ed
public void testGetGuestDocument() {
printStores();
getGuestDocument();
}
private void getGuestDocument() {
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
} catch (AuthenticationFault authenticationFault) {
authenticationFault.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
System.out.println("testtt"+contentService.getClass());
if (contentService == null) {
System.out.println("content service not available");
}
Reference ref = new Reference();
ref.setUuid("9b2469fe-ba26-11db-8e3a-43f788d364ed");
ref.setStore(STORE);
Predicate predicate = new Predicate();
predicate.setNodes(new Reference[]{ref});
// call the service and make sure we get some details back
NodeDefinition[] nodeDefs = new NodeDefinition[0];
try {
nodeDefs = WebServiceFactory.getRepositoryService().describe(predicate);
} catch (RemoteException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Assert.assertNotNull("nodeDefs should not be null", nodeDefs);
Assert.assertTrue("There should be at least one result", nodeDefs.length > 0);
NodeDefinition nodeDef = nodeDefs[0];
Assert.assertNotNull("The nodeDef should not be null", nodeDef);
ClassDefinition typeDef = nodeDef.getType();
Assert.assertNotNull("Type definition should not be null", typeDef);
System.out.println("type name = " + typeDef.getName());
for(PropertyDefinition def:typeDef.getProperties()){
System.out.println(""+def.getName() );
}
// Read the newly added content from the respository
Content[] readResult = new Content[0];
try {
readResult = contentService.read(new Predicate(new Reference[]{ref}, STORE, null), Constants.PROP_CONTENT);
} catch (RemoteException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Content content = readResult[0];
System.out.println("content url " + content.getUrl());
ContentUtils.copyContentToFile(content, new File("/home/dcrossma/Desktop/guest.pdf"));
AuthenticationUtils.endSession();
}
private void printStores() {
// Start the session
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
} catch (AuthenticationFault authenticationFault) {
authenticationFault.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
try {
// Get the respoitory service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Get array of stores available in the repository
Store[] stores = new Store[0];
try {
stores = repositoryService.getStores();
} catch (RemoteException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if (stores == null) {
// NOTE: empty array are returned as a null object, this is a issue with the generated web service code.
System.out.println("There are no stores avilable in the repository.");
} else {
// Output the names of all the stores available in the repository
System.out.println("The following stores are available in the repository:");
for (Store store : stores) {
System.out.println(store.getScheme() + "://" + store.getAddress());
}
}
}
finally {
// End the session
AuthenticationUtils.endSession();
}
}
}
03-01-2007 01:26 AM
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.