Examples of TMLUserProfile


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

                WGDatabase db = _context.getdocument().getDatabase();
          db.openSession();
                db.getSessionContext().setTask(taskDescr);
               
                // Eventually open pers db too so profile is available
                TMLUserProfile profile = _context.getprofile();
               
                if (profile != null && !profile.getprofile().getDatabase().isSessionOpen()) {
                    WGDatabase persDB = profile.getprofile().getDatabase();
                    persDB.openSession();
                    persDB.getSessionContext().setTask(taskDescr);
                }
   
                RhinoContextAction contextAction = new RhinoContextAction(_context, _function, _overrideFunctionScope, _params);
View Full Code Here

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

        // retrieve fieldvalue from source
        if (source.equals("content")) {
            WGDocument doc = _context.getdocument();
            return FormBase.getFieldValue(doc, _context, _form.getforminfo(), fieldname, meta, defaultvalue, useRelation);           
        } else if (source.equals("profile")) {
            TMLUserProfile profile = _context.getprofile();
            return FormBase.getFieldValue(profile,  _context, _form.getforminfo(), fieldname, meta, defaultvalue);
        } else if (source.equals("portlet")) {
            TMLPortlet portlet = _context.getportlet();
            return FormBase.getFieldValue(portlet,  _context, _form.getforminfo(), fieldname, meta, defaultvalue);
        } else if (source.equals("none")) {
View Full Code Here

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

        }
   
    String dbKey = (String) db.getAttribute(WGACore.DBATTRIB_DBKEY);
   
    HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
    TMLUserProfile userProfile = null;
    if (request != null) {
      userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
    }
   
    String contentType = contentEvent.getContentType();
View Full Code Here

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

    }
   
    String dbKey = (String) db.getAttribute(WGACore.DBATTRIB_DBKEY);
   
    HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
    TMLUserProfile userProfile = null;
    if (request != null) {
      userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
    }
   
    String contentType = contentEvent.getContentType();
View Full Code Here

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

        }
       
    String dbKey = (String) db.getDbReference();
   
    HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
    TMLUserProfile userProfile = null;
    if (request != null) {
      userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
    }
   
    String contentType = "*";
 
View Full Code Here

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

        }
   
    String dbKey = (String) db.getAttribute(WGACore.DBATTRIB_DBKEY);
   
    HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
    TMLUserProfile userProfile = null;
    if (request != null) {
      userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
    }
   
    String contentType = "*";
 
View Full Code Here

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

        }
       
        String dbKey = (String) db.getAttribute(WGACore.DBATTRIB_DBKEY);
       
        HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
        TMLUserProfile userProfile = null;
        if (request != null) {
            userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
        }
       
        String contentType = "*";
 
View Full Code Here

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

        }
       
        String dbKey = (String) db.getDbReference();
       
        HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
        TMLUserProfile userProfile = null;
        if (request != null) {
            userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
        }
       
        String contentType = contentEvent.getContentType();
View Full Code Here

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

        if (request.getQueryString() != null && request.getQueryString().toLowerCase().indexOf("dropcache") != -1 && isAdminLoggedIn(request)) {
            content.dropCache();
        }

        // Personalize
        TMLUserProfile tmlUserProfile = null;
        try {
            if (_core.isPersonalisationEnabled()) {
                tmlUserProfile = this.fetchUserProfile(request, response, database, session);
                if (tmlUserProfile != null && !tmlUserProfile.getprofile().isDeleted()) {
                    if (!isBrowserInterface(session)) {
                        this.registerHit(tmlUserProfile.getprofile(), database, content);
                    }
                }
            }
        }
        catch (WGAPIException e) {
            _log.error("Unable to personalize tmlrequest.", e);
        }

        // Set context attributes for tml
        request.setAttribute(WGACore.ATTRIB_MAINCONTEXT, content);
        request.setAttribute(WGACore.ATTRIB_WGPPATH, path.getPublisherURL());
        request.setAttribute(WGACore.ATTRIB_TAGIDS, WGUtils.createSynchronizedMap());
        request.setAttribute(WGACore.ATTRIB_TMLCONTEXTS, WGUtils.createSynchronizedMap());
        request.setAttribute(WGACore.ATTRIB_REQUESTURL, completeUrl);
        request.setAttribute(WGACore.ATTRIB_MIMETYPE, mimeType);
        request.setAttribute(WGACore.ATTRIB_MEDIAKEY, mediaKey);
        request.setAttribute(WGACore.ATTRIB_REQUESTTYPE, REQUESTTYPE_TML);

        if (mediaKeyObj.isBinary()) {
            request.setAttribute(WGACore.ATTRIB_SERVLETRESPONSE, response);
        }

        // Determine tml design for this request
        WGTMLModule tmlLib = null;
        if (path.getLayoutKey() != null) {
            tmlLib = (WGTMLModule) database.getDesignObject(WGDocument.TYPE_TML, path.getLayoutKey(), mediaKey);
            if (tmlLib != null && tmlLib.isDirectAccessAllowed() == false) {
                throw new HttpErrorException(java.net.HttpURLConnection.HTTP_FORBIDDEN, "This design is not allowed for direct access: " + tmlLib.getName() + " (" + tmlLib.getMediaKey() + ")", path
                        .getDatabaseKey());
            }
        }
        else {
            WGStructEntry entry = content.getStructEntry();
            if (entry == null) {
                throw new HttpErrorException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Content " + content.getContentKey().toString() + " has no struct entry", path.getDatabaseKey());
            }
            tmlLib = entry.getOuterLayout(mediaKey);
        }

        if (tmlLib == null || tmlLib.isDummy()) {
            if (path.getLayoutKey() != null) {
                throw new HttpErrorException(404, "No WebTML layout '" + path.getLayoutKey() + "' for media key '" + mediaKey + "' available in app '" + database.getDbReference() + "'", path.getDatabaseKey());
            }
            else {
                throw new HttpErrorException(500, "Outer layout of struct entry '" + content.getStructEntry().getTitle() + "(" + content.getStructEntry().getStructKey() + ")"
                        + "' not available for media key '" + mediaKey + "'", path.getDatabaseKey());
            }
        }

        request.setAttribute(WGACore.ATTRIB_OUTER_DESIGN, tmlLib.getName());


        // TML Cache control
        if (tmlLib.isCacheable()) {
            response.setHeader("Cache-Control", "must-revalidate");

            long lastModified;
            // determine lastModified
            // - last modified of binary response depends only on resource
            // change date
            // - last change date of textual response additionally depends on
            // character encoding change date
            if (isBinary(response)) {
                lastModified = getCore().getDeployer().getLastChangedOrDeployed(database).getTime();
            }
            else {
                lastModified = Math.max(getCore().getDeployer().getLastChangedOrDeployed(database).getTime(), _core.getCharacterEncodingLastModified());
                lastModified = Math.max(lastModified, _core.getDesignEncodingLastModified(database.getDbReference()));
            }

            // Test modified since
            if (browserCacheIsValid(request, lastModified)) {
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                return;
            }
            else {
                response.setDateHeader("Last-Modified", lastModified);
                response.setHeader("ETag", '"' + String.valueOf(lastModified) + '"');
            }
        }
        else {
            response.setHeader("Pragma", "No-Cache");
            if (mediaKeyObj.isBinary()) {
                response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            }
            else {
                response.setHeader("Cache-Control", "No-Cache");
            }
        }

        // check if we have an ajaxcall
        String encAjaxInfo = request.getParameter("$ajaxInfo");
        if (encAjaxInfo != null) {
            tmlLib = processAjaxCall(request, database, encAjaxInfo);
            ajax = true;
        }

        // Update usage statistics
        getCore().getUsageStatistics().addRequestStatistic(request, session, database, tmlUserProfile);

        // Dispatch to jsp
        String targetJSP = _core.getDeployer().locateTmlResource(tmlLib);

        try {
            if (targetJSP != null) {
                if (!"HEAD".equalsIgnoreCase(request.getMethod())) {
                    if (mediaKeyObj.isBinary()) {
                        if (request instanceof RenderServletRequestWrapper) {
                            HttpServletRequestWrapper wrapper = (HttpServletRequestWrapper) request;
                            wrapper.getRequest().getRequestDispatcher(targetJSP).include(wrapper.getRequest(), new DummyServletResponse(response));
                        }
                        else {
                            this.getServletContext().getRequestDispatcher(targetJSP).include(request, new DummyServletResponse(response));
                        }
                    }
                    else {
                        if (request instanceof RenderServletRequestWrapper) {
                            HttpServletRequestWrapper wrapper = (HttpServletRequestWrapper) request;
                            wrapper.getRequest().getRequestDispatcher(targetJSP).include(wrapper.getRequest(), response);
                        }
                        else {
                            this.getServletContext().getRequestDispatcher(targetJSP).include(request, response);
                        }
                    }
                }
            }
            else {
                throw new HttpErrorException(500, "tml design not active: " + tmlLib.getName(), path.getDatabaseKey());
            }

            // Eventually do redirect
            if (request.getAttribute(WGACore.ATTRIB_REDIRECT) != null) {
               
                if (!ajax) { // On AJAX requests the redirect is performed by Root.tmlEndTag()
                    if (!session.isNew()) { // on new sessions we must not reset the response (#00000147)
                        response.reset();
                    }
                    response.sendRedirect(String.valueOf(request.getAttribute(WGACore.ATTRIB_REDIRECT)));
                }
            }

            // Eventually save profile
            if (tmlUserProfile != null && tmlUserProfile.isSavedOnEnd() && !tmlUserProfile.isSaved()) {

                // To keep profile storage operation from delaying the response
                commitResponse(response);

                if (!tmlUserProfile.getprofile().save()) {
                    getCore().getLog().error("Unable to save profile on request end");
                }

            }
        }
