diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSection.java b/ccm-cms/src/com/arsdigita/cms/ContentSection.java index 2d3cf266c..8a884a14a 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSection.java @@ -1082,6 +1082,11 @@ public class ContentSection extends Application { return getDefaultSection().getBaseDataObjectType(); } + public static ContentSection create(final String name) { + final Category rootCategory = createRootCategory(name); + return create(name, rootCategory); + } + /** * Creates a content section of the given name using default values and * returns it. @@ -1089,10 +1094,10 @@ public class ContentSection extends Application { * @param name Name of the content section * @return ContentSection */ - public static ContentSection create(final String name) { + public static ContentSection create(final String name, final Category rootCategory) { Folder folder = createRootFolder(name); - Category category = createRootCategory(name); + //Category category = createRootCategory(name); Group staff = createStaffGroup(name); // Some default classes for a content section. @@ -1103,7 +1108,7 @@ public class ContentSection extends Application { ContentSection section = ContentSection.create(name, folder, - category, + rootCategory, staff, prc, irc, diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSectionServlet.java b/ccm-cms/src/com/arsdigita/cms/ContentSectionServlet.java index 7e0c1a211..67511bf39 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSectionServlet.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSectionServlet.java @@ -172,7 +172,8 @@ public class ContentSectionServlet extends BaseApplicationServlet { m_resolver = (ApplicationFileResolver) Classes.newInstance(resolverName); } if (s_log.isDebugEnabled()) { - s_log.debug("Template path is " + m_templatePath + " with resolver " + m_resolver.getClass().getName()); + s_log.debug("Template path is " + m_templatePath + " with resolver " + m_resolver. + getClass().getName()); } // NEW STUFF here used to process the pages in this servlet @@ -512,7 +513,8 @@ public class ContentSectionServlet extends BaseApplicationServlet { if (item == null) { if (s_log.isDebugEnabled()) { - s_log.debug("Did not find content item in cache, so trying " + "to retrieve and cache..."); + s_log.debug("Did not find content item in cache, so trying " + + "to retrieve and cache..."); } //item not cached, so retreive it and cache it item = itemResolver.getItem(section, url, ContentItem.LIVE); @@ -633,14 +635,15 @@ public class ContentSectionServlet extends BaseApplicationServlet { public static ContentItem itemURLCacheGet(ContentSection section, final String sURL, final String lang) { - final BigDecimal itemID = (BigDecimal) getItemURLCache(section) - .get(sURL + CACHE_KEY_DELIMITER + lang); + final BigDecimal itemID = (BigDecimal) getItemURLCache(section).get( + sURL + CACHE_KEY_DELIMITER + lang); if (itemID == null) { return null; } else { try { - return (ContentItem) DomainObjectFactory.newInstance(new OID(ContentItem.BASE_DATA_OBJECT_TYPE, itemID)); + return (ContentItem) DomainObjectFactory.newInstance(new OID( + ContentItem.BASE_DATA_OBJECT_TYPE, itemID)); } catch (DataObjectNotFoundException donfe) { return null; } @@ -652,6 +655,13 @@ public class ContentSectionServlet extends BaseApplicationServlet { if (s_itemURLCacheMap == null) { initializeItemURLCache(); } + + if (s_itemURLCacheMap.get(section.getPath()) == null) { + final CacheTable cache = new CacheTable("ContentSectionServletItemURLCache" + + section.getID().toString()); + s_itemURLCacheMap.put(section.getPath(), cache); + } + return (CacheTable) s_itemURLCacheMap.get(section.getPath()); } diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java index bff8e4673..936cbf210 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionCreateForm.java @@ -27,12 +27,18 @@ import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.NotEmptyValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.categorization.Category; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.SessionManager; -import com.arsdigita.persistence.TransactionContext; +import java.math.BigDecimal; /** * Form for creating a new ContentSection. Used by the {@link ContentSectionAppManager}. @@ -44,6 +50,7 @@ public class ContentSectionCreateForm extends Form { public final static String FORM_NAME = "ContentSectionCreateForm"; private final static String NEW_SECTION_NAME = "newSectionName"; + private final static String NEW_SECTION_ROOT_CAT = "newSectionRootCategory"; private final SaveCancelSection saveCancelSection; public ContentSectionCreateForm() { @@ -56,6 +63,23 @@ public class ContentSectionCreateForm extends Form { sectionNameField.addValidationListener(new NotEmptyValidationListener()); add(sectionNameField); + add(new Label(GlobalizationUtil.globalize("cms.ui.section.new_section_root_category"))); + final SingleSelect rootCategorySelect = new SingleSelect(NEW_SECTION_ROOT_CAT); + final DataCollection categories = SessionManager.getSession().retrieve( + Category.BASE_DATA_OBJECT_TYPE); + rootCategorySelect.addOption(new Option("")); + Category current; + while (categories.next()) { + current = (Category) DomainObjectFactory.newInstance(categories.getDataObject()); + if (current.isRoot()) { + rootCategorySelect.addOption(new Option(current.getID().toString(), + current.getDisplayName())); + } + } + rootCategorySelect.addValidationListener(new NotNullValidationListener()); + rootCategorySelect.addValidationListener(new NotEmptyValidationListener()); + add(rootCategorySelect); + saveCancelSection = new SaveCancelSection(); add(saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); @@ -76,20 +100,24 @@ public class ContentSectionCreateForm extends Form { final String newSectionName = data.getString(NEW_SECTION_NAME); -// final TransactionContext tctx = SessionManager.getSession().getTransactionContext(); -// tctx.beginTxn(); - ContentSectionSetup.setupContentSectionAppInstance(newSectionName, - config.getDefaultRoles(), - config.getDefaultWorkflows(), - config.isPubliclyViewable(), - config.getItemResolverClass(), - config.getTemplateResolverClass(), - config.getContentSectionsContentTypes(), - config.getUseSectionCategories(), - config.getCategoryFileList()); -// tctx.commitTxn(); - + final Category rootCategory = new Category(new BigDecimal(data.getString( + NEW_SECTION_ROOT_CAT))); + if (!rootCategory.isRoot()) { + throw new IllegalArgumentException("The category given is not a root category."); + } + + ContentSectionSetup.setupContentSectionAppInstance( + newSectionName, + rootCategory, + config.getDefaultRoles(), + config.getDefaultWorkflows(), + config.isPubliclyViewable(), + config.getItemResolverClass(), + config.getTemplateResolverClass(), + config.getContentSectionsContentTypes()); + data.put(NEW_SECTION_NAME, ""); + data.put(NEW_SECTION_ROOT_CAT, ""); } } @@ -103,7 +131,7 @@ public class ContentSectionCreateForm extends Form { public void submitted(final FormSectionEvent event) throws FormProcessException { if (saveCancelSection.getCancelButton().isSelected(event.getPageState())) { event.getFormData().put(NEW_SECTION_NAME, ""); - + throw new FormProcessException("Canceled"); } } diff --git a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java index 55636b269..c0d096edc 100644 --- a/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java +++ b/ccm-cms/src/com/arsdigita/cms/contentsection/ContentSectionSetup.java @@ -135,6 +135,36 @@ public final class ContentSectionSetup { } + public static ContentSection setupContentSectionAppInstance(String name, + Category rootCategory, + List defaultRoles, + List defaultWorkflows, + Boolean isPubliclyViewable, + String itemResolverClassName, + String templateResolverClassName, + List sectionContentTypes) { + s_log.info("Creating content section on /" + name); + + ContentSection section = ContentSection.create(name, rootCategory); + ContentSectionSetup setup = new ContentSectionSetup(section); + + // Setup the access controls + setup.registerRoles(defaultRoles); + setup.registerWorkflowTemplates(defaultWorkflows); + setup.registerViewers(isPubliclyViewable); + setup.registerPublicationCycles(); + setup.registerResolvers(itemResolverClassName, templateResolverClassName); + + // setup.registerContentTypes((List)m_conf.getParameter(TYPES)); + setup.registerContentTypes(sectionContentTypes); + + setup.registerAlerts(); + + section.save(); + + return section; + } + /** * Steps through a list of roles which are part of a staff group and * delegates processing of each role. @@ -276,7 +306,8 @@ public final class ContentSectionSetup { s_log.info("Registering " + itemResolverClassName + " as the item resolver class"); } else { - m_section.setItemResolverClass(ContentSection.getConfig().getDefaultItemResolverClass().getName()); + m_section.setItemResolverClass(ContentSection.getConfig().getDefaultItemResolverClass(). + getName()); s_log.info("Registering " + itemResolverClassName + " as the item resolver class"); } @@ -286,7 +317,8 @@ public final class ContentSectionSetup { s_log.info("Registering " + templateResolverClassName + " as the template resolver class"); } else { - m_section.setTemplateResolverClass(ContentSection.getConfig().getDefaultTemplateResolverClass().getName()); + m_section.setTemplateResolverClass(ContentSection.getConfig(). + getDefaultTemplateResolverClass().getName()); s_log.info("Registering " + templateResolverClassName + " as the template resolver class"); } @@ -399,7 +431,8 @@ public final class ContentSectionSetup { // If this workflow should be the default or is the first one // save it for easy access in registerContentType - if (m_wf == null || (workflow.containsKey("isDefault") && workflow.get("isDefault").equals("true"))) { + if (m_wf == null || (workflow.containsKey("isDefault") && workflow.get("isDefault"). + equals("true"))) { m_section.setDefaultWorkflowTemplate(wf); m_wf = wf; } diff --git a/ccm-core/src/com/arsdigita/categorization/CategoryTreeModelLite.java b/ccm-core/src/com/arsdigita/categorization/CategoryTreeModelLite.java index f3ee151a0..519a5900f 100755 --- a/ccm-core/src/com/arsdigita/categorization/CategoryTreeModelLite.java +++ b/ccm-core/src/com/arsdigita/categorization/CategoryTreeModelLite.java @@ -39,7 +39,7 @@ public class CategoryTreeModelLite extends DataQueryTreeModel { /** * Initializes with the passed in the root Category. * - * @param rootCategory the root category for this TreeModel + * @param root the root category for this TreeModel */ public CategoryTreeModelLite(Category root) { this(root,null); @@ -47,7 +47,7 @@ public class CategoryTreeModelLite extends DataQueryTreeModel { /** * Initializes with the passed in the root Category. * - * @param rootCategory the root category for this TreeModel + * @param root the root category for this TreeModel * @param order the field to order by */ public CategoryTreeModelLite(Category root, String order) { @@ -57,6 +57,7 @@ public class CategoryTreeModelLite extends DataQueryTreeModel { m_order = order; } + @Override protected DataQueryTreeIterator getDataQueryTreeIterator (DataQueryTreeNode node, String getSubCategories) { return new CategoryTreeIterator(node, getSubCategories, m_order); @@ -69,6 +70,7 @@ public class CategoryTreeModelLite extends DataQueryTreeModel { addOrder(order); } } + @Override public Object next() { DataQueryTreeNode node = (DataQueryTreeNode)super.next(); diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/admin/DomainMappingAddForm.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/admin/DomainMappingAddForm.java index a736ccae8..a78ee1611 100644 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/admin/DomainMappingAddForm.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/admin/DomainMappingAddForm.java @@ -110,8 +110,9 @@ public class DomainMappingAddForm extends Form { throw new UncheckedWrapperException(ex); } context.setSize(20); - context.addValidationListener(new NotNullValidationListener()); - context.addValidationListener(new StringInRangeValidationListener(1, 100)); + //For some purposes it is neccessary to map a domain with a null context + //context.addValidationListener(new NotNullValidationListener()); + //context.addValidationListener(new StringInRangeValidationListener(1, 100)); add(new Label(TermGlobalizationUtil.globalize("term.domain.mapping.ui.context"))); add(context); diff --git a/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java b/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java index 9b13f8af5..abc9d5add 100755 --- a/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java +++ b/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java @@ -92,8 +92,7 @@ public abstract class AbstractObjectList } public Element generateObjectListXML(HttpServletRequest request, - HttpServletResponse response) { - final long start = System.nanoTime(); + HttpServletResponse response) { Assert.isLocked(this); String pageNumberValue = request.getParameter("pageNumber"); @@ -108,12 +107,8 @@ public abstract class AbstractObjectList throw new UncheckedWrapperException( "cannot parse page number " + pageNumber, ex); } - - final long loadObjectsStart = System.nanoTime(); + DataCollection objects = getObjects(request, response); - ////System.out.printf("Got objects for list in %d ms\n", (System.nanoTime() - loadObjectsStart) / 1000000); - - ////System.out.printf("(100) Needed %d ms until here...\n", (System.nanoTime() - start) / 1000000); // Quasimodo: Begin // Limit list to objects in the negotiated language and language invariant items diff --git a/ccm-navigation/src/com/arsdigita/navigation/ui/object/CustomizableObjectList.java b/ccm-navigation/src/com/arsdigita/navigation/ui/object/CustomizableObjectList.java index 167cb55bf..a9b88f80d 100644 --- a/ccm-navigation/src/com/arsdigita/navigation/ui/object/CustomizableObjectList.java +++ b/ccm-navigation/src/com/arsdigita/navigation/ui/object/CustomizableObjectList.java @@ -90,6 +90,8 @@ public class CustomizableObjectList extends ComplexObjectList { */ private final Map filters = new LinkedHashMap(); + + private CategoryFilter categoryFilter; /** * The available sort fields. We use an {@link LinkedHashMap} here to * preserve the insertation order. @@ -174,6 +176,13 @@ public class CustomizableObjectList extends ComplexObjectList { propertyIsNumeric); filters.put(label, filter); } + + public CategoryFilter addCategoryFilter(final String label, + final String rootCategory) { + categoryFilter = CategoryFilter.createCategoryFilter(label, rootCategory); + + return categoryFilter; + } /** * Add a sort field option. @@ -237,6 +246,10 @@ public class CustomizableObjectList extends ComplexObjectList { } final DataCollection objects = super.getObjects(request, response); + + if ((objects != null) && (categoryFilter != null)) { + categoryFilter.applyFilter(objects); + } return objects; } @@ -313,6 +326,13 @@ public class CustomizableObjectList extends ComplexObjectList { filterEntry.getValue().setValue(value); } } + if (categoryFilter != null) { + final String value = Globalization.decodeParameter(request, "categoryFilter"); + + if ((value != null) && !value.isEmpty()) { + categoryFilter.setValue(value); + } + } final Element controls = content.newChildElement("filterControls"); controls.addAttribute("customName", m_customName); @@ -321,6 +341,9 @@ public class CustomizableObjectList extends ComplexObjectList { for (Map.Entry filterEntry : filters.entrySet()) { filterElems.addContent(filterEntry.getValue().getXml()); } + if (categoryFilter != null) { + filterElems.addContent(categoryFilter.getXml()); + } if (!sortFields.isEmpty()) { //Look for a sort parameter. If one is found, use one to sort the data diff --git a/ccm-sci-bundle/web/themes/mandalay/settings/global.xml b/ccm-sci-bundle/web/themes/mandalay/settings/global.xml index ad2ae9218..5f72ed107 100755 --- a/ccm-sci-bundle/web/themes/mandalay/settings/global.xml +++ b/ccm-sci-bundle/web/themes/mandalay/settings/global.xml @@ -28,5 +28,4 @@ | - true diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java index ef5aee43e..3de8c0f57 100644 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java +++ b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java @@ -47,12 +47,12 @@ import com.arsdigita.util.LockableImpl; public class SiteTable extends Table implements TableActionListener { private static final String TABLE_COL_EDIT = "table_col_edit"; - private static final String TABLE_COL_DEL = "table_col_del"; + private static final String TABLE_COL_DEL = "table_col_del"; private final SiteSelectionModel siteSelect; public SiteTable(final SiteSelectionModel siteSelect) { super(); - + this.siteSelect = siteSelect; setEmptyView(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.no_subsites"))); @@ -136,7 +136,11 @@ public class SiteTable extends Table implements TableActionListener { case 3: return site.getStyleDirectory(); case 4: - return site.getRootCategory().getDisplayName(); + if (site.getRootCategory() == null) { + return ""; + } else { + return site.getRootCategory().getDisplayName(); + } case 5: return SubsiteGlobalizationUtil.globalize("subsite.ui.edit"); case 6: