cancel
Showing results for 
Search instead for 
Did you mean: 

Access remotely Alfresco with Web Service

alcazar
Champ in-the-making
Champ in-the-making
Hi all,

I am attempting to start an alfresco session on a remote machine but I am getting the error:

(404)/alfresco/api/AuthenticationService

I have a webserviceclient.properties file in the path:
\webroot\WEB-INF\lib\alfresco,

with the follow sentence: repository.location=http://10.114.197.207:8080/alfresco/api

Is that correct? Can anyone help me with this?
12 REPLIES 12

alcazar
Champ in-the-making
Champ in-the-making
Well,

I have changed the code, now I have written:


AuthenticationUtils.startSession"admin","admin");
String _ticket = AuthenticationUtils.getCurrentTicket();



And now the error has changed, when I am attempting to start an alfresco session on a remote machine appear:

org.alfresco.webservice.util.WebServiceException: Error starting session

What is the problem?

alcazar
Champ in-the-making
Champ in-the-making
well, finally I have achieved this one.

Now, I want to get a list of spaces or content for an user…  really, I want to show the nodes of alfresco in an object, that it can be represented in html.

Thanks in advance.

Best regards

nimind
Champ in-the-making
Champ in-the-making
Watch the Alfresco SDK 2.0. It has examples. One of them is a search of content and list the worspaces.

You can do a search:


AuthenticationUtils.startSession(USER, PASS);
   
         repositoryService = WebServiceFactory.getRepositoryService();        
         
         //buildQuery = "-TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\" AND TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"";
         buildQuery = "-TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\"";
         if (sSolutionText !=null && sSolutionText!="") buildQuery = buildQuery + " TEXT:\""+sSolutionText+"\" ";
         if (metadata != null)
         {
            for (i=0; i < metadata.size(); i++)
            {
               buildQuery = buildQuery + " @cm\\:metadata1:\""+metadata.get(i)+"\" ";
               buildQuery = buildQuery + " @cm\\:metadata2:\""+metadata.get(i)+"\" ";
               buildQuery = buildQuery + " @cm\\:metadata3:\""+metadata.get(i)+"\" ";
               buildQuery = buildQuery + " @cm\\:metadata4:\""+metadata.get(i)+"\" ";
               buildQuery = buildQuery + " @cm\\:metadata5:\""+metadata.get(i)+"\" ";   
            }
         }
         // Create a query object, looking for all items with alfresco in the name of text
         query = new Query(Constants.QUERY_LANG_LUCENE, buildQuery);
       
         // Execute the query
         queryResult = repositoryService.query(store, query, false);
       
         // Display the results
         resultSet = queryResult.getResultSet();
         rows = resultSet.getRows();

and then, recursively, you can do querychildren in order to search the children of each node

alcazar
Champ in-the-making
Champ in-the-making
thanks a lot!!!!!!!!!

I am going to try it immediately!!!!

I am really expectant with this!!!

and I will tell you the final result.

Regards

alcazar
Champ in-the-making
Champ in-the-making
ok!

Only one things:

- what type of object is 'metadata'? is it initialized?
- what type of object is 'store'?

thanks

nimind
Champ in-the-making
Champ in-the-making
Metadata is a custom property that i created in the files.
Store is a constant, simply add at the begining 

protected static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

alcazar
Champ in-the-making
Champ in-the-making
thaks, I have resolved the problem of 'store'.

Now, I can run the web service, but the 'rows' objets is null

Agggggr!!!! My code is below:

try
{
//AuthenticationUtils.startSession(_uid, _pwd);
Store store = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

RepositoryServiceSoapBindingStub repositoryService =
WebServiceFactory.getRepositoryService();         

//buildQuery = "-TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\" AND TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"";

String buildQuery = "-
TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\"";
Object sSolutionText = "Diccionario";

// Create a query object, looking for all items with alfresco in the name of text

Query query = new Query(Constants.QUERY_LANG_LUCENE, buildQuery);
        // Execute the query
        QueryResult queryResult = repositoryService.query(store, query, false);
        // Display the results
        ResultSet resultSet = queryResult.getResultSet();
        ResultSetRow[] rows = resultSet.getRows();
        if (rows == null )
        {
           System.out.println("\n null \n");
        }
       
  
       
      }
catch(Exception e)
{
   System.out.println("\n  catch " + e.getMessage() + "\n");
}
}

nimind
Champ in-the-making
Champ in-the-making
You are looking for something that it is not a folder, but you don't say what text you are looking for. Modify with this:

String buildQuery = "-
TYPE:\"{http://www.alfresco.org/model/content/1.0}folder\"";
buildQuery = buildQuery + " TEXT:\"diccionario\" ";

With this query, you are looking for nodes(files,spaces,…) that are not folders and contain the word diccionario.

Don´t forget to upload a file containing that word.

Other: where are you creating the files? Now in Alfresco 2.0 you can create contents in personal space  (with alfresco web client) and in alfresco 1.4, you can only create content in enterprise space. I think that it can be solve with the function getRoot().

Are you spanish?

alcazar
Champ in-the-making
Champ in-the-making
Thanks nimind!

I am going to try it.

and, I am spanish, how you have guessed it? And you?