}
private WGTMLModule processAjaxCall(javax.servlet.http.HttpServletRequest request, WGDatabase database, String encAjaxInfo) throws HttpErrorException, WGException {
WGTMLModule tmlLib;
AjaxInfo ajaxInfo = null;
try {
// decrypt
byte[] zipped = this.getCore().getDesEncrypter().decrypt(encAjaxInfo);
if (zipped == null) {
this.getCore().getLog().error("Retrieved AjaxInfo could not be decrypted. Maybe the ajax call was defined for another WGA instance.");
throw new HttpErrorException(HttpURLConnection.HTTP_INTERNAL_ERROR, "Retrieved AjaxInfo could not be decrypted. Maybe the ajax call was defined for another WGA instance.", null);
}
// unzip
String unzipped = Zipper.unzip(zipped);
// deserialize
ajaxInfo = (AjaxInfo) new XStream(new Dom4JDriver()).fromXML(unzipped);
// put ajaxInfo on request so root tag can retrieve it
request.setAttribute(WGACore.ATTRIB_AJAXINFO, ajaxInfo);
}
catch (HttpErrorException e) {
throw e;
}
catch (Exception e) {
this.getCore().getLog().error("Retrieved AjaxInfo could not be restored.", e);
throw new HttpErrorException(HttpURLConnection.HTTP_INTERNAL_ERROR, "Retrieved AjaxInfo could not be restored. Check log for details.", null);
}
// fetch correct db for ajax (if designdb on include tag is present use
// design db, if not use current db)
WGDatabase ajaxDB = null;
String ajaxDesignDBKey = ajaxInfo.getDesignDB();
if (ajaxDesignDBKey != null) {
// fetch design db
try {
ajaxDB = _core.openContentDB(ajaxDesignDBKey, request);
}
catch (WGUnavailableException e) {
throw new HttpErrorException(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "The website is currently unavailable", ajaxDesignDBKey);
}
catch (de.innovationgate.wgpublisher.AuthenticationException e) {
throw new HttpErrorException(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage(), null);
}
catch (AccessException e) {
throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, e.getMessage(), null);
}
if (ajaxDB == null) {
throw new HttpErrorException(HttpServletResponse.SC_NOT_FOUND, "No database of key " + ajaxDesignDBKey, null);
}
else if (ajaxDB.isSessionOpen() == false) {
throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, "Database '" + ajaxDesignDBKey + "' could not be opened by ajaxCall.", null);
}
}
else {
ajaxDB = database;
}
// search for tml module
tmlLib = (WGTMLModule) ajaxDB.getDesignObject(WGDocument.TYPE_TML, ajaxInfo.getTmlmodule(), ajaxInfo.getMediaKey());
if (tmlLib == null) {
throw new HttpErrorException(HttpServletResponse.SC_NOT_FOUND, "No WebTML layout '" + ajaxInfo.getTmlmodule() + "' for media key '" + ajaxInfo.getMediaKey() + "' available in app '" + ajaxDB.getDbReference() + "'", ajaxDB
.getDbReference());
}
return tmlLib;
}