cancel
Showing results for 
Search instead for 
Did you mean: 

Changing dynamic models?

moschops
Champ in-the-making
Champ in-the-making
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="mySmiley TongueublishedDate">
               <type>d:datetime</type>
            </property>

to

         <properties>
            <property name="mySmiley TongueublishedDate">
               <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.
2 REPLIES 2

slothrop
Champ in-the-making
Champ in-the-making
I have encountered this same problem.

How can it be avoided?

moschops
Champ in-the-making
Champ in-the-making
My solution was to spend more time on design of the model up front so it doesn't change, and stop using any of the dynamic features except for ui customization.  Its a shame because prototyping is definitely a time when you don't want to be starting and resatarting the server.  Also you definitely don't want to add much content at all (unless you have an automated process to do it) until you have really nailed own your model. 

In theory alfresco could add modelling level ui features and tools to make it easier tto migrate data between content models, but for now I think its not a priority - you'll just have to write your own scripts.  That's assuming you can even change the model at all, which you can't.  If you want to look at the source code it is pretty obvious what to change to sidetrack this constraint check…

My theory is that experienced alfresco users and content management designers don't need this flexibility anyway. So really having the model in the ui for anything other than reference is a gimmick to them.