cancel
Showing results for 
Search instead for 
Did you mean: 

Custom content type with mimetype constraint

cszamudio
Champ on-the-rise
Champ on-the-rise
Hi,

I'm having trouble getting my head around this.  Is it possible to create a custom type which has constraints on the mimetype of the content. For example, a content type which can only have "application/pdf" as its content mimetype? I realize this can be accomplished at the application-level during content creation, but I am curious if the model could enforce this.

Any hints would be appreciated.

Carlos S. Zamudio
4 REPLIES 4

kaynezhang
World-Class Innovator
World-Class Innovator
I'am afraid there is no such feature in model level.

ipirat
Champ in-the-making
Champ in-the-making
Hi Carlos,

it should be possible to add a constraint in the model, e.g.

<type name="foo:bar">
   <parent name="cm:content"/>
   <overrides>
     <property cm:mimrtype>
        <constraints>
           <constraint type="REGEX">
             <property name="expression" value="application/pdf">
           </c onstraint>
         </constraints>
      </property>
   </overrides>
</type>


(not having my dev environment at hand – the syntax may be slightly incorrect, but you should get the idea)

BUT: mime type is typically something managed by the system, so you'll have to check whether this will provide you with what you need:

<ul>
<li>if mime type is not PDF, the system should not let you change type into your content type foo:bar
<li>if content type of the object is foo:bar, the system should not let you change the mime type to anything other than PDF
<li>there may be other cases that need consideration…
</ul>

cszamudio
Champ on-the-rise
Champ on-the-rise
Thanks for the suggestion. I tried something similar, but I'll experiment with different forms of the property name and if I find something that works, I'll post it. Cheers.

kaynezhang
World-Class Innovator
World-Class Innovator
I don't think iPirat'solution will work,because:
"cm:mimetype" is not a property of "cm:cotent type" and the overrided logic will not work on it.
Correct me if I'm wrong