AnsweredAssumed Answered

Changing dynamic models?

Question asked by moschops on Jan 29, 2009
Latest reply on Feb 6, 2009 by moschops
I'm prototyping a solution and thought I would take advantage of dynamic models to avoid continuous server restarting while I develop and debug my content model.

However I've found that even the simplest change to a model is triggering errors when I try to save it where Alfresco claims the model is invalid because it "found non-incrementally updated TYPE".  Here's a sample exception snippet:

02:30:28,587 ERROR [org.alfresco.webdav.protocol] Internal Server Error:
org.alfresco.error.AlfrescoRuntimeException: Failed to validate model update - found non-incrementally updated TYPE '{my.new.model}sop'
   at org.alfresco.repo.dictionary.DictionaryDAOImpl.validateModel(DictionaryDAOImpl.java:1192)
   at org.alfresco.repo.dictionary.DictionaryModelType$DictionaryModelTypeTransactionListener$1.doWork(DictionaryModelType.java:465)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:437)

As an example of what caused this I used the standard example model with the my:sop type - everything works fine until I tried to make one of the SOP type properties mandatory so that the meta-data property sheet would require it of new documents.  Specifically I tried changing:

         <properties>
            <property name="my:publishedDate">
               <type>d:datetime</type>
            </property>

to

         <properties>
            <property name="my:publishedDate">
               <type>d:datetime</type>
               <mandatory enforced="true">true</mandatory>
            </property>

which triggered the above exception.  Now if I make the mandatory element say false (both the attribute and value part - its not clear why we need both or what the distinction) then I can save.  But as soon as I try to make them true again I get the exception all over.

I thought it might be because I already had some content without the publisedDate set - so I set the date and saved that document then treid the model change again.  No such luck.  Then I thought maybe I should be making the model inactive while I make the change but it wont let you inactivate a model that you instances of kicking around.

Am I up against a bug, a genuine restriction (which seems pretty darned limiting!) or is there some other way to change the model like this?

EDIT: Adding additional info…

I've verified this is nothing to do with content using the model already existing - I added a new model and got the same problem without creating any docs using it as their content type.  I was also able to create a model where one parameter already had a mandatory => true element.  When I did that I could set the value to false or delete the mandatory element,  but once I did I couldn't put it back.  An parameter that already had a mandatory => false element when the model was added wouldn't let me set it to true.  So it seems like the checking lets you relax the constraints but not increase them.

I also found I could add parameters to my models content types but could not remove them - even if no content used them yet. 

I'm pretty sure these restrictions do not apply when you do not use dynamic models - you just edit the files in the classes/alfresco/extensions dir and restart the server.  In that case am I risking breaking something further down the line?  I know the docs warn of breaking your repository with model changes and being ready to throw stuff away until you've done with content model definition but surely non-conflicting changes (at least in respect to existing content) like this should be possible?  I would love to know if there is a flag to disable some of these checks when using dynamic models - or at least get warning instead of errors - and how to set it.

Outcomes