diff --git a/devdocs/specs/core-import-v7.txt b/devdocs/specs/core-import-v7.txt index 409ed596..b02a677e 100644 --- a/devdocs/specs/core-import-v7.txt +++ b/devdocs/specs/core-import-v7.txt @@ -75,7 +75,9 @@ NOTES FOR DOCS - LOCALES - MUST be a default locale set before import because new raven keys will be added to imported v7 locale using the default locale only - IMPORTED USERS - - login and passwords are not imported and need to be setup again after import - - no Authorization Role is set and therefore no rights to anything. A role needs to be set after import for each user + - In order to ensure security imported users are not imported ready to login but rather must be edited individually after import: + - All users are imported with Active status set to false and must be individually edited and set to Active=true as required + - login and passwords are not imported and need to be individually set after import as required + - no Authorization Role is set and therefore no rights to anything. A role needs to be set after import for each user - TAGS, the following objects are imported as tags - TODO: List of objects diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 31e787ee..d18680a4 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -32,6 +32,7 @@ Overall plan for now: anything standing in the way of making the initial client - NEED a document with checklist to go over to ensure that a v7 object ported to RAVEN is "DONE" i.e. not missing any biz rules or properties or something - Tag groups (modify tags already coded) - Localized text + - ** DEVISE a system to ensure no unused keys are brought forward to raven - Search and search text indexing - Auto visible id number assigning code - User routes for create update delete the core User object (no user settings in it) {also see rights in BizRoles.cs as it is not fully fleshed out yet} diff --git a/server/AyaNova/biz/TagBiz.cs b/server/AyaNova/biz/TagBiz.cs index 0990a2aa..3ded6aba 100644 --- a/server/AyaNova/biz/TagBiz.cs +++ b/server/AyaNova/biz/TagBiz.cs @@ -40,13 +40,7 @@ namespace AyaNova.Biz //CREATE internal async Task CreateAsync(string inObj) { - //Must be lowercase per rules - //This may be naive when we get international customers but for now supporting utf-8 and it appears it's safe to do this with unicode - inObj = inObj.ToLowerInvariant(); - - //No spaces in tags, replace with dashes - inObj = inObj.Replace(" ", "-"); - + inObj = CleanTagName(inObj); Validate(inObj, true); if (HasErrors) return null; @@ -65,6 +59,22 @@ namespace AyaNova.Biz } } + private static string CleanTagName(string inObj) + { + //Must be lowercase per rules + //This may be naive when we get international customers but for now supporting utf-8 and it appears it's safe to do this with unicode + inObj = inObj.ToLowerInvariant(); + //No spaces in tags, replace with dashes + inObj = inObj.Replace(" ", "-"); + //Remove multiple dash sequences + inObj = System.Text.RegularExpressions.Regex.Replace(inObj, "-+", "-"); + //Ensure doesn't start or end with a dash + inObj = inObj.Trim('-'); + //No longer than 35 characters + inObj = StringUtil.MaxLength(inObj, 35); + return inObj; + } + //////////////////////////////////////////////////////////////////////////////////////////////// /// GET @@ -142,6 +152,8 @@ namespace AyaNova.Biz //put internal bool Put(Tag dbObj, Tag inObj) { + //Ensure it follows the rules + inObj.Name = CleanTagName(inObj.Name); //Replace the db object with the PUT object CopyObject.Copy(inObj, dbObj, "Id"); @@ -149,10 +161,6 @@ namespace AyaNova.Biz //this will allow EF to check it out ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken; - //Must be lowercase per rules - //This may be naive when we get international customers but for now supporting utf-8 and it appears it's safe to do this with unicode - dbObj.Name = dbObj.Name.ToLowerInvariant(); - Validate(dbObj.Name, false); if (HasErrors) return false; @@ -166,7 +174,8 @@ namespace AyaNova.Biz //Do the patching objectPatch.ApplyTo(dbObj); ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken; - dbObj.Name = dbObj.Name.ToLowerInvariant(); + //Ensure it follows the rules + dbObj.Name = CleanTagName(dbObj.Name); Validate(dbObj.Name, false); if (HasErrors) return false; @@ -251,8 +260,8 @@ namespace AyaNova.Biz var NewTagName = j["Name"].Value(); var OldV7Id = new Guid(j["ID"].Value()); - //In RAVEN tags can only be 35 characters - NewTagName = StringUtil.MaxLength(NewTagName, 35); + //Ensure it follows the rules + NewTagName = CleanTagName(NewTagName); //There might already be a tag of the same name since so many different types of V7 objects are becoming tags //Weighed the pros and cons of uniquifying by object type versus just using the same name for different object types: diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index 4d8c3026..b63b0daf 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -436,7 +436,7 @@ namespace AyaNova.Biz i.UserType = UserType.Subcontractor; } - i.Active = j["Active"].Value(); + i.Active = false;//Ignore incoming value and set all imports to false so that there's no chance of licensing getting circumvented; users all need to be edited anyway for pw and login i.EmployeeNumber = j["EmployeeNumber"].Value(); i.Notes = j["Notes"].Value();