[
https://jira.jboss.org/jira/browse/JBPORTAL-1324?page=com.atlassian.jira....
]
Antoine Herzog commented on JBPORTAL-1324:
------------------------------------------
Hi Thomas,
The problem is that "portal.defaultObjectName" is not working.
I had looked deeply at the code when I opened the jira. (quite a long time ago...)
And the use of "default" is locked by hard coding in one of the class that is
involved in this process.
the class have a "default" string hard coded into it.
that's why I did this workaround, which is the most clean way I found.
but globally, it is true that it would be much better to have it in the -object.xml
descriptor.
I understand now why my solution (workaround) was not used in the JBP code....
but then, the xml tag must be working to provide the feature.
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