Examples of LocaleManager


Examples of org.jasig.portal.i18n.LocaleManager

  public Document getUserLayout (IPerson person, UserProfile profile) throws Exception {
    int userId = person.getID();
    int realUserId = userId;
    ResultSet rs;
    Connection con = RDBMServices.getConnection();
    LocaleManager localeManager = profile.getLocaleManager();

    try {
      Document doc = DocumentFactory.getNewDocument();
      Element root = doc.createElement("layout");
      Statement stmt = con.createStatement();
      // A separate statement is needed so as not to interfere with ResultSet
      // of statements used for queries
      Statement insertStmt = con.createStatement();
      try {
        long startTime = System.currentTimeMillis();
        // eventually, we need to fix template layout implementations so you can just do this:
        //        int layoutId=profile.getLayoutId();
        // but for now:
        int layoutId = this.getLayoutID(userId, profile.getProfileId());

       if (layoutId == 0) { // First time, grab the default layout for this user
          RDBMServices.setAutoCommit(con, false);          // May speed things up, can't hurt
          try {
              String sQuery = "SELECT USER_DFLT_USR_ID, USER_DFLT_LAY_ID FROM UP_USER WHERE USER_ID=" + userId;
              if (log.isDebugEnabled())
                  log.debug("RDBMUserLayoutStore::getUserLayout(): " + sQuery);
              rs = stmt.executeQuery(sQuery);
              try {
                boolean hasRow = rs.next();
                userId = rs.getInt(1);
                layoutId = rs.getInt(2);
              } finally {
                rs.close();
              }
   
              // Make sure the next struct id is set in case the user adds a channel
              sQuery = "SELECT NEXT_STRUCT_ID FROM UP_USER WHERE USER_ID=" + userId;
              if (log.isDebugEnabled())
                  log.debug("RDBMUserLayoutStore::getUserLayout(): " + sQuery);
              int nextStructId;
              rs = stmt.executeQuery(sQuery);
              try {
                boolean hasRow = rs.next();
                nextStructId = rs.getInt(1);
              } finally {
                rs.close();
              }
   
              int realNextStructId = 0;
   
              if (realUserId != userId) {
                // But never make the existing value SMALLER, change it only to make it LARGER
                // (so, get existing value)
                sQuery = "SELECT NEXT_STRUCT_ID FROM UP_USER WHERE USER_ID=" + realUserId;
                if (log.isDebugEnabled())
                    log.debug("RDBMUserLayoutStore::getUserLayout(): " + sQuery);
                rs = stmt.executeQuery(sQuery);
                try {
                  boolean hasRow = rs.next();
                  realNextStructId = rs.getInt(1);
                } finally {
                  rs.close();
                }
              }
   
              if (nextStructId > realNextStructId) {
                sQuery = "UPDATE UP_USER SET NEXT_STRUCT_ID=" + nextStructId + " WHERE USER_ID=" + realUserId;
                if (log.isDebugEnabled())
                    log.debug("RDBMUserLayoutStore::getUserLayout(): " + sQuery);
                stmt.executeUpdate(sQuery);
              }
   
              RDBMServices.commit(con); // Make sure it appears in the store
          }
          catch (Exception e) {
              RDBMServices.rollback(con);
              throw e;
          }
          finally {
              //Reset commit state
              RDBMServices.setAutoCommit(con, true);
          }
        }

        int firstStructId = -1;

        //Flags to enable a default layout lookup if it's needed
        boolean foundLayout = false;
        boolean triedDefault = false;

        //This loop is used to ensure a layout is found for a user. It tries
        //looking up the layout for the current userID. If one isn't found
        //the userID is replaced with the template user ID for this user and
        //the layout is searched for again. This loop should only ever loop once.
        do {
            String sQuery = "SELECT INIT_STRUCT_ID FROM UP_USER_LAYOUT WHERE USER_ID=" + userId + " AND LAYOUT_ID = " + layoutId;
            if (log.isDebugEnabled())
                log.debug("RDBMUserLayoutStore::getUserLayout(): " + sQuery);
            rs = stmt.executeQuery(sQuery);
            try {
              if (rs.next()) {
                firstStructId = rs.getInt(1);
              } else {
                throw new Exception("RDBMUserLayoutStore::getUserLayout(): No INIT_STRUCT_ID in UP_USER_LAYOUT for USER_ID: " + userId + " and LAYOUT_ID: " + layoutId);
              }
            } finally {
              rs.close();
            }

            String sql;
            if (localeAware) {
                // This needs to be changed to get the localized strings
                sql = "SELECT ULS.STRUCT_ID,ULS.NEXT_STRUCT_ID,ULS.CHLD_STRUCT_ID,ULS.CHAN_ID,ULS.NAME,ULS.TYPE,ULS.HIDDEN,"+
              "ULS.UNREMOVABLE,ULS.IMMUTABLE";
            else {
                sql = "SELECT ULS.STRUCT_ID,ULS.NEXT_STRUCT_ID,ULS.CHLD_STRUCT_ID,ULS.CHAN_ID,ULS.NAME,ULS.TYPE,ULS.HIDDEN,"+
              "ULS.UNREMOVABLE,ULS.IMMUTABLE";
            }
            if (this.databaseMetadata.supportsOuterJoins()) {
              sql += ",USP.STRUCT_PARM_NM,USP.STRUCT_PARM_VAL FROM " + this.databaseMetadata.getJoinQuery().getQuery("layout");
            } else {
              sql += " FROM UP_LAYOUT_STRUCT ULS WHERE ";
            }
            sql += " ULS.USER_ID=" + userId + " AND ULS.LAYOUT_ID=" + layoutId + " ORDER BY ULS.STRUCT_ID";
            if (log.isDebugEnabled())
                log.debug("RDBMUserLayoutStore::getUserLayout(): " + sql);
            rs = stmt.executeQuery(sql);

            //check for rows in the result set
            foundLayout = rs.next();

            if (!foundLayout && !triedDefault && userId == realUserId) {
                //If we didn't find any rows and we haven't tried the default user yet
                triedDefault = true;
                rs.close();

                //Get the default user ID and layout ID
                sQuery = "SELECT USER_DFLT_USR_ID, USER_DFLT_LAY_ID FROM UP_USER WHERE USER_ID=" + userId;
                if (log.isDebugEnabled())
                    log.debug("RDBMUserLayoutStore::getUserLayout(): " + sQuery);
                rs = stmt.executeQuery(sQuery);
                try {
                  rs.next();
                  userId = rs.getInt(1);
                  layoutId = rs.getInt(2);
                } finally {
                  rs.close();
                }
            }
            else {
                //We tried the default or actually found a layout
                break;
            }
        } while (!foundLayout);

        HashMap layoutStructure = new HashMap();
        StringBuffer structChanIds = new StringBuffer();

        try {
          int lastStructId = 0;
          LayoutStructure ls = null;
          String sepChar = "";
          if (foundLayout) {
            int structId = rs.getInt(1);
            // Result Set returns 0 by default if structId was null
            // Except if you are using poolman 2.0.4 in which case you get -1 back
            if (rs.wasNull()) {
              structId = 0;
            }
            readLayout: while (true) {
              if (DEBUG > 1) System.err.println("Found layout structureID " + structId);

              int nextId = rs.getInt(2);
              if (rs.wasNull()) {
                nextId = 0;
              }
              int childId = rs.getInt(3);
              if (rs.wasNull()) {
                childId = 0;
              }
              int chanId = rs.getInt(4);
              if (rs.wasNull()) {
                chanId = 0;
              }
              String temp5=rs.getString(5); // Some JDBC drivers require columns accessed in order
              String temp6=rs.getString(6); // Access 5 and 6 now, save till needed.

              // uPortal i18n
              int name_index, value_index;
              if (localeAware) {
                  ls = new LayoutStructure(
                              structId, nextId, childId, chanId,
                              rs.getString(7),rs.getString(8),rs.getString(9),
                              localeManager.getLocales()
                              [0].toString());
                  name_index=10;
                  value_index=11;
              else {
                  ls = new LayoutStructure(structId, nextId, childId, chanId, rs.getString(7),rs.getString(8),rs.getString(9));
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

                    String msg = "The system user profile has no theme stylesheet Id.";
                    throw new IllegalStateException(msg);
                }
            }
            UserProfile userProfile = new UserProfile(profileId, temp2, temp3,temp4, layoutId, structSsId, themeSsId);
            userProfile.setLocaleManager(new LocaleManager(person));
            return userProfile;
          }
          else {
            throw new Exception("Unable to find User Profile for user " + userId + " and profile " + profileId);
          }
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

                    String msg = "The system user profile has no theme stylesheet Id.";
                    throw new IllegalStateException(msg);
                }
            }
            UserProfile userProfile = new UserProfile(profileId, profileFname, profileName, profileDesc, layoutId, structSsId, themeSsId);
            userProfile.setLocaleManager(new LocaleManager(person));
            return userProfile;
          }
          else {
          /* Try to copy the template profile. */
          log.debug("Copying template profile " + profileFname + " to user " + person.getID());
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

    public UserInstance(IPerson person, HttpServletRequest request) {
        this.person = person;

        // instantiate locale manager (uPortal i18n)
        final String acceptLanguage = request.getHeader("Accept-Language");
        this.localeManager = new LocaleManager(person, acceptLanguage);

        //Create the UserPreferencesManager
        this.preferencesManager = new UserPreferencesManager(request, this.person, this.localeManager);
        if (preferencesManager.isUserAgentUnmapped()) {
            this.log.warn("A Mapping User-Agent could not be found for the UserPreferencesManager");
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

    /* (non-Javadoc)
     * @see org.jasig.portal.rendering.IPortalRenderingPipeline#renderState(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.jasig.portal.IUserInstance)
     */
    public void renderState(HttpServletRequest req, HttpServletResponse res, IUserInstance userInstance) throws PortalException {
        final IPerson person = userInstance.getPerson();
        final LocaleManager localeManager = userInstance.getLocaleManager();
        final IUserPreferencesManager uPreferencesManager = userInstance.getPreferencesManager();
        final ChannelManager channelManager = userInstance.getChannelManager();
        final Object renderingLock = userInstance.getRenderingLock();
       
        UPFileSpec upfs = new UPFileSpec(req);
        String rootNodeId = upfs.getMethodNodeId();
        if (rootNodeId == null) {
            rootNodeId = UPFileSpec.USER_LAYOUT_ROOT_NODE;
        }
       
        // see if a new root target has been specified
        String newRootNodeId = req.getParameter("uP_detach_target");

        // set optimistic uPElement value
        UPFileSpec uPElement = new UPFileSpec(UPFileSpec.RENDER_METHOD, rootNodeId, null, null);

        if (newRootNodeId != null) {
            // set a new root
            uPElement.setMethodNodeId(newRootNodeId);
        }
       
        channelManager.setUPElement(uPElement);

        // proccess possible portlet action
        final IPortletWindowId targetedPortletWindowId = this.portletRequestParameterManager.getTargetedPortletWindowId(req);
        if (targetedPortletWindowId != null) {
            final PortletUrl portletUrl = this.portletRequestParameterManager.getPortletRequestInfo(req, targetedPortletWindowId);
           
            if (RequestType.ACTION.equals(portletUrl.getRequestType())) {
                final IPortletEntity targetedPortletEntity = this.portletWindowRegistry.getParentPortletEntity(req, targetedPortletWindowId);
                if (targetedPortletEntity != null) {
                    final String channelSubscribeId = targetedPortletEntity.getChannelSubscribeId();
                    final boolean actionExecuted = channelManager.doChannelAction(req, res, channelSubscribeId, false);
                   
                    if (actionExecuted) {
                        // The action completed, return immediately
                        return;
                    }
   
                    // The action didn't execute, continue and try to render normally
                }
            }
        }
       
        // process possible worker dispatch
        final boolean workerDispatched = this.processWorkerDispatchIfNecessary(req, res, uPreferencesManager, channelManager);
        if (workerDispatched) {
            //If a worker was dispatched to return immediately
            return;
        }
       
        //Set a larger buffer to allow for explicit flushing
        res.setBufferSize(16 * 1024);
       
        final long startTime = System.currentTimeMillis();
        synchronized (renderingLock) {
            // This function does ALL the content gathering/presentation work.
            // The following filter sequence is processed:
            //        userLayoutXML (in UserPreferencesManager)
            //              |
            //        incorporate StructureAttributes
            //              |
            //        Structure transformation
            //              + (buffering step)
            //        ChannelRendering Buffer
            //              |
            //        ThemeAttributesIncorporation Filter
            //              |
            //        Theme Transformatio
            //              |
            //        ChannelIncorporation filter
            //              |
            //        Serializer (XHTML/WML/HTML/etc.)
            //              |
            //        JspWriter
            //

            try {

                // determine uPElement (optimistic prediction) --begin
                // We need uPElement for ChannelManager.setReqNRes() call. That call will distribute uPElement
                // to Privileged channels. We assume that Privileged channels are smart enough not to delete
                // themselves in the detach mode !

                // In general transformations will start at the userLayoutRoot node, unless
                // we are rendering something in a detach mode.
                IUserLayoutNodeDescription rElement = null;
                // see if an old detach target exists in the servlet path

                // give channels the current locale manager
                channelManager.setLocaleManager(localeManager);

                IUserLayoutManager ulm = uPreferencesManager.getUserLayoutManager();

                // determine uPElement (optimistic prediction) --end

                // set up the channel manager

                channelManager.startRenderingCycle(req, res, uPElement);

                // after this point the layout is determined

                UserPreferences userPreferences = uPreferencesManager.getUserPreferences();
                StructureStylesheetDescription ssd = uPreferencesManager.getStructureStylesheetDescription();
                ThemeStylesheetDescription tsd = uPreferencesManager.getThemeStylesheetDescription();

                // verify upElement and determine rendering root --begin
                if (newRootNodeId != null && (!newRootNodeId.equals(rootNodeId))) {
                    // see if the new detach traget is valid
                    try {
                        rElement = ulm.getNode(newRootNodeId);
                    }
                    catch (PortalException e) {
                        rElement = null;
                    }

                    if (rElement != null) {
                        // valid new root id was specified. need to redirect
                        // peterk: should we worry about forwarding
                        // parameters here ? or those passed with detach
                        // always get sacked ?
                        // Andreas: Forwarding parameters with detach
                        // are not lost anymore with the URLUtil class.

                        // Skip the uP_detach_target parameter since
                        // it has already been processed
                        String[] skipParams = new String[] { "uP_detach_target" };

                        try {
                            URLUtil.redirect(req, res, newRootNodeId, true, skipParams, CHARACTER_SET);
                        }
                        catch (PortalException pe) {
                            log.error("PortalException occurred while redirecting",
                                    pe);
                        }
                        return;
                    }
                }

                // LogService.log(LogService.DEBUG,"uP_detach_target=\""+rootNodeId+"\".");
                try {
                    rElement = ulm.getNode(rootNodeId);
                }
                catch (PortalException e) {
                    rElement = null;
                }
                // if we haven't found root node so far, set it to the userLayoutRoot
                if (rElement == null) {
                    rootNodeId = UPFileSpec.USER_LAYOUT_ROOT_NODE;
                }

                // update the render target
                uPElement.setMethodNodeId(rootNodeId);

                // inform channel manager about the new uPElement value
                channelManager.setUPElement(uPElement);
                // verify upElement and determine rendering root --begin
               
                // Increase output buffer size, buffer will be flushed before and after every <channel>
                res.setBufferSize(16 * 1024);

                // Disable page caching
                res.setHeader("pragma", "no-cache");
                res.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate");
                res.setDateHeader("Expires", 0);
                // set the response mime type
                res.setContentType(tsd.getMimeType() + "; charset=" + CHARACTER_SET);
                // obtain the writer - res.getWriter() must occur after res.setContentType()
                Writer out = new BufferedWriter(res.getWriter(), 1024);
                // get a serializer appropriate for the target media
                BaseMarkupSerializer markupSerializer =
                    MEDIA_MANAGER.getSerializerByName(tsd.getSerializerName(),
                        new ChannelTitleIncorporationWiterFilter(out, channelManager, ulm));
                // set up the serializer
                markupSerializer.asContentHandler();
                // see if we can use character caching
                boolean ccaching = (CHARACTER_CACHE_ENABLED && (markupSerializer instanceof CachingSerializer));
                channelManager.setCharacterCaching(ccaching);
                // pass along the serializer name
                channelManager.setSerializerName(tsd.getSerializerName());
                // initialize ChannelIncorporationFilter
                CharacterCachingChannelIncorporationFilter cif = new CharacterCachingChannelIncorporationFilter(markupSerializer, channelManager, CACHE_ENABLED && CHARACTER_CACHE_ENABLED, req, res);

                String cacheKey = null;
                boolean output_produced = false;
                if (CACHE_ENABLED) {
                    boolean ccache_exists = false;
                    // obtain the cache key
                    cacheKey = constructCacheKey(uPreferencesManager, rootNodeId);
                    if (ccaching) {
                        // obtain character cache
                        List<CacheEntry> cacheEntries = systemCharacterCache.get(cacheKey);
                        if(cacheEntries!=null && cacheEntries.size()>0) {
                            ccache_exists = true;
                            if (log.isDebugEnabled())
                                log
                                        .debug("retreived transformation character block cache for a key \""
                                                + cacheKey + "\"");
                            // start channel threads
                            for(int i=0;i<cacheEntries.size();i++) {
                                CacheEntry ce = cacheEntries.get(i);
                                if (ce.getCacheType().equals(CacheType.CHANNEL_CONTENT)) {
                                    String channelSubscribeId = ((ChannelContentCacheEntry)ce).getChannelId();
                                    if(channelSubscribeId!=null) {
                                        try {
                                            channelManager.startChannelRendering(req, res, channelSubscribeId);
                                        } catch (PortalException e) {
                                            log.error("UserInstance::renderState() : unable to start rendering channel (subscribeId=\""+channelSubscribeId+"\", user="+person.getID()+" layoutId="+uPreferencesManager.getCurrentProfile().getLayoutId(),e);
                                        }
                                    } else {
                                        log.error("channel entry " + Integer.toString(i)
                                            + " in character cache is invalid (user=" + person.getID() + ")!");
                                    }
                                }
                            }
                            channelManager.commitToRenderingChannelSet();

                            // go through the output loop
                            CachingSerializer cSerializer = (CachingSerializer) markupSerializer;
                            cSerializer.setDocumentStarted(true);

                            for(int sb=0; sb<cacheEntries.size();sb++) {
                                CacheEntry ce = cacheEntries.get(sb);
                                if (log.isDebugEnabled()) {
                                    DebugCachingSerializer dcs = new DebugCachingSerializer();
                                    log.debug("----------printing " + ce.getCacheType() + " cache block "+Integer.toString(sb));
                                    ce.replayCache(dcs, channelManager, req, res);
                                    log.debug(dcs.getCache());
                                }

                                // get cache block output
                                ce.replayCache(cSerializer, channelManager, req, res);
                            }

                            cSerializer.flush();
                            output_produced = true;
                        }
                    }
                    // if this failed, try XSLT cache
                    if ((!ccaching) || (!ccache_exists)) {
                        // obtain XSLT cache

                        SAX2BufferImpl cachedBuffer = systemCache.get(cacheKey);
                        if (cachedBuffer != null) {
                            // replay the buffer to channel incorporation filter
                            if (log.isDebugEnabled()) {
                                log.debug("retreived XSLT transformation cache for a key '" + cacheKey + "'");
                            }
                           
                            // attach rendering buffer downstream of the cached buffer
                            ChannelRenderingBuffer crb = new ChannelRenderingBuffer(cachedBuffer, channelManager, ccaching, req, res);
                           
                            // attach channel incorporation filter downstream of the channel rendering buffer
                            cif.setParent(crb);
                            crb.setOutputAtDocumentEnd(true);
                            cachedBuffer.outputBuffer(crb);

                            output_produced = true;
                        }
                    }
                }
                // fallback on the regular rendering procedure
                if (!output_produced) {

                    // obtain transformer handlers for both structure and theme stylesheets
                    TransformerHandler ssth = XSLT.getTransformerHandler(ResourceLoader.getResourceAsURL(this.getClass(), ssd.getStylesheetURI()).toString());
                    TransformerHandler tsth = XSLT.getTransformerHandler(tsd.getStylesheetURI(), localeManager
                            .getLocales(), this);

                    // obtain transformer references from the handlers
                    Transformer sst = ssth.getTransformer();
                    sst.setErrorListener(cErrListener);
                    Transformer tst = tsth.getTransformer();
                    tst.setErrorListener(cErrListener);
                   
                    // pass resourcesDao into transformer
                    tst.setParameter(ResourcesXalanElements.SKIN_RESOURCESDAO_PARAMETER_NAME, resourcesElementsProvider);
                    tst.setParameter(ResourcesXalanElements.CURRENT_REQUEST, req);

                    // initialize ChannelRenderingBuffer and attach it downstream of the structure transformer
                    ChannelRenderingBuffer crb = new ChannelRenderingBuffer(channelManager, ccaching, req, res);
                    ssth.setResult(new SAXResult(crb));

                    // determine and set the stylesheet params
                    // prepare .uP element and detach flag to be passed to the stylesheets
                    // Including the context path in front of uPElement is necessary for phone.com browsers to work
                    sst.setParameter("baseActionURL", uPElement.getUPFile());
                    // construct idempotent version of the uPElement
                    UPFileSpec uPIdempotentElement = new UPFileSpec(uPElement);
                    sst.setParameter("baseIdempotentActionURL", uPElement.getUPFile());

                    Hashtable<String, String> supTable = userPreferences.getStructureStylesheetUserPreferences()
                            .getParameterValues();
                    for (Map.Entry<String, String> param : supTable.entrySet()) {
                        String pName = param.getKey();
                        String pValue = param.getValue();
                        if (log.isDebugEnabled())
                            log.debug("setting sparam \"" + pName + "\"=\"" + pValue
                                    + "\".");
                        sst.setParameter(pName, pValue);
                    }

                    // all the parameters are set up, fire up structure transformation

                    // filter to fill in channel/folder attributes for the "structure" transformation.
                    StructureAttributesIncorporationFilter saif = new StructureAttributesIncorporationFilter(ssth,
                            userPreferences.getStructureStylesheetUserPreferences());

                    // This is a debug statement that will print out XML incoming to the
                    // structure transformation to a log file serializer to a printstream
                    StringWriter dbwr1 = null;
                    OutputFormat outputFormat = null;
                    if (logXMLBeforeStructureTransformation && log.isDebugEnabled()) {
                        dbwr1 = new StringWriter();
                        outputFormat = new OutputFormat();
                        outputFormat.setIndenting(true);
                        XMLSerializer dbser1 = new XMLSerializer(dbwr1, outputFormat);
                        SAX2DuplicatingFilterImpl dupl1 = new SAX2DuplicatingFilterImpl(ssth, dbser1);
                        dupl1.setParent(saif);
                    }

                    // if operating in the detach mode, need wrap everything
                    // in a document node and a <layout_fragment> node
                    boolean detachMode = !rootNodeId.equals(UPFileSpec.USER_LAYOUT_ROOT_NODE);
                    if (detachMode) {
                        saif.startDocument();
                        saif.startElement("",
                                "layout_fragment",
                                "layout_fragment",
                                new org.xml.sax.helpers.AttributesImpl());

                        //                            emptyt.transform(new DOMSource(rElement),new SAXResult(new ChannelSAXStreamFilter((ContentHandler)saif)));
                        if (rElement == null) {
                            ulm.getUserLayout(new ChannelSAXStreamFilter((ContentHandler) saif));
                        }
                        else {
                            ulm.getUserLayout(rElement.getId(), new ChannelSAXStreamFilter((ContentHandler) saif));
                        }

                        saif.endElement("", "layout_fragment", "layout_fragment");
                        saif.endDocument();
                    }
                    else {
                        if (rElement == null) {
                            ulm.getUserLayout(saif);
                        }
                        else {
                            ulm.getUserLayout(rElement.getId(), saif);
                        }
                        //                            emptyt.transform(new DOMSource(rElement),new SAXResult((ContentHandler)saif));
                    }
                    // all channels should be rendering now

                    // Debug piece to print out the recorded pre-structure transformation XML
                    if (logXMLBeforeStructureTransformation && log.isDebugEnabled()) {
                            log.debug("XML incoming to the structure transformation :\n\n"
                                            + dbwr1.toString() + "\n\n");
                    }

                    // prepare for the theme transformation

                    // set up of the parameters
                    tst.setParameter("baseActionURL", uPElement.getUPFile());
                    tst.setParameter("baseIdempotentActionURL", uPIdempotentElement.getUPFile());
                    if (externalLoginUrl != null) {
                        tst.setParameter("EXTERNAL_LOGIN_URL", externalLoginUrl);
                    }

                    Hashtable<String, String> tupTable = userPreferences.getThemeStylesheetUserPreferences()
                            .getParameterValues();
                    for (Map.Entry<String, String> param : tupTable.entrySet()) {
                        String pName = param.getKey();
                        String pValue = param.getValue();
                        if (log.isDebugEnabled())
                            log.debug("setting tparam \"" + pName + "\"=\"" + pValue
                                    + "\".");
                        tst.setParameter(pName, pValue);
                    }

                    VersionsManager versionsManager = VersionsManager.getInstance();
                    Version[] versions = versionsManager.getVersions();

                    for (Version version : versions) {
                        String paramName = "version-" + version.getFname();
                        tst.setParameter(paramName, version.dottedTriple());
                    }

                    // the uP_productAndVersion stylesheet parameter is deprecated
                    // instead use the more generic "version-UP_VERSION" generated from the
                    // framework's functional name when all versions are pulled immediately
                    // above.
                    Version uPortalVersion = versionsManager.getVersion(IPermission.PORTAL_FRAMEWORK);
                    tst.setParameter("uP_productAndVersion", "uPortal " + uPortalVersion.dottedTriple());

                    final Locale[] locales = localeManager.getLocales();
                    if (locales != null && locales.length > 0 && locales[0] != null) {
                        tst.setParameter("USER_LANG", locales[0].toString().replace('_', '-'));
                    }

                    // initialize a filter to fill in channel attributes for the "theme" (second) transformation.
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

    private ChannelRuntimeData getRuntimeData(HttpServletRequest req) {
        // construct runtime data
        this.binfo=new BrowserInfo(req);
        String acceptLanguage = req.getHeader("Accept-Language");
        String requestLocalesString = req.getParameter("locale");
        this.lm=new LocaleManager(this.staticData.getPerson(), acceptLanguage);
        this.lm.setSessionLocales(LocaleManager.parseLocales(requestLocalesString));

        Hashtable<String, Object> targetParams = new Hashtable<String, Object>();
        UPFileSpec upfs=new UPFileSpec(req);
        String channelTarget = upfs.getTargetNodeId();
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

   */
  public Locale getCurrentUserLocale(HttpServletRequest request) {

    IUserInstance ui = userInstanceManager.getUserInstance(request);
    IUserPreferencesManager upm = ui.getPreferencesManager();
        LocaleManager localeManager = upm.getUserPreferences().getProfile().getLocaleManager();
       
        // first check the session locales
        Locale[] sessionLocales = localeManager.getSessionLocales();
        if (sessionLocales != null && sessionLocales.length > 0) {
          return sessionLocales[0];
        }
       
        // if no session locales were found, check the user locales
        Locale[] userLocales = localeManager.getUserLocales();
        if (userLocales != null && userLocales.length > 0) {
            return userLocales[0];
        }
       
        // if no selected locale was found either in the session or user layout,
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

   */
  public void updateUserLocale(HttpServletRequest request, String localeString) {

    IUserInstance ui = userInstanceManager.getUserInstance(request);
    IUserPreferencesManager upm = ui.getPreferencesManager();
        LocaleManager localeManager = upm.getUserPreferences().getProfile().getLocaleManager();

        if (localeString != null) {
         
          // build a new Locale[] array from the specified locale
            Locale userLocale = parseLocale(localeString);
            Locale[] locales = new Locale[] { userLocale };
           
            // set this locale in the session
            localeManager.setSessionLocales(locales);
           
            // if the current user is logged in, also update the persisted
            // user locale
            if (!ui.getPerson().isGuest()) {
                try {
                    localeManager.persistUserLocales(new Locale[] { userLocale });
                    upm.getUserLayoutManager().loadUserLayout();
                } catch (Exception e) {
                    throw new PortalException(e);
                }
            }
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

    public GuestUserInstance(IPerson person, GuestUserPreferencesManager preferencesManager, HttpServletRequest request) {
        this.person = person;
       
        // instantiate locale manager (uPortal i18n)
        final String acceptLanguage = request.getHeader("Accept-Language");
        this.localeManager = new LocaleManager(person, acceptLanguage);

        //Use the shared user preferences manager
        final HttpSession session = request.getSession(false);
        final String sessionId = session.getId();
       
View Full Code Here

Examples of org.jasig.portal.i18n.LocaleManager

        if (!person.isGuest()) {
            // Request to change the locale
            final String localesString = request.getParameter(Constants.LOCALES_PARAM);
            if (localesString != null) {
                final UserProfile profile = userPreferences.getProfile();
                final LocaleManager localeManager = profile.getLocaleManager();

                final Locale[] locales = LocaleManager.parseLocales(localesString);
                localeManager.setSessionLocales(locales);
            }
           
            // save processing handled at end to provide persisting of changes
            // if desired.
            final String saveWhat = request.getParameter("uP_save");
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.