[
https://jira.jboss.org/jira/browse/JBPORTAL-1324?page=com.atlassian.jira....
]
Antoine Herzog reopened JBPORTAL-1324:
--------------------------------------
Hello,
the issue have been closed, but the modification is not in the last version.
and seems that there is no way to really define the default portal.
I may have missed something, but this forum post shows that it is still not working.
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170406#...
--------------------------------------------------------------
This modification of the JMX Service is very light, and do not prevent any other way of
configuration (via the XML descriptor etc...).
it is only adding a property to the service : defaultPortalName
and allow it's configuration via the attributes of service descriptor.
and use it in the method that provide the default portal object.
the code is provided on the first comment of this jira.
Many thanks,
Antoine
Multiple portals / custom url : set the default portal name
-----------------------------------------------------------
Key: JBPORTAL-1324
URL:
https://jira.jboss.org/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
Assignee: Thomas Heute
Fix For: 2.6.2 Final, 2.8 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:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira