Subsite Handling der Startseite verbessert, Fehlerkorrekturen, NPE abfangen, Nachführen Änderungen in ccm-sci-bundle.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1334 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2011-12-13 10:18:08 +00:00
parent b48d60cd60
commit 7248a226db
11 changed files with 211 additions and 115 deletions

View File

@ -42,7 +42,7 @@ com.arsdigita.cms.category_authoring_add_form=com.arsdigita.aplaws.ui.ItemCatego
com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp
com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp
com.arsdigita.cms.default_template_resolver_class=com.arsdigita.london.subsite.dispatcher.SubsiteItemTemplateResolver com.arsdigita.cms.default_template_resolver_class=com.arsdigita.subsite.dispatcher.SubsiteItemTemplateResolver
; Configure dhtml editor for use in cms content-center ; Configure dhtml editor for use in cms content-center
; Xinha is default and should work out of the box ; Xinha is default and should work out of the box

View File

@ -38,12 +38,12 @@
<!-- Applications --> <!-- Applications -->
<ccm:application name="ccm-navigation"/> <ccm:application name="ccm-navigation"/>
<ccm:application name="ccm-portalworkspace"/> <ccm:application name="ccm-portalworkspace"/>
<ccm:application name="ccm-subsite"/>
<ccm:application name="ccm-themedirector"/> <ccm:application name="ccm-themedirector"/>
<!-- LDN extension --> <!-- LDN extension -->
<ccm:application name="ccm-ldn-search"/> <ccm:application name="ccm-ldn-search"/>
<ccm:application name="ccm-ldn-shortcuts"/> <ccm:application name="ccm-ldn-shortcuts"/>
<ccm:application name="ccm-ldn-subsite"/>
<ccm:application name="ccm-ldn-terms"/> <ccm:application name="ccm-ldn-terms"/>
<ccm:application name="ccm-ldn-util"/> <ccm:application name="ccm-ldn-util"/>

View File

@ -42,7 +42,7 @@ com.arsdigita.cms.category_authoring_add_form=com.arsdigita.aplaws.ui.ItemCatego
com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp
com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp
com.arsdigita.cms.default_template_resolver_class=com.arsdigita.london.subsite.dispatcher.SubsiteItemTemplateResolver com.arsdigita.cms.default_template_resolver_class=com.arsdigita.subsite.dispatcher.SubsiteItemTemplateResolver
; Configure dhtml editor for use in cms content-center ; Configure dhtml editor for use in cms content-center
; Xinha is default and should work out of the box ; Xinha is default and should work out of the box

View File

@ -38,12 +38,12 @@
<!-- Applications --> <!-- Applications -->
<ccm:application name="ccm-navigation"/> <ccm:application name="ccm-navigation"/>
<ccm:application name="ccm-portalworkspace"/> <ccm:application name="ccm-portalworkspace"/>
<ccm:application name="ccm-subsite"/>
<ccm:application name="ccm-themedirector"/> <ccm:application name="ccm-themedirector"/>
<!-- LDN extension --> <!-- LDN extension -->
<ccm:application name="ccm-ldn-search"/> <ccm:application name="ccm-ldn-search"/>
<ccm:application name="ccm-ldn-shortcuts"/> <ccm:application name="ccm-ldn-shortcuts"/>
<ccm:application name="ccm-ldn-subsite"/>
<ccm:application name="ccm-ldn-terms"/> <ccm:application name="ccm-ldn-terms"/>
<ccm:application name="ccm-ldn-util"/> <ccm:application name="ccm-ldn-util"/>

View File

@ -38,7 +38,7 @@
<filter> <filter>
<filter-name>subsite</filter-name> <filter-name>subsite</filter-name>
<filter-class>com.arsdigita.london.subsite.SubsiteFilter</filter-class> <filter-class>com.arsdigita.subsite.SubsiteFilter</filter-class>
</filter> </filter>
<!-- NOT USED HERE <!-- NOT USED HERE
@ -271,16 +271,16 @@
</init-param> </init-param>
</servlet> </servlet>
<!-- module ccm-ldn-subsite - servlet declarations BEGIN --> <!-- module ccm-subsite - servlet declarations BEGIN -->
<servlet> <servlet>
<servlet-name>subsite-files</servlet-name> <servlet-name>subsite-files</servlet-name>
<servlet-class>com.arsdigita.web.ApplicationFileServlet</servlet-class> <servlet-class>com.arsdigita.web.ApplicationFileServlet</servlet-class>
<init-param> <init-param>
<param-name>template-path</param-name> <param-name>template-path</param-name>
<param-value>/templates/ccm-ldn-subsite</param-value> <param-value>/templates/ccm-subsite</param-value>
</init-param> </init-param>
</servlet> </servlet>
<!-- module ccm-ldn-subsite - servlet declarations END --> <!-- module ccm-subsite - servlet declarations END -->
<!-- module ccm-ldn-terms - servlet declarations BEGIN --> <!-- module ccm-ldn-terms - servlet declarations BEGIN -->
<servlet> <servlet>
@ -372,12 +372,12 @@
<url-pattern>/ccm-ldn-shortcuts/files/*</url-pattern> <url-pattern>/ccm-ldn-shortcuts/files/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- module ccm-ldn-subsite - servlet mappings BEGIN --> <!-- module ccm-subsite - servlet mappings BEGIN -->
<servlet-mapping> <servlet-mapping>
<servlet-name>subsite-files</servlet-name> <servlet-name>subsite-files</servlet-name>
<url-pattern>/ccm-ldn-subsite/files/*</url-pattern> <url-pattern>/ccm-subsite/files/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- module ccm-ldn-subsite - servlet mappings END --> <!-- module ccm-subsite - servlet mappings END -->
<!-- module ccm-ldn-terms - servlet mappings BEGIN --> <!-- module ccm-ldn-terms - servlet mappings BEGIN -->
<servlet-mapping> <servlet-mapping>

View File

@ -44,7 +44,7 @@ com.arsdigita.cms.category_authoring_add_form=com.arsdigita.aplaws.ui.ItemCatego
com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp
com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp
com.arsdigita.cms.default_template_resolver_class=com.arsdigita.london.subsite.dispatcher.SubsiteItemTemplateResolver com.arsdigita.cms.default_template_resolver_class=com.arsdigita.subsite.dispatcher.SubsiteItemTemplateResolver
; Configure dhtml editor for use in cms content-center ; Configure dhtml editor for use in cms content-center
; Xinha is default and should work out of the box ; Xinha is default and should work out of the box

View File

@ -66,6 +66,7 @@
<!-- <ccm:application name="ccm-forum"/> --> <!-- <ccm:application name="ccm-forum"/> -->
<ccm:application name="ccm-navigation"/> <ccm:application name="ccm-navigation"/>
<ccm:application name="ccm-portalworkspace"/> <ccm:application name="ccm-portalworkspace"/>
<ccm:application name="ccm-subsite"/>
<ccm:application name="ccm-themedirector"/> <ccm:application name="ccm-themedirector"/>
<!-- <ccm:application name="ccm-simplesurvey"/> --> <!-- <ccm:application name="ccm-simplesurvey"/> -->
<ccm:application name="ccm-user-preferences"/> <ccm:application name="ccm-user-preferences"/>
@ -83,7 +84,6 @@
<ccm:application name="ccm-ldn-rss"/> <ccm:application name="ccm-ldn-rss"/>
<ccm:application name="ccm-ldn-search"/> <ccm:application name="ccm-ldn-search"/>
<ccm:application name="ccm-ldn-shortcuts"/> <ccm:application name="ccm-ldn-shortcuts"/>
<ccm:application name="ccm-ldn-subsite"/>
<ccm:application name="ccm-ldn-terms"/> <ccm:application name="ccm-ldn-terms"/>
<ccm:application name="ccm-ldn-util"/> <ccm:application name="ccm-ldn-util"/>

View File

@ -44,7 +44,7 @@ com.arsdigita.cms.category_authoring_add_form=com.arsdigita.aplaws.ui.ItemCatego
com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp com.arsdigita.cms.default_folder_template_path=/default/aplaws-folder.jsp
com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp com.arsdigita.cms.default_item_template_path=/default/aplaws-item.jsp
com.arsdigita.cms.default_template_resolver_class=com.arsdigita.london.subsite.dispatcher.SubsiteItemTemplateResolver com.arsdigita.cms.default_template_resolver_class=com.arsdigita.subsite.dispatcher.SubsiteItemTemplateResolver
; Configure dhtml editor for use in cms content-center ; Configure dhtml editor for use in cms content-center
; Xinha is default and should work out of the box ; Xinha is default and should work out of the box

View File

@ -49,6 +49,7 @@
<ccm:application name="ccm-navigation"/> <ccm:application name="ccm-navigation"/>
<ccm:application name="ccm-portalworkspace"/> <ccm:application name="ccm-portalworkspace"/>
<ccm:application name="ccm-simplesurvey"/> <ccm:application name="ccm-simplesurvey"/>
<ccm:application name="ccm-subsite"/>
<ccm:application name="ccm-themedirector"/> <ccm:application name="ccm-themedirector"/>
<ccm:application name="ccm-user-preferences"/> <ccm:application name="ccm-user-preferences"/>
@ -57,7 +58,6 @@
<ccm:application name="ccm-ldn-rss"/> <ccm:application name="ccm-ldn-rss"/>
<ccm:application name="ccm-ldn-search"/> <ccm:application name="ccm-ldn-search"/>
<ccm:application name="ccm-ldn-shortcuts"/> <ccm:application name="ccm-ldn-shortcuts"/>
<ccm:application name="ccm-ldn-subsite"/>
<ccm:application name="ccm-ldn-terms"/> <ccm:application name="ccm-ldn-terms"/>
<ccm:application name="ccm-ldn-util"/> <ccm:application name="ccm-ldn-util"/>

View File

@ -23,6 +23,7 @@ import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.ClassParameter; import com.arsdigita.util.parameter.ClassParameter;
import com.arsdigita.util.parameter.Parameter; import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.ResourceParameter; import com.arsdigita.util.parameter.ResourceParameter;
import com.arsdigita.util.parameter.StringArrayParameter;
import com.arsdigita.util.parameter.StringParameter; import com.arsdigita.util.parameter.StringParameter;
import com.arsdigita.london.util.ui.ApplicationCategoryPicker; import com.arsdigita.london.util.ui.ApplicationCategoryPicker;
@ -80,6 +81,18 @@ public class SubsiteConfig extends AbstractConfig {
StringParameter("com.arsdigita.subsite.front_page_application", StringParameter("com.arsdigita.subsite.front_page_application",
Parameter.REQUIRED, Parameter.REQUIRED,
"com.arsdigita.portalworkspace.Workspace"); "com.arsdigita.portalworkspace.Workspace");
/** Array of class name of application types, which are usable as front page
* application for a subsite and whose instances are to be included in a
* selection box to choose a custom front page appplication for a specific
* subsite.
*/
private Parameter m_frontPageApplicationTypes= new
StringArrayParameter("com.arsdigita.subsite.front_page_application",
Parameter.REQUIRED, new String[] {
"com.arsdigita.navigation.Navigation",
"com.arsdigita.portalworkspace.Workspace",
"com.arsdigita.portalserver.Portalsite"
});
/** /**
* *
@ -105,6 +118,7 @@ public class SubsiteConfig extends AbstractConfig {
register(m_adapters); register(m_adapters);
register(m_frontPageApplicationTypeParameter); register(m_frontPageApplicationTypeParameter);
register(m_frontPageApplicationTypes);
register(m_frontPageParentURLParameter); register(m_frontPageParentURLParameter);
register(m_rootCategoryPicker); register(m_rootCategoryPicker);
@ -123,6 +137,14 @@ public class SubsiteConfig extends AbstractConfig {
return (String)get(m_frontPageApplicationTypeParameter); return (String)get(m_frontPageApplicationTypeParameter);
} }
/**
*
* @return
*/
public String[] getFrontPageApplicationTypes() {
return (String[])get(m_frontPageApplicationTypes);
}
public String getFrontPageParentURL() { public String getFrontPageParentURL() {
return (String)get(m_frontPageParentURLParameter); return (String)get(m_frontPageParentURLParameter);
} }

View File

@ -25,7 +25,6 @@ import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.RadioGroup;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.Widget; import com.arsdigita.bebop.form.Widget;
import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.event.PrintListener;
@ -43,48 +42,63 @@ import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.ParameterData; import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.london.util.ui.CategoryPicker; import com.arsdigita.london.util.ui.CategoryPicker;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.subsite.Site; import com.arsdigita.subsite.Site;
import com.arsdigita.subsite.Subsite; import com.arsdigita.subsite.Subsite;
import com.arsdigita.ui.UI;
import com.arsdigita.util.StringUtils; import com.arsdigita.util.StringUtils;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.util.Classes; import com.arsdigita.util.Classes;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
import com.arsdigita.web.ApplicationType; import com.arsdigita.web.ApplicationCollection;
import java.math.BigDecimal;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger;
/** /**
* Class creates the administration input form. * Class creates the administration input form.
* *
* Used by ControlCenterPanel to construct the 'create new site' and
* 'edit existing site' input forms.
*/ */
public class SiteForm extends Form { public class SiteForm extends Form {
/** A logger instance. */
private static final Logger s_log = Logger.getLogger(SiteForm.class);
private SiteSelectionModel m_site; private SiteSelectionModel m_site;
private BigDecimal siteDefaultRootPageID;
/** Input field subsite title */ /** Input field subsite title */
private TextField m_title; private TextField m_title;
private TextField m_hostname; private TextField m_hostname;
private TextArea m_description; private TextArea m_description;
private RadioGroup m_customHomepage; private SingleSelect m_customFrontpageApp;
private TextField m_customHomepage_url;
private TextField m_styleDir; private TextField m_styleDir;
private CategoryPicker m_rootCategory; private CategoryPicker m_rootCategory;
private SingleSelect m_themes; private SingleSelect m_themes;
private SaveCancelSection m_buttons; private SaveCancelSection m_buttons;
private final static String DEFAULT_APP = "DEFAULT_APP";
private final static String DEFAULT_APP_LABEL = "Site Wide Default ";
private final static String DEFAULT_STYLE = "DEFAULT_STYLE"; private final static String DEFAULT_STYLE = "DEFAULT_STYLE";
private final static String DEFAULT_STYLE_LABEL = "Site Wide Default"; private final static String DEFAULT_STYLE_LABEL = "Site Wide Default ";
private final static String OTHER_STYLE = "OTHER_STYLE"; private final static String OTHER_STYLE = "OTHER_STYLE";
private final static String OTHER_STYLE_LABEL = "Other (type in box below)"; private final static String OTHER_STYLE_LABEL = "Other (type in box below)";
/** /**
* Constructor create input widgets and adds them to form. * Constructor create input widgets and adds them to form.
* *
@ -98,6 +112,11 @@ public class SiteForm extends Form {
setRedirecting(true); setRedirecting(true);
m_site = site; m_site = site;
String defAppPath = UI.getRootPageURL() ;
s_log.debug("defAppPath is: " + defAppPath );
siteDefaultRootPageID =
Application.retrieveApplicationForPath(defAppPath )
.getID();
/* Setup text input field for subsite title property */ /* Setup text input field for subsite title property */
m_title = new TextField(new StringParameter("title")); m_title = new TextField(new StringParameter("title"));
@ -107,6 +126,7 @@ public class SiteForm extends Form {
m_title.setSize(40); m_title.setSize(40);
add(m_title); // adds title input field to form add(m_title); // adds title input field to form
/* Setup text input field for hostname property */ /* Setup text input field for hostname property */
m_hostname = new TextField(new StringParameter("hostname")); m_hostname = new TextField(new StringParameter("hostname"));
m_hostname.addValidationListener(new NotNullValidationListener()); m_hostname.addValidationListener(new NotNullValidationListener());
@ -118,6 +138,7 @@ public class SiteForm extends Form {
); );
add(m_hostname); // adds hostname input field to form add(m_hostname); // adds hostname input field to form
/* Setup text input area for description property */ /* Setup text input area for description property */
m_description = new TextArea(new StringParameter("description")); m_description = new TextArea(new StringParameter("description"));
m_description.addValidationListener(new NotNullValidationListener()); m_description.addValidationListener(new NotNullValidationListener());
@ -129,49 +150,30 @@ public class SiteForm extends Form {
); );
add(m_description); // adds description input field to form add(m_description); // adds description input field to form
/* Setup Radio selection group for subsite start page (front page) */
m_customHomepage = new RadioGroup("customHome");
m_customHomepage.addOption(new Option(Boolean.FALSE.toString(),
"Use main site homepage"));
m_customHomepage.addOption(new Option(Boolean.TRUE.toString(),
"Create custom homepage"));
m_customHomepage.addValidationListener(new NotNullValidationListener());
m_customHomepage.setHint(
"Select to create a custom homepage for the subsite"
);
try {
m_customHomepage.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
RadioGroup target = (RadioGroup)e.getTarget();
if (m_site.isSelected(e.getPageState())) {
target.setReadOnly();
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("cannot happen", ex);
}
add(m_customHomepage); // adds Radio group start page to form
/* Setup text inpout field for subsite start page (front page) */ /* Setup selection box for subsite start page (front page) Application
m_customHomepage_url = new TextField( * by URL */
new StringParameter("customHomepage_url")); m_customFrontpageApp = new SingleSelect(
m_customHomepage_url.setMetaDataAttribute("title", new StringParameter("customFrontpageApp"));
"Front Page name (url)"); m_customFrontpageApp.setMetaDataAttribute("title",
m_customHomepage_url.setSize(40); "Front Page (url)");
m_customHomepage_url.setHint( // m_customFrontpageApp.setSize(40);
"Enter the name of the custom homepage, i.e. the last part of url. " + m_customFrontpageApp.setHint(
" " "Select the name (url) of the subsite custom homepage");
); try {
add(m_customHomepage_url); // adds inputfield start page to form m_customFrontpageApp.addPrintListener(new FrontpageAppListener());
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("This cannot happen", ex);
}
add(m_customFrontpageApp); // adds selectfield start page to form
/* Setup selection box for themes */ /* Setup selection box for themes */
m_themes = new SingleSelect(new StringParameter("selectStyleDir")); m_themes = new SingleSelect(new StringParameter("selectStyleDir"));
m_themes.setMetaDataAttribute("title", "XSLT Directory"); m_themes.setMetaDataAttribute("title", "XSLT Directory");
m_themes.setHint("Select an existing theme from the list, " + m_themes.setHint("Select an existing theme from the list, select" +
"select 'Other' to type something below or " + " 'Other' to type something below or select" +
"select 'Site Wide Default' to get the default " + " 'Site Wide Default' to get the default themes." );
"themes.");
try { try {
m_themes.addPrintListener(new ThemesListener()); m_themes.addPrintListener(new ThemesListener());
} catch (TooManyListenersException ex) { } catch (TooManyListenersException ex) {
@ -179,21 +181,21 @@ public class SiteForm extends Form {
} }
add(m_themes); // adds themes selection box to form add(m_themes); // adds themes selection box to form
/* Setup text input field to manually enter a style direcotry */ /* Setup text input field to manually enter a style direcotry */
m_styleDir = new TextField(new StringParameter("styleDir")); m_styleDir = new TextField(new StringParameter("styleDir"));
m_styleDir.setMetaDataAttribute("title", "XSLT Directory (Other)"); m_styleDir.setMetaDataAttribute("title", "XSLT Directory (Other)");
m_styleDir.setSize(40); m_styleDir.setSize(40);
m_styleDir.setHint( m_styleDir.setHint( "Enter the directory for the custom XSLT styles, "
"Enter the directory for the custom XSLT styles, " + +"or leave blank for the default styling." );
"or leave blank for the default styling"
);
add(m_styleDir); // adds inputfield style dir to form add(m_styleDir); // adds inputfield style dir to form
/* Setup selection box for cagtegory domain */ /* Setup selection box for cagtegory domain */
m_rootCategory = (CategoryPicker)Classes.newInstance( m_rootCategory = (CategoryPicker)Classes.newInstance(
Subsite.getConfig().getRootCategoryPicker(), Subsite.getConfig().getRootCategoryPicker(),
new Class[] { String.class }, new Class[] { String.class },
new Object[] { "rootCategory" }); new Object[] { "rootCategory" });
if (m_rootCategory instanceof Widget) { if (m_rootCategory instanceof Widget) {
((Widget)m_rootCategory) ((Widget)m_rootCategory)
.setMetaDataAttribute("title", "Root category"); .setMetaDataAttribute("title", "Root category");
@ -202,11 +204,13 @@ public class SiteForm extends Form {
} }
add(m_rootCategory); // adds domain category selection box to form add(m_rootCategory); // adds domain category selection box to form
m_buttons = new SaveCancelSection(); m_buttons = new SaveCancelSection();
m_buttons.getSaveButton().setHint("Save the details in the form"); m_buttons.getSaveButton().setHint("Save the details in the form");
m_buttons.getCancelButton().setHint("Abort changes & reset the form"); m_buttons.getCancelButton().setHint("Abort changes & reset the form");
add(m_buttons); add(m_buttons);
addSubmissionListener(new SiteSubmissionListener()); addSubmissionListener(new SiteSubmissionListener());
addProcessListener(new SiteProcessListener()); addProcessListener(new SiteProcessListener());
addInitListener(new SiteInitListener()); addInitListener(new SiteInitListener());
@ -229,9 +233,10 @@ public class SiteForm extends Form {
} }
/** /**
* * Validate the subsite form user input.
*/ */
private class SiteValidationListener implements FormValidationListener { private class SiteValidationListener implements FormValidationListener {
public void validate(FormSectionEvent e) { public void validate(FormSectionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
if (!m_buttons.getCancelButton().isSelected(state)) { if (!m_buttons.getCancelButton().isSelected(state)) {
@ -262,12 +267,26 @@ public class SiteForm extends Form {
OTHER_STYLE_LABEL + "'"); OTHER_STYLE_LABEL + "'");
} }
} }
}
} /* Check whether a valid Root category has been selected. The
* default entry "-- pick one--" provides a null String
* ( null pointer exception). */
try {
Category testExist = m_rootCategory.getCategory(state);
String test = testExist.getDefaultDomainClass();
}
catch (Exception ex) {
data.addError(
"No valid category selected. Check category selection!");
}
} // End if (!m_buttons ...)
} // End validate(FormSectionEvent e)
} }
/** /**
* * Checks whether hostname is alreafy in use.
*/ */
private class HostNameValidationListener implements ParameterListener { private class HostNameValidationListener implements ParameterListener {
public void validate(ParameterEvent e) { public void validate(ParameterEvent e) {
@ -294,26 +313,42 @@ public class SiteForm extends Form {
} }
/** /**
* * Initializes the form.
* (when a new input form is requested by user either by editing an
* existing subsite or by creating a new one).
*/ */
private class SiteInitListener implements FormInitListener { private class SiteInitListener implements FormInitListener {
public void init(FormSectionEvent e) public void init(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
Site site = m_site.getSelectedSite(state); Site site = m_site.getSelectedSite(state);
if (site == null) { if (site == null) {
m_title.setValue(state, null); m_title.setValue(state, null);
m_description.setValue(state, null);
m_hostname.setValue(state, null); m_hostname.setValue(state, null);
m_description.setValue(state, null);
m_customFrontpageApp.setValue(state, DEFAULT_APP);
m_styleDir.setValue(state, null); m_styleDir.setValue(state, null);
m_themes.setValue(state, DEFAULT_STYLE); m_themes.setValue(state, DEFAULT_STYLE);
m_rootCategory.setCategory(state, null); m_rootCategory.setCategory(state, null);
} else { } else {
Category root = site.getRootCategory(); m_title.setValue(state, site.getTitle());
String styleURL = site.getStyleDirectory(); m_hostname.setValue(state, site.getHostname());
m_description.setValue(state, site.getDescription());
// BigDecimal siteDefaultRootPageID
BigDecimal currentFrontpageID = site.getFrontPage().getID();
s_log.debug(" Site default frontpage is: "+siteDefaultRootPageID
+", Current frontpage is: "+currentFrontpageID) ;
m_customFrontpageApp.setValue(
state,
currentFrontpageID == siteDefaultRootPageID ?
DEFAULT_APP : currentFrontpageID.toString() );
String styleURL = site.getStyleDirectory();
// if the value is in the config map, then styleDir is // if the value is in the config map, then styleDir is
// empty and themeDir gets the value. Otherwise, if the // empty and themeDir gets the value. Otherwise, if the
// value is null, themeDir gets DEFAULT and styleDir is // value is null, themeDir gets DEFAULT and styleDir is
@ -332,20 +367,11 @@ public class SiteForm extends Form {
styleDir = styleURL; styleDir = styleURL;
} }
} }
m_title.setValue(state, site.getTitle());
m_description.setValue(state, site.getDescription());
m_hostname.setValue(state, site.getHostname());
m_styleDir.setValue(state, styleDir); m_styleDir.setValue(state, styleDir);
m_themes.setValue(state, themeDir); m_themes.setValue(state, themeDir);
m_rootCategory.setCategory(state, root);
m_customHomepage.setValue( Category root = site.getRootCategory();
state, m_rootCategory.setCategory(state, root);
site.getFrontPage().getPrimaryURL()
.equals(Subsite.getConfig().getFrontPageParentURL()) ?
Boolean.FALSE.toString() :
Boolean.TRUE.toString());
} }
} }
} }
@ -357,11 +383,13 @@ public class SiteForm extends Form {
public void process(FormSectionEvent e) public void process(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
Category root = m_rootCategory.getCategory(state); Category root = m_rootCategory.getCategory(state);
Site site = m_site.getSelectedSite(state); Site site = m_site.getSelectedSite(state);
String style = (String)m_styleDir.getValue(state); String style = (String)m_styleDir.getValue(state);
String theme = (String)m_themes.getValue(state); String theme = (String)m_themes.getValue(state);
if (style != null) { if (style != null) {
@ -373,39 +401,41 @@ public class SiteForm extends Form {
styleDir = theme; styleDir = theme;
} }
} }
/* Pre-process selected frontpage application: retrieve application */
String subsiteSelectedFrontpage = (String) m_customFrontpageApp
.getValue(state);
s_log.debug(" Site default frontpage ID is: " + siteDefaultRootPageID
+", selected frontpage Value is: "
+subsiteSelectedFrontpage) ;
Application frontpageApp ;
if (subsiteSelectedFrontpage.equals(DEFAULT_APP)) {
s_log.debug("About to create frontpage app ID: " + DEFAULT_APP );
frontpageApp = Application
.retrieveApplication(siteDefaultRootPageID);
} else {
s_log.debug("About to create frontpage app ID: "
+ subsiteSelectedFrontpage );
frontpageApp = Application
.retrieveApplication(new BigDecimal(subsiteSelectedFrontpage));
}
Assert.exists(frontpageApp,Application.class);
s_log.debug("Created frontpage app ID: " + frontpageApp.getID() );
if (site == null) { // (sub)site not yet exists, create new one if (site == null) { // (sub)site not yet exists, create new one
/* Retrieve application type object */ if (!siteDefaultRootPageID.equals(frontpageApp.getID()) ) {
ApplicationType appType = ApplicationType
.retrieveApplicationTypeForApplication
(Subsite.getConfig().getFrontPageApplicationType());
Assert.exists(appType,ApplicationType.class);
/* Retrieve parent application object */ // Previous version executed setRoot.... for newly created
Application parentApp = Application // application, which were created for the purpose to serve
.retrieveApplicationForPath( // as a dedicated front page application for the created
Subsite.getConfig().getFrontPageParentURL()); // subsite with an added comment:
Assert.exists(parentApp,Application.class); // "NB, explicitly don't set cat on shared front page!"
s_log.debug("Front page application ID: "
+ frontpageApp.getID() );
s_log.debug("About to set cat on dedicated front page." );
Category.setRootForObject(frontpageApp,root);
Application frontPage = null;
if (Boolean.TRUE.toString()
.equals(m_customHomepage.getValue(state))) {
// custom homepage selected - create one
// hostname hard coded as front page url
frontPage = Application.createApplication
( appType,
(String)m_hostname.getValue(state),
(String)m_title.getValue(state),
parentApp
);
frontPage.setDescription((String)m_description.getValue(state));
Category.setRootForObject(frontPage,root);
} else {
frontPage = parentApp;
// NB, explicitly don't set cat on shared front page!
} }
// actually create a new subsite // actually create a new subsite
@ -414,21 +444,25 @@ public class SiteForm extends Form {
(String)m_hostname.getValue(state), (String)m_hostname.getValue(state),
styleDir, styleDir,
root, root,
frontPage); frontpageApp);
} else { // (sub)site already exists, modify mutable configuration } else { // (sub)site already exists, modify mutable configuration
// FRONT_PAGE Application not mutable
site.setTitle((String)m_title.getValue(state)); site.setTitle((String)m_title.getValue(state));
site.setDescription((String)m_description.getValue(state)); site.setDescription((String)m_description.getValue(state));
site.setHostname((String)m_hostname.getValue(state)); site.setHostname((String)m_hostname.getValue(state));
site.setStyleDirectory(styleDir); site.setStyleDirectory(styleDir);
site.setRootCategory(root); site.setRootCategory(root);
// XXX Check: Frontpage application was not mutable in previous
// version! Check if we explicitly have to handle cat whether
// or not frontpage is shared. See comment above!
site.setFrontPage(frontpageApp);
} }
m_site.clearSelection(state); m_site.clearSelection(state);
Application app = Application.retrieveApplicationForPath("/navigation/"); Application app = Application
.retrieveApplicationForPath("/navigation/");
Category.setRootForObject(app, Category.setRootForObject(app,
root, root,
site.getTemplateContext().getContext()); site.getTemplateContext().getContext());
@ -437,10 +471,49 @@ public class SiteForm extends Form {
} }
/**
*
*/
private class FrontpageAppListener implements PrintListener {
public void prepare(PrintEvent e) {
final SingleSelect target = (SingleSelect)e.getTarget();
// final PageState state = e.getPageState();
ApplicationCollection customApps ;
// target.addOption(new Option(SELECT_APP, SELECT_APP_LABEL));
target.addOption(new Option(DEFAULT_APP, DEFAULT_APP_LABEL));
String[] customAppTypes = (String[])Subsite.getConfig()
.getFrontPageApplicationTypes();
if ( customAppTypes != null) {
for (int i=0; i < customAppTypes.length; i++) {
customApps = Application.retrieveAllApplications(
customAppTypes[i]);
while(customApps.next()) {
/* Create an entry for each application, consisting
* of the (BigDecimal) ID as value and the URL as
* label. */
String appID = customApps.get(ACSObject.ID).toString() ;
target.addOption( new
Option(appID ,
( customApps.getPrimaryURL()
+"("+appID+")") ));
}
}
}
}
}
/** /**
* *
*/ */
private class ThemesListener implements PrintListener { private class ThemesListener implements PrintListener {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect target = (SingleSelect)e.getTarget(); SingleSelect target = (SingleSelect)e.getTarget();
PageState state = e.getPageState(); PageState state = e.getPageState();
@ -458,5 +531,6 @@ public class SiteForm extends Form {
} }
target.addOption(new Option(OTHER_STYLE, OTHER_STYLE_LABEL)); target.addOption(new Option(OTHER_STYLE, OTHER_STYLE_LABEL));
} }
} }
} }