cancel
Showing results for 
Search instead for 
Did you mean: 

Read operation - content-service.wsdl

slax
Champ in-the-making
Champ in-the-making
Hello all,

I am trying to do the following : I would like a third party application to be able to download files (content nodes) from Alfresco, update them, then put them back. Basically, I want to be able to check out, do whatever to it (modify it) and check it back in. The webservice API is the best way I found to do that, but I am running into a problem :

The way I see it, I should use the "read" operation to retrieve all the content, modify it somehow, then use the "write" operation (converting the contents to base64binary… but that's ok)… Assuming that is correct (if it isn't please tell me the right way to proceed), I have trouble with the "read" operation because all it returns is a link to the file/node, and this link leads to a login page before granting access to the file… Which is logical in a way, but then how can I make my third party application access the file itself ?

I thought about using the authoring-service to do some check out / check in procedure, but no luck there either (I can't manage to check out by downloading the file… Anyone know how to do that ?)

Another option would be to change security policy to cancel the required authentication to access a certain space… Does anyone know how to do that ?

Thanks a lot in advance.
1 REPLY 1

vsuarez
Champ in-the-making
Champ in-the-making
Hello all,
The way I see it, I should use the "read" operation to retrieve all the content, modify it somehow, then use the "write" operation (converting the contents to base64binary… but that's ok)… Assuming that is correct (if it isn't please tell me the right way to proceed), I have trouble with the "read" operation because all it returns is a link to the file/node, and this link leads to a login page before granting access to the file… Which is logical in a way, but then how can I make my third party application access the file itself ?

Hi again!

You must add the session ticket as parameter in the URL returned by the "read" operation. Something like this:

    protected byte[] getContentFromUrl(String contentUrl, String ticket) {
        if (ticket != null)
            contentUrl += "?ticket=" + ticket;
       
        try {
            URL url = new URL(contentUrl);
            InputStream is = url.openStream();
            byte[] bytes = fillByteArray(is);
            is.close();
            return bytes;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    byte[] fillByteArray(InputStream is) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        byte[] buffer = new byte[512];
        int read = 0;
        while ((read = is.read(buffer)) > 0) {
            bos.write(buffer, 0, read);
        }
        return bos.toByteArray();
    }


If you download de Alfresco SDK, you will get a lot of samples for accessing resources by web services.