obtenir les fichiers issus d'une certaine template

cancel
Showing results for 
Search instead for 
Did you mean: 
smedini
Member II

obtenir les fichiers issus d'une certaine template

Bonjour,

J'ai écrit le code suivant pour obtenir la liste de fichiers, dans un web project, issus d'un webform X et d'une template Y et présents dans le chemin Z.
Je me suis inspiré de org.alfresco.web.forms.FormDataFunctions.

   
public List<String> listRenditions(String formName, String templateName, String avmPath) {
      logger.info("formName=" + formName + ", templateName=" + templateName + ", avmPath=" + avmPath);
      
      // Listing du dossier correspondant à avmPath.
      final Map<String, AVMNodeDescriptor> entries = this.avmRemote.getDirectoryListing(-1, avmPath);
      logger.info(entries.size() + " entrées trouvées.");
      
      // La liste de résultats.
      final List<String> results = new ArrayList<String>();
      
      // Filtrage de entries pour remplir results.
      for (Map.Entry<String, AVMNodeDescriptor> entry : entries.entrySet()) {
         final String entryName = entry.getKey();
         AVMNodeDescriptor entryNode = entry.getValue();
         
         //si fichier
         if (entryNode.isFile()) {
            
            //si issu du bon form
            PropertyValue pv = this.avmRemote.getNodeProperty(-1, avmPath + '/' + entryName,
                  WCMAppModel.PROP_PARENT_FORM_NAME);
            if (pv != null) {
               if (formName.equals(pv.getStringValue())) {      
                  
                  //si issu de la bonne template
                  pv = this.avmRemote.getNodeProperty(-1, avmPath + '/' + entryName,WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE);
                  if(pv!=null){
                     
                     logger.info(pv.getStringValue());
                     
                     NodeRef nodeRef = (NodeRef)pv.getValue(DataTypeDefinition.NODE_REF);
                     
                     Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
                     String name = this.avmRemote.getNodeProperty(avmVersionPath.getFirst(), avmVersionPath.getSecond(), ContentModel.PROP_TITLE).getStringValue();
                     
                     if(name.equals(templateName)){
                        
                        // si l'entrée à passé toutes les conditions, on la met dans le résultat.
                        results.add(entryName);
                     }
                  }
               }
            }
         }
      }
      logger.info(results.size() + " entrées trouvées après filtrage:");
      logger.info(results);
      return results;
   }

Cela me donne la trace suivante:

INFO: Server startup in 7701 ms
17 avr. 2009 15:45:26 com.company.web.RenditionsBean getRenditionList
INFO: start
17 avr. 2009 15:45:26 com.company.web.FormDataFunctions listRenditions
INFO: formName=infoPerenne, templateName=pageInfoPerenne, avmPath=site-monsite–admin:/www/avm_webapps/ROOT/contenu/infosPerennes
17 avr. 2009 15:45:26 com.company.web.FormDataFunctions listRenditions
INFO: 12 entrées trouvées.
17 avr. 2009 15:45:26 com.company.web.FormDataFunctions listRenditions
INFO: workspace://SpacesStore/02357b70-1663-4b50-bce2-4e247f6cf828
17 avr. 2009 15:45:26 org.alfresco.repo.avm.AVMNodeConverter ToAVMVersionPath
GRAVE: 02357b70-1663-4b50-bce2-4e247f6cf828
17 avr. 2009 15:45:26 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: "Servlet.service()" pour la servlet jsp a généré une exception
org.alfresco.service.cmr.avm.AVMException: Bad Node Reference: 02357b70-1663-4b50-bce2-4e247f6cf828
   at org.alfresco.repo.avm.AVMNodeConverter.ToAVMVersionPath(AVMNodeConverter.java:89)
   at com.company.web.FormDataFunctions.listRenditions(FormDataFunctions.java:74)
   at com.company.web.ServletContextFormDataFunctionsAdapter.listRenditions(ServletContextFormDataFunctionsAdapter.java:41)
   at com.company.web.RenditionsBean.getRenditionList(RenditionsBean.java:18)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.commons.el.FunctionInvocation.evaluate(FunctionInvocation.java:172)
   at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
   at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)
   at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:924)
   at org.apache.jsp.view.components.infosPerennes_002dlist_jsp._jspx_meth_c_005fforEach_005f0(infosPerennes_002dlist_jsp.java:97)
   at org.apache.jsp.view.components.infosPerennes_002dlist_jsp._jspService(infosPerennes_002dlist_jsp.java:70)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   at org.alfresco.catalina.valve.AVMUrlValve.invoke(AVMUrlValve.java:376)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   at org.alfresco.catalina.valve.AVMUrlValve.invoke(AVMUrlValve.java:719)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
   at java.lang.Thread.run(Thread.java:619)

Cordialement
1 Reply
smedini
Member II

Re: obtenir les fichiers issus d'une certaine template

Je précise mes versions:
je suis sous windows XP SP2, Alfresco-Enterprise-3.0.1