+ /**
+ * Validates the vlan number
+ *
+ * @return the result of the check as Status object
+ */
+ private Status validateVlan() {
+ if (dlVlan != null) {
+ short vlanId = 0;
+ try {
+ String[] elemArray = dlVlan.split(",");
+ for (String elem : elemArray) {
+ if (elem.contains("-")) {
+ String[] limits = elem.split("-");
+ if (Short.parseShort(limits[0]) < 0
+ || Short.parseShort(limits[0]) >= Short.parseShort(limits[1])
+ || Short.parseShort(limits[1]) > 0xfff) {
+ return new Status(StatusCode.BADREQUEST, "Invalid vlan id");
+ }
+ } else {
+ vlanId = Short.parseShort(elem);
+ if (vlanId < 0 || vlanId > 0xfff) {
+ return new Status(StatusCode.BADREQUEST, "Invalid vlan id");
+ }
+ }
+ }
+ } catch (NumberFormatException e) {
+ return new Status(StatusCode.BADREQUEST, "Invalid vlan id");
+ }
+ }
+ return new Status(StatusCode.SUCCESS);
+ }
+