06-25-2010 08:12 AM
06-25-2010 08:35 AM
var resultString = "Action failed",
resultCode = false;
resultString = "Could not create space";
var doc = args.q,
store = args.s,
time = args.t;
var nodeNew;
if ((doc== null) || (doc == ""))
{
resultString = "document must be specified";
}
else
{
var nodeParent = roothome.childByNamePath("Company Home/Sites/ITD");
var testCompany = roothome.childByNamePath("Company Home/Sites/ITD/" + store);
if (testCompany == null)
{
var nodenewstore;
nodenewstore = nodeParent.createFolder(store);
nodenewstore.properties["cm:title"] = store;
nodenewstore.properties["cm:description"] = "storage space for company specific files";
nodenewstore.properties["app:icon"] = "space-icon-default";
nodenewstore.save();
resultString = "created store site";
resultCode = true;
}
nodeParent = roothome.childByNamePath("Company Home/Sites/ITD/" + store);
var testMonth = roothome.childByNamePath("Company Home/Sites/ITD/" + store + "/" + time);
if (testMonth == null)
{
var nodenewmonth;
nodenewmonth = nodeParent.createFolder(time);
nodenewmonth.properties["cm:title"] = time;
nodenewmonth.properties["cm:description"] = "Monthly storage for company specific files";
nodenewmonth.properties["app:icon"] = "space-icon-default";
nodenewmonth.save();
resultString = "Created month site";
resultCode = true;
}
else
{
resultString = "Already exists, would then move files";
resultCode = false;
}
}
if (doc == undefined || doc.length == 0)
{
model.returnCode = 1;
model.message = "Document name was not provided.";
}
else
{
path = '+PATH:"/app:company_home/st:sites/cm:ITD//*"';
file = '+@\\{http\\://www.alfresco.org/model/content/1.0\\}name:' + doc + '*';
mime = '+@\\{http\\://www.alfresco.org/model/content/1.0\\}content.mimetype:image/jpeg';
querie = path + " " + file + " " + mime;
var nodes = search.luceneSearch(querie);
if (nodes == null || nodes.length == 0 || nodes == undefined)
{
resultString = "File does not exist"
}
else
{
resultString = nodes.name
var stagingFolder = roothome.childByNamePath("/Company Home/Data Dictionary/Sites/ITD/documentLibrary/Stage");
var placeInto = roothome.childByNamePath("Company Home/Sites/ITD/" + store + "/" + time + "/");
var fullPathStr = "/Company Home/Sites/ITD/" + store + "/" + time + "/"
if(stagingFolder != null)
{
// *****************************************************************************************************************************
// move document witin folder/node stagingFolder with name specified in doc, into folder/node placeInto
// *****************************************************************************************************************************
}
}
}
model.resultString = resultString;
model.resultCode = resultCode;
06-25-2010 08:55 AM
06-25-2010 08:59 AM
http://wiki.alfresco.com/wiki/3.4_JavaScript_API#ScriptNode_API
there's a 'move' method. Give it the new parent node.
06-26-2010 10:09 AM
06-28-2010 05:34 AM
path = '+PATH:"/app:company_home/st:sites/cm:ITD//*"';
file = '+@\\{http\\://www.alfresco.org/model/content/1.0\\}name:' + doc + '*';
mime = '+@\\{http\\://www.alfresco.org/model/content/1.0\\}content.mimetype:image/jpeg';
querie = path + " " + file + " " + mime;
var nodes = search.luceneSearch(querie);
if (nodes == null || nodes.length == 0 || nodes == undefined)
{
resultString = "File does not exist";
}
else
{
var stagingFolder = roothome.childByNamePath("/Company Home/Data Dictionary/Sites/ITD/documentLibrary/Stage");
var placeInto = roothome.childByNamePath("Company Home/Sites/ITD/documentLibrary/" + store + "/" + time + "/");
nodes.move(placeInto);
nodes.save();
resultString = "Move successful";
}
Message: 05283325 Wrapped Exception (with status template): 05283324 Failed to execute script '/sortDoc.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': 05283323 TypeError: Cannot find function move. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/sortDoc.get.js#84)
Exception: org.mozilla.javascript.EcmaError - TypeError: Cannot find function move. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/sortDoc.get.js#84)
06-28-2010 06:09 AM
06-28-2010 07:17 AM
06-28-2010 07:21 AM
Try using "nodes[0].move(placeInto);" instead of "nodes.move(placeInto);" and see if it helps.
Cheers,
Lista.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.