cancel
Showing results for 
Search instead for 
Did you mean: 

Determine ContentType

z3r0
Champ in-the-making
Champ in-the-making
Hi,

I have a method to detect the uuid. How can i detect the content type?


String uuid = null;

AuthenticationUtils.startSession("admin", "admin");

final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

// Get a reference to the respository web service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();        
       
// Create a query object, looking for all items with alfresco in the name of text
Query query = new Query(Constants.QUERY_LANG_LUCENE, queryText);
       
        QueryResult queryResult = null;
      // Execute the query
           queryResult = repositoryService.query(STORE, query, false);
       
        // Display the results
        ResultSet resultSet = queryResult.getResultSet();
        ResultSetRow[] rows = resultSet.getRows();

        if (rows != null)
            {

                // Get the id of the first result
                String firstResultId = rows[0].getNode().getId();
                uuid = firstResultId;
            }

AuthenticationUtils.endSession();
           
return uuid;
5 REPLIES 5

rliu
Champ in-the-making
Champ in-the-making
The resultSet returns node references.

Use
QName contentType = nodeService.getType(nodeRef);


NodeService.getType(nodeRef) and compare with org.alfresco.model.ContentModel prefixed TYPE_ values.

z3r0
Champ in-the-making
Champ in-the-making
Hi,

thanks for your answer. But if I write
row[0].getNode().getType()
I get the content model. But I want the ContentType, such as PDF, for example application/pdf or image/jpg or only pdf or jpg.

z3r0
Champ in-the-making
Champ in-the-making
Hello,
is it not possible to determine the MIMETYPE?

mrogers
Star Contributor
Star Contributor
http://wiki.alfresco.com/wiki/3.0_JavaScript_API#ScriptNode_API

var mimetype = document.properties.content.mimetype;

norgan
Champ in-the-making
Champ in-the-making
Hi,

thanks for your answer. But if I write
row[0].getNode().getType()
I get the content model. But I want the ContentType, such as PDF, for example application/pdf or image/jpg or only pdf or jpg.

Hi,
just in case you did not notice The word "contenttype" is a reserved keyword in Content management developement 😉