cancel
Showing results for 
Search instead for 
Did you mean: 

Module Applying Aspects to Default Spaces at Bootstrap?

pjaromin
Champ on-the-rise
Champ on-the-rise
I've got a use case where I need to apply an aspect to a couple default spaces. The built-in space definitions don't have node UUID's, so it appears that using the bootstrap spaces to UPDATE these won't work, correct? I've attempted to create my own versions of the "view" XML documents in the same package of my maven project to override the defaults, but that didn't work either. I suppose I could override the import bean definition(s) and change the location for some of the view files I want to change, but that's a *lot* to copy and maintain.

As a last resort I'm presently considering writing my own Java code to apply these aspects at module bootstrap, but wanted to verify that I'm not missing a more flexible, supported method.

Is there a standard mechanism or best practice for doing this?

Thanks!
5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator
Hello,

relying on node UUIDs for bootstrap should be considered bad practice in my opinion. The import mechanism allows for different types of references besides UUID. In the scope of a single self-contained bootstrap you can use a bootstrap-local, internal import ID to reference nodes imported in the same view. For all other instances you can use XPath references to select nodes with well known paths (such as default spaces) and then use that reference to update them.

This is slightly different than a UUID based update, which is the only type documented in the wiki. I usually use it when I need to add new nodes to different existing locations and don't want to split up my import view into hundreds of small XMLs. Please find an adapted example below:


<?xml version='1.0' encoding='UTF-8'?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:custom="http://www.example.com/model/custom/0.1">

    <view:reference view:pathref="app:company_home/cm:yourExistingSpace">
        <view:aspects>
            <custom:myAspect />
        </view:aspects>
    </view:reference>

</view:view>

Regards
Axel

pjaromin
Champ on-the-rise
Champ on-the-rise
Thanks for this.

I've tried it but it doesn't appear to be working for me, so perhaps I've got something wrong here?

One of the spaces we wish to hide (as it can't be removed without breaking Share) is the "Sites" folder. So my test view file looks like this:

<?xml version='1.0' encoding='UTF-8'?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
   xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0"
   xmlns:custom="http://www.example.com/model/custom/0.1">
   <view:reference view:pathref="/app:company_home/st:sites">
      <view:aspects>
         <sys:hidden />
      </view:aspects>
   </view:reference>
</view:view>

(note - bootstrap fails if I don't include the leading '/' in the pathref above, complains it can't find the path)

Then I've added an entry into the bootstrapViews list that looks like:

<props>
   <prop key="uuidBinding">UPDATE_EXISTING</prop>
   <prop key="path">/${spaces.company_home.childname}</prop>
   <prop key="location">alfresco/module/${artifactId}/bootstrap/hideSpaces.xml</prop>
</props>

I've tried both with and without the uuidBinding, modifying the path in the view, etc. and the result is always the same - the aspect is not applied to the space.

Can you see what may be wrong here?  I'm running community 4.0.d.

Thanks!

-Patrick

pjaromin
Champ on-the-rise
Champ on-the-rise
OK, so it looks like something else is going on. This method appears to work just fine for other aspects.

The only aspect I can't seem to apply with this is "sys:hidden".

-Patrick

afaust
Legendary Innovator
Legendary Innovator
Hello,

I don't know what's special about sys:hidden that it can't be applied.

In terms of the XPath and leading "/": You only need the leading "/" since your bootstrap path (in the Spring *context.xml) is already set to "/app:company_home" and from there, the import can't find the relative path "app:company_home/st:sites". By specifying a leading "/" you force the search from the root using an absolute path. What I usually do is, have the path in the *context.xml as just "/" and then use relative paths from that on. I personally don't like import views where a base location is specified via *context.xml, but the view supersedes this with an absolute path.

Regards
Axel

pjaromin
Champ on-the-rise
Champ on-the-rise
Yeah, I was trying to sort this out and figure out the best approach here. Seemed rather arbitrary which portion of the path to specify in the context vs. the view. I had recently actually changed the context path to '/' just as you suggest.

As for 'sys:hidden' I've not debugged this, but it clearly is the case as I've subsequently applied numerous other aspects and always all but sys:hidden takes using your method. I wound up (for now) extending the module bootstrap importer and adding code to specifically apply the sys:hidden aspect. Doing it through the Java API does work, so it's clearly something about the view importer.

I needed my own Java module bootstrap class to perform some post import steps anyway due to the multilingual documents not properly importing from ACP.

Thanks!

-Patrick