KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > commands > RuleBasedCommand


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.module.admininterface.commands;
14
15 import info.magnolia.cms.core.ItemType;
16 import info.magnolia.cms.util.Rule;
17 import org.apache.commons.lang.StringUtils;
18
19 /**
20  * @author Sameer Charles
21  * $Id: RuleBasedCommand.java 6592 2006-10-05 15:52:17Z philipp $
22  */

23 public abstract class RuleBasedCommand extends BaseRepositoryCommand {
24
25     /**
26      * You can pass a rule to the command (optional)
27      */

28     public static final String JavaDoc ATTRIBUTE_RULE = "rule";
29
30     /**
31      * All subnodes of this types are activated imediately (without using the recursion)
32      */

33     private String JavaDoc itemTypes = ItemType.CONTENTNODE.getSystemName();
34
35     private Rule rule;
36
37     protected Rule getRule() {
38         // lazy bound but only if this is a clone
39
if (rule == null && isClone()) {
40             rule = new Rule();
41             String JavaDoc[] nodeTypes = StringUtils.split(this.getItemTypes(), " ,");
42             for (int i = 0; i < nodeTypes.length; i++) {
43                 String JavaDoc nodeType = nodeTypes[i];
44                 rule.addAllowType(nodeType);
45             }
46
47             // magnolia resource and metadata must always be included
48
rule.addAllowType(ItemType.NT_METADATA);
49             rule.addAllowType(ItemType.NT_RESOURCE);
50         }
51         return rule;
52     }
53
54     public String JavaDoc getItemTypes() {
55         return itemTypes;
56     }
57
58     public void setItemTypes(String JavaDoc nodeTypes) {
59         this.itemTypes = nodeTypes;
60     }
61
62     /**
63      * @param rule the Rule to set
64      */

65     public void setRule(Rule rule) {
66         this.rule = rule;
67     }
68
69 }
70
Popular Tags