You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Marco Piovesana (JIRA)" <ji...@apache.org> on 2018/05/04 12:52:00 UTC

[jira] [Commented] (OAK-7479) custom property does not respect type

    [ https://issues.apache.org/jira/browse/OAK-7479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16463834#comment-16463834 ] 

Marco Piovesana commented on OAK-7479:
--------------------------------------

The issue seems similar to OAK-3621 that was closed in version 1.4

> custom property does not respect type 
> --------------------------------------
>
>                 Key: OAK-7479
>                 URL: https://issues.apache.org/jira/browse/OAK-7479
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.6.1, 1.8.1
>         Environment: The repository is file system based:
> {code:java}
> File driveFile = new File(directory, "oakrepo");
> File repositoryFile = new File(driveFile, "repository");
> File dataStoreFile = new File(driveFile, "datastore");
> BlobStore blobStore = new FileBlobStore(dataStoreFile.getAbsolutePath());
> fileStore = FileStoreBuilder.fileStoreBuilder(repositoryFile).withBlobStore(blobStore).build();
> nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
> Jcr jcr = new Jcr(nodeStore);
> repository = jcr.createRepository();
> {code}
>            Reporter: Marco Piovesana
>            Priority: Major
>         Attachments: oakRunImage.png
>
>
> I've defined a custom mixin with s single *long* property. When I add that mixing to a node I can set a value of a different type (e.g. *string*) without any error. Same behaviour if I define the mixin using the {{customCND}} or using the {{NodeTypeTemplate.}}
>  Here the code example:
> {code:java}
> NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
> NodeTypeTemplate nt = nodeTypeManager.createNodeTypeTemplate();
> nt.setName("custom:runtime");
> nt.setMixin(true);
> PropertyDefinitionTemplate opt = nodeTypeManager.createPropertyDefinitionTemplate();
> opt.setMandatory(false);
> opt.setName("custom:runtimeTest");
> opt.setRequiredType(PropertyType.LONG);
> opt.setOnParentVersion(OnParentVersionAction.COPY);
> List pdt = nt.getPropertyDefinitionTemplates();
> pdt.add(opt);
> nodeTypeManager.registerNodeType(nt, true);
> session.save();
> Node mynode = JcrUtils.getOrAddNode(session.getRootNode(), "mynode");
> mynode.addMixin("custom:runtime");
> session.save();
> mynode.setProperty("custom:runtimeTest", "my test value");
> session.save();{code}
> If I open the repository using oak-run the property {{custom:runtimeTest}} has type STRING and not LONG (attached image)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)