Skip to Content
Former Member
Feb 15, 2016 at 08:44 AM

Overriding getDownloadUrl of MediaModel


Hello experts, We have a property calling as downloadURL belonged to Media type in core-items.xml. When we needed to manipulate this property return value, we had used aspect for that. But now, we have some performance issues. So, we try to get rid of aop usage. I guess, I have no chance with interceptor because of non-writable property. What practice would you suggest me in this situation? Thx

             <attribute autocreate="true" qualifier="downloadURL" type="java.lang.String">
                     <property name="modelPrefetchMode">
                 <persistence type="jalo"/>
                 <modifiers read="true" write="false" removable="true" search="false" optional="true"/>
                     <getter name="downloadurl" deprecated="true"/>
                     <setter name="downloadurl" deprecated="true"/>

Solution with aspect (already existed in system now): The code is here what i want to override out of aop: (it is in an aspect class for now)

 @Around("execution(public *")
 public String getDownloadUrlByAspect(final ProceedingJoinPoint pjp) throws Throwable
     final LocalMediaWebURLStrategy localMediaWebURLStrategy = Registry.getApplicationContext()

     final MediaStorageConfigService mediaStorageConfigService = Registry.getApplicationContext()

     MediaModel mediaModel = (MediaModel) pjp.getThis();

     MediaStorageConfigService.MediaFolderConfig config = mediaStorageConfigService

     final String downloadURL = localMediaWebURLStrategy.getDownloadUrlForMedia(config, new ModelMediaSource(mediaModel));

     LogMF.debug(LOG, "new media download url for media is {0}", new Object[]
     { downloadURL });

     return downloadURL;