Verschiedene Verbesserungen beim Anlegen neuer ContentSections und dem Zusammenspiel zwischen Sections und Kategorien.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2321 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-09-21 12:44:25 +00:00
parent 4a764a8b4e
commit cba909a57d
10 changed files with 141 additions and 41 deletions

View File

@ -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,

View File

@ -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());
}

View File

@ -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, "");
}
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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);

View File

@ -93,7 +93,6 @@ public abstract class AbstractObjectList
public Element generateObjectListXML(HttpServletRequest request,
HttpServletResponse response) {
final long start = System.nanoTime();
Assert.isLocked(this);
String pageNumberValue = request.getParameter("pageNumber");
@ -109,11 +108,7 @@ public abstract class AbstractObjectList
"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

View File

@ -90,6 +90,8 @@ public class CustomizableObjectList extends ComplexObjectList {
*/
private final Map<String, Filter> filters =
new LinkedHashMap<String, Filter>();
private CategoryFilter categoryFilter;
/**
* The available sort fields. We use an {@link LinkedHashMap} here to
* preserve the insertation order.
@ -175,6 +177,13 @@ public class CustomizableObjectList extends ComplexObjectList {
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.
*
@ -238,6 +247,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<String, Filter> 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

View File

@ -28,5 +28,4 @@
<setting id="separator"> | </setting>
<setting id="includeFileNameIntoFileLinks">true</setting>
</settings>

View File

@ -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: