cancel
Showing results for 
Search instead for 
Did you mean: 

IndexOutOfBoundsException when trying to get company_home

shay
Champ in-the-making
Champ in-the-making
Hi,

I'm using the following code in order to get the company_home node:

// locate the company home node
        StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
        ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home\"");
        return resultSet.getNodeRef(0);

most of the times it works fine but some times i get the following error:

java.lang.IndexOutOfBoundsException
   at org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet.translateIndex(FilteringResultSet.java:98 )
   at org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet.getNodeRef(FilteringResultSet.java:103)


the error appears when the line:
resultSet.getNodeRef(0);
attempts to commit.


I found a way to detour this problem, i create a new space via the web client and delete it. then i run my code again and i get no execption.

is it a bug in the alfresco or is it somthing wrong in my code?

Thanks in advance,
Shay.
4 REPLIES 4

andy
Champ on-the-rise
Champ on-the-rise
Hi

Please describe your deployment stack. Then I can see if I can reproduce this.

Andy

shay
Champ in-the-making
Champ in-the-making
Hi Andy,

I just realize when this problem appears:

first i get the NodeRef of the company_home by this function:

protected NodeRef getCompanyHome() throws Exception
   {
        // locate the company home node
        StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
        ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home\"");
        return resultSet.getNodeRef(0);
   }

NodeRef companyHome = getCompanyHome();

then i add a new space to the company home with this function:

protected NodeRef addChildSpace(NodeRef fatherNode,String spaceName) throws Exception
   {
    // assign name
           Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
           String legalSpaceName = getLegalName(spaceName);
           contentProps.put(ContentModel.PROP_NAME, legalSpaceName);
   
           // create space node
           ChildAssociationRef association = nodeService.createNode(fatherNode,
                 ContentModel.ASSOC_CONTAINS,
                 QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, spaceName),
                   ContentModel.TYPE_FOLDER,
                   contentProps);

           return  association.getChildRef();
   }

NodeRef test = addChildSpace(companyHome,"test");

now you can see in the web client that there is a new space in the company_home, but if you delete this test space via the web client and then try to run the code again you will get the exception in the getCompanyHome function in line:
resultSet.getNodeRef(0);

Shay.

andy
Champ on-the-rise
Champ on-the-rise
Hi

There is no way to reproduce or investigate this unless you tell us which version of alfresco, what OS, what JVM, what DB ….. as well as what the problem may be.

Cheers

Andy

shay
Champ in-the-making
Champ in-the-making
the problem appears  when i use:
alfresco 2.0
windows xp and linux as well
jvm ver: 1.5.0_07
mySQL 5.0

the problem is:
i create a space or a content in the company_home using the java api,
then i delete this space or content using the web client.
now, if i'll try to get the company_home NodeRef i'll get the exception.