@Override @Nonnull public String getOakName(@Nonnull String jcrName) throws RepositoryException { return namePathMapper.getOakName(jcrName); }
@Test public void testEmptyName() throws RepositoryException { assertEquals("", npMapper.getJcrName("")); assertEquals("", npMapper.getOakNameOrNull("")); assertEquals("", npMapper.getOakName("")); }
@Override @NotNull public String getOakName(@NotNull String jcrName) throws RepositoryException { return namePathMapper.getOakName(jcrName); }
@Override @NotNull public String getOakName(@NotNull String jcrName) throws RepositoryException { return namePathMapper.getOakName(jcrName); }
/** * Returns the internal name for the specified JCR name. * * @param jcrName JCR node type name. * @return the internal representation of the given JCR name. * @throws javax.jcr.RepositoryException If there is no valid internal representation * of the specified JCR name. */ @NotNull protected final String getOakName(String jcrName) throws RepositoryException { return getNamePathMapper().getOakName(jcrName); }
/** * Returns the internal name for the specified JCR name. * * @param jcrName JCR node type name. * @return the internal representation of the given JCR name. * @throws javax.jcr.RepositoryException If there is no valid internal representation * of the specified JCR name. */ @NotNull protected final String getOakName(String jcrName) throws RepositoryException { return getNamePathMapper().getOakName(jcrName); }
/** * Returns the internal name for the specified JCR name. * * @param jcrName JCR node type name. * @return the internal representation of the given JCR name. * @throws javax.jcr.RepositoryException If there is no valid internal representation * of the specified JCR name. */ @Nonnull protected final String getOakName(String jcrName) throws RepositoryException { return getNamePathMapper().getOakName(jcrName); }
/** * Validates the given node type names. * * @param nodeTypeNames the node type names. * @return the node type names as oak names. * @throws javax.jcr.nodetype.NoSuchNodeTypeException if one of the node type names refers to * an non-existing node type. * @throws javax.jcr.RepositoryException if an error occurs while reading from the * node type manager. */ @Nullable private String[] validateNodeTypeNames(@Nullable String[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { if (nodeTypeNames == null) { return null; } String[] oakNames = new String[nodeTypeNames.length]; for (int i = 0; i < nodeTypeNames.length; i++) { ntMgr.getNodeType(nodeTypeNames[i]); oakNames[i] = namePathMapper.getOakName(nodeTypeNames[i]); } return oakNames; }
/** * Validates the given node type names. * * @param nodeTypeNames the node type names. * @return the node type names as oak names. * @throws javax.jcr.nodetype.NoSuchNodeTypeException if one of the node type names refers to * an non-existing node type. * @throws javax.jcr.RepositoryException if an error occurs while reading from the * node type manager. */ @Nullable private String[] validateNodeTypeNames(@Nullable String[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { if (nodeTypeNames == null) { return null; } String[] oakNames = new String[nodeTypeNames.length]; for (int i = 0; i < nodeTypeNames.length; i++) { ntMgr.getNodeType(nodeTypeNames[i]); oakNames[i] = namePathMapper.getOakName(nodeTypeNames[i]); } return oakNames; }
/** * Validates the given node type names. * * @param nodeTypeNames the node type names. * @return the node type names as oak names. * @throws javax.jcr.nodetype.NoSuchNodeTypeException if one of the node type names refers to * an non-existing node type. * @throws javax.jcr.RepositoryException if an error occurs while reading from the * node type manager. */ @CheckForNull private String[] validateNodeTypeNames(@Nullable String[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { if (nodeTypeNames == null) { return null; } String[] oakNames = new String[nodeTypeNames.length]; for (int i = 0; i < nodeTypeNames.length; i++) { ntMgr.getNodeType(nodeTypeNames[i]); oakNames[i] = namePathMapper.getOakName(nodeTypeNames[i]); } return oakNames; }
private boolean hasPrivileges(@Nullable String absPath, @Nullable Privilege[] privileges, @NotNull PermissionProvider provider, long permissions, boolean checkAcContent) throws RepositoryException { Tree tree; if (absPath == null) { tree = null; if (permissions != Permissions.NO_PERMISSION) { checkPermissions(null, permissions); } } else { tree = getTree(getOakPath(absPath), permissions, checkAcContent); } if (privileges == null || privileges.length == 0) { // null or empty privilege array -> return true log.debug("No privileges passed -> allowed."); return true; } else { Set<String> privilegeNames = new HashSet<>(privileges.length); for (Privilege privilege : privileges) { privilegeNames.add(namePathMapper.getOakName(privilege.getName())); } return provider.hasPrivileges(tree, privilegeNames.toArray(new String[0])); } } }
@Override @SuppressWarnings("deprecation") public Value getValue(int type) throws RepositoryException { if (type == PropertyType.BINARY) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { Base64.decode(value, baos); return valueFactory.createValue( new ByteArrayInputStream(baos.toByteArray())); } catch (IOException e) { throw new RepositoryException( "Failed to decode binary value: " + value, e); } } // The ValueFactory instance takes care of name and path mapping // from JCR to Oak values, but here we need an additional level of // mapping for XML to JCR values. String jcrValue; if (type == PropertyType.NAME) { jcrValue = namePathMapper.getOakName(value); } else if (type == PropertyType.PATH) { jcrValue = namePathMapper.getOakPath(value); } else { jcrValue = value; } return valueFactory.createValue(jcrValue, type); }
@Override @SuppressWarnings("deprecation") public Value getValue(int type) throws RepositoryException { if (type == PropertyType.BINARY) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { Base64.decode(value, baos); return valueFactory.createValue( new ByteArrayInputStream(baos.toByteArray())); } catch (IOException e) { throw new RepositoryException( "Failed to decode binary value: " + value, e); } } // The ValueFactory instance takes care of name and path mapping // from JCR to Oak values, but here we need an additional level of // mapping for XML to JCR values. String jcrValue; if (type == PropertyType.NAME) { jcrValue = namePathMapper.getOakName(value); } else if (type == PropertyType.PATH) { jcrValue = namePathMapper.getOakPath(value); } else { jcrValue = value; } return valueFactory.createValue(jcrValue, type); }
@Test public void testBracketsInNodeName() throws Exception { String[] childNames = { "{A}", "B}", "{C", "(D)", "E)", "(F", }; for (String name : childNames) { assertEquals(name, npMapper.getOakName(name)); } }
@Override @SuppressWarnings("deprecation") public Value getValue(int targetType) throws RepositoryException { try { if (targetType == PropertyType.BINARY) { return valueFactory.createValue(stream()); } String jcrValue = retrieveString(); if (targetType == PropertyType.NAME) { jcrValue = namePathMapper.getOakName(jcrValue); } else if (targetType == PropertyType.PATH) { jcrValue = namePathMapper.getOakPath(jcrValue); } return valueFactory.createValue(jcrValue, targetType); } catch (IOException e) { throw new RepositoryException( "failed to retrieve serialized value", e); } }
@Override @SuppressWarnings("deprecation") public Value getValue(int targetType) throws RepositoryException { try { if (targetType == PropertyType.BINARY) { return valueFactory.createValue(stream()); } String jcrValue = retrieveString(); if (targetType == PropertyType.NAME) { jcrValue = namePathMapper.getOakName(jcrValue); } else if (targetType == PropertyType.PATH) { jcrValue = namePathMapper.getOakPath(jcrValue); } return valueFactory.createValue(jcrValue, targetType); } catch (IOException e) { throw new RepositoryException( "failed to retrieve serialized value", e); } }
@Override @SuppressWarnings("deprecation") public Value getValue(int targetType) throws RepositoryException { try { if (targetType == PropertyType.BINARY) { return valueFactory.createValue(stream()); } String jcrValue = retrieveString(); if (targetType == PropertyType.NAME) { jcrValue = namePathMapper.getOakName(jcrValue); } else if (targetType == PropertyType.PATH) { jcrValue = namePathMapper.getOakPath(jcrValue); } return valueFactory.createValue(jcrValue, targetType); } catch (IOException e) { throw new RepositoryException( "failed to retrieve serialized value", e); } }
private SelectorImpl parseSelector() throws ParseException { String nodeTypeName = readName(); if (namePathMapper != null) { try { nodeTypeName = namePathMapper.getOakName(nodeTypeName); } catch (RepositoryException e) { ParseException e2 = getSyntaxError("could not convert node type name " + nodeTypeName); e2.initCause(e); throw e2; } } NodeTypeInfo nodeTypeInfo = nodeTypes.getNodeTypeInfo(nodeTypeName); if (!nodeTypeInfo.exists()) { throw getSyntaxError("unknown node type"); } String selectorName = nodeTypeName; if (readIf("AS")) { selectorName = readName(); } return factory.selector(nodeTypeInfo, selectorName); }
private SelectorImpl parseSelector() throws ParseException { String nodeTypeName = readName(); if (namePathMapper != null) { try { nodeTypeName = namePathMapper.getOakName(nodeTypeName); } catch (RepositoryException e) { ParseException e2 = getSyntaxError("could not convert node type name " + nodeTypeName); e2.initCause(e); throw e2; } } NodeTypeInfo nodeTypeInfo = nodeTypes.getNodeTypeInfo(nodeTypeName); if (!nodeTypeInfo.exists()) { throw getSyntaxError("unknown node type"); } String selectorName = nodeTypeName; if (readIf("AS")) { selectorName = readName(); } return factory.selector(nodeTypeInfo, selectorName); }
private SelectorImpl parseSelector() throws ParseException { String nodeTypeName = readName(); if (namePathMapper != null) { try { nodeTypeName = namePathMapper.getOakName(nodeTypeName); } catch (RepositoryException e) { ParseException e2 = getSyntaxError("could not convert node type name " + nodeTypeName); e2.initCause(e); throw e2; } } NodeTypeInfo nodeTypeInfo = nodeTypes.getNodeTypeInfo(nodeTypeName); if (!nodeTypeInfo.exists()) { throw getSyntaxError("unknown node type"); } String selectorName = nodeTypeName; if (readIf("AS")) { selectorName = readName(); } return factory.selector(nodeTypeInfo, selectorName); }