Fetch all secondary types from repository using CMIS getTypeDefinition

Showing results for 
Search instead for 
Did you mean: 
Active Member II

Fetch all secondary types from repository using CMIS getTypeDefinition

I am trying to get all the type definitions (specifically aspects, so they are secondary types) from the repository.I am connecting to a locally started bootstrap jar projects that starts up alfresco on localhost:8080. 

So far connecting to this alfresco has been working fine, and I have been able to create documents, folders etc on my localhost:8080 alfresco instance. 

My code does not seem to work as I get the below error. Please can you let me know what the issue could be and how do I get all the secondary type definitions (alfersco aspects) from the repository?

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException: Type '-default-' is unknown!
at org.apache.chemistry.opencmis.client.bindings.spi.browser.AbstractBrowserBindingService.convertStatusCode(AbstractBrowserBindingService.java:296)
at org.apache.chemistry.opencmis.client.bindings.spi.browser.AbstractBrowserBindingService.read(AbstractBrowserBindingService.java:410)

String user = "admin";
String pwd = "admin";
String serviceUrl = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser";
Session session = SessionManager.getInstance().createSession(new SessionContext(user, pwd, serviceUrl));
SearchService.searchDocuments(session, null);

 public static List<Document> searchDocuments(Session session, SearchTerms searchTerms) {
//        ObjectType typeDefinition = session.getTypeDefinition(session.getRepositoryInfo().getId());

        String repoId = session.getRepositoryInfo().getId();
        ObjectType typeDefinition1 = session.getTypeDefinition(repoId);

        return null;

public Session createSession(SessionContext context){
    try {
        String user = context.getUser();
        SessionFactory factory = SessionFactoryImpl.newInstance();
        Map<String, String> parameters = new HashMap<>();
        parameters.put(SessionParameter.USER, context.getUser());
        parameters.put(SessionParameter.PASSWORD, context.getPassword());
        parameters.put(SessionParameter.BROWSER_URL, context.getServiceUrl());
        parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());
        List<Repository> repositories = factory.getRepositories(parameters);
        Session session = repositories.get(0).createSession();
        sessions.put(user, session);
        return session;
    }catch(CmisConnectionException e) {
        // The server is unreachable
    catch(CmisRuntimeException e) {
        // The user/password have probably been rejected by the server.
    return null;
4 Replies
Alfresco Employee

Re: Fetch all secondary types from repository using CMIS getTypeDefinition

You cannot ask for every type / aspect definition in Alfresco by using CMIS API. 

The method you are using is expecting a CMIS Type ID, like in this sample: Working with Types - Apache Chemistry Samples 

You should use Alfresco REST API to recover a list of deployed types and aspects.

Software Engineer in Alfresco Search Team.
Active Member II

Re: Fetch all secondary types from repository using CMIS getTypeDefinition

Hi Angel,

Based on a previous thread where in Axel Faust‌ had suggested  that I use repository services from CMIS to get all secondary types, I was trying out the same. Please refer below thread


I am trying to see if I can use CMIS across my client API that I am trying to build and move away from REST services, (unless totally unavoidable.


Re: Fetch all secondary types from repository using CMIS getTypeDefinition

With a CMIS call like https://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser?cmisselector=typeDesc... you can load the type definitions of all aspects exposed via CMIS (note that Alfresco hides some core aspects due to its implementation and its mapping to CMIS equivalents). So, in your Java code for working with OpenCMIS, you simply need to put in cmis:secondary as the base type ID (there is even a constant for this somewhere) and use getTypeDescendants to list aspects. Of course if you already know the type ID (aspect name) you can call getTypeDefinition directly, which might be more efficient especially if you have enabled type definition caching.

Active Member II

Re: Fetch all secondary types from repository using CMIS getTypeDefinition

Thanks a lot for your response Axel Faust‌ , this really helps. I would like to clarify on the above post, the CMIS call that you have provided is a REST call, is there a way I can pass the cmisselector and typeid from a JAVA API call, something like ay to a session.query and obtain the QueryResult? Just checking if there is a java API equivalent of the above.