You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Tycho Nijon <ty...@divault.nl> on 2018/02/21 11:59:54 UTC

Adding custom properties to CMIS Server.

Hi,

I have been trying to add functionality to my custom CMIS server that 
allows for custom properties to be set. The CMIS server implementation 
is an adaptation of the OpenCMIS server framework stub, where the File 
System structure has been replaced by object based storage with 
ElasticSearch. I need these custom properties to allow not only 
"cmis:file" types, but also "cmis:folder" types to have a url property 
where you can download the appropriate metadata file. The "cmis:file" 
type has a contentStream where you can find the actual content (usually 
a PDF), where this custom property is also required to link to the 
metadata file of the "cmis:file".

Based on the instructions at this URL: 
(https://chemistry.apache.org/docs/cmis-samples/samples/properties/index.html), 
I have tried multiple variations of the following code:

                 // CMIS 1.1 properties
                 if (context.getCmisVersion() != CmisVersion.CMIS_1_0) {
                     addPropertyString(result, typeId, filter,
    PropertyIds.DESCRIPTION, null);

                     List<String> secondaryTypes = new ArrayList<String>();
                     secondaryTypes.add("tmlo:metaDataFile");

                     addPropertyIdList(result, typeId, filter,
    PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
                     addPropertyString(result, typeId, filter,
    "tmlo:metaDataFile", tmloCmisObject.getMetaDataFileLocation());
                 }

/Note that the syntax is slightly different from the URL, because the 
framework implementation comes with the "addProperty[X]" functions as 
opposed to the "properties.put" found in the URL.
/

This results in the following exception, however, when trying to connect 
to the CMIS server:

    CMIS Exception: objectNotFound Type 'tmlo:metaDataFile' is unknown!

       Error Content: <html><head><title>Apache Chemistry OpenCMIS -
    objectNotFound error</title><style><!--H1
    {font-size:24px;line-height:normal;font-weight:bold;background-color:#f0f0f0;color:#003366;border-bottom:1px
    solid #3c78b5;padding:2px;} BODY
    {font-family:Verdana,arial,sans-serif;color:black;font-size:14px;}
    HR {color:#3c78b5;height:1px;}--></style></head><body><h1>HTTP
    Status 404 -
    <!--exception-->objectNotFound<!--/exception--></h1><p><!--message-->Type
    'tmlo:metaDataFile' is unknown!<!--/message--></p></body></html>

I have not been able to find out what causes the error. There have been 
responses to similar questions that "custom properties should be defined 
in the repository", but they come without information on how to actually 
do that.

If further information is required I will gladly supply it.

Best regards,

Tycho Nijon

-- 
Digitaal Archief Service

mob      +31 6 43599147
mail     tycho@divault.nl
web      www.divault.com
adres:   Schieland 18, 1948RM, Beverwijk

DiVault in beeld: VIDEO <http://youtu.be/Yse1JvmhJ64>



Deze e-mail inclusief inhoud is alleen voor de ontvanger van deze e-mail.
Elk gebruik anders dan gebruik door de ontvanger is verboden en onrechtmatig.
De verzender is niet verantwoordelijk voor de juiste en complete verzending
van de informatie noch voor enige vertraging.

This email and any attachments thereto may contain private, confidential,
and privileged material for the sole use of the intended recipient.
Any review, copying, or distribution of this email (or any attachments thereto)
by others is strictly prohibited. If you are not the intended recipient,
please contact the sender immediately and permanently delete the original and
  any copies of this email and any attachments thereto.
                               © DiVault 2018


Re: Adding custom properties to CMIS Server.

Posted by Florian Müller <fm...@apache.org>.
Hi Tycho,

I assume you used the OpenCMIS FileShare code as a starting point. If 
so, there should be a class FileShareTypeManager. (You may have renamed 
it.)
The type definitions are set up in the constructor.

To make your use case work, you need two additional type definitions: 
The base secondary type and your secondary type.
The class TypeDefinitionFactory should help you constructing these type 
definitions.


- Florian


> Hi,
> 
> I have been trying to add functionality to my custom CMIS server that
> allows for custom properties to be set. The CMIS server implementation
> is an adaptation of the OpenCMIS server framework stub, where the File
> System structure has been replaced by object based storage with
> ElasticSearch. I need these custom properties to allow not only
> "cmis:file" types, but also "cmis:folder" types to have a url property
> where you can download the appropriate metadata file. The "cmis:file"
> type has a contentStream where you can find the actual content
> (usually a PDF), where this custom property is also required to link
> to the metadata file of the "cmis:file".
> 
> Based on the instructions at this URL:
> (https://chemistry.apache.org/docs/cmis-samples/samples/properties/index.html),
> I have tried multiple variations of the following code:
> 
>                 // CMIS 1.1 properties
>                 if (context.getCmisVersion() != CmisVersion.CMIS_1_0) {
>                     addPropertyString(result, typeId, filter,
>    PropertyIds.DESCRIPTION, null);
> 
>                     List<String> secondaryTypes = new 
> ArrayList<String>();
>                     secondaryTypes.add("tmlo:metaDataFile");
> 
>                     addPropertyIdList(result, typeId, filter,
>    PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
>                     addPropertyString(result, typeId, filter,
>    "tmlo:metaDataFile", tmloCmisObject.getMetaDataFileLocation());
>                 }
> 
> /Note that the syntax is slightly different from the URL, because the
> framework implementation comes with the "addProperty[X]" functions as
> opposed to the "properties.put" found in the URL.
> /
> 
> This results in the following exception, however, when trying to
> connect to the CMIS server:
> 
>    CMIS Exception: objectNotFound Type 'tmlo:metaDataFile' is unknown!
> 
>       Error Content: <html><head><title>Apache Chemistry OpenCMIS -
>    objectNotFound error</title><style><!--H1
> 
> {font-size:24px;line-height:normal;font-weight:bold;background-color:#f0f0f0;color:#003366;border-bottom:1px
>    solid #3c78b5;padding:2px;} BODY
>    {font-family:Verdana,arial,sans-serif;color:black;font-size:14px;}
>    HR {color:#3c78b5;height:1px;}--></style></head><body><h1>HTTP
>    Status 404 -
>    
> <!--exception-->objectNotFound<!--/exception--></h1><p><!--message-->Type
>    'tmlo:metaDataFile' is unknown!<!--/message--></p></body></html>
> 
> I have not been able to find out what causes the error. There have
> been responses to similar questions that "custom properties should be
> defined in the repository", but they come without information on how
> to actually do that.
> 
> If further information is required I will gladly supply it.
> 
> Best regards,
> 
> Tycho Nijon
> 
> --
> Digitaal Archief Service
> 
> mob      +31 6 43599147
> mail     tycho@divault.nl
> web      www.divault.com
> adres:   Schieland 18, 1948RM, Beverwijk
> 
> DiVault in beeld: VIDEO <http://youtu.be/Yse1JvmhJ64>
> 
> 
> 
> Deze e-mail inclusief inhoud is alleen voor de ontvanger van deze 
> e-mail.
> Elk gebruik anders dan gebruik door de ontvanger is verboden en 
> onrechtmatig.
> De verzender is niet verantwoordelijk voor de juiste en complete 
> verzending
> van de informatie noch voor enige vertraging.
> 
> This email and any attachments thereto may contain private, 
> confidential,
> and privileged material for the sole use of the intended recipient.
> Any review, copying, or distribution of this email (or any attachments 
> thereto)
> by others is strictly prohibited. If you are not the intended 
> recipient,
> please contact the sender immediately and permanently delete the 
> original and
>  any copies of this email and any attachments thereto.
>                               © DiVault 2018