<#assign contador = 0 >
<#assign tamanio = 0 >
<#list space.childrenByXPath[".//*"] as child>
<#if child.isDocument>
<#assign contador = contador+1 >
<#assign tamanio = tamanio + child.size>
</#if>
</#list>
<#assign tamanio = (tamanio/1024)/>
<#assign tamanio = (tamanio/1024)/>
<table border="0" celpadding="0" cellspacing="0">
<tr><td>Numero de docs en el espacio: ${contador}</td></tr>
<tr><td>Tamaño de los documentos: ${tamanio}</td></tr>
</table>
<table>
<#macro recurse_macro node depth>
<#if node.isContainer>
<tr>
<td align='left'>(${depth})
<#if (depth>0) >
<#list 1..depth as i>.</#list>
</#if>
<img src="/alfresco${node.icon16}"> <a href="/alfresco${node.url}">${node.properties.name}</a>
</td>
</tr>
<#list node.children as child>
<#if child.isContainer && node.children?size != 0 >
<@recurse_macro node=child depth=depth+1/>
</#if>
</#list>
</#if>
</#macro>
<b>Recursive Listing of Spaces:</b>
<table border="1" celpadding="1" cellspacing="1">
<tr><th> Name Space </th></tr>
<@recurse_macro node=companyhome depth=0/>
</table>
var carpeta = args.carpeta;
var resultados = new Array();
var espacio = roothome.childByNamePath(carpeta);
var i=0;
for(var j=0; j<espacio.children.length; j++){
var hijo = espacio.children[j];
if(hijo.isDocument){
resultados[i]=hijo;
i++;
}
// A partir de aquí no me entra , no sé como acceder a un asubcarpeta en webscript
if(hijo.isContainer){
var espacio2 = roothome.childByNamePath(carpeta+"/"+hijo.name);
for(var x=0; x<espacio2.children.length; x++){
var hijo2=espacio2.childen[x];
if(hijo2.isDocument){
resultados[i]=hijo2;
i++;
}
}
}
}
model.resultados=resultados;
… Lo que tengo que realizar es recorrer una carpeta y sus subcarpetas recursivamente, y obtener los documentos de dichas carpetas.
En el js, solo consigo recorrer la carpeta de un nivel, pero el resto no me funciona, no sé como crear una subcarpeta en webscritp, te muestro el código para ver si me podrías comentar como tirar:
function muestraRutas(node)
{
for each(n in node.children)
{
if ( n.isDocument )
salida+="Ruta de los archivos: "+n.displayPath+"/"+n.name+"\n\r";
for ( var i = 0; i < n.children.length; i++ ) {
if ( n.children[i].isContainer == true )
muestraRutas( n.children[i] );
}
}
}
// Objetos modificables
var nodo_raiz = "" ;
var salida = "";
var logFile = script.parent.childByNamePath( "muestraRutas.txt" );
// Precondiciones
if ( logFile == null )
logFile = script.parent.createFile( "muestraRutas.txt" );
if ( nodo_raiz == "" )
{
var space = companyhome;
}
else{
var space = companyhome.childByNamePath( nodo_raiz );
}
if (space != null) {
muestraRutas( space );
}
else{
salida += "Error al localizar el espacio raiz: " + nodo_raiz + "\n\r";
if (logger.isLoggingEnabled())
{
logger.log("Error al localizar el espacio raiz: " + nodo_raiz );
}
}
logFile.content = salida;
logFile.save();
logFile.content;
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.