cancel
Showing results for 
Search instead for 
Did you mean: 

Path Information

nathan
Champ in-the-making
Champ in-the-making
I have a folder within Alfresco that contains news articles. Using web services, I'd like to get into this folder and grab the headline from each article so that it can be displayed elsewhere. Looking at the web services examples, I see references like this:

protected static final Reference SAMPLE_FOLDER = new Reference(STORE, null, "/app:company_home/cm:sample_folder"); 

This Reference is used to check for the existence of the sample folder. However, in the web interface, we don't see "sample_folder" anywhere, but rather "Web Service Sample Folder", the name given to it on creation. If I want to refer to the "Web Projects" folder or the spaces within it, the actual folder/node names are not easily accessible. How do I go about creating References to such folders?
7 REPLIES 7

alexcocia
Champ in-the-making
Champ in-the-making
Hi nathan

I use the "node explorer" in admin's console. You can navigate through items, and children. Child's name is showed there.

Not the best solution, there might be a better one, but it works….

nathan
Champ in-the-making
Champ in-the-making
Thanks, I got the path from the node browser, which gives me this:

avm://mywebproject/-1;www;avm_webapps;ROOT;articles

How do I access this folder's contents using the web services API (with Java)? I have looked through the SDK web services examples, but none of them interact with a web project. This query returns nothing:

Query query = new Query(Constants.QUERY_LANG_LUCENE, "+PARENT:\"/avm://mywebproject/-1;www;avm_webapps;ROOT;articles\"");

Where am I going wrong?

alexcocia
Champ in-the-making
Champ in-the-making
Hi nathan,
I have not much experience with queries yet, but hope it might help you:

Once you have the reference to your folder, you can get its children with the web services.


Reference ref = new Reference(STORE, uuid_folder, null);
QueryResult resultado = WebServiceFactory.getRepositoryService().queryChildren(ref);
if (resultado != null) {
   ResultSet resultset = resultado.getResultSet();
   if (resultset.getRows() != null) {
      for (ResultSetRow row : resultset.getRows()) {
         for (NamedValue nm : row.getColumns()) {
               System.out.println(nm.getName() + " = " + nm.getValue());
               }
            }
         }
      }

nathan
Champ in-the-making
Champ in-the-making
Hi alex,
Thanks for the tip. Using your code, I was able to dig down a little deeper into the folder structure. I still can't get all the way down to a content level, though. For instance, let's say I use this reference:

Reference reference = new Reference(STORE, null, "/app:company_home/app:wcm/cm:myWebProject");

I'm able to get down to the level of myWebProject and see its three children. This is immediately suspicious because my web project only has one child (at least, that's the way it appears in the web client). Here are the results of such a query:

