Hi I have a simple script which recieves file and pushes it into repo. one of the requirement is request can contain tags t associate with newly uploaded file, while preserving tags case.folowing is the code i am using to create tags
/**
* @param tags array( with tag names in it)
*/
function getTag(tags){
var store = "workspace://SpacesStore/";
for(var t=0; t< tags.length; t++) {
var tag = taggingService.getTag(store, tags[t]);
var tagExists = (tag != null);
if (!tagExists){
//It creates tag with lower case
tag = taggingService.createTag(store, tags[t]);
//For some reason after createTag tag was null in some cases
var tagNode = search.findNode("workspace://SpacesStore/"+tag.id);
//Give it a name originally intended
tagNode.properties.name=tags[t];
tagNode.save();
}
tags[t] = tag;
}
return tags;
}
when i try to use returned array of tag nodes elsewhere as;
tags = getTag(tags);
for(var t=0; t<tags.length; t++) {
//This line works fine
logger.info(tags[t].name);
//This line again sometimes throws NullPointer even though tags array has all nodes
upload.addTag(tags[t].name);
}
upload is a node created but not called save() upon.With webscript debugger attaching break point at logger.info and letting it go every time it stops seems to fix the issue.Any ideas, it's urgent