/** * {@inheritDoc} */ public String getAuthorizableId(DocViewNode node) { // try Oak way of storing the id first: DocViewProperty idProp = node.props.get("rep:authorizableId"); if (idProp == null || idProp.isMulti) { // jackrabbit 2.x or Oak with migrated Jackrabbit 2.x content return org.apache.jackrabbit.util.Text.unescapeIllegalJcrChars(node.name); } else { // oak 1.x return idProp.values[0]; } }
/** * * @param encodedFileName * @param useMultiByte * @return */ public static String fileNameDecode( String encodedFileName, boolean useMultiByte ) { if ( useMultiByte ) { return Text.unescapeIllegalJcrChars( ISO9075.decode( encodedFileName ) ); } else { return Text.unescapeIllegalJcrChars( encodedFileName ); } }
private static String getPathName(String pathToACNode) { return Text.unescapeIllegalJcrChars(Text.getName(pathToACNode)); }
private static String getPathName(String pathToACNode) { return Text.unescapeIllegalJcrChars(Text.getName(pathToACNode)); }
/** * Returns the unescaped name of the node that defines this <code>Authorizable</code>. * * @return the unescaped name of the node that defines this <code>Authorizable</code>. * @see Authorizable#getID() */ public String getID() throws RepositoryException { return Text.unescapeIllegalJcrChars(getNode().getName()); }
/** * Returns the unescaped name of the node that defines this <code>Authorizable</code>. * * @return the unescaped name of the node that defines this <code>Authorizable</code>. * @see Authorizable#getID() */ public String getID() throws RepositoryException { return Text.unescapeIllegalJcrChars(getNode().getName()); }
String hint = Text.unescapeIllegalJcrChars(nodeName); int idLength = hint.length(); StringBuilder segment = new StringBuilder();
String hint = Text.unescapeIllegalJcrChars(nodeName); int idLength = hint.length(); StringBuilder segment = new StringBuilder();
String hint = Text.unescapeIllegalJcrChars(nodeName); int idLength = hint.length(); StringBuilder segment = new StringBuilder();
@CheckForNull public static String getAuthorizableId(@Nonnull Tree authorizableTree) { checkNotNull(authorizableTree); if (UserUtil.isType(authorizableTree, AuthorizableType.AUTHORIZABLE)) { PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID); if (idProp != null) { return idProp.getValue(STRING); } else { return Text.unescapeIllegalJcrChars(authorizableTree.getName()); } } return null; }
@Nullable public static String getAuthorizableId(@NotNull Tree authorizableTree) { checkNotNull(authorizableTree); if (UserUtil.isType(authorizableTree, AuthorizableType.AUTHORIZABLE)) { PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID); if (idProp != null) { return idProp.getValue(STRING); } else { return Text.unescapeIllegalJcrChars(authorizableTree.getName()); } } return null; }
/** * Retrieve the id from the given {@code authorizableTree}, which must have * been verified for being a valid authorizable of the specified type upfront. * * @param authorizableTree The authorizable tree which must be of the given {@code type}/ * @param type The type of the authorizable tree. * @return The id retrieved from the specified {@code AuthorizableTree}. */ @NotNull public static String getAuthorizableId(@NotNull Tree authorizableTree, @NotNull AuthorizableType type) { checkArgument(UserUtil.isType(authorizableTree, type)); PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID); if (idProp != null) { return idProp.getValue(STRING); } else { return Text.unescapeIllegalJcrChars(authorizableTree.getName()); } }
/** * Retrieve the id from the given {@code authorizableTree}, which must have * been verified for being a valid authorizable of the specified type upfront. * * @param authorizableTree The authorizable tree which must be of the given {@code type}/ * @param type The type of the authorizable tree. * @return The id retrieved from the specified {@code AuthorizableTree}. */ @Nonnull public static String getAuthorizableId(@Nonnull Tree authorizableTree, @Nonnull AuthorizableType type) { checkArgument(UserUtil.isType(authorizableTree, type)); PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID); if (idProp != null) { return idProp.getValue(STRING); } else { return Text.unescapeIllegalJcrChars(authorizableTree.getName()); } }
public Iterator<String> list() throws MessagingException { try { Session session = login(); try { Collection<String> keys = new ArrayList<String>(); QueryManager manager = session.getWorkspace().getQueryManager(); Query query = manager.createQuery("/jcr:root/" + MAIL_PATH + "//element(*,james:mail)", Query.XPATH); NodeIterator iterator = query.execute().getNodes(); while (iterator.hasNext()) { String name = iterator.nextNode().getName(); keys.add(Text.unescapeIllegalJcrChars(name)); } return keys.iterator(); } finally { session.logout(); } } catch (RepositoryException e) { throw new MessagingException("Unable to list messages", e); } }
@Override public Iterator<MailKey> list() throws MessagingException { try { Session session = login(); try { Collection<String> keys = new ArrayList<>(); QueryManager manager = session.getWorkspace().getQueryManager(); Query query = manager.createQuery("/jcr:root/" + MAIL_PATH + "//element(*,james:mail)", Query.XPATH); NodeIterator iterator = query.execute().getNodes(); while (iterator.hasNext()) { String name = iterator.nextNode().getName(); keys.add(Text.unescapeIllegalJcrChars(name)); } return keys.stream() .map(MailKey::new) .iterator(); } finally { session.logout(); } } catch (RepositoryException e) { throw new MessagingException("Unable to list messages", e); } }
/** * Writes the mail attributes from the <code>jamesattr:*</code> property. * * @param node * mail node * @param mail * mail message * @throws RepositoryException * if a repository error occurs * @throws IOException * if an IO error occurs */ private void getAttributes(Node node, Mail mail) throws RepositoryException, IOException { PropertyIterator iterator = node.getProperties("jamesattr:*"); while (iterator.hasNext()) { Property property = iterator.nextProperty(); String name = Text.unescapeIllegalJcrChars(property.getName().substring("jamesattr:".length())); if (property.getType() == PropertyType.BINARY) { try (InputStream input = property.getStream()) { ObjectInputStream stream = new ObjectInputStream(input); mail.setAttribute(name, (Serializable) stream.readObject()); } catch (ClassNotFoundException e) { throw new IOException(e.getMessage()); } } else { mail.setAttribute(name, property.getString()); } } }
while (iterator.hasNext()) { Property property = iterator.nextProperty(); String name = Text.unescapeIllegalJcrChars(property.getName().substring("jamesattr:".length())); if (property.getType() == PropertyType.BINARY) { InputStream input = property.getStream();
/** * Reads a mail message from the given mail node. * * @param node * mail node * @return mail message * @throws MessagingException * if a messaging error occurs * @throws RepositoryException * if a repository error occurs * @throws IOException * if an IO error occurs */ private Mail getMail(Node node) throws MessagingException, RepositoryException, IOException { String name = Text.unescapeIllegalJcrChars(node.getName()); MailImpl mail = new MailImpl(name, getSender(node), getRecipients(node), getMessage(node)); mail.setState(getState(node)); mail.setLastUpdated(getLastUpdated(node)); mail.setErrorMessage(getError(node)); mail.setRemoteHost(getRemoteHost(node)); mail.setRemoteAddr(getRemoteAddr(node)); getAttributes(node, mail); return mail; }
/** * Reads a mail message from the given mail node. * * @param node * mail node * @return mail message * @throws MessagingException * if a messaging error occurs * @throws RepositoryException * if a repository error occurs * @throws IOException * if an IO error occurs */ private Mail getMail(Node node) throws MessagingException, RepositoryException, IOException { String name = Text.unescapeIllegalJcrChars(node.getName()); MailImpl mail = new MailImpl(name, getSender(node), getRecipients(node), getMessage(node)); mail.setState(getState(node)); mail.setLastUpdated(getLastUpdated(node)); mail.setErrorMessage(getError(node)); mail.setRemoteHost(getRemoteHost(node)); mail.setRemoteAddr(getRemoteAddr(node)); getAttributes(node, mail); return mail; }