cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Models

fedeparma
Champ in-the-making
Champ in-the-making
Is there a function to get all custom models of a Store using Web Services?
1 REPLY 1

jonas
Champ in-the-making
Champ in-the-making
Hi

One simple way, by search.

Here is sample code.

public void testAAA() throws Exception {
      //    Start a new session
       AuthenticationUtils.startSession("admin", "admin");
      //Try and get a user that does not exist
       try
       {
           UserDetails user = WebServiceFactory.getAdministrationService().getUser("admin");
           //fail("An exception should have been raised since we are trying to get hold of a user that does not exist.");
           for(NamedValue obj: user.getProperties())
              System.out.println(obj.getName() + "=" + obj.getValue());
           ParentReference parentReference = new ParentReference(new Store(Constants.WORKSPACE_STORE, "SpacesStore"), null, "/app:company_home", Constants.ASSOC_CONTAINS, "Users Home");
           System.out.println("Node " + parentReference.getPath());
          
           Reference ref = new Reference();
           ref.setStore(new Store(Constants.WORKSPACE_STORE, "SpacesStore"));
           ref.setUuid("78becace-0642-11dc-9e81-5b7e6e431e74");
           //ref.setPath("/app:company_home");
          
           QueryResult queryResult = WebServiceFactory.getRepositoryService().queryChildren(ref);
          
         
           System.out.println("Query " + queryResult.getResultSet().getRows());
          
           ResultSet resultSet = queryResult.getResultSet();
           if (resultSet.getTotalRowCount() > 0)
           {
               ResultSetRow[] rows = resultSet.getRows();
               for (int x = 0; x < rows.length; x++)
               {
                   ResultSetRow row = rows[x];
                   NamedValue[] columns = row.getColumns();
                   for (int y = 0; y < columns.length; y++)
                   {
                       System.out.println("\trow " + x + ": "
                               + row.getColumns(y).getName() + " = "
                               + row.getColumns(y).getValue());
                   }
                  
                   // Check that the aspects are being set
                   ResultSetRowNode node = row.getNode();
                   assertNotNull(node);
                   assertNotNull(node.getId());
                   assertNotNull(node.getType()); 
                   System.out.println("Type = " + node.getType());
                   //String[] aspects = node.getAspects();
                   //assertNotNull(aspects);
               }
              
           } else
           {
              System.out.println("The query returned no results");
               fail("The query returned no results");
           }
       }
       catch (Exception exception)
       {
           // Ignore since this is what we would expect to happen
          //exception.printStackTrace();
       }
       // END a new session
       AuthenticationUtils.endSession();
   }