+ try {
+ Node node = getJcrNode();
+ if (DName.creationdate.equals(key))
+ key = JcrName.created.qName();
+ else if (DName.getlastmodified.equals(key))
+ key = JcrName.lastModified.qName();
+ else if (DName.getcontenttype.equals(key)) {
+ String contentType = null;
+ if (node.isNodeType(NodeType.NT_FILE)) {
+ Node content = node.getNode(Node.JCR_CONTENT);
+ if (content.isNodeType(NodeType.MIX_MIMETYPE)) {
+ contentType = content.getProperty(Property.JCR_MIMETYPE).getString();
+ if (content.hasProperty(Property.JCR_ENCODING))
+ contentType = contentType + ";encoding="
+ + content.getProperty(Property.JCR_ENCODING).getString();
+ }
+ }
+ if (contentType == null)
+ contentType = "application/octet-stream";
+ return CrAttributeType.cast(clss, contentType);
+ } else if (DName.checkedOut.equals(key)) {
+ if (!node.hasProperty(Property.JCR_IS_CHECKED_OUT))
+ return Optional.empty();
+ boolean isCheckedOut = node.getProperty(Property.JCR_IS_CHECKED_OUT).getBoolean();
+ if (!isCheckedOut)
+ return Optional.empty();
+ // FIXME return URI
+ return (Optional<A>) Optional.of(new Object());
+ } else if (DName.checkedIn.equals(key)) {
+ if (!node.hasProperty(Property.JCR_IS_CHECKED_OUT))
+ return Optional.empty();
+ boolean isCheckedOut = node.getProperty(Property.JCR_IS_CHECKED_OUT).getBoolean();
+ if (isCheckedOut)
+ return Optional.empty();
+ // FIXME return URI
+ return (Optional<A>) Optional.of(new Object());
+ }
+
+ Object value = get(node, key.toString());
+ if (value instanceof List<?> lst)
+ return Optional.of((A) lst);
+ // TODO check other collections?
+ return CrAttributeType.cast(clss, value);
+ } catch (RepositoryException e) {
+ throw new JcrException(e);
+ }