Remove old getIdFromFilename for let admin can implement it himself
Closed this issue · 0 comments
hdsdi3g commented
And migrate it to a brand new JSModule.
Test with:
mydmam-cli.bash jsinjava -class "hd3gtv.mydmam.pathindexing.IdExtractorFileName" -module IdExtractorFileName -method isValidId -args "<file name>"
and
mydmam-cli.bash jsinjava -class "hd3gtv.mydmam.pathindexing.IdExtractorFileName" -module IdExtractorFileName -method getId -args "<file name>"
Example code:
getId: function(filename) {
if (filename == null) {
return null;
}
if (filename.length < 8) {
return null;
}
var curchar;
for (var pos = 0; pos < 8; pos++) {
curchar = filename.charCodeAt(pos);
if ((curchar > 47) && (curchar < 58)) {
// * from 0 to 9
continue;
}
if (((curchar == 83) || (curchar == 115)) && (pos == 0)) {
// * Start by "S" or "s"
continue;
}
return null;
}
return filename.substring(0, 8);
},
And
isValidId: function(filename) {
if (filename == null) {
return null;
}
if (filename.length < 8) {
return null;
}
var curchar;
for (var pos = 0; pos < 8; pos++) {
curchar = filename.charCodeAt(pos);
if ((curchar > 47) && (curchar < 58)) {
// * from 0 to 9
continue;
}
if (((curchar == 83) || (curchar == 115)) && (pos == 0)) {
// * Start by "S" or "s"
continue;
}
return false;
}
return true;
},