Update of
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action
In directory
james.mmbase.org:/tmp/cvs-serv15021/applications/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action
Modified Files:
AbstractRelationAction.java DeleteNodeAction.java Action.java
AbstractNodeAction.java SortRelationAction.java
CreateRelationAction.java CreateNodeAction.java
Log Message:
work in progress
See also:
http://cvs.mmbase.org/viewcvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action
Index: AbstractRelationAction.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action/AbstractRelationAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- AbstractRelationAction.java 18 Aug 2008 19:13:05 -0000 1.1
+++ AbstractRelationAction.java 8 Sep 2008 16:52:10 -0000 1.2
@@ -10,6 +10,8 @@
import org.mmbase.bridge.Relation;
import org.mmbase.bridge.RelationManager;
import org.mmbase.bridge.Transaction;
+import org.mmbase.util.logging.Logger;
+import org.mmbase.util.logging.Logging;
/**
* @author Ernst Bunders
@@ -17,6 +19,8 @@
*/
public abstract class AbstractRelationAction extends AbstractNodeAction {
+ private static final Logger log =
Logging.getLoggerInstance(AbstractRelationAction.class);
+
protected Node sourceNode = null;
protected Node destinationNode = null;
protected String sourceNodeNumber;
@@ -32,9 +36,10 @@
addGlobalError("error.property.required", new String[]
{ "role", this.getClass().getName() });
return null;
} else {
+ try{
relationManager = transaction.getRelationManager(role);
- if (relationManager != null) {
if (resolveSourceAndDestination(transaction,
idMap)) {
+ log.debug("source and destination
successfully resolved");
// create the relation node.
if (mayCreate(relationManager)
&&
checkTypeRel(relationManager, sourceNode, destinationNode)) {
@@ -45,7 +50,8 @@
return null;
}
}
- } else {
+ } catch(NotFoundException e) {
+ log.error("relation manager "+ role+" does not
exist");
addGlobalError("error.illegal.relationmanager",
new String[] { "role" });
return null;
}
@@ -79,11 +85,14 @@
protected final Node resolveNode(String refNotFoundErrorKey, String
nodeRef, String nodenr,
Map<String, Node> idMap, Transaction transaction) {
Node result = null;
- if (nodenr == null) {
- if (nodeRef == null) {
+ if (StringUtils.isBlank(nodenr)) {
+ if (StringUtils.isBlank(nodeRef)) {
+ log.debug("nodenr is empty and noderef is empty
too. this stinks!");
addGlobalError(refNotFoundErrorKey);
} else {
+ log.debug(String.format("trying to find node
with id %s in the idmap", nodeRef));
if (idMap.get(nodeRef) == null) {
+ log.warn(String.format("oops, could not
find node in idMap with id %s", nodeRef));
addGlobalError("error.node.notfound.idmap", new String[] { nodeRef });
} else {
result = idMap.get(nodeRef);
@@ -94,6 +103,7 @@
try {
result = transaction.getNode(nodenr);
} catch (NotFoundException e) {
+ log.warn(String.format("could not find node
with number %s", nodenr));
addGlobalError("error.node.notfound", new
String[] { nodenr });
}
}
Index: DeleteNodeAction.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action/DeleteNodeAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DeleteNodeAction.java 18 Aug 2008 19:13:05 -0000 1.1
+++ DeleteNodeAction.java 8 Sep 2008 16:52:10 -0000 1.2
@@ -29,7 +29,7 @@
}
@Override
- public void process(Map<String, Node> nodeMap, ResultContainer
resultContainer) {
+ public void process(ResultContainer resultContainer) {
if(StringUtils.isBlank(nodenr)){
resultContainer.getGlobalErrors().add(
new GlobalError(
Index: Action.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action/Action.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Action.java 11 Aug 2008 13:03:30 -0000 1.1
+++ Action.java 8 Sep 2008 16:52:10 -0000 1.2
@@ -12,5 +12,5 @@
*
*/
public abstract class Action {
- public abstract void process(Map<String,Node> nodeMap, ResultContainer
resultContainer);
+ public abstract void process(ResultContainer resultContainer);
}
Index: AbstractNodeAction.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action/AbstractNodeAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- AbstractNodeAction.java 18 Aug 2008 19:13:05 -0000 1.2
+++ AbstractNodeAction.java 8 Sep 2008 16:52:10 -0000 1.3
@@ -14,6 +14,7 @@
import org.mmbase.applications.vprowizards.spring.ResultContainer;
import org.mmbase.applications.vprowizards.spring.cache.CacheFlushHint;
import org.mmbase.applications.vprowizards.spring.util.DateTime;
+import org.mmbase.bridge.Cloud;
import org.mmbase.bridge.Node;
import org.mmbase.bridge.NodeList;
import org.mmbase.bridge.NodeManager;
@@ -40,7 +41,6 @@
private boolean nodeChanged = false;
-
private ResultContainer resultContainer;
/**
@@ -59,11 +59,11 @@
* When the id is set on this action, the node is added to the idmap.
*/
@Override
- public final void process(Map<String, Node> nodeMap, ResultContainer
resultContainer) {
+ public final void process(ResultContainer resultContainer) {
this.resultContainer = resultContainer;
- //get the node
- node = createNode(resultContainer.getTransaction(), nodeMap,
resultContainer.getRequest());
+ // get the node
+ node = createNode(resultContainer.getTransaction(),
resultContainer.getIdMap(), resultContainer.getRequest());
if (hasErrors()) {
return;
@@ -71,22 +71,26 @@
if (node == null && isNodeNullIllegal()) {
throw new IllegalStateException(
- "No node has been provided, and no
error has been set. Either of these should happen");
+ "No node has been provided, and no
error has been set. Either of these should happen*");
}
- //now check if no illegal fields are set for this node type
- if(node != null){
+ // now check if no illegal fields are set for this node type
+ if (node != null) {
checkBasicFields();
}
- //no error and no overridden 'proceed' flag? Set the values and
- //call the post processing callback method.
+ // no error and no overridden 'proceed' flag? Set the values and
+ // call the post processing callback method.
if (!hasErrors() && shouldProcess(node)) {
- if(node!= null){
+ if (node != null) {
+ log.debug("setting the field values on the
node");
setBasicFields();
+ if (node.getNodeManager().hasField("handle")) {
+ setHandlerField();
+ }
}
- if (resultContainer.containsFieldErrors()) {
+ if (resultContainer.hasFieldErrors()) {
return;
}
@@ -98,15 +102,16 @@
processNode(resultContainer.getTransaction());
}
- //even with a null node it can be necessary to create a
cache flush hint
- //for instance when a node was deleted.
+ // even with a null node it can be necessary to create
a cache flush hint
+ // for instance when a node was deleted.
createCacheFlushHints();
}
}
/**
- * This template method determines if it is an error when the node is
null.
- * Override this for concrete actions that actually don't need a node
always.
+ * This template method determines if it is an error when the node is
null. Override this for concrete actions that
+ * actually don't need a node always.
+ *
* @return true by default.
*/
protected boolean isNodeNullIllegal() {
@@ -129,9 +134,13 @@
* Check if all the fields set for this node action actually exist in
the nodemanager.
*/
private void checkBasicFields() {
- for(String fieldName: fields.keySet()){
- if(!node.getNodeManager().hasField(fieldName)){
- addFieldError(fieldName,
"error.field.nonexistant", new String[]{fieldName,
node.getNodeManager().getName()});
+ for (String field : fields.keySet()) {
+ if (!node.getNodeManager().hasField(field)) {
+ log.warn(String.format(
+ "You try to set field '%s' on a
node of type '%s', but the nodetype does not have this field",
+ field,
node.getNodeManager().getName()));
+ addGlobalError("error.field.unknown", new
String[] { field, this.getClass().getName(),
+ node.getNodeManager().getName()
});
}
}
}
@@ -151,7 +160,7 @@
* @param request
*
*/
- abstract protected Node createNode(Transaction transaction,
Map<String,Node> idMap, HttpServletRequest request);
+ abstract protected Node createNode(Transaction transaction, Map<String,
Node> idMap, HttpServletRequest request);
/**
* This template method is called after the values that have been
injected in this action in the fields and
@@ -161,16 +170,17 @@
* @param node
* @param resultContainer
*/
- protected void processNode(Transaction transaction) {};
+ protected void processNode(Transaction transaction) {
+ };
- protected final Locale getLocale(){
+ protected final Locale getLocale() {
return resultContainer.getLocale();
}
/**
* @return the node that is created for this node action.
*/
- protected final Node getNode(){
+ protected final Node getNode() {
return node;
}
@@ -185,66 +195,68 @@
return nodeChanged;
}
-
/**
* Creates a field error for this action
+ *
* @param field
* @param key
* @param placeholderValues
*/
protected final void addFieldError(String field, String key, String[]
placeholderValues) {
- resultContainer.getFieldErrors().add(new FieldError(field, key,
placeholderValues, getLocale()));
+ resultContainer.addFieldError(new FieldError(field, key,
placeholderValues, getLocale()));
}
/**
* Create a field error for this action, using a key without place
holder values
+ *
* @param field
* @param key
*/
protected final void addFieldError(String field, String key) {
- resultContainer.getFieldErrors().add(new FieldError(field, key,
getLocale()));
+ resultContainer.addFieldError(new FieldError(field, key,
getLocale()));
}
-
-
/**
- * Creates a field error for this action, where there is some sort of
error when setting the field.
- * This version does not take the (offending) field value but the error
message.
- * This method uses it's own error message key.
+ * Creates a field error for this action, where there is some sort of
error when setting the field. This version
+ * does not take the (offending) field value but the error message.
This method uses it's own error message key.
+ *
* @param field
* @param message
*/
protected final void addFieldErrorTypeMessage(String field, String
message) {
- resultContainer.getFieldErrors().add(new FieldError(field,
"error.field.message",new String[]{field, message}, getLocale()));
+ resultContainer.addFieldError(new FieldError(field,
"error.field.message", new String[] { field, message },
+ getLocale()));
}
/**
- * Creates a field error for this action, where the value set on some
field is
- * invalid.
- * This method uses it's own error message key.
+ * Creates a field error for this action, where the value set on some
field is invalid. This method uses it's own
+ * error message key.
+ *
* @param field
* @param value
*/
protected final void addFieldErrorTypeValue(String field, String value)
{
- resultContainer.getFieldErrors().add(new FieldError(field,
"error.field.value",new String[]{field, value}, getLocale()));
+ resultContainer.addFieldError(new FieldError(field,
"error.field.value", new String[] { field, value },
+ getLocale()));
}
-
/**
* Creates a global error for this action.
+ *
* @param key
* @param placeholderValues
*/
protected final void addGlobalError(String key, String[]
placeholderValues) {
- resultContainer.getGlobalErrors().add(new GlobalError(key,
placeholderValues, getLocale()));
+ resultContainer.addGlobalError(new GlobalError(key,
placeholderValues, getLocale()));
}
/**
* Creates a global error for this action.
+ *
* @param key
*/
protected final void addGlobalError(String key) {
- resultContainer.getGlobalErrors().add(new GlobalError(key,
getLocale()));
+ resultContainer.addGlobalError(new GlobalError(key,
getLocale()));
}
protected final void addCachFlushHint(CacheFlushHint hint) {
@@ -265,20 +277,33 @@
*/
private final void setBasicFields() {
NodeManager nm = node.getNodeManager();
- for (String field : fields.keySet()) {
- if (!nm.hasField(field)) {
- addGlobalError("error.field.unknown", new
String[] { field, this.getClass().getName(), nm.getName() });
+ if (fields.isEmpty()) {
+ log.debug("** no fields set for this createnode
action");
}
+ for (String field : fields.keySet()) {
+
+ // the existence of fields is already checked in
'checkFields()' so we don't have
+ // to set errors when non existent fields are set
+ if (nm.hasField(field)) {
if
(!node.getStringValue(field).equals(fields.get(field))) {
setChanged();
- }
+ log.debug(String.format("setting value
'%s' on field '%s' of node of type '%s'", fields.get(field),
+ field,
node.getNodeManager().getName()));
node.setStringValue(field, fields.get(field));
+ } else {
+ log.debug(String.format(
+ "not setting value '%s'
on field '%s' of node of type '%s': value is same as current",
+ fields.get(field),
field, node.getNodeManager().getName()));
+
+ }
+ }
}
for (String field : dateFields.keySet()) {
try {
if (!nm.hasField(field)) {
- addGlobalError("error.field.unknown",
new String[] { field, this.getClass().getName(), nm.getName() });
+ addGlobalError("error.field.unknown",
+ new String[] { field,
this.getClass().getName(), nm.getName() });
}
if (dateFields.get(field).getDateInSeconds() !=
node.getIntValue(field)) {
node.setDateValue(field,
dateFields.get(field).getParsedDate());
@@ -368,107 +393,118 @@
* these are the setter methods for the data binding.
*/
+ public Map<String, DateTime> getDateFields() {
+ return dateFields;
+ }
+
public void setDateFields(Map<String, DateTime> dateFields) {
this.dateFields = dateFields;
}
- public void setFields(Map<String, String> fields) {
- this.fields = fields;
+ public Map<String, String> getFields() {
+ return fields;
}
- public void setFile(MultipartFile file) {
- this.file = file;
- }
-
- public void setId(String id) {
- this.id = id;
+ public void setFields(Map<String, String> fields) {
+ this.fields = fields;
}
public MultipartFile getFile() {
return file;
}
+ public void setFile(MultipartFile file) {
+ this.file = file;
+ }
+
public String getId() {
return id;
}
+ public void setId(String id) {
+ log.info("** id is set to " + id);
+ this.id = id;
+ }
+
/**
- * Check if a relation is possible from the given source to the given
destination with
- * the given relation manager.
+ * Check if a relation is possible from the given source to the given
destination with the given relation manager.
+ *
* @param relationManager
* @return
*/
protected final boolean checkTypeRel(RelationManager relationManager,
Node sourceNode, Node destinationNode) {
- String constraints = String.format(
- "snumber=%s AND dnumber=%s and rnumber=%s",
- "" + sourceNode.getNodeManager().getNumber(),
- "" +
destinationNode.getNodeManager().getNumber(),
- "" + relationManager.getNumber());
- NodeList nl = relationManager.getList(constraints, null, null);
- if(nl.size() == 0){
- addGlobalError(
- "error.create.relation.typerel",
- new
String[]{sourceNode.getNodeManager().getName(),
destinationNode.getNodeManager().getName(), relationManager.getName()});
- addGlobalError("error.create.relation");
+ NodeManager typerelManager =
relationManager.getCloud().getNodeManager("typerel");
+ String constraints = String.format("snumber=%s AND dnumber=%s
AND rnumber=%s", ""
+ + sourceNode.getNodeManager().getNumber(), "" +
destinationNode.getNodeManager().getNumber(), ""
+ + relationManager.getNumber());
+ NodeList nl = typerelManager.getList(constraints, null, null);
+ if (nl.size() == 0) {
+ log.warn(String.format("could not find typerel record
with these constraints: '%s', where snumber type is %s"
+ + " and dnumber type is %s and rnumber
type is %s",
+ constraints,
sourceNode.getNodeManager().getName(),
+
destinationNode.getNodeManager().getName(),
+ relationManager.getName()));
+ addGlobalError("error.create.relation.typerel", new
String[] { sourceNode.getNodeManager().getName(),
+
destinationNode.getNodeManager().getName(), relationManager.getName() });
return false;
}
return true;
}
-
/**
- * can the current owner create a node of this type?
- * set global error when fail.
+ * can the current owner create a node of this type? set global error
when fail.
+ *
* @param nodeManager
* @return true when allowed.
*/
protected final boolean mayWrite(NodeManager nodeManager) {
- if(nodeManager == null){
+ if (nodeManager == null) {
throw new NullPointerException("argument nodeManager is
null");
}
- boolean mayWrite= nodeManager.mayWrite();
- if(!mayWrite){
- addGlobalError("error.authorization.write", new
String[]{nodeManager.getName()});
+ boolean mayWrite = nodeManager.mayWrite();
+ if (!mayWrite) {
+ addGlobalError("error.authorization.write", new
String[] { nodeManager.getName() });
}
return mayWrite;
}
/**
- * can the current owner create a node of this type?
- * set global error when fail.
+ * can the current owner create a node of this type? set global error
when fail.
+ *
* @param nodeManager
* @return true when allowed.
*/
protected final boolean mayCreate(NodeManager nodeManager) {
- if(nodeManager == null){
+ if (nodeManager == null) {
throw new NullPointerException("argument nodeManager is
null");
}
boolean mayCreate = nodeManager.mayCreateNode();
- if(!mayCreate){
- addGlobalError("error.authorization.create", new
String[]{nodeManager.getName()});
+ if (!mayCreate) {
+ addGlobalError("error.authorization.create", new
String[] { nodeManager.getName() });
}
return mayCreate;
}
/**
- * can the current owner delete this node?
- * set global error when fail.
+ * can the current owner delete this node? set global error when fail.
+ *
* @param nodeManager
* @return true when allowed.
*/
protected final boolean mayDelete(Node node) {
- if(node == null){
+ if (node == null) {
throw new NullPointerException("argument node is null");
}
boolean mayDelete = node.mayDelete();
- if(!mayDelete){
- addGlobalError("error.authorization.delete", new
String[]{node.getNumber()+"", node.getNodeManager().getName()});
+ if (!mayDelete) {
+ addGlobalError("error.authorization.delete", new
String[] { node.getNumber() + "",
+ node.getNodeManager().getName() });
}
return mayDelete;
}
- protected final boolean hasErrors(){
- return (resultContainer.getGlobalErrors().size() == 0 &&
resultContainer.getFieldErrors().size() == 0);
+ protected final boolean hasErrors() {
+ return (resultContainer.hasGlobalErrors() ||
resultContainer.hasFieldErrors());
}
@Override
Index: SortRelationAction.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action/SortRelationAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- SortRelationAction.java 18 Aug 2008 19:13:05 -0000 1.1
+++ SortRelationAction.java 8 Sep 2008 16:52:10 -0000 1.2
@@ -11,6 +11,7 @@
import org.mmbase.bridge.Node;
import org.mmbase.bridge.NodeIterator;
import org.mmbase.bridge.NodeList;
+import org.mmbase.bridge.NodeManager;
import org.mmbase.bridge.Query;
import org.mmbase.bridge.Transaction;
import org.mmbase.bridge.util.Queries;
@@ -57,10 +58,10 @@
protected Node doCreateNode(Transaction transaction, Map<String, Node>
idMap, HttpServletRequest request) {
//preconditions
if (!DIRECTION_UP.equals(direction) &&
!DIRECTION_DOWN.equals(direction)){
- addFieldErrorTypeValue("direction", direction);
+ addGlobalError("error.property.illegal.sortdirection",
new String[]{direction, this.getClass().getName(), DIRECTION_UP,
DIRECTION_DOWN});
}
if(!relationManager.hasField(sortField)){
- addFieldError("sortField", "error.field.nonexistant",
new String[]{"sortField", relationManager.getName()});
+ addGlobalError("error.property.illegal.sortfield", new
String[]{sortField, this.getClass().getName(), role});
}
if(!hasErrors()){
@@ -85,7 +86,9 @@
new String[]{role, "" +
sourceNode.getNumber(), "" + destinationNode.getNumber()});
return null;
}else{
- return
transaction.getNode(nl.getNode(0).getStringValue(pathBuilder.getStep(1) +
".number"));
+ Node result =
transaction.getRelation(nl.getNode(0).getStringValue(pathBuilder.getStep(1) +
".number"));
+ log.debug("node found for RelationSortAction:
"+result);
+ return result;
}
}
return null;
@@ -109,6 +112,7 @@
PathBuilder pb = createPathBuilder();
+ boolean relationFound = false;
for (int i = 0; i < nl.size(); i++) {
//String thisDestinationNodeNumber =
nl.getNode(i).getNodeValue(pb.getStep(2)).getStringValue("number");
@@ -116,39 +120,58 @@
// log.debug(i + ": number: " + thisNodeNumber + "
posrel: "
// +
nl.getNode(i).getStringValue(action.getRole() + ".pos"));
// }
-
+// log.debug(String.format("testing [%s] with
[%s]",nl.getNode(i).getNodeValue(pb.getStep(1)).getNumber(),
getNode().getNumber()));
if (getNode().getNumber() ==
nl.getNode(i).getNodeValue(pb.getStep(1)).getNumber()) {
- log.debug("relation node found at position
"+i+" with sort field value: "+nl.getNode(i).getIntValue(pb.getStep(1) + "." +
sortField));
+ relationFound = true;
+ log.debug("relation node found at list position
"+i+" with sort field value: "+nl.getNode(i).getIntValue(pb.getStep(1) + "." +
sortField));
// node found. now find the relation node node
that we are going to
// have to swap places with
Node nodeToSwapWith = null;
+ int nodeToSwapIndex = -1;
// Node relationNode =
nl.getNode(i).getNodeValue(pb.getStep(1));
if (direction.equals(
DIRECTION_UP)) {
if (i > 0) {
+ log.debug("direction is up and
list index is "+i);
nodeToSwapWith = nl.getNode(i -
1).getNodeValue(pb.getStep(1));
+ nodeToSwapIndex = i-1;
+// log.debug("step to extract from
virtual node: "+pb.getStep(1));
+// log.debug("node to swap(nl):
"+nl.getNode(i - 1));
+// log.debug("node to swap:
"+nodeToSwapWith);
} else {
log.error("you want to go up,
but you are at the top of the list. Abort!");
return;
}
} else if (direction.equals(
DIRECTION_DOWN)) {
- if (i < nl.size()) {
+ if (i < ( nl.size() - 1 )) {
+ log.debug("direction is down
and list index is "+i+" and list size = "+nl.size());
nodeToSwapWith = nl.getNode(i +
1).getNodeValue(pb.getStep(1));
+ nodeToSwapIndex = i + 1;
} else {
log.error("you want to go down,
but you are at the end of the list. Abort!");
return;
}
+ }else{
+ log.fatal(String.format("attribute
'direction has illegal value [%s], while this value should have been checked.
Bug!", direction));
}
// this should not happen
- if (nodeToSwapWith == null) {
- log.error("other node is null! can not
beeee");
+ if (nodeToSwapIndex == -1) {
+ log.fatal("Next or preveaus relation
node to swap position with is not found. this is a BUG!");
return;
}
+ nodeToSwapWith =
transaction.getRelation(nl.getNode(nodeToSwapIndex).getStringValue(pb.getStep(1)
+ ".number"));
+ log.debug(String.format(
+ "Swap relation found at list
position %s with sort field value %s",
+ nodeToSwapIndex,
+
nodeToSwapWith.getIntValue(sortField)));
+
+ log.debug(String.format("node number is %s and
swap node number is %s", getNode().getNumber(), nodeToSwapWith.getNumber()));
+
// now let the two nodes swap position
int p1 = getNode().getIntValue(sortField);
int p2 = nodeToSwapWith.getIntValue(sortField);
@@ -156,12 +179,18 @@
getNode().setIntValue(sortField, p2);
nodeToSwapWith.setIntValue(sortField, p1);
- // create cache flush hint
+ // a cacheflush hint needs to be created for
this action.
doSetCachflushHint();
// we can stop iterating
return;
}
+
+ }
+ if(!relationFound){
+ log.fatal(String.format(
+ "relation node with number %s not found
in nodelist [%s]. This is a BUG!",
+ getNode().getNumber(), nl));
}
}
@@ -242,7 +271,7 @@
/**
* creates a list of of virtual nodes nodes that exist between the
- * source node and destination node type, with te given relation role.
+ * source node and destination node type, with the given relation role.
* @param transaction
* @return a virtual node list containing the sortfield values.
*/
@@ -255,9 +284,9 @@
NodeList nl = transaction.getList(
"" + sourceNode.getNumber(),
pb.getPath(),
- pb.getStep(1) + sortField,
+ pb.getStep(1) + "." + sortField,
null,
- pb.getStep(1) + sortField,
+ pb.getStep(1) + "." + sortField,
"up",
null,
false);
Index: CreateRelationAction.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action/CreateRelationAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- CreateRelationAction.java 18 Aug 2008 19:13:05 -0000 1.2
+++ CreateRelationAction.java 8 Sep 2008 16:52:10 -0000 1.3
@@ -7,6 +7,7 @@
import nl.vpro.redactie.ResultContainer;
import org.apache.commons.lang.StringUtils;
+import org.mmbase.applications.vprowizards.spring.FieldError;
import org.mmbase.applications.vprowizards.spring.cache.CacheFlushHint;
import org.mmbase.applications.vprowizards.spring.util.PathBuilder;
import org.mmbase.bridge.Node;
@@ -53,11 +54,11 @@
protected Node doCreateNode(Transaction transaction, Map<String, Node>
idMap, HttpServletRequest request) {
//preconditions
if(!SORT_POSITION_BEGIN.equals(sortPosition) &&
!SORT_POSITION_END.equals(sortPosition)){
- addFieldErrorTypeValue("sortPosition", sortPosition);
+ addGlobalError("error.field.value", new
String[]{"sortPosition", sortPosition} );
}
if(!StringUtils.isBlank(sortField)){
if(!relationManager.hasField(sortField)){
- addFieldError("sortField",
"error.field.nonexistant", new String[]{"sortField",
relationManager.getName()});
+ addGlobalError("error.field.unknown", new
String[]{"sortField", this.getClass().getName(), relationManager.getName()});
}
}
Index: CreateNodeAction.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/org/mmbase/applications/vprowizards/spring/action/CreateNodeAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- CreateNodeAction.java 18 Aug 2008 19:13:05 -0000 1.2
+++ CreateNodeAction.java 8 Sep 2008 16:52:10 -0000 1.3
@@ -11,6 +11,9 @@
import org.mmbase.bridge.Node;
import org.mmbase.bridge.NodeManager;
import org.mmbase.bridge.Transaction;
+import org.mmbase.datatypes.NodeManagerNamesDataType;
+import org.mmbase.util.logging.Logger;
+import org.mmbase.util.logging.Logging;
/**
* This action will create a node of the type that you set in the field
@@ -20,7 +23,7 @@
*
*/
public class CreateNodeAction extends AbstractNodeAction {
-
+ private static final Logger log =
Logging.getLoggerInstance(CreateNodeAction.class);
private String nodeType;
public final void setNodeType(String nodemanger) {
@@ -45,6 +48,7 @@
return null;
} else {
if(mayCreate(nodeManager)){
+ log.info(String.format("Creating new node of
type '%s'", nodeManager.getName()));
return nodeManager.createNode();
}
return null;
@@ -58,12 +62,19 @@
* @return the node manager used to create a new node with
*/
protected NodeManager resolveNodemanager(Transaction transaction) {
+ if(transaction == null){
+ throw new IllegalStateException("transaction should not
be null!");
+ }
if (StringUtils.isBlank(nodeType)) {
+ log.debug("Can not create node manager instance: name
field is empty");
addGlobalError("error.property.required", new String[]
{ "nodemanager", CreateNodeAction.class.getName() });
return null;
} else if (transaction.hasNodeManager(nodeType)) {
- return transaction.getNodeManager(nodeType);
+ NodeManager nodeManager =
transaction.getNodeManager(nodeType);
+ log.debug(String.format("Returning node manager of type
'%s'", nodeManager.getName()));
+ return nodeManager;
} else {
+ log.debug(String.format("Node manager of type '%s' does
not exist: can not get instance.", nodeType));
addGlobalError("error.illegal.nodemanager", new
String[] { nodeType });
return null;
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs