openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ariel Constenla-Haile <arie...@apache.org>
Subject Re: CMIS UCP
Date Sun, 02 Jun 2013 06:36:06 GMT

Hi Rajath,

On Sun, Jun 02, 2013 at 09:58:56AM +0530, Rajath Shashidhara wrote:
> Hello,
> 
> Now that I have added a UNO Object of IDL type Content, there are some
> methods that need to be implemented.
> Out of which, com.sun.star.ucb.XContentIdentifier getIdentifier() is one of
> them.
> I have read the api reference for XContentIdentifier.
> 
> It needs XComponentContext as an argument for its constructor.

XContentIdentifier is a class, it does not have constructor.
http://www.openoffice.org/api/docs/common/ref/com/sun/star/ucb/XContentIdentifier.html


> That can be obtained from the argument to the constructor of my UCP class.
> But, my question is what is identifier?
> Is it the name of the file/folder ?
> Also, the second method, getContentProviderScheme()
> does it refer to the way of writing the path as cmis://<path> ?

At the beginning you can simply use the default implementation. Try the
following macro in an office installation without your extension, it
will return cmis as schema is the identifier starts with cmis://


REM  *****  BASIC  *****

Option Explicit

Sub Main
    Dim aMap as Object
    aMap = com.sun.star.container.EnumerableMap.create("string","com.sun.star.ucb.XContentIdentifier")

    Dim oUCB as Object
    oUCB = CreateUnoService("com.sun.star.ucb.UniversalContentBroker")

    Dim sIds()
    sIds = Array(_
        "file:///tmp",_
        "http://www.openoffice.org",_
        "ftp://demo@openoffice.org/test/dummy",_
        "cmis://cmis.alfresco.com:80/cmisatom/" )
    Dim sId$
    For Each sId in sIds
        aMap.put( sId, oUCB.createContentIdentifier( sId ) )
    Next

    Dim oEnum as Object
    oEnum = aMap.createElementEnumeration(false)
    While oEnum.hasMoreElements()
        Dim oPair as Object
        oPair = oEnum.nextElement()
        MsgBox "URL: " + oPair.First + Chr(13) + _
                "Content ID: " + oPair.Second.getContentIdentifier() + Chr(13) + _
                "Content Scheme: " + oPair.Second.getContentProviderScheme()
    Wend
End Sub


If you want to implement the content identifier yourself, just create
a class that implements XContentIdentifier.

And simply reuse the XContentIdentifier you get in queryContent():

    public XContent queryContent(XContentIdentifier xIdentifier) throws IllegalIdentifierException
{
        if (!isValidIdentifier(xIdentifier)) {
            throw new IllegalIdentifierException();
        }
        // Check if a content with given XContentIdentifier already exists
        // TODO implement a cache mechanism, for example a hash map
        // Key: xIdentifier.getContentIdentifier()
        // Value: xIdentifier
        XContent xRet = queryExistingContent(xIdentifier);
        if (xRet != null) {
            return xRet;
        }

        CMISContent aContent = new CMISContent(m_xContext, xIdentifier);
        // cache the new content
        registerNewContent(aContent);

        return aContent;
    }


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

Mime
View raw message