cancel
Showing results for 
Search instead for 
Did you mean: 

How to get storeref for alfresco content categories

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I am using Alfresco 3.2r with Tomcat 6 with JDK 1.6.

I want to know how can i get storeref for alfresco categories. Here is my code:


StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");

LuceneCategoryServiceImpl categoryServiceImpl = new LuceneCategoryServiceImpl();
       Collection<ChildAssociationRef> listOfCategories = categoryServiceImpl.getCategories(storeRef , QName.createQName("{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/content/1...."), CategoryService.Depth.ANY);

Here i am getting error as:

java.lang.NullPointerException
   at org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl.getClassificationNodes(LuceneCategoryServiceImpl.java:284)
   at org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl.getCategories(LuceneCategoryServiceImpl.java:274)
   at com.jindal.alfresco.km.constraints.CommunitySearchConstraint.getAllowedValues(CommunitySearchConstraint.java:162)

org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl.getClassificationNodes(LuceneCategoryServiceImpl.java:284) states this:

private Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
    {
        storeRef = tenantService.getName(storeRef); <– Line no 284

        ResultSet resultSet = null;
….


I think that i am putting right parameters but its not the case.

I also tried this:

StoreRef storeRef =new StoreRef("workspace://SpacesStore/{http://www.alfresco.org/model/content/1.0}categoryRoot");
StoreRef storeRef =new StoreRef("workspace://SpacesStore/");{http://www.alfresco.org/model/content/1.0}category_root");

But no luck!!


Any help?
5 REPLIES 5

janv
Employee
Employee
Please check your Spring bean config for 'LuceneCategoryServiceImpl' … an NPE on that line implies that the 'tenantService' has not been injected ?


    <bean id="…." class="org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl">
        ….
        <property name="tenantService">
            <ref bean="tenantService"/>
        </property>
        ….
    </bean>
Regards,
Jan

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi Jan,

Here is my entry for LuceneCategoryServiceImpl in core-services-context.xml under …/WEB-INF/classes/alfresco

<bean id="luceneCategoryService" class="org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl">
        <property name="nodeService">
            <ref bean="nodeService" />
        </property>
        <property name="publicNodeService">
            <ref bean="NodeService" />
        </property>
        <property name="tenantService">
            <ref bean="tenantService"/>
        </property>
        <property name="dictionaryService">
            <ref bean="dictionaryService" />
        </property>
        <property name="namespacePrefixResolver">
            <ref bean="namespaceService" />
        </property>
        <property name="indexerAndSearcher">
            <ref bean="indexerAndSearcherFactory" />
        </property>
    </bean>

It means that tenantService is getting injected. I am having doubt over StoreRef value being passed to it. Can you tell me how to get a StoreRef particularly for category?

Can it be like this:

StoreRef storeRef =new StoreRef("workspace://SpacesStore/{http://www.alfresco.org/model/content/1.0}/cm:generalclassifiable");

Is there any need to get login to repository for this as:

Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));

janv
Employee
Employee
No, your latter StoreRef examples are not valid. A StoreRef is a reference to an Alfresco store ("<protocol>://<identifier>") for example:


StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
or


StoreRef storeRef = new StoreRef("workspace://SpacesStore");
or even


StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
Regards,
Jan

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi Jan,

Thanks again.

I tried with
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");

So it means that tenantservice is not getting injected?

As a matter of fact, i am struggling with getting handler to any of services as tenantservice, searchservice, nodeservice etc.I am getting this error:

net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext

Please have a look at this post of mine:

http://forums.alfresco.com/en/viewtopic.php?f=4&t=25855&p=84025#p84025

All i want is to get list of all categories defined in alfresco repository in a list so that i can populate them in a drop down.But its not happening as i am trying to get the same using searchservice or LuceneCategoryServiceImpl but getting this error.

net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext


I am desperate to get any clue as i tried a number of things to get services but no luck.Seriously its frustrating. :evil:.Can you please help me?

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I could make it working by getting all categories as a list of checkboxes.

Please refer to this post of mine:

http://forums.alfresco.com/en/viewtopic.php?f=9&t=20589&p=84639#p84639