1 10 11 package org.mmbase.bridge.util; 12 import javax.servlet.*; 13 import java.util.*; 14 import java.io.*; 15 16 import org.mmbase.bridge.*; 17 import org.mmbase.bridge.implementation.BasicFieldList; 18 import org.mmbase.util.logging.*; 19 import org.mmbase.util.*; 20 21 31 public abstract class AbstractNodeManager extends AbstractNode implements NodeManager { 32 private static final Logger log = Logging.getLoggerInstance(AbstractNodeManager.class); 33 34 35 protected Map values = new HashMap(); 36 protected final Cloud cloud; 37 protected AbstractNodeManager(Cloud c) { 38 cloud = c; 39 } 40 41 protected void setValueWithoutChecks(String fieldName, Object value) { 42 values.put(fieldName, value); 43 } 44 public Object getValueWithoutProcess(String fieldName) { 45 return values.get(fieldName); 46 } 47 protected void edit(int action) { 48 } 50 51 protected void setSize(String fieldName, long size) { 52 } 54 public long getSize(String fieldName) { 55 return 2; 57 } 58 public NodeManager getNodeManager() { 59 return cloud.getNodeManager("typedef"); 60 } 61 public Cloud getCloud() { 62 return cloud; 63 } 64 65 66 public Node createNode() { throw new UnsupportedOperationException ();} 67 public NodeList getList(String where, String sorted, boolean direction) { throw new UnsupportedOperationException (); } 68 public NodeList getList(String where, String sorted, String direction) { throw new UnsupportedOperationException (); } 69 70 71 public FieldList createFieldList() { 72 return new BasicFieldList(Collections.EMPTY_LIST, this); 73 } 74 75 public NodeList createNodeList() { 76 return new CollectionNodeList(Collections.EMPTY_LIST, this); 77 } 78 79 public RelationList createRelationList() { 80 return new CollectionRelationList(Collections.EMPTY_LIST, this); 81 } 82 83 public boolean mayCreateNode() { 84 return false; 85 } 86 87 public NodeList getList(NodeQuery query) { throw new UnsupportedOperationException (); } 88 89 public NodeQuery createQuery() { throw new UnsupportedOperationException (); } 90 public NodeList getList(String command, Map parameters, ServletRequest req, ServletResponse resp){ throw new UnsupportedOperationException ();} 91 92 public NodeList getList(String command, Map parameters){ throw new UnsupportedOperationException ();} 93 94 95 public RelationManagerList getAllowedRelations() { return BridgeCollections.EMPTY_RELATIONMANAGERLIST; } 96 public RelationManagerList getAllowedRelations(String nodeManager, String role, String direction) { return BridgeCollections.EMPTY_RELATIONMANAGERLIST; } 97 98 public RelationManagerList getAllowedRelations(NodeManager nodeManager, String role, String direction) { return BridgeCollections.EMPTY_RELATIONMANAGERLIST; } 99 100 public String getInfo(String command) { return getInfo(command, null,null);} 101 102 public String getInfo(String command, ServletRequest req, ServletResponse resp){ throw new UnsupportedOperationException ();} 103 104 105 protected abstract Map getFieldTypes(); 106 107 108 public final boolean hasField(String fieldName) { 109 Map fieldTypes = getFieldTypes(); 110 return fieldTypes.isEmpty() || fieldTypes.containsKey(fieldName); 111 } 112 113 public final FieldList getFields() { 114 return getFields(NodeManager.ORDER_NONE); 115 } 116 117 public final FieldList getFields(int order) { 118 return new BasicFieldList(getFieldTypes().values(), this); 119 } 120 121 public final Field getField(String fieldName) throws NotFoundException { 122 Field f = (Field) getFieldTypes().get(fieldName); 123 if (f == null) throw new NotFoundException("Field '" + fieldName + "' does not exist in NodeManager '" + getName() + "'.(" + getFieldTypes() + ")"); 124 return f; 125 } 126 127 public String getGUIName() { 128 return getGUIName(NodeManager.GUI_SINGULAR); 129 } 130 131 public String getGUIName(int plurality) { 132 return getGUIName(plurality, null); 133 } 134 135 public String getGUIName(int plurality, Locale locale) { 136 return getName(); 137 } 138 139 public String getName() { 140 return "virtual_manager"; 141 } 142 public String getDescription() { 143 return getDescription(null); 144 } 145 146 public String getDescription(Locale locale) { 147 return ""; 148 } 149 150 public NodeManager getParent() { 151 return null; 152 } 153 154 155 public String getProperty(String name) { 156 return null; 157 } 158 public Map getProperties() { 159 return Collections.EMPTY_MAP; 160 } 161 162 public NodeManagerList getDescendants() { 163 return BridgeCollections.EMPTY_NODEMANAGERLIST; 164 } 165 166 public Collection getFunctions() { 167 return Collections.EMPTY_LIST; 168 } 169 170 } 171 | Popular Tags |