Marco Piovesana created OAK-7479:
------------------------------------

             Summary: 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.8.1, 1.6.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
         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)

Reply via email to