public abstract class ConfigurationObject implements Serializable {
private static final long serialVersionUID = 1L;
- private static final String DEFAULT_REGEX = "^[\\w-=\\+\\*\\/\\.\\(\\)\\[\\]\\@\\|\\:]{1,256}$";
+ private static final String DEFAULT_REGEX = "^[\\w-=\\+\\*\\.\\(\\)\\[\\]\\@\\|\\:]{1,256}$";
private static final String REGEX_PROP_NAME = "resourceNameRegularExpression";
private static String regex;
import org.opendaylight.controller.sal.utils.StatusCode;
/**
- * The class describes a switch configuration
+ * The class describes a switch configuration as a collection of properties
*/
public class SwitchConfig extends ConfigurationObject implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
}
private Status validateNodeId() {
- if (!isValidResourceName(nodeId)) {
- return new Status(StatusCode.BADREQUEST, "Invalid NodeId");
+ if (nodeId == null || nodeId.trim().isEmpty()) {
+ return new Status(StatusCode.BADREQUEST, "Invalid node id");
}
return new Status(StatusCode.SUCCESS);
}
private Status validateNodeProperties() {
if (nodeProperties == null) {
- return new Status(StatusCode.BADREQUEST, "nodeProperties cannot be null");
+ return new Status(StatusCode.BADREQUEST, "Node properties must be specified");
+ }
+ if (nodeProperties.containsKey(Description.propertyName)) {
+ if (!isValidResourceName(((Description)nodeProperties.get(Description.propertyName)).getValue())) {
+ return new Status(StatusCode.BADREQUEST, "Invalid node description");
+ }
}
return new Status(StatusCode.SUCCESS);
}