@POST
   @Produces(MediaType.APPLICATION_JSON)
   @Path("list/{repository}/{workspace}")
   public Response list(@PathParam("repository") String repository, @PathParam("workspace") String workspace,
      @QueryParam("name") String name)
   {
      Session ses = null;
      try
      {
         ses =
            sessionProviderService.getSessionProvider(null).getSession(workspace,
               repositoryService.getRepository(repository));

         String xpath = "//element(*, exo:groovyResourceContainer)";

         Query query = ses.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH);
         QueryResult result = query.execute();
         NodeIterator nodeIterator = result.getNodes();

         ArrayList<String> scriptList = new ArrayList<String>();

         if (name == null || name.length() == 0)
         {
            while (nodeIterator.hasNext())
            {
               Node node = nodeIterator.nextNode();
               scriptList.add(node.getParent().getPath());
            }
         }
         else
         {
            StringBuilder p = new StringBuilder();
            // add '.*' pattern at the start
            p.append(".*");
            for (int i = 0; i < name.length(); i++)
            {
               char c = name.charAt(i);
               if (c == '*' || c == '?')
               {
                  p.append('.');
               }
               if (".()[]^$|".indexOf(c) != -1)
               {
                  p.append('\\');
               }
               p.append(c);
            }
            // add '.*' pattern at he end
            p.append(".*");

            Pattern pattern = Pattern.compile(p.toString(), Pattern.CASE_INSENSITIVE);
            while (nodeIterator.hasNext())
            {
               Node node = nodeIterator.nextNode();
               String scriptName = node.getParent().getPath();

               if (pattern.matcher(scriptName).matches())
               {
                  scriptList.add(scriptName);
               }
            }
         }
         Collections.sort(scriptList);
         return Response.status(Response.Status.OK).entity(new ScriptList(scriptList)).type(MediaType.APPLICATION_JSON)
            .build();
      }
      catch (Exception e)
      {
         LOG.error(e.getMessage(), e);
         return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage())
            .type(MediaType.TEXT_PLAIN).build();
      }
      finally
      {
         if (ses != null)
         {
            ses.logout();
         }
      }
   }
@ POST @ Produces ( MediaType . APPLICATION_JSON ) @ Path ( "list/{repository}/{workspace}" ) public Response list ( @ PathParam ( "repository" ) String repository , @ PathParam ( "workspace" ) String workspace , @ QueryParam ( "name" ) String name ) { Session ses = null ; try { ses = sessionProviderService . getSessionProvider ( null ) . getSession ( workspace , repositoryService . getRepository ( repository ) ) ; String xpath = "//element(*, exo:groovyResourceContainer)" ; Query query = ses . getWorkspace ( ) . getQueryManager ( ) . createQuery ( xpath , Query . XPATH ) ; QueryResult result = query . execute ( ) ; NodeIterator nodeIterator = result . getNodes ( ) ; ArrayList < String > scriptList = new ArrayList < String > ( ) ; if ( name == null || name . length ( ) == 0 ) { while ( nodeIterator . hasNext ( ) ) { Node node = nodeIterator . nextNode ( ) ; scriptList . add ( node . getParent ( ) . getPath ( ) ) ; } } else { StringBuilder p = new StringBuilder ( ) ; p . append ( ".*" ) ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { char c = name . charAt ( i ) ; if ( c == '*' || c == '?' ) { p . append ( '.' ) ; } if ( ".()[]^$|" . indexOf ( c ) != - 1 ) { p . append ( '\\' ) ; } p . append ( c ) ; } p . append ( ".*" ) ; Pattern pattern = Pattern . compile ( p . toString ( ) , Pattern . CASE_INSENSITIVE ) ; while ( nodeIterator . hasNext ( ) ) { Node node = nodeIterator . nextNode ( ) ; String scriptName = node . getParent ( ) . getPath ( ) ; if ( pattern . matcher ( scriptName ) . matches ( ) ) { scriptList . add ( scriptName ) ; } } } Collections . sort ( scriptList ) ; return Response . status ( Response . Status . OK ) . entity ( new ScriptList ( scriptList ) ) . type ( MediaType . APPLICATION_JSON ) . build ( ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e ) ; return Response . status ( Response . Status . INTERNAL_SERVER_ERROR ) . entity ( e . getMessage ( ) ) . type ( MediaType . TEXT_PLAIN ) . build ( ) ; } finally { if ( ses != null ) { ses . logout ( ) ; } } }
Returns the list of all groovy-scripts found in workspace.

@param repository repository name
@param workspace workspace name
@param name additional search parameter. If not empty method returns the
list of script names matching wildcard else returns all the
scripts found in workspace.
@return list of groovy services
@response
{code:json}
"scriptList" : the list of all groovy scripts found in workspace.
{code}
@LevelAPI Provisional