Package org.apache.jetspeed.services.rundata

Examples of org.apache.jetspeed.services.rundata.JetspeedRunData


        {
            return;
        }
       
        // Get the Portlet using the PSML document and the PEID
        JetspeedRunData jdata = (JetspeedRunData)rundata;
        Entry entry = jdata.getProfile().getDocument().getEntryById(peid);
        if ( entry == null )
        {
            logger.warn("Failed to get PEID (" + peid + ") entry for User ("
              + rundata.getUser().getName() + ")");
            return;
        }
        Portlet portlet = PortletFactory.getPortlet(entry);
       
        // Now unset the portlet to minimized
        if (( portlet != null )&&( portlet instanceof PortletState ))
        {
            ((PortletState)portlet).setMinimized( false, rundata );
        }

        // make sure we use the default template
        while (jdata.getCustomized()!=null)
        {
            jdata.setCustomized(null);
        }

        //remove the maximized portlet name - nothing is maximized now
        jdata.getUser().removeTemp("js_peid");

        jdata.setScreenTemplate("Home");
    }
View Full Code Here


        if ( peid == null )
        {
            return;
        }
       
        JetspeedRunData jdata = (JetspeedRunData)rundata;

        // Get the Portlet using the PSML document and the PEID
        Entry entry = jdata.getProfile().getDocument().getEntryById(peid);
        if ( entry == null )
        {
            if (logger.isWarnEnabled())
            {
                logger.warn("Failed to get PEID (" + peid + ") entry for User ("
View Full Code Here

    /**
     * @param rundata The RunData object for the current request
     */
    public void doPerform( RunData rundata ) throws Exception
    {
        JetspeedRunData jdata = (JetspeedRunData)rundata;

        if (jdata.getUser() == null)
        {
            return;
        }
        if(jdata.getProfile() == null)
        {
            return;
        }

        // read some parameters
        String editMediaType = jdata.getParameters().getString ("mtype");
        String resetStack = jdata.getParameters().getString ("reset");
        String peid = jdata.getParameters().getString("js_peid");

        // get the customization state for this page
        SessionState customizationState = jdata.getPageSessionState();

        // this will be the profile we are editing
        Profile profile = null;

        // the "reset" parameter's presence signals the start of customization
        if (    (resetStack != null)
            &&  ((resetStack.equalsIgnoreCase("on")) || (resetStack.equalsIgnoreCase("1"))))
        {
            // clear out any prior customization state
            jdata.cleanupFromCustomization();
        }

        // if we have not yet setup for customization, do so now
        if (jdata.getCustomizedProfile() == null)
        {
            ProfileLocator locator = (ProfileLocator)jdata.getProfile().clone();

            if (editMediaType != null)
            {
                locator.setMediaType(editMediaType);
            }

            // get a profile to edit
            profile = (Profile) Profiler.getProfile(locator).clone();
            jdata.setCustomizedProfile(profile);
        }

        // we are continuing an on-going customization
        else
        {
            // get the profile we are working on
            profile = jdata.getCustomizedProfile();
        }

        // Get js_peid parmameter.
        // If it does not exist, we will customize the root of the profile
        if ( peid == null )
        {
            // use the id of the root set of the profile
            peid = profile.getRootSet().getID();
            jdata.setJs_peid(peid);
        }

        // find the portlet within the profile with this peid %%% isn't there a better way to do this? -ggolden
        Portlet found = null;
        Stack sets = new Stack();
        sets.push(profile.getRootSet());

        while ((found==null) && (sets.size() > 0))
        {
            PortletSet set = (PortletSet)sets.pop();

            if (set.getID().equals(peid))
            {
                found = set;
            }
            else
            {
                Enumeration en = set.getPortlets();
                while((found==null) && en.hasMoreElements())
                {
                    Portlet p = (Portlet)en.nextElement();

                    // unstack the controls to find the real PortletSets
                    Portlet real = p;
                    while (real instanceof PortletControl)
                    {
                        real = ((PortletControl)p).getPortlet();
                    }

                    if (real instanceof PortletSet)
                    {
                        if (real.getID().equals(peid))
                        {
                            found=real;
                        }
                        else
                        {
                            // we'll explore this set afterwards
                            sets.push(real);
                        }
                    }
                    else if (p.getID().equals(peid))
                    {
                        found = p;
                    }
                }
            }
        }

        if (found!=null)
        {
            PortalResource portalResource = new PortalResource(found);
            try
            {
                JetspeedLink jsLink = JetspeedLinkFactory.getInstance(rundata);
                portalResource.setOwner(jsLink.getUserName());
                JetspeedLinkFactory.putInstance(jsLink);
            }
            catch (Exception e)
            {
                logger.warn(e.toString());
                portalResource.setOwner(null);
            }

            if(!JetspeedSecurity.checkPermission((JetspeedUser) jdata.getUser(),
                                                 portalResource,
                                                 JetspeedSecurity.PERMISSION_CUSTOMIZE))
            {
                logger.warn("User " + jdata.getUser().getUserName() + " has no customize permission for portlet with id " + peid);
                jdata.setMessage("Sorry, you have no customize permission for this portlet");
                return;
            }
            jdata.setCustomized(found);
            jdata.setScreenTemplate("Customize");
        }

    }
View Full Code Here

     *
     * @return SKIP_BODY, as it is intended to be a single tag.
     */
    public int doStartTag() throws JspException
    {
        JetspeedRunData data = (JetspeedRunData) pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
       
        try
        {
            ConcreteElement result = null;
            Profile baseProfile = null;
            ProfileLocator baseLocator = Profiler.createLocator();
            int rootType = JetspeedLink.DEFAULT;
            String rootValue = null;
            int elementType = JetspeedLink.DEFAULT;
            String elementValue = null;

            // Create locator to retrieve profile settings
            if (this.psml != null)
            {
               baseLocator.createFromPath(this.psml);
               if (baseLocator.getUser() != null)
               {
                   rootType = JetspeedLink.USER;
                   rootValue = baseLocator.getUserName();
               }
               else if (baseLocator.getRole() != null)
               {
                   rootType = JetspeedLink.ROLE;
                   rootValue = baseLocator.getRoleName();
               }
               else if (baseLocator.getGroup() != null)
               {
                   rootType = JetspeedLink.GROUP;
                   rootValue = baseLocator.getGroupName();
               }
            }
            else
            {
               rootType = JetspeedLink.CURRENT;
               rootValue = "";
               baseProfile = data.getProfile();
               baseLocator.createFromPath(baseProfile.getPath());
            }

            //  Determine search method
            if (baseLocator != null)
            {               
                // search by portlet name
                if (this.name != null)
                {
                    elementType = JetspeedLink.PORTLET_ID_QUERY;
                    elementValue = this.name;
                }
                else if (this.jspeid != null)
                {
                    elementType = JetspeedLink.PORTLET_ID;
                    elementValue = this.jspeid;
                }
                // Build the link
                JetspeedLink link = JetspeedLinkFactory.getInstance(data);
                DynamicURI uri = link.getLink(rootType,
                                              rootValue,
                                              baseLocator.getName(),
                                              elementType,
                                              elementValue,
                                              this.action == null ? "controls.Maximize" : this.action,
                                              null,
                                              baseLocator.getMediaType(),
                                              baseLocator.getLanguage(),
                                              baseLocator.getCountry());
                result = new StringElement(uri.toString());
                JetspeedLinkFactory.putInstance(link);
            }

            // Output the result
            if (result != null)
            {
                pageContext.getOut().print(result);
            }

        }
        catch (Exception e)
        {
            String message = "Error processing name '" + name + "'.";
            logger.error(message, e);
            try
            {
                data.getOut().print("Error processing portlet '" + name + "'. See log for more information.");
            }
            catch (java.io.IOException ioe)
            {
            }
        }
View Full Code Here

            }
        }

        // now, define Jetspeed specific properties, using the customized
        // RunData properties
        JetspeedRunData jdata = null;

        try
        {
            jdata = (JetspeedRunData) data;
        }
        catch (ClassCastException e)
        {
            logger.error("The RunData object does not implement the expected interface, "
                      + "please verify the RunData factory settings");
            return;
        }
        String language = (String) data.getRequest().getParameter("js_language");

        if (null != language)
        {
            user.setPerm("language", language);
        }

        // Get the locale store it in the user object
        CustomLocalizationService locService =
            (CustomLocalizationService) ServiceUtil.getServiceByName(LocalizationService.SERVICE_NAME);
        Locale locale = locService.getLocale(data);
        if (locale == null)
        {
            locale = new Locale(TurbineResources.getString("locale.default.language", "en"),
                                TurbineResources.getString("locale.default.country", "US"));
        }

        data.getUser().setTemp("locale", locale);

        // if a portlet is referenced in the parameters request, store it
        // in the RunData object
        String paramPortlet = jdata.getParameters().getString("js_peid");
        if (paramPortlet != null && paramPortlet.length() > 0)
        {
            jdata.setJs_peid(paramPortlet);
        }

    }
View Full Code Here

            ActionLoader.getInstance().getInstance(
                JetspeedResources.getString(TurbineConstants.ACTION_LOGIN)
                ).doPerform(rundata);

            // Update the profile in rundata - not sure why this is not happening automatically?
            JetspeedRunData jdata = (JetspeedRunData) rundata;
            jdata.setProfile(Profiler.getProfile(jdata));

        }
        catch (Exception e)
        {
            logger.error("Exception", e);
View Full Code Here

    public void doPerform( RunData data ) throws Exception
    {
        JetspeedUser user = (JetspeedUser)data.getUser();

        getACL(data);
        JetspeedRunData jdata = null;
       
        try
        {
            jdata = (JetspeedRunData)data;
        }
        catch (ClassCastException e)
        {
            logger.error("The RunData object does not implement the expected interface, "
                       + "please verify the RunData factory settings", e);
            return;
        }

        Profile newProfile = null;
        Profile currentProfile = null;

        try
        {
            // get the profile and store it in the RunData
            newProfile = Profiler.getProfile(jdata);
            currentProfile = jdata.getProfile();
        }
        catch (Throwable other)
        {
            data.setScreenTemplate(JetspeedResources.getString(TurbineConstants.TEMPLATE_ERROR));
            String message = other.getMessage() != null ? other.getMessage() : other.toString();
            data.setMessage(message);
            data.setStackTrace(org.apache.turbine.util.StringUtils.stackTrace(other), other);

            if (currentProfile == null)
            {
                currentProfile = Profiler.createProfile();
            }
            if (newProfile == null)
            {
                newProfile = Profiler.createProfile();
            }
            if (data.getUser() == null)
            {
                JetspeedUser juser = new FakeJetspeedUser(JetspeedSecurity.getAnonymousUserName(), false);
                data.setUser(juser);
            }
        }


        if ((currentProfile == null)
         || (!currentProfile.equals(newProfile)))
        {
            // the profile changed due to the request parameters,
            // change it in the RunData
            jdata.setProfile(newProfile);
        }
    }
View Full Code Here

*/
public class UpdateAccount extends Action
{
    public void doPerform( RunData rundata ) throws Exception
    {
        JetspeedRunData data = (JetspeedRunData)rundata;

        // check to make sure the user has logged in before accessing this screen
        if ( ! data.getUser().hasLoggedIn() )
        {
            data.setScreenTemplate( JetspeedResources.getString( "services.JspService.screen.error.NotLoggedIn", "Error" ) );
            return;
        }

        String cancelBtn = data.getParameters().getString( "CancelBtn" , "" );
        String username  = data.getParameters().getString( "username" , "" );
        String oldPassword  = JetspeedSecurity.convertPassword(data.getParameters().getString( "old_password" , "" ));
        String password  = JetspeedSecurity.convertPassword(data.getParameters().getString( "password" , "" ));
        String password2 = JetspeedSecurity.convertPassword(data.getParameters().getString( "password_confirm" , "" ));
        String firstname = data.getParameters().getString( "firstname", "" );
        String lastname  = data.getParameters().getString( "lastname" , "" );
        String email     = data.getParameters().getString( "email" , "" );
        boolean userRequestsRememberMe = data.getParameters().getBoolean( "rememberme" , false );

        // Save user input in case there is an error and
        // we have to go back to the EditAccount screen
        Hashtable screenData = new Hashtable();
        screenData.put( "username",  username );
        screenData.put( "firstname", firstname );
        screenData.put( "lastname",  lastname );
        screenData.put( "email",     email );
        data.getRequest().setAttribute( "ScreenDataEditAccount", screenData );

        // CANCEL BUTTON
        //
        // check to see if the Cancel button was pressed.
        // if so, return to the screen we were previously on
        // defined by nextscreen in the EditAccount screen
        if ( cancelBtn.equalsIgnoreCase( "Cancel" ) )
        {
            return;
        }

        // PASSWORD
        //
        // if the fields are empty, then don't do anything to the passwords
        boolean changepass = false;
        if ( password.trim().length() > 0 && password2.trim().length() > 0 )
        {
            changepass = true;
        }
       
        if ( changepass == true && ! password.equals( password2 ) )
        {
            data.setMessage(Localization.getString(rundata, "UPDATEACCOUNT_PWNOTMATCH"));
            backToEditAccount( data, screenData );
            return;
        }
       
        if ( changepass == true && password.equals( oldPassword ) )
        {
            // old password = new passwod, so do not change.
            changepass = false;
        }

            // FIRSTNAME
        //
        // make sure the firstname exists
        if ( firstname.length() == 0 )
        {
            data.setMessage(Localization.getString(rundata, "UPDATEACCOUNT_NOFIRSTNAME"));
            backToEditAccount( data, screenData );
            return;
        }

        // LASTNAME
        //
        // make sure the lastname exists
        if ( lastname.length() == 0 )
        {
            data.setMessage(Localization.getString(rundata, "UPDATEACCOUNT_NOLASTNAME"));
            backToEditAccount( data, screenData );
            return;
        }

        // AUTOMATIC LOGIN
        //
        // if automatic login is enabled, then handle the remember me checkbox
        if ( JetspeedResources.getBoolean("automatic.logon.enable", false) )
        {
          if ( ! userRequestsRememberMe )
          {
            if ( data.getRequest().getCookies() != null &&
                 data.getCookies().getString("username") != null &&
                 data.getCookies().getString("logincookie") != null )
            {
              // remove cookies by re-adding them with zero MaxAge, which deletes them
              Cookie userName = new Cookie("username","");
              Cookie loginCookie = new Cookie("logincookie","");

              String comment = JetspeedResources.getString("automatic.logon.cookie.comment","");
              String domain = JetspeedResources.getString("automatic.logon.cookie.domain");
              String path = JetspeedResources.getString("automatic.logon.cookie.path","/");

              if (domain == null)
              {
                String server = data.getServerName();
                domain = "." + server;
              }

              userName.setMaxAge(0);
              userName.setComment(comment);
              userName.setDomain(domain);
              userName.setPath(path);

              loginCookie.setMaxAge(0);
              loginCookie.setComment(comment);
              loginCookie.setDomain(domain);
              loginCookie.setPath(path);

              data.getResponse().addCookie(userName);
              data.getResponse().addCookie(loginCookie);

              data.getCookies().remove("username");
              data.getCookies().remove("logincookie");
            }
          }
          else
          {
            if ( data.getRequest().getCookies() == null ||
                 !data.getCookies().getString("username","").equals(data.getUser().getUserName()) ||
                 !data.getCookies().getString("logincookie","").equals(data.getUser().getPerm("logincookie")) )
            {
              String loginCookieValue = (String)data.getUser().getPerm("logincookie");
              if (loginCookieValue == null || loginCookieValue.length() == 0)
              {
                loginCookieValue = ""+Math.random();
                data.getUser().setPerm("logincookie",loginCookieValue);
                JetspeedSecurity.saveUser( data.getJetspeedUser() );
              }

              Cookie userName = new Cookie("username",data.getUser().getUserName());
              Cookie loginCookie = new Cookie("logincookie",loginCookieValue);

              int maxage = JetspeedResources.getInt("automatic.logon.cookie.maxage",-1);
              String comment = JetspeedResources.getString("automatic.logon.cookie.comment","");
              String domain = JetspeedResources.getString("automatic.logon.cookie.domain");
              String path = JetspeedResources.getString("automatic.logon.cookie.path","/");

              if (domain == null)
              {
                String server = data.getServerName();
                domain = "." + server;
              }

              userName.setMaxAge(maxage);
              userName.setComment(comment);
              userName.setDomain(domain);
              userName.setPath(path);

              loginCookie.setMaxAge(maxage);
              loginCookie.setComment(comment);
              loginCookie.setDomain(domain);
              loginCookie.setPath(path);

              data.getResponse().addCookie(userName);
              data.getResponse().addCookie(loginCookie);

              data.getCookies().add("username",data.getUser().getUserName());
              data.getCookies().add("logincookie",loginCookieValue);
            }
          }
        }

        // EMAIL
        //
        // make sure the email exists
        if ( email.length() == 0 )
        {
            data.setMessage(Localization.getString(rundata, "UPDATEACCOUNT_NOEMAIL"));
            backToEditAccount( data, screenData );
            return;
        }

        boolean enableMail = JetspeedResources.getBoolean("newuser.confirm.enable", false);

        String currentEmail = (String) data.getUser().getEmail();
        if ( enableMail && ( currentEmail == null || ! currentEmail.equalsIgnoreCase(email) ) )
            {
                //Send confirmation email if different than current
                data.getUser().setEmail( email );
                data.getUser().setConfirmed( GenerateUniqueId.getIdentifier() );
                JetspeedSecurity.saveUser( data.getJetspeedUser() );
                ActionLoader.getInstance().exec(data, "SendConfirmationEmail");
                // add in the username to the parameters because ConfirmRegistration needs it
                data.getParameters().add("username", data.getUser().getUserName() );
                data.setMessage(Localization.getString(rundata, "UPDATEACCOUNT_NEWEMAILCONFIRM"));
                data.setScreenTemplate("ConfirmRegistration");
            }
        else
            {      
                JetspeedSecurity.saveUser( data.getJetspeedUser() );
            }
           
        // update currently logged in information that might have changed
        data.getUser().setFirstName( firstname );
        data.getUser().setLastName( lastname );
        data.getUser().setEmail( email );
        if ( changepass )
        {
            try
            {
              JetspeedSecurity.changePassword(data.getJetspeedUser(),oldPassword, password);
            } catch (JetspeedSecurityException e)
            {
                data.setMessage(e.getMessage());
                backToEditAccount( data, screenData );
                return;
            }
        }

        //allow sub-classes to update additional information
        updateUser(data);

        JetspeedSecurity.saveUser( data.getJetspeedUser() );
        data.setMessage (Localization.getString(rundata, "UPDATEACCOUNT_DONE"));
       
    }
View Full Code Here

     */
    protected void buildNormalContext(VelocityPortlet portlet,
                                      Context context,
                                      RunData rundata) throws Exception
    {
        JetspeedRunData jdata = (JetspeedRunData) rundata;
        SessionState customizationState = jdata.getPageSessionState();
        Profile profile = jdata.getCustomizedProfile();
        String mediaType = profile.getMediaType ();

        // set velocity variable of mediatype (displayed in the customizer menu)
        context.put("mtype", profile.getMediaType());

View Full Code Here

        try
        {
            JetspeedRunDataService runDataService =
               (JetspeedRunDataService)TurbineServices.getInstance()
                   .getService(RunDataService.SERVICE_NAME);
            JetspeedRunData rundata = runDataService.getCurrentRunData();
            Profile profile = Profiler.createProfile();
            profile.setGroup(group);
            profile.setMediaType("html");
            Profiler.createProfile(rundata, profile);
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.services.rundata.JetspeedRunData

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.