Uploaded image for project: 'Alfresco One Platform'
  1. Alfresco One Platform
  2. ACE-2606

Surf Web Scripts can not be stored inside repository

    Details

    • Type: Feature
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.2.e Community
    • Fix Version/s: None
    • Component/s: Web Scripts and Surf
    • Labels:
      None
    • Environment:
      Ubuntu 13.04 64bit

      Description

      I want to store surf webscripts inside repository (dynamic Share webscripts functionality)
      I have added the folloowing beans into

      tomcat/shared/classes/alfresco/web-extension/alfresco-remote-ws-context.xml
      
      <bean id="webframework.webscripts.store.alfresco.remote" parent="webframework.store.remote.abstract">
            <property name="path"><value>alfresco/site-data/webscripts</value></property>
      </bean>
      

      and I have overrided the webframework.webscripts.searchpath bean

         <!-- Web Scripts - Search Path -->   
         <bean id="webframework.webscripts.searchpath" class="org.springframework.extensions.webscripts.SearchPath">
            <property name="searchPath">
               <list>
                  <ref bean="webframework.webscripts.store.alfresco.custom" />
                  <ref bean="webframework.webscripts.store.alfresco.classpath" />
                  <ref bean="webframework.webscripts.store.classpath" />
                  <ref bean="webscripts.store.alfresco" />
                  <ref bean="webscripts.store" />
      <!-- Remote search path added here -->
                  <ref bean="webframework.webscripts.store.alfresco.remote" />
               </list>
            </property>
         </bean>
      

      Now all repository webscripts, that stored inside /company home/sites/surf-config/webscripts should be accepted! But it does not work.

      Steps to reproduce:
      1. Create test.get.desc.xml inside /company home/sites/surf-config/webscripts

      <webscript>
      	<shortname>My test component</shortname>
      	<description>My test component</description>
      	<url>/alftest/mycomponent</url>
      </webscript>
      

      2. Create empty test.get.html.ftl file inside /company home/sites/surf-config/webscripts
      3. Now refresh webscripts and go to webscripts index page (share/page/index/uri/). There is no newly created webscript.

      The reason
      Webscript framework makes the following request to repository in order to list all webscripts:

      http://localhost:8080/alfresco/s/remoteadm/listpattern/alfresco/site-data/webscripts?s=sitestore&m=*.desc.xml
      

      And this webscript returns nothing.
      Let's change request argument m to t*.desc.xml

      http://localhost:8080/alfresco/s/remoteadm/listpattern/alfresco/site-data/webscripts?s=sitestore&m=t*.desc.xml
      

      Now this webscripts returns
      /alfresco/site-data/webscripts/test.get.desc.xml
      Looks very strange.

      I have looked at implementation org.alfresco.repo.web.scripts.bean.ADMRemoteStore
      org.alfresco.repo.web.scripts.bean.ADMRemoteStore.listDocuments(WebScriptResponse, String, String, String)
      This method uses StringBuilder, that skips empty string tokens!
      And this method executes outputFileNodes with recurse=false argument. recurse should be eqauls to "true".

      The patch
      The patch for remote webscripts can be the following:

          @Override
          protected void listDocuments(final WebScriptResponse res, final String store, final String path, final String pattern)
              throws IOException
      ....
                          StringBuilder buf = new StringBuilder(pattern.length());
                          if (pattern.charAt(0) == '*') {
                              buf.append('*');
                          }
                          for (StringTokenizer t = new StringTokenizer(pattern, "*"); t.hasMoreTokens(); /**/)
                          {
                              buf.append(encodePath(t.nextToken()));
                              if (t.hasMoreTokens())
                              {
                                  buf.append('*');
                              }
                          }
      ...
                      try
                      {
                          outputFileNodes(
                                  res.getWriter(), fileInfo,
                                  aquireSurfConfigRef(encpath + "/" + filePattern, false),
                                  filePattern, true);
                      }
      
      ....
      

        Attachments

          Structure

            Activity

              People

              • Assignee:
                kroast Kevin Roast [X] (Inactive)
                Reporter:
                kroast Kevin Roast [X] (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Structure Helper Panel