cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to create if missing using ImporterModuleComponent?

idwright
Star Collaborator
Star Collaborator

I'm bootstrapping some files using the ImporterModuleComponent and what I'd like to do is create them if they are missing but otherwise leave them alone.

If I don't set a uuidBinding then the module won't start due to a uuid collision

According to Import strategy | Alfresco Documentation  I can only create, update or replace none of which fits what I want to do - install some templates etc in the data dictionary but don't overwrite them if they've been changed in situ

It seems like it should be possible...

Thanks.

6 REPLIES 6

afaust
Legendary Innovator
Legendary Innovator

There is no fine grained control available for that. You also should never rely on the UUID of a node via UUID_BINDING for updating because a previously imported node may have been deleted and a new one but in its place on the same path.

In case you need situational updating there is usually no way around implementing a custom module component that properly checks existing nodes against expectations and updates / creates individual nodes as necessary. This requires Java implementation.

idwright
Star Collaborator
Star Collaborator

So am I correct in thinking that you're saying that in order install, e.g. a template in the data dictionary, as part of a module it's necessary to write some custom java?

Given that the template may, or may not, have been previously installed and/or edited.

(I don't really understand why there are sometimes conflicts, and sometimes no conflict on start up)

afaust
Legendary Innovator
Legendary Innovator

No - in order to simply install a new template in Data Dictionary you should not need to write Java code and simply use the existing importert module component. But if you want to be able to detect existing nodes at the same path and install / not install accordingly, then yes, you would need some Java code.

The importer module component has no ability to check if a path already exists. That feature is only supported in the GenericBootstrapPatch class. It would be great if such ability were to be added to bootstrap views in general, i.e. for each view XML / ACP you could define a (set of) check path(s) that must not exist for the view to be imported. Then you might only have to create very granular view XML / ACP files.

idwright
Star Collaborator
Star Collaborator

I'm still confused as to why sometimes my instance fails to start due to a conflict down to a previously bootstrapped file, and sometimes it doesn't.

It's consistent i.e. once it's started failing it will always fail but I can't tell why it starts failing

idwright
Star Collaborator
Star Collaborator

Answering my own question a bit here in the hope that it's useful...

It turns out that the id of the bean definition for org.alfresco.repo.module.ImporterModuleComponent is important i.e. if you change the id then the bootstrap process will attempt to reload the defined views, which is why I've been getting a conflict and having the instance fail to start.

So the id attribute value is used to determine whether the import has already run and therefore doesn't need to be run again.

My problem was that I'd changed the id between versions, if I keep the id the same then it does what I want i.e. run the import just the first time that the module is installed

afaust
Legendary Innovator
Legendary Innovator

That is true for all module components that use the AbstractModuleComponent as the base. The name of the bean (can technically be set to something different than the id, but usually is not) is used to record module executions in the module registry of the system:system node store.