The admin form of a PortalWorkspace now shows a mapped category system without a restart (issue #1899).
git-svn-id: https://svn.libreccm.org/ccm/trunk@2708 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
bacea5257f
commit
da6df35eff
|
|
@ -22,12 +22,14 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
import com.arsdigita.bebop.Tree;
|
import com.arsdigita.bebop.Tree;
|
||||||
import com.arsdigita.bebop.event.ActionEvent;
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
import com.arsdigita.bebop.event.ActionListener;
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
import com.arsdigita.bebop.tree.TreeModel;
|
import com.arsdigita.bebop.tree.TreeModel;
|
||||||
import com.arsdigita.bebop.tree.TreeModelBuilder;
|
import com.arsdigita.bebop.tree.TreeModelBuilder;
|
||||||
|
import com.arsdigita.bebop.tree.TreeNode;
|
||||||
import com.arsdigita.categorization.Category;
|
import com.arsdigita.categorization.Category;
|
||||||
import com.arsdigita.categorization.CategoryTreeModelLite;
|
import com.arsdigita.categorization.CategoryTreeModelLite;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
|
@ -41,6 +43,7 @@ import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import com.arsdigita.web.Application;
|
import com.arsdigita.web.Application;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryComponent.
|
* CategoryComponent.
|
||||||
|
|
@ -49,8 +52,7 @@ import com.arsdigita.web.Web;
|
||||||
*/
|
*/
|
||||||
public class CategoryComponent extends SimpleContainer {
|
public class CategoryComponent extends SimpleContainer {
|
||||||
|
|
||||||
private static final Logger s_log = Logger
|
private static final Logger s_log = Logger.getLogger(CategoryComponent.class);
|
||||||
.getLogger(CategoryComponent.class);
|
|
||||||
private ACSObjectSelectionModel m_catModel;
|
private ACSObjectSelectionModel m_catModel;
|
||||||
private CategoryTree m_tree;
|
private CategoryTree m_tree;
|
||||||
private ApplicationSelectionModel m_appModel;
|
private ApplicationSelectionModel m_appModel;
|
||||||
|
|
@ -63,12 +65,6 @@ public class CategoryComponent extends SimpleContainer {
|
||||||
* @param appModel
|
* @param appModel
|
||||||
*/
|
*/
|
||||||
public CategoryComponent(ApplicationSelectionModel appModel) {
|
public CategoryComponent(ApplicationSelectionModel appModel) {
|
||||||
// this model means that the server needs a restart
|
|
||||||
// if you want to map a category to this personal portal
|
|
||||||
// AND vice versa - if you remove a domain mapping you need to
|
|
||||||
// restart the server otherwise you will get an exception next time
|
|
||||||
// this Component is viewed.
|
|
||||||
if (m_root != null) {
|
|
||||||
setNamespace(WorkspacePage.PORTAL_XML_NS);
|
setNamespace(WorkspacePage.PORTAL_XML_NS);
|
||||||
setTag("portal:categoryPanel");
|
setTag("portal:categoryPanel");
|
||||||
|
|
||||||
|
|
@ -83,7 +79,6 @@ public class CategoryComponent extends SimpleContainer {
|
||||||
m_error = new Label("");
|
m_error = new Label("");
|
||||||
add(m_error);
|
add(m_error);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -150,23 +145,115 @@ public class CategoryComponent extends SimpleContainer {
|
||||||
/**
|
/**
|
||||||
* A TreeModelBuilder that loads the tree from the current category
|
* A TreeModelBuilder that loads the tree from the current category
|
||||||
*/
|
*/
|
||||||
private static class SectionTreeModelBuilder extends LockableImpl implements
|
private static class SectionTreeModelBuilder extends LockableImpl implements TreeModelBuilder {
|
||||||
TreeModelBuilder {
|
|
||||||
|
/**
|
||||||
|
* A RequestLocal wrapper for the model. It is necessary to wrap the model into a
|
||||||
|
* {@link RequestLocal} wrapper because the contents of the model may change. Before this
|
||||||
|
* was introduced the system had be restarted if a new category system was mapped to
|
||||||
|
* a PortalWorkspace.
|
||||||
|
*/
|
||||||
|
final RequestLocal treeModel = new TreeModelRequestLocal();
|
||||||
|
|
||||||
public SectionTreeModelBuilder() {
|
public SectionTreeModelBuilder() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TreeModel makeModel(Tree t, PageState s) {
|
public TreeModel makeModel(Tree t, PageState s) {
|
||||||
|
return (TreeModel) treeModel.get(s);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The RequestLocal used by the {@link SectionTreeModelBuilder}.
|
||||||
|
*/
|
||||||
|
private static class TreeModelRequestLocal extends RequestLocal {
|
||||||
|
|
||||||
|
public TreeModelRequestLocal() {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the initial value for this {@code {RequestLocal}. If a category system
|
||||||
|
* is mapped to the current PortalWorkspace (the current Application instance), the method
|
||||||
|
* returns a {@link CategoryTreeModelLite} instance. The {link CategoryTreeModelLite} is
|
||||||
|
* created using the root category of the mapped category system.
|
||||||
|
* If there is no mapping the method returns an instance of {@link EmptyTreeModel}.
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Object initialValue(final PageState state) {
|
||||||
Application app = Web.getWebContext().getApplication();
|
Application app = Web.getWebContext().getApplication();
|
||||||
Category root = null;
|
Category root = null;
|
||||||
while (app != null && root == null) {
|
while (app != null && root == null) {
|
||||||
root = Category.getRootForObject(app);
|
root = Category.getRootForObject(app);
|
||||||
app = (Application) app.getParentResource();
|
app = (Application) app.getParentResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (root == null) {
|
||||||
|
return new EmptyTreeModel();
|
||||||
|
|
||||||
|
} else {
|
||||||
Assert.exists(root, Category.class);
|
Assert.exists(root, Category.class);
|
||||||
return new CategoryTreeModelLite(root);
|
return new CategoryTreeModelLite(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple helper class representing an empty tree.
|
||||||
|
*/
|
||||||
|
private static class EmptyTreeModel implements TreeModel {
|
||||||
|
|
||||||
|
public EmptyTreeModel() {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TreeNode getRoot(final PageState data) {
|
||||||
|
return new EmptyTreeRootNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasChildren(final TreeNode node,
|
||||||
|
final PageState state) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator getChildren(final TreeNode node,
|
||||||
|
final PageState data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root node of an empty tree.
|
||||||
|
*/
|
||||||
|
private static class EmptyTreeRootNode implements TreeNode {
|
||||||
|
|
||||||
|
public EmptyTreeRootNode() {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKey() {
|
||||||
|
return "empty";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElement() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
name="ScientificCMS"
|
name="ScientificCMS"
|
||||||
prettyName="Scientific CMS"
|
prettyName="Scientific CMS"
|
||||||
version="2.3.0"
|
version="2.3.0"
|
||||||
release="devel-SNAPSHOT-r2691"
|
release="devel-SNAPSHOT-r2707"
|
||||||
webxml="sci-web.xml"
|
webxml="sci-web.xml"
|
||||||
portletxml="sci-portlet.xml"
|
portletxml="sci-portlet.xml"
|
||||||
webapp="libreccm"
|
webapp="libreccm"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue