Переглянути джерело

Fixed Permissions SimpleAttribute: added better constraint

Yentl Van Tendeloo 8 роки тому
батько
коміт
01b8785177
2 змінених файлів з 12 додано та 6 видалено
  1. 0 3
      bootstrap/library.alc
  2. 12 3
      core/core_formalism.mvc

+ 0 - 3
bootstrap/library.alc

@@ -1,7 +1,6 @@
 include "primitives.alh"
 
 Element function export_node(model_name : String, model_reference : Element):
-	log("Export to " + model_name)
 	Element splitted
 	splitted = string_split(model_name, "/")
 	Integer length
@@ -23,8 +22,6 @@ Element function export_node(model_name : String, model_reference : Element):
 	// current now contains the place where we should add the element
 	if (bool_not(dict_in(current, splitted[length]))):
 		dict_add(current, splitted[length], model_reference)
-	else:
-		log(("Could not export to " + model_name) + ": already in use!")
 
 	return model_reference!
 

+ 12 - 3
core/core_formalism.mvc

@@ -15,10 +15,19 @@ SimpleClassDiagrams CoreFormalism {
     SimpleAttribute Permissions {
         constraint = $
             String function constraint(model : Element, name : String):
-                if (bool_not(is_physical_string(model["model"][name]))):
+                Element self
+                self = model["model"][name]
+                if (bool_not(is_physical_string(self))):
                     return "Permissions has no string value"!
-                else:
-                    return "OK"!
+                if (bool_not(string_len(self) == 3)):
+                    return "Permissions string is not of correct length"!
+                if (bool_or(cast_s2i(string_get(self, 0)) < 0, cast_s2i(string_get(self, 0)) > 2)):
+                    return "Owner permission is not in range [0, 2]"!
+                if (bool_or(cast_s2i(string_get(self, 1)) < 0, cast_s2i(string_get(self, 1)) > 2)):
+                    return "Group permission is not in range [0, 2]"!
+                if (bool_or(cast_s2i(string_get(self, 2)) < 0, cast_s2i(string_get(self, 2)) > 2)):
+                    return "Other permission is not in range [0, 2]"!
+                return "OK"!
             $
     }