cancel
Showing results for 
Search instead for 
Did you mean: 

Change content Type

naval
Champ in-the-making
Champ in-the-making
Hi,

I have created a custom content type. I want change the type of the document uploaded in the alfresco to custom content type. I am using nodeservice.setType() API. However, it is giving me Invalid type exception.

I have changed the customModel.xml and custom-model-context.xml and with the help of FirstFoundationClient.java using nodeservice.setType() API trying to change the type of document to my content type.
Anything missed out from me.

Regards,
Naval
7 REPLIES 7

kaynezhang
World-Class Innovator
World-Class Innovator
Invalid type exception means repository dosen't know the type name you want to set.
The model in which your custom content type defined in is not registered successfully, please check it.

jpotts
World-Class Innovator
World-Class Innovator
It would really help if you would provide a code snippet that includes the setType call as well as a snippet from your content model XML showing the type's name and namespace.

Jeff

naval
Champ in-the-making
Champ in-the-making
Thanks to both for reply.

Hi jeff, Please look at the snippet below:

ResultSet deleteResultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home/cm:abc/*\" AND TYPE:\"cm:content\"");
NodeRef deletenode = deleteResultSet.getNodeRef(0);
deleteResultSet.close();
    NodeService nodeservice = serviceRegistry.getNodeService();
nodeservice.setType(deletenode, QName.createQName("{http://www.alfresco.org/model/test/1.0}test"));


testModel.xml

<?xml version="1.0" encoding="UTF-8"?>
<model name="tt:testmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Example custom Model</description>
   <author>John</author>
   <version>1.0</version>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <namespaces>
      <namespace uri="http://www.alfresco.org/model/test/1.0" prefix="tt"/>
   </namespaces>
  
   <types>
      <type name="tt:test">
         <title>Standard Operating Procedure</title>
         <parent>cm:content</parent>
         <properties>
            <property name="tt:testName">
               <type>d:text</type>
            </property>  
         </properties>  
      </type>   
    </types> 
</model>

kaynezhang
World-Class Innovator
World-Class Innovator
It seems there is nothing wrong with you model defination and your java code is fine.
How did you deploy your model,I guess it didn't deploy successfully.

naval
Champ in-the-making
Champ in-the-making
I deployed context and model files under alfresco/extension folder.
I dont understand where is the issue. I am using Alfresco 4.1.6.

Again, for nodeservice.moveNode() i am getting below exception.

Caused by: org.alfresco.repo.security.permissions.AccessDeniedException: 02061839 Access Denied.  You do not have the appropriate permissions to perform this operation.


mitpatoliya
Star Collaborator
Star Collaborator
You need to run that piece of code as administrator or system user.
Could you please post piece of code you are trying?

kaynezhang
World-Class Innovator
World-Class Innovator
Make sure alfresco/extension folder is under your classpath and your spring context file named ***-context.xml.
You'd better paste your spring context file. and complete code you are running .