[jboss-jira] [JBoss JIRA] Commented: (JBPORTAL-1324) Multiple portals / custom url : set the default portal name

Antoine Herzog (JIRA) jira-events at lists.jboss.org
Thu Jul 5 05:05:51 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBPORTAL-1324?page=comments#action_12367809 ] 
            
Antoine Herzog commented on JBPORTAL-1324:
------------------------------------------

The default object name property seems to be (working) only for a page in the portlet.

I am quiet sure that it was not working when I did the customization of the factory (jbp2.4.1).
(did some test,... ended with this solution).

I upgraded without looking at all this for 2.6. Of course it works like that.

Sure a better solution is to set it in the portals descriptor file, then the DefaultPortalCommandFactory  is set up with the one defined there.

For what I remember, the setting of default portal name was kind of hard coded to "default" name.

Which is not a bad option... but when the default portal is "your wonderfull portal", marketing wants to have an url with "www.toto.com/.../.../your_wonderfull_portal/..." ;-)

CLASSES AND SERVICE INVOLVED ?
By the way : what are the classes and services involved in the process of reading the xml descriptor files, and setting the portal object definition ?

I may need to add things to this process.
example : define a few "windows always in pages", to avoid put these windows definition in all the pages definition.
inheriting page definition would be the best... but it is not in the JSR.
working at the portal container level would be a more compliant solution, no ?
another solution : using some xml include file, and play with these includes (if this works).
but anyway interested in tips (documentation ?) about this internal portal process .

NAMING SUGGESTION
Also : "default" is not a really helping word.
when searching in source classes and service descriptors for "where all this is coded", default is a word that is everywhere.
using a more specific word would be helpfull. 
avoiding "portal" also.
"defPtal" ? "defaultJBPortal" ? "myPortalName" ?

idem for the url with "host/portal/portal/default"
all this portal is "search impossible".

for my portal, I used :
host/pcr/dc/myportalname
pcr : portal context root
dc : default command

for a general jboss release, I suggest :
pcr => portalCtx
dc => defaultPCommand

ending to url : host/portalCtx/defaultPCommand/defaultJBPortal

more explicit.
ok for newbe that needs to have a nice portal running out of the box
helpfull for the one that want to customize
helpfull for the guy who write the documentation.

loosing the nice : "start with http://localhost:8080/portal" 
to "start with http://localhost:8080/portalCtx" 


> Multiple portals / custom url : set the default portal name
> -----------------------------------------------------------
>
>                 Key: JBPORTAL-1324
>                 URL: http://jira.jboss.com/jira/browse/JBPORTAL-1324
>             Project: JBoss Portal
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>          Components: Portal Core
>         Environment: JBoss Portal 2.4.0 final
>            Reporter: Antoine Herzog
>         Assigned To: Julien Viet
>             Fix For: 2.8 Final, 2.6.1 Final
>
>
> Here the code of the jmx service class
> public class ConfigurableDefaultPortalCommandFactory extends
> 		DefaultPortalCommandFactory {
> 	private static final Log logger = LogFactory
> 			.getLog(ConfigurableDefaultPortalCommandFactory.class);
> 	/**
> 	 * The JMX attribute for default portal name.
> 	 */
> 	private String defaultPortalName;
> 	/**
> 	 * 
> 	 */
> 	public ConfigurableDefaultPortalCommandFactory() {
> 		super();
> 	}
> 	/*
> 	 * (non-Javadoc)
> 	 * 
> 	 * @see org.jboss.portal.core.model.portal.DefaultPortalCommandFactory#doMapping(org.jboss.portal.server.ServerInvocation,
> 	 *      java.lang.String, java.lang.String)
> 	 */
> 	public ControllerCommand doMapping(ServerInvocation invocation,
> 			String portalContextPath, String portalRequestPath) {
> 		// orginal code : ControllerCommand cmd =
> 		// nextFactory.doMapping(invocation,
> 		ControllerCommand cmd = getNextFactory().doMapping(invocation,
> 				portalContextPath, portalRequestPath);
> 		if (cmd == null) {
> 			// orginal code : Context ctx = container.getContext();
> 			Context ctx = getContainer().getContext();
> 			if (ctx == null) {
> 				throw new IllegalStateException(
> 						"Default context does not exist");
> 			}
> 			// orginal code : Portal portal = ctx.getDefaultPortal();
> 			PortalObject portalObject = ctx.getChild(getDefaultPortalName());
> 			if (portalObject == null) {
> 				throw new IllegalStateException(
> 						"PortalObject as Default Portal is not found. Default Portal name is defined to : "
> 								+ getDefaultPortalName());
> 			}
> 			Portal portal = null;
> 			if (portalObject instanceof Portal) {
> 				portal = (Portal) portalObject;
> 			} else {
> 				throw new IllegalStateException(
> 						"Can't find PortalObject with default portal name : "
> 								+ getDefaultPortalName());
> 			}
> 			// if (portal == null) {
> 			// throw new IllegalStateException("Default portal does not exist");
> 			// }
> 			Page page = portal.getDefaultPage();
> 			if (page == null) {
> 				throw new IllegalStateException("Default page does not exist");
> 			}
> 			String handle = page.getId();
> 			cmd = new RenderPageCommand(handle);
> 		}
> 		return cmd;
> 	}
> 	/**
> 	 * The JMX attribute for default portal name.
> 	 * 
> 	 * @return the defaultPortalName
> 	 */
> 	public String getDefaultPortalName() {
> 		return this.defaultPortalName;
> 	}
> 	/**
> 	 * The JMX attribute for default portal name.
> 	 * 
> 	 * @param defaultPortalName
> 	 *            the defaultPortalName to set
> 	 */
> 	public void setDefaultPortalName(String defaultPortalName) {
> 		this.defaultPortalName = defaultPortalName;
> 	}
> 	/**
> 	 * Call the super method first, then check the {@link #defaultPortalName} is
> 	 * not null and not "". Throw an exception if so.
> 	 */
> 	protected void createService() throws Exception {
> 		super.createService();
> 		if (getDefaultPortalName() == null
> 				|| getDefaultPortalName().compareTo("") == 0) {
> 			throw new Exception(
> 					"The attribute DefaultPortalName can't be null or empty string. Set it in the JMX service descriptor.");
> 		}
> 	}
> 	/*
> 	 * (non-Javadoc)
> 	 * 
> 	 * @see org.jboss.system.ServiceMBeanSupport#startService()
> 	 */
> 	@Override
> 	protected void startService() throws Exception {
> 		logger.info(this.getName() + " service starting. Default portal name : getDefaultPortalName() = "+getDefaultPortalName());
> 		super.startService();
> 	}
> 	/*
> 	 * (non-Javadoc)
> 	 * 
> 	 * @see org.jboss.system.ServiceMBeanSupport#stopService()
> 	 */
> 	@Override
> 	protected void stopService() throws Exception {
> 		super.stopService();
> 		logger.info(this.getName() + " service stoping.");
> 	}
> }
> And add the attribute in the jmx service descriptor :
> <!-- Default portal name : "default" is the default for native jboss portal (downloaded version). -->
> <attribute name="DefaultPortalName">MyDefaultPortalNameHere</attribute>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list