cancel
Showing results for 
Search instead for 
Did you mean: 

Adding new Content to a buried Space

csbrown
Champ in-the-making
Champ in-the-making
I need to be able to add documents at various levels in our "Spaces" heirarchy setup in alfresco, as is normal, I'm sure.  The Spaces were setup using the Web Client, but I need to add documents via WebServices.

What is the best way via the WebServices client to locate a Space that is buried within other Spaces in order to add new content to it?  It seems like there would be an easier way of getting a reference to a Space folder than performing a query to find it.  But if that is the standard method, then that will work.

Thanks for the help,

Colby
2 REPLIES 2

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

For the time being using a query is the best way to get hold of the reference you require.

This can be done using the query method on the repository service, using Lucene, or you can provide a path query to a reference or predicate object that can be used in most of the method calls.  The path provided to the reference will be resolved to the node when the web service method is exectued.

In the future there will be a file/folder service that will make normal file and folder operations easier to perform.

Cheers,
Roy

csbrown
Champ in-the-making
Champ in-the-making
Thanks for the reply Roy.

Here's how I ended up building the reference to the folder location I wanted to write new content to.


// Set the folder location
protected static String DOCUMENT_FOLDER = "/app:company_home/*[@cm:name=\"Web Service Sample Folder\"]";

// Start the session
AuthenticationUtils.startSession(USERNAME, PASSWORD);

Reference homeReference = new Reference(STORE, null, DOCUMENT_FOLDER);
Node[] readResult = WebServiceFactory.getRepositoryService().get(
                                             new Predicate(new Reference[]{homeReference}, STORE, null)
                                             );
         
// Update the homeReference variable as read from repository
homeReference = readResult[0].getReference();

Then I can use the homeReference variable to build the ParentRefence to use when creating new elements.

Thanks again,

Colby