Page 1 of 1
using blStaticAssetService to fetch url.prefix in service
Posted: Wed Sep 19, 2012 1:37 pm
by srini
Hi,
I am trying to fetch staticAssetEnvironmentUrlPrefix value in my service layer like below but the value is coming as null. Is there something I need to do besides the below code. Please advise.
@Resource(name="blStaticAssetService")
protected StaticAssetService staticAssetService;
cmsUrl = staticAssetService.getStaticAssetEnvironmentUrlPrefix();
Thanks,
Srini.
Re: using blStaticAssetService to fetch url.prefix in service
Posted: Wed Sep 19, 2012 4:12 pm
by phillipuniverse
Do you have the asset.server.url.prefix property set in a properties file?
Re: using blStaticAssetService to fetch url.prefix in service
Posted: Wed Sep 19, 2012 4:20 pm
by srini
Yes Phillip. I am able to get the property value using cms:url from jsp but not in the service.
Thanks,
Srini.
Re: using blStaticAssetService to fetch url.prefix in service
Posted: Thu Sep 20, 2012 9:34 am
by phillipuniverse
From StaticAssetServiceImpl:
Code: Select all
@Override
public void setStaticAssetUrlPrefix(String staticAssetUrlPrefix) {
this.staticAssetUrlPrefix = staticAssetUrlPrefix;
}
@Override
public String getStaticAssetEnvironmentUrlPrefix() {
return fixEnvironmentUrlPrefix(staticAssetEnvironmentUrlPrefix);
}
...
...
private String fixEnvironmentUrlPrefix(String urlPrefix) {
if (urlPrefix != null) {
urlPrefix = urlPrefix.trim();
if ("".equals(urlPrefix)) {
urlPrefix = null;
} else if (urlPrefix.equals(staticAssetUrlPrefix)) {
urlPrefix = null;
}
}
if (urlPrefix != null && !urlPrefix.endsWith("/")) {
urlPrefix = urlPrefix + "/";
}
return urlPrefix;
}
That fixEnvironmentUrlPrefix method will return null if it is the same as getStaticAssetUrlPrefix(). Is this the case?