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

Antoine Herzog (JIRA) jira-events at lists.jboss.org
Wed Mar 21 15:13:56 EDT 2007


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




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