Uploaded image for project: 'JBoss Portal'
  1. JBoss Portal
  2. JBPORTAL-1324

Multiple portals / custom url : set the default portal name

    Details

    • Type: Feature Request
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2.6.2 Final, 2.8 Final
    • Component/s: Portal Core
    • Labels:
      None
    • Environment:

      JBoss Portal 2.4.0 final

      Description

      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
        Unknown macro: { 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>

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                theute Thomas Heute
                Reporter:
                antoine_h Antoine Herzog
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: