0

When i create a user page using gatein public api i got an org.gatein.api.EntityNotFoundException exception. Here follows my code for creating user page


User user = PortalRequest.getInstance().getUser();

 Portal portal = PortalRequest.getInstance().getPortal();

f(portal.getPage(new PageId(user, pageName))==null){

Page newpage = portal.createPage(new PageId(user, pageName));// Here i got the exception

}

Here follows the stack trace of exception


 org.gatein.api.EntityNotFoundException: Site Site.Id[type=dashboard, name=supervisor] doesn't exist

    at org.gatein.api.PortalImpl.createPage(PortalImpl.java:271) [exo.portal.component.api-3.6.0.Final.jar:3.6.0.Final]

    at com.radiant.cisms.view.bean.DynamicDashBoardBean.createUserSpecificPage(DynamicDashBoardBean.java:146)

    at com.radiant.cisms.view.bean.DynamicDashBoardBean.saveNewPortlets(DynamicDashBoardBean.java:115)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_45]

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_45]

    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_45]

    at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)

    ... 121 more

Also here i am attaching my portal-configuration.xml for reference


<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
    xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">

    <external-component-plugins>
        <!-- The full qualified name of the UserPortalConfigService -->
        <target-component>org.exoplatform.portal.config.UserPortalConfigService
        </target-component>
        <component-plugin>
            <name>new.portal.config.user.listener</name>
            <set-method>initListener</set-method>
            <type>org.exoplatform.portal.config.NewPortalConfigListener</type>
            <description>this listener init the portal configuration
            </description>
            <init-params>
                <value-param>
                    <name>default.portal</name>
                    <description>The default portal for checking db is empty or not
                    </description>
                    <value>MPortal</value>
                </value-param>
                <value-param> <
                   <name>override</name>
                   <description>The flag parameter to decide if portal metadata is overriden on restarting server</description>
                   <value>true</value>
                </value-param>
                <object-param>
                    <name>portal.configuration</name>
                    <description>description</description>
                    <object type="org.exoplatform.portal.config.NewPortalConfig">
                        <field name="predefinedOwner">
                            <collection type="java.util.HashSet">
                                <value>
                                    <string>classic</string>
                                </value>
                                <value>
                                    <string>MPortal1</string>
                                </value>
                                <value>
                                    <string>MPortalForgotPassword</string>
                                </value>
                                <value>
                                    <string>MPortalWizard</string>
                                </value>
                               <value>
                                    <string>MPortalEndUser</string>
                                </value>
                            </collection>
                        </field>
                        <field name="ownerType">
                            <string>portal</string>
                        </field>
                        <field name="templateLocation">
                            <string>war:/conf/gtec/</string>
                        </field>
                        <field name="importMode"> 
                             <string>overwrite</string>
                        </field>
                    </object>
                </object-param>
            </init-params>
        </component-plugin>
    </external-component-plugins>

</configuration>

Can you help me to give a reason about this issue?

Anish Antony
  • 875
  • 3
  • 17
  • 35
  • I guess you use GateIn 3.6 ? I tested your snippet of code in a basic portlet, and my page has been successfully created. Can you try with a fresh GateIn ? Did you add some custom configuration that could impact users' pages ? – Thomas Nov 25 '13 at 08:13
  • @Thomas I am using fresh GateIn. But i do it in my own portal applcation. But i can create page when `SiteKey` instead of `user` like follows `portal.createPage(new PageId("newPortal", "myPage"));` – Anish Antony Nov 25 '13 at 08:55
  • The exception says that the dashboard of your user has not been created. The dashboard is created when the user is created, by the listener org.exoplatform.portal.config.UserPortalConfigListener declared in the file portal.war/WEB-INF/conf/portal/portal-configuration.xml. Did you remove/overwrite this configuration ? – Thomas Nov 25 '13 at 09:31
  • Ya i edited it you can find out my portal-configuration.xml from above. Is there is any issue on my portal-configuration.xml? – Anish Antony Nov 25 '13 at 12:02
  • @Thomas I resolved the issue in one level. I can create user page for users who are under `predefinedOwner` tag in portal-configuration.xml. But i cant create user portal for users which i created programatically (I think because they are not in `predefindOwner` category). How can i add users to `predefindOwner` category programatically? – Anish Antony Nov 25 '13 at 13:00
  • How do you create your users programmatically ? Do you enable the broadcast (which calls the listener I mentionned above) ? – Thomas Nov 25 '13 at 16:02
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/41926/discussion-between-anish-antony-and-thomas) – Anish Antony Nov 26 '13 at 05:17

1 Answers1

3

The error says that the dashboard of your user does not exist. The dashboard is created automatically when the user is created, thanks to the listener org.exoplatform.portal.config.UserPortalConfigListener declared in the file portal.war/WEB-INF/conf/portal/portal-configuration.xml. So I guess in your case, the listener has not been triggred when the user has been created.

If you create your users programmatically, you have to be sure that the broadcast option is enabled (which will triggered the listeners), by setting the second argument of the createUser method to true : orgService.getUserHandler().createUser(user, true);

Thomas
  • 541
  • 2
  • 10