Package de.innovationgate.wgpublisher.webtml.utils

Examples of de.innovationgate.wgpublisher.webtml.utils.AjaxInfo


            status.setOption(OPTION_AJAX_DIVTAG_ID, uniquePortletID, null);
            // set tmlModule as option, so tags from included module can retrieve the tmlmodulename
            status.setOption(OPTION_PORTLET_TMLMODULE, pReg.getDesign(), null);
                               
            // create ajaxInfo
            AjaxInfo ajaxInfo = new AjaxInfo(uniquePortletID);
            try {
        URLBuilder builder = new URLBuilder(getTMLContext().getrequest());
        builder.removeParameter("$action");
        java.net.URL url = builder.rebuild();
        ajaxInfo.setQueryString(url.getQuery());
      } catch (Exception e1) {
        getTMLContext().addwarning("Unable to build request querystring for ajax environment.");
      }
            ajaxInfo.setTmlmodule(pReg.getDesign());
            ajaxInfo.setDesignDB(pReg.getDesignDb() != null ? pReg.getDesignDb() : getDesigndb());
            ajaxInfo.setMediaKey((String)this.getOption(OPTION_CURRENT_MEDIAKEY));
            if (portletContext != null) {
              ajaxInfo.setContextPath(portletContext.getpath());
            } else {
              ajaxInfo.setContextPath(this.getTMLContext().getpath());
            }
            ajaxInfo.setOptions(getStatus().getTagOptions());
            if (getTMLContext().getprofile() != null) {
                ajaxInfo.setSaveProfileOnEnd(getTMLContext().getprofile().isSavedOnEnd());
            }
            else {
                ajaxInfo.setSaveProfileOnEnd(false);
            }
            ajaxInfo.setSuperform(getStatus().getRelevantForm());

           
            // create javascript object with ajaxInfo                   
            // serialize       
            String serAjaxInfo = new XStream(new Dom4JDriver()).toXML(ajaxInfo);
View Full Code Here


    }

    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;
    }
View Full Code Here

TOP

Related Classes of de.innovationgate.wgpublisher.webtml.utils.AjaxInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.