Package javax.portlet

Examples of javax.portlet.PortletException


            // TODO: better validation
            String spaceName = name.replace(' ', '_');               
                String templateFolderPath = actionRequest.getPreferences().getValue(SPACE_TEMPLATE, DEFAULT_SPACE_TEMPLATE);              
                if (!pageManager.folderExists(templateFolderPath))
                {
                    throw new PortletException("Space template folder does not exist: " + templateFolderPath);
                }
               
                Folder templateFolder = pageManager.getFolder(templateFolderPath);
                String owner = actionRequest.getUserPrincipal().getName();
                try
                {
                    userManager.getUser(owner);
                }
                catch (SecurityException notFoundEx)
                {
                    throw new PortletException("Space owner is not found: " + owner);
                }
               
                Space space = spacesService.createSpace(spaceName, owner, templateFolder, title, title, description, theme, constraint);
                // redirect
                String path = admin.getPortalURL(actionRequest, actionResponse, space.getPath());
                actionResponse.sendRedirect(path);
          }
          else
          {
                String owner = scrapeParameter(actionRequest, "spaceOwner");
                // FIXME: lookupSpace() can find system spaces only, not user space.
                //        So, what if a system space name is as same as a user space name?
                Space space = spacesService.lookupSpace(name);
               
                if (space == null)
                {
                    space = spacesService.lookupUserSpace(name);
                }
               
                if (space != null)
                {
                space.setDescription(description);
                space.setTitle(title);
                space.setShortTitle(title);
                  space.setTheme(theme);
                 
                  if (constraint.equals(""))
                  {
                    String old = space.getSecurityConstraint();
                    if (old != null)
                    {
                      if (!"".equals(old))
                        space.setSecurityConstraint(constraint);                       
                    }
                     
                  }
                  else
                  {
                    space.setSecurityConstraint(constraint);
                  }
                 
                  if (owner != null && !owner.equals(space.getOwner()))
                  {
                        try
                        {
                            userManager.getUser(owner);
                        }
                        catch (SecurityException notFoundEx)
                        {
                            throw new PortletException("Space owner is not found: " + owner);
                        }
                        space.setOwner(owner);
                  }
                 
                  spacesService.storeSpace(space);
View Full Code Here


    public void init(PortletConfig config) throws PortletException
    {
        super.init(config);
        admin = (PortalAdministration) getPortletContext().getAttribute(
                CommonPortletServices.CPS_PORTAL_ADMINISTRATION);
        if (null == admin) { throw new PortletException(
                "Failed to find the Portal Administration on portlet initialization"); }
        userManager = (UserManager) getPortletContext().getAttribute(
                CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
        if (null == userManager) { throw new PortletException(
                "Failed to find the User Manager on portlet initialization"); }

        // roles
        this.roles = getInitParameterList(config, IP_ROLES);

        // groups
        this.groups = getInitParameterList(config, IP_GROUPS);

        // rules (name,value pairs)
        List names = getInitParameterList(config, IP_RULES_NAMES);
        List values = getInitParameterList(config, IP_RULES_VALUES);
        rules = new HashMap();
        for (int ix = 0; ix < ((names.size() < values.size()) ? names.size()
                : values.size()); ix++)
        {
            rules.put(names.get(ix), values.get(ix));
        }

        this.templateLocation = config.getInitParameter(IP_TEMPLATE_LOCATION);
        if (templateLocation == null)
        {
            templateLocation = "/WEB-INF/view/userreg/";
        }
        templateLocation = getPortletContext().getRealPath(templateLocation);
        this.templateName = config.getInitParameter(IP_TEMPLATE_NAME);
        if (templateName == null)
        {
            templateName = "userRegistrationEmail.vm";
        }
       
        ArrayList roots = new ArrayList(1);
        roots.add(templateLocation);

        try
        {
            templateLocator = new JetspeedTemplateLocator(roots, "email", getPortletContext().getRealPath("/"));
            templateLocator.start();
        }
        catch (FileNotFoundException e)
        {
            throw new PortletException("Could not start the template locator.", e);
        }
       
        // user attributes ?

        this.optionForceEmailsToBeSystemUnique = Boolean.valueOf(
View Full Code Here

            // urls in the content resolve predictably)
            String baseURL = request.getPreferences().getValue("SRC", null);
            String portalBasePath = request.getPreferences().getValue("PORTALPATH", null);
            if ((baseURL == null) || (portalBasePath == null))
            {
                throw new PortletException("Required SRC and PORTALPATH preferences not set");
            }
            if (!baseURL.endsWith("/"))
            {
                baseURL += "/";
            }
            if (!portalBasePath.startsWith("/"))
            {
                portalBasePath = "/"+portalBasePath;
            }       
            if (!portalBasePath.endsWith("/"))
            {
                portalBasePath += "/";
            }       
            // view content page based on portal request URL
            String portalRequestPath = rc.getPath();
            if (!portalRequestPath.startsWith(portalBasePath))
            {
                throw new PortletException("Unable to map portal request path: "+portalRequestPath+" onto portal base path: "+portalBasePath);
            }
            sourceURL = baseURL+portalRequestPath.substring(portalBasePath.length());           
        }

        // get web content
        byte[] content = null;
        try
        {
            // initialize and lock stateful rewriter
            String basePortalPath = rc.getPortalURL().getPageBasePath();
            initializeRewriter(DynamicWebContentRewriter.class);
            ((DynamicWebContentRewriter)getRewriter()).setBasePortalPath(basePortalPath);
       
            // get and rewrite web content
            if (log.isDebugEnabled())
            {
                log.debug("Portal request: "+rc.getPath()+", Web content: "+sourceURL);
            }
            try
            {
                content = doWebContent(sourceURL, sourceParams, sourcePostMethod, request, response);
            }
            catch (Throwable t)
            {
                throw new PortletException("Error retrieveing web content: "+t, t);
            }
        }
        finally
        {
            // unlock stateful rewriter
View Full Code Here

    {
        super.init(config);
        sso = (SSOManager)getPortletContext().getAttribute(CommonPortletServices.CPS_SSO_COMPONENT);
        if (null == sso)
        {
            throw new PortletException("Failed to find the SSO Provider on portlet initialization");
        }
        userManager = (UserManager) getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
        if (null == userManager)
        {
            throw new PortletException("Failed to find the User Manager on portlet initialization");
        }
    }
View Full Code Here

    {
        super.init(config);
        sso = (SSOManager)getPortletContext().getAttribute(CommonPortletServices.CPS_SSO_COMPONENT);
        if (null == sso)
        {
            throw new PortletException("Failed to find the SSO Manager on portlet initialization");
        }
        userManager = (UserManager) getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
        if (null == userManager)
        {
            throw new PortletException("Failed to find the User Manager on portlet initialization");
        }
        groupManager = (GroupManager) getPortletContext().getAttribute(CommonPortletServices.CPS_GROUP_MANAGER_COMPONENT);
        if (null == groupManager)
        {
            throw new PortletException("Failed to find the Group Manager on portlet initialization");
        }       
    }
View Full Code Here

    {
        super.init(config);
        userManager = (UserManager) getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
        if (null == userManager)
        {
            throw new PortletException("Failed to find the User Manager on portlet initialization");
        }
        audit = (AuditActivity)getPortletContext().getAttribute(CommonPortletServices.CPS_AUDIT_ACTIVITY);
        if (null == audit)
        {
            throw new PortletException("Failed to find the Audit Activity on portlet initialization");           
        }
        authorization = (AuthenticationProvider)getPortletContext().getAttribute(CommonPortletServices.CPS_AUTHENTICATION_PROVIDER);
        if (null == authorization)
        {
            throw new PortletException("Failed to find the Authorization Provider on portlet initialization");           
        }
       
        // Read maximum lifetime for authentication cookies.
        String cookie = getInitParameter("cookieLifetime");
        String max = getInitParameter("maxNumberOfAuthenticationFailures");
View Full Code Here

                    PortletMessaging.publish(request, VIEW, views[ix][1]);
                    result = views[ix][1];
                }
                catch (Exception e)
                {
                    throw new PortletException(e);
                }
                break;
            }
        }
        return result;
View Full Code Here

        super.init(config);
        PortletContext context = getPortletContext();               
        registry = (PortletRegistry)context.getAttribute(CommonPortletServices.CPS_REGISTRY_COMPONENT);
        if (null == registry)
        {
            throw new PortletException("Failed to find the Portlet Registry on portlet initialization");
        }       
        searchEngine = (SearchEngine)context.getAttribute(CommonPortletServices.CPS_SEARCH_COMPONENT);
        if (null == searchEngine)
        {
            throw new PortletException("Failed to find the Search Engine on portlet initialization");
        }
        securityAccessController = (SecurityAccessController)context.getAttribute(CommonPortletServices.CPS_SECURITY_ACCESS_CONTROLLER);
        if (null == securityAccessController)
        {
            throw new PortletException("Failed to find the Security Access Controller on portlet initialization");
        }
        profiler = (Profiler)context.getAttribute(CommonPortletServices.CPS_PROFILER_COMPONENT);
        if (null == profiler)
        {
            throw new PortletException("Failed to find the Profiler on portlet initialization");
        }       
        pageLayoutComponent = (PageLayoutComponent)context.getAttribute(CommonPortletServices.CPS_PAGE_LAYOUT_COMPONENT);
        if (null == pageLayoutComponent)
        {
            throw new PortletException("Failed to find the PageLayoutComponent on portlet initialization");
        }       
        preferenceService = (PortletPreferencesProvider)context.getAttribute(CommonPortletServices.CPS_PORTLET_PREFERENCES_PROVIDER);
        if (null == preferenceService)
        {
            throw new PortletException("Failed to find the Prefs Service on portlet initialization");
        }
        rand = new Random( 19580427 );
    }
View Full Code Here

        categories = new ArrayList();
        PortletPreferences prefs = request.getPreferences();
        String cats = prefs.getValue("Categories", null);
        if (cats == null)
        {
            throw new PortletException("No categories defined, please add categories via edit mode.");
        }
        StringTokenizer catTokenizer = new StringTokenizer(cats, ",");
        while (catTokenizer.hasMoreTokens())
        {
            String name = catTokenizer.nextToken().trim();
View Full Code Here

                    preferenceService.storeDefaults(portlet, prefs);                   
                }
            }
            catch (Exception e)
            {
                throw new PortletException("Failed to update portlet", e);
            }
            PortletSession session = request.getPortletSession();
            session.removeAttribute(PORTLETS);
            session.removeAttribute(CATEGORIES);
            actionResponse.setPortletMode(PortletMode.VIEW);
View Full Code Here

TOP

Related Classes of javax.portlet.PortletException

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.