public void init(Map initData) throws WebloggerException {
// need a weblog request so that we can know the weblog and locale
WeblogRequest weblogRequest = (WeblogRequest) initData.get("parsedRequest");
if(weblogRequest == null) {
throw new WebloggerException("Expected 'weblogRequest' init param!");
}
// PreviewURLModel only works on preview requests, so cast weblogRequest
// into a WeblogPreviewRequest and if it fails then throw exception
if(weblogRequest instanceof WeblogPreviewRequest) {
this.previewRequest = (WeblogPreviewRequest) weblogRequest;
} else {
throw new WebloggerException("weblogRequest is not a WeblogPreviewRequest."+
" PreviewURLModel only supports preview requests.");
}
this.weblog = weblogRequest.getWeblog();
this.locale = weblogRequest.getLocale();
// look for url strategy
urlStrategy = (URLStrategy) initData.get("urlStrategy");
if(urlStrategy == null) {
urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();