cancel
Showing results for 
Search instead for 
Did you mean: 

Webservice show the url the documents of a space

berenicestr69
Champ in-the-making
Champ in-the-making
Hello, i´m trying to do a webservice.

When its called, send for paremeter the space folder to serarch the documents.

If there is documents, show the url to download it.

¿how can I do it??? Please  I need Help.


This is the code of my WebService:

package org.alfresco.documentos.webservice;

import java.rmi.RemoteException;

import org.alfresco.webservice.authentication.AuthenticationFault;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.repository.RepositoryFault;
import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.WebServiceFactory;

public class ObtenerDocumentos {
     private static String URL_SERVER  = "http://localhost:8080/Alfresco/api"; 
   
     /** Estaclece la url al servidor de Alfresco
     * @param AlfrescoServerUrl */
      
         private static  void setServerUrl(String AlfrescoServerUrl) { 
             WebServiceFactory.setEndpointAddress(AlfrescoServerUrl); 
         } 
         private static void obtenerWSDocumentos(Store store, String myUuid)
         {
            setServerUrl(URL_SERVER);
               try {
               try {
                  AuthenticationUtils.startSession("admin", "admin");
               } catch (AuthenticationFault e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
               }
                 Reference myFolder = new Reference(store, myUuid, null); // You can specify the path instead of the uuid if you prefer
                  RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
                  QueryResult queryResult = null;
               try {
                  queryResult = repositoryService.queryChildren(myFolder);
               } catch (RepositoryFault e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
               } catch (RemoteException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
               }
                  ResultSet resultSet = queryResult.getResultSet();

                  ResultSetRow[] rows = resultSet.getRows();
                  for(ResultSetRow row : rows) {
                     // Every "row" is pointing to a file
                     // Whow can I get the url????   PLEASE HELP
  
                  }
            } 
               finally 
                { 
                    // Finalizamos la sesión 
                    AuthenticationUtils.endSession(); 
         
                }    

         }
   
   }
2 REPLIES 2

colindstephenso
Champ in-the-making
Champ in-the-making
I think you will need to do something like:

ResultSetRow[] rows = resultSet.getRows();
for(ResultSetRow row : rows) {
    // Every "row" is pointing to a file
    // Whow can I get the url???? PLEASE HELP

    NamedValue[] columns = row.getColumns();
    for (int y = 0; y < columns.length; y++) {
        String fieldName = row.getColumns()[y].getName();
        String fieldValue = row.getColumns(y).getValue();
}

I cannot remember why property you will need,

Cheers,
Colin.

berenicestr69
Champ in-the-making
Champ in-the-making
Perfect!!

Thanks a lot for your colabotation!!!

Smiley Very Happy