View Full Code Here

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

        // Try to retrieve previously stored user profile in session
        String wgpid = (String) session.getAttribute(SESSION_PROFILENAME_INDIVIDUALDB + database.getDbReference());
        if (wgpid != null) {
            WGUserProfile profile = persDB.getUserProfile(wgpid);
            if (profile != null) {
                TMLUserProfile tmlProfile = new TMLUserProfile(profile, getCore());
                request.setAttribute(WGACore.ATTRIB_PROFILE + database.getDbReference(), tmlProfile);
                return tmlProfile;
            }
        }

        // Fetch user profile using database's persmode. If not available we
        // take the default value for the option
        String persModeStr = (String) _core.readPublisherOptionOrDefault(database, WGACore.DBATTRIB_PERSMODE);
        Integer persMode;
        if (persModeStr != null) {
            persMode = Integer.valueOf(persModeStr);
        }
        // Backup for sure, which should not happen as the option is defined for
        // all databases
        else {
            persMode = Constants.PERSMODE_AUTO;
        }

        // If in Mode AUTO, the User Profile is retrieved automatically
        // (otherwise it is set in the login process)
        WGUserProfile userProfile = null;
        boolean created = false;
        if (persMode == Constants.PERSMODE_AUTO) {
            boolean secureMode = database.getBooleanAttribute(WGACore.DBATTRIB_SECURE_APP, false);
            String cookieName = COOKIE_WGPID;
            if (secureMode) {
                cookieName = COOKIE_SECURE_WGPID;
            }

            wgpid = this.findCookie(request.getCookies(), cookieName);
            if (wgpid != null) {
                userProfile = persDB.getUserProfile(wgpid);
            }

            if (userProfile == null) {
                userProfile = createUserProfile((String) request.getHeader("User-Agent"), persDB, wgpid, Constants.PERSMODE_AUTO);
                created = true;
            }

            if (userProfile != null && !userProfile.isDummy()) {
                Cookie wgpidCookie = new Cookie(cookieName, userProfile.getName());
                wgpidCookie.setPath("/");
                wgpidCookie.setSecure(secureMode);
                wgpidCookie.setMaxAge(60 * 60 * 24 * 365);
                response.addCookie(wgpidCookie);
            }
        }

        else if (persMode == Constants.PERSMODE_LOGIN) {
            if (database.getSessionContext().isAnonymous()) {
                // no profile for anonymous
                return null;
            }
            String userName = database.getSessionContext().getUser();
            userProfile = persDB.getUserProfile(userName);
            if (userProfile == null) {
                userProfile = createUserProfile((String) request.getHeader("User-Agent"), persDB, userName, Constants.PERSMODE_LOGIN);
                created =  true;
            }
        }

        // If valid user profile, set in session object and register new session
        if (userProfile != null && !userProfile.isDeleted()) {

            // Drop cache so we can be sure to be up-to-date with the backend
            // database
            // (Since backend changes - maybe from other cluster nodes - are not
            // registered for user profiles)
            userProfile.dropCache();

            session.setAttribute(SESSION_PROFILENAME_INDIVIDUALDB + database.getDbReference(), userProfile.getName());
            TMLUserProfile tmlProfile = new TMLUserProfile(userProfile, getCore());
            request.setAttribute(WGACore.ATTRIB_PROFILE + database.getDbReference(), tmlProfile);
            this.registerSession(userProfile, request, session, created);
            return tmlProfile;
        }
        else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.