cancel
Showing results for 
Search instead for 
Did you mean: 

Adding children to store root

hsjawanda
Champ in-the-making
Champ in-the-making
Hi,

I have been trying a few things, have been getting unexpected results, and now I am confused.  So here are my questions:

Is there anything special about adding a node (say, a folder) directly as a child of a store root? I have a store with protocol "workspace" – will the following code work for adding a folder directly under the store root:


// this.storeRef points to the store I am interested in.
NodeRef rootNode = nodeService.getRootNode(this.storeRef);

// Creating a folder as a direct child of storeRef
ChildAssociationRef childAssocRef = nodeService.createNode(rootNode,
        ContentModel.PROP_CONTAINS, QName.createQName(
                NamespaceService.CONTENT_MODEL_1_0_URI, folderName),
        ContentModel.TYPE_FOLDER);

Does it matter whether I use ContentModel.PROP_CONTAINS or some other QName as the assocTypeQName when adding a child to a store's root?

What are the differences between creating child associations and creating plain-jane associations (NodeService#createAssociation())? I think one of the differences is that (recursive) searching under a parent node will search those nodes related through child associations, but not those related through plain associations – is this correct?

If I don't put any "PATH:" term in my Lucene search, does the whole store get searched? For example, if I construct a query like this:


String query = "+TYPE:\"" + ContentModel.TYPE_FOLDER.toString() + "\"";

will I get back a list of all the folders in the store being searched?  Will the assocTypeQName I use while adding children make a difference to the results of the above query?

I apologize for asking so many questions in a single post, but I am getting confused by some of the results I am seeing :-).

Thanks.
28 REPLIES 28

soeursourire
Champ in-the-making
Champ in-the-making
Thanks for the fast answer.
Is there a wiki or documentation about the structure of the database (a entity-relationship diagram)?

Where can I check the properties values of a node person (from node people) in the database by sql command line?

Thanks

kevinr
Star Contributor
Star Contributor
This query will find the users from the node_properties table:

select string_value, guid from node_properties where protocol='user' and qname='{http://www.alfresco.org/model/user/1.0}username';
Get the value the "guid" column value for the user you are interested in, then execute something like this to see all the properties for that user instance:

select * from node_properties where guid='9e86231c-9cb7-11da-a085-9f5761485f4e';
Remember that the passwords field is encrypted.

Hope this helps,

Kevin

soeursourire
Champ in-the-making
Champ in-the-making
Thanks for help. So that allows me to access the users properties (username, password…) but not the person properties (firstname, lastname, etc…) ?

Please would you mind telling me where the node 'People' ("/sysSmiley Tongueeople") is created in the code? the node 'person' is created while creating a user in PersonService but where is created the node 'people'?

Thanks.

soeursourire
Champ in-the-making
Champ in-the-making
Oki I found… it is done while calling the function getPeopleContainer right?

Another question… in the function startWizardForEdit from NewUserWizard what does this code means:

UIActionLink link = (UIActionLink) event.getComponent();
     Map<String, String> params = link.getParameterMap();
     String id = params.get("id");

What is this id? the uuid of the node?
If I am creating 2 different nodes during this newuserwizard, how will he choose which uuid to use? How can I be sure that if I create two different nodes in sys:system I will have different uuid for the children of the first node and the children of the second node?

Thanks in advance

soeursourire
Champ in-the-making
Champ in-the-making
Another question as well…
I am able to create a new node Functions under System. Then I create nodes function in Functions. But in the NodeBrowser it appears that the node function I create has the same uuid than the node person that I create at the same time. Can it be due to nodebrowser bug? or because I am badly using userTransaction?

Then I wanted to add a class FunctionsBean similar to UsersBean to display all functions in my jsp page users.jsp however I have error message in my jsp page saying that it cannot find my functionService, where should I define the bean functionService and the bean FunctionsBean? in faces-config, in application-context, in authentication-context, in network-protocol..?

soeursourire
Champ in-the-making
Champ in-the-making
I think I managed to add my nodes correctly but now I would like to get all nodes like when you get all person nodes with the class UsersBean. But I do not understand how this UsersBean is instantiate (where and when the nodeService is defined for example)?

<a:richList id="users-list" binding="#{UsersBean.usersRichList}" viewMode="details" pageSize="10"
                                    styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
                                    value="#{UsersBean.users}" var="r" initialSortColumn="userName" initialSortDescending="true">

gavinc
Champ in-the-making
Champ in-the-making
Hi,

UsersBean is a JSF managed bean, as such it is defined in the JSF configuration files (in our case faces-config-beans.xml). The JSF framework instantiates the bean when it is required. The NodeService is also defined in the config file as a managed property, this means the nodeService object is "injected" into the bean, ready for your code to use.

I would highly recommend doing some background reading on JSF, there are several great sites with loads of articles and tutorials, some we've found useful are:

http://www.jsftutorials.net
http://www.jsfcentral.com
http://www-128.ibm.com/developerworks/library/j-jsf1 (series of 4 articles introducing JSF)

These may help answer a few of your questions and give you a better insight into how the Alfresco web client works.

Hope this helps

kevinr
Star Contributor
Star Contributor
Gavin is correct. Also to understand the architecture of how our services are defined and configured using Spring you should take a look at the Spring Framework tutorials and do a a little background reading. Once you are familiar with JSF and Spring you are ready to get deeper in Alfresco.

http://www.theserverside.com/resources/article.jsp?l=SpringFramework
http://www.springframework.org/documentation

Thanks,

Kevin

soeursourire
Champ in-the-making
Champ in-the-making
Thanks a lot for your advices. I started looking at the documentation and I am getting more familiar to JSF.

Now I am getting into troubles while doing this:

List<ChildAssociationRef> childRefs = nodeService.getChildAssocs(functionRef);

although my nodeService and functionRef seem correct (good reference):
functionRef= workspace://SpacesStore/e79e7952-a87a-11da-ab9f-0774da8876d0
nodeService= org.alfresco.repo.node.db.DbNodeServiceImpl@1e932fcf
storeRef= workspace://SpacesStore

And I get this error message:
A system error happened during the operation: Bad credentials presented

What kind of error is it? Can it be due to my insertion of nodes in the repository (when I add a node Functions under system and some nodes function in Functions)?

Thanks again

soeursourire
Champ in-the-making
Champ in-the-making
In your WIKI when you are talking about XPath Search while doing that:
List<ChildAssocRef> answer =  nodeService.selectNodes(rootNodeRef, "*", null, namespacePrefixResolver, false);  

I guess it is a mistake, nodeService has no selectNodes. We should use searchService right?