{http://www.alfresco.org/model/wcmappmodel/1.0}username = admin
{http://www.alfresco.org/model/system/1.0}node-uuid = 105aa31d-3f93-11dc-9bd4-9980daf60ad1
{http://www.alfresco.org/model/system/1.0}node-dbid = 475
{http://www.alfresco.org/model/system/1.0}store-protocol = workspace
{http://www.alfresco.org/model/content/1.0}name = 105aa31d-3f93-11dc-9bd4-9980daf60ad1
{http://www.alfresco.org/model/system/1.0}store-identifier = SpacesStore
{http://www.alfresco.org/model/wcmappmodel/1.0}role = ContentManager
associationType = {http://www.alfresco.org/model/wcmappmodel/1.0}webuser
associationName = {http://www.alfresco.org/model/wcmappmodel/1.0}webuser
isPrimary = true
nthSibling = 0
{http://www.alfresco.org/model/content/1.0}path = /{http://www.alfresco.org/model/application/1.0}company_home/
{http://www.alfresco.org/model/application/1.0}wcm/
{http://www.alfresco.org/model/content/1.0}myWebProject/
{http://www.alfresco.org/model/wcmappmodel/1.0}webuser
{http://www.alfresco.org/model/content/1.0}description =
{http://www.alfresco.org/model/system/1.0}node-uuid = 10a95f71-3f93-11dc-9bd4-9980daf60ad1
{http://www.alfresco.org/model/system/1.0}node-dbid = 476
{http://www.alfresco.org/model/content/1.0}title = article
{http://www.alfresco.org/model/wcmappmodel/1.0}formname = article
{http://www.alfresco.org/model/wcmappmodel/1.0}outputpathpattern = ${name}.xml
{http://www.alfresco.org/model/system/1.0}store-protocol = workspace
{http://www.alfresco.org/model/content/1.0}name = 10a95f71-3f93-11dc-9bd4-9980daf60ad1
{http://www.alfresco.org/model/system/1.0}store-identifier = SpacesStore
associationType = {http://www.alfresco.org/model/wcmappmodel/1.0}webform
associationName = {http://www.alfresco.org/model/wcmappmodel/1.0}webform
isPrimary = true
nthSibling = 1
{http://www.alfresco.org/model/content/1.0}path = /{http://www.alfresco.org/model/application/1.0}company_home/
{http://www.alfresco.org/model/application/1.0}wcm/{http://www.alfresco.org/model/content/1.0}
myWebProject/{http://www.alfresco.org/model/wcmappmodel/1.0}webform
{http://www.alfresco.org/model/wcmappmodel/1.0}workflowname = jbpm$wcmwf:submit
{http://www.alfresco.org/model/system/1.0}node-uuid = 10c12d3e-3f93-11dc-9bd4-9980daf60ad1
{http://www.alfresco.org/model/system/1.0}node-dbid = 479
{http://www.alfresco.org/model/system/1.0}store-protocol = workspace
{http://www.alfresco.org/model/wcmappmodel/1.0}workflowdefaultproperties = contentUrl=store://2007/7/31/14/22/10c37731-3f93-11dc-9bd4-9980daf60ad1.bin|
mimetype=application/octet-stream|size=701|encoding=UTF-8|locale=en_US_
{http://www.alfresco.org/model/wcmappmodel/1.0}filenamepattern = .*
{http://www.alfresco.org/model/content/1.0}name = 10c12d3e-3f93-11dc-9bd4-9980daf60ad1
{http://www.alfresco.org/model/system/1.0}store-identifier = SpacesStore
associationType = {http://www.alfresco.org/model/wcmappmodel/1.0}webworkflowdefaults
associationName = {http://www.alfresco.org/model/wcmappmodel/1.0}webworkflowdefaults
isPrimary = true
nthSibling = 2
{http://www.alfresco.org/model/content/1.0}path = /{http://www.alfresco.org/model/application/1.0}company_home/
{http://www.alfresco.org/model/application/1.0}wcm/
{http://www.alfresco.org/model/content/1.0}myWebProject/
{http://www.alfresco.org/model/wcmappmodel/1.0}webworkflowdefaults
Result 1: id=105aa31d-3f93-11dc-9bd4-9980daf60ad1; name=105aa31d-3f93-11dc-9bd4-9980daf60ad1; description=null; created=null; url=null
Result 2: id=10a95f71-3f93-11dc-9bd4-9980daf60ad1; name=10a95f71-3f93-11dc-9bd4-9980daf60ad1; description=; created=null; url=null
Result 3: id=10c12d3e-3f93-11dc-9bd4-9980daf60ad1; name=10c12d3e-3f93-11dc-9bd4-9980daf60ad1; description=null; created=null; url=null

All of these children are of the type: {http://www.alfresco.org/model/wcmappmodel/1.0}

I just get a long error message if I try using one of these references:
Reference reference = new Reference(STORE, null, "/app:company_home/app:wcm/cm:unbroken/app:webuser");
Reference reference = new Reference(STORE, null, "/app:company_home/app:wcm/cm:unbroken/cm:webuser");

Does this wcmappmodel type have its own namespace prefix? Also, is this the right place to be looking for my web content? It doesn't seem to mirror the behavior of the web client.

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

As far as I've seen (which is not than much), I 've experienced that some folders contains, lets say "hidden files", in which workflows, actions and so on are defined. Those files are shown in the web service search, but not in the web client.

I think that might be the reason for the other two unknown nodes you mention. the question now wuld be to differenciate those files from the ones you want to be shown

By the way, rows for node have a "type" attribute, which is quite usefull for this.

row.getNode().getType()

Try and see the differences between nodes.

There might be a more experienced answer to this, but this is as far as I got so far.
Hope it helps…

nathan
Champ in-the-making
Champ in-the-making
Hi alex, thanks for all your help. I think I've got it figured out now.

I've already run the getType query, that gives me the same sort of type string that I've seen already ({http://www.alfresco.org/model/wcmappmodel/1.0}webuser). Putting that type directly into a reference path causes an error, and there is no namespace listed for it at http://wiki.alfresco.com/wiki/Alfresco_Namespaces.

Also of note is that adding or removing content in the root level of the project using the web interface does not change the number of nodes returned by querying the root level of the project using the reference shown above. This suggested to me that I was looking in the wrong place entirely. Using the node browser, I could see that, in fact, none of these nodes had any children anyway, further leading me to believe that this was a dead end.

It turns out that I was in the wrong store for what I wanted to do. I needed to be in avm, not workspace. Using the following code, I'm able to finally get to the web project's ROOT folder:

Store STORE = new Store("avm", "myWebProject");
Reference reference = new Reference(STORE, null, "/cm:www/cm:avm_webapps/cm:ROOT");

jefrainmx
Champ in-the-making
Champ in-the-making
Is it possible to create a Reference but instead of a folder to the a file? I'm using the execute script functionality but i do not want to indicate the name of the web script by using the UUID instead i want to be able to create the reference by the name of the web script.