cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in import

santigt
Champ in-the-making
Champ in-the-making
Hi everybody!

I just have a problem when I try to import data to Alfresco. I have a lot of data, so my idea was to create sub-spaces and import in each sub-space, each type of contents.

When I import contents to a specific sub-space, and these contents have references to other contents that are in another specific sub-space, Alfresco put me this error:

org.alfresco.service.cmr.view.ImporterException: Failed to import package at line 32; column 55 due to error: Cannot find node referenced by path cm:person_700001

So, my problem is that I don't know how can I indicate the reference of a content, if this one is in a different sub-space that the new content I want to import.

I try to explain it with an example:

I have this structure in Alfresco:


/company_home
       /persons
       /books
       /edtors

I import the content PERSON_1 into the persons sub-space. The XML code to import is:


<cm:person xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:wcm="http://www.alfresco.org/model/wcmmodel/1.0" xmlns:wca="http://www.alfresco.org/model/wcmappmodel/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:wcmwf="http://www.alfresco.org/model/wcmworkflow/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" view:childName="cm:person_5800001">
  <view:aspects>
  …
  </view:aspects>
  <view:properties>
    <app:editInline>true</app:editInline>
  <cm:content>contentUrl=contents/test.jpg|mimetype=image/jpeg|encoding=UTF-8|locale=en</cm:content>
    <cm:author>Me</cm:author>
    <cm:created>2007-06-21T15:43:01.504Z</cm:created>
    <cm:creator>admin</cm:creator>
    <cm:modifier>admin</cm:modifier>
    <cm:modified>2007-06-21T15:43:01.505Z</cm:modified>
    <cm:name>Person</cm:name>
  …
  </view:properties>
  <view:associations></view:associations>
</variazioni:person>

Then, I have the content BOOK_1 that has a reference with the PERSON_1 content.

I want to import the content BOOK_1 into the books sub-space. So the XML code for this reference can be:


<view:reference xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:wcm="http://www.alfresco.org/model/wcmmodel/1.0" xmlns:wca="http://www.alfresco.org/model/wcmappmodel/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:wcmwf="http://www.alfresco.org/model/wcmworkflow/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" view:pathref="cm:book_200030">
  <view:associations>
    <cm:com_person>
      <view:reference view:pathref="cm:person_5800001"></view:reference>
    </cmi:com_person>
  </view:associations>
</view:reference>

Please, can you help for this problem? Thanks a lot!

Regards,



Santigt
4 REPLIES 4

santigt
Champ in-the-making
Champ in-the-making
I investigate and I see in the importer code that the "SearchParameter" class cannot search into sub-spaces and sub-folder.

Here you have the code fragment for the search ("ImporterComponent.java" file):


                SearchParameters searchParameters = new SearchParameters();
                searchParameters.addStore(sourceNodeRef.getStoreRef());
                searchParameters.setLanguage(SearchService.LANGUAGE_LUCENE);
                searchParameters.setQuery("PATH:\"" + importedRef + "\"");
                searchParameters.excludeDataInTheCurrentTransaction((binding == null) ? true : !binding.allowReferenceWithinTransaction());


Now I will try to find a solution to search into sub-spaces and sub-folders. If anyone have solved this problem, please help me.

Thanks so much! Regards,



Santigt

santigt
Champ in-the-making
Champ in-the-making
Ok, I have resolved the problem. In the SearchParameter file I see that:


    /**
     * Set the stores to be supported - currently there can be only one. Searching across multiple stores is on the todo
     * list.
     *
     * @param store
     */
    public void addStore(StoreRef store)


So, It's impossible to search into sub-spaces and sub-folders. I am trying to coding this search. Later I will put the Java code for this kind of search.

Regards,




Santigt

santigt
Champ in-the-making
Champ in-the-making
I have a problem because I don't know how can I navigate into the spaces, using only a NodeRef instance.

I want to know how many childs has a NodeRef, and how can I obtain the NodeRef of this childs? The NodeRef API is very small, so it's impossible to use it only.

It's possible there is a function that obtains a Node instance, using the NodeRef value as a parameter, but I'm not sure.

If anyone knows about this, please help me! Thanks

Regards,


Santigt

gavinc
Champ in-the-making
Champ in-the-making
You use the NodeService.

There is a method called getChildAssocs which takes a NodeRef as a parameter. This will return a List of child nodes. The size of the list obviously gives you the number of children.

The NodeService is used for most interactions with nodes i.e. to retrieve and set properties, get aspects etc. etc.