throws IOException, RepositoryException { try { ContentHandler handler = getExportContentHandler(out); exportDocumentView(absPath, handler, skipBinary, noRecurse); } catch (SAXException e) { Exception exception = e.getException();
throws IOException, RepositoryException { try { ContentHandler handler = getExportContentHandler(out); exportSystemView(absPath, handler, skipBinary, noRecurse); } catch (SAXException e) { Exception exception = e.getException();
/** * Calls {@link #getItem(String)} with the given path and returns * <code>true</code> if the call succeeds. Returns <code>false</code> * if a {@link PathNotFoundException} was thrown. Other exceptions are * passed through. * * @param absPath absolute path * @return <code>true</code> if an item exists at the given path, * <code>false</code> otherwise * @throws RepositoryException if an error occurs */ public boolean itemExists(String absPath) throws RepositoryException { try { getItem(absPath); return true; } catch (PathNotFoundException e) { return false; } }
/** * Checks whether a node with the given absolute path exists. * * @see Session#nodeExists(String) * @param absPath absolute path * @return <code>true</code> if a node with the given path exists, * <code>false</code> otherwise * @throws RepositoryException if the path is invalid */ public boolean nodeExists(String absPath) throws RepositoryException { if (absPath.equals("/")) { return true; } else { return getRootNode().hasNode(toRelativePath(absPath)); } }
Node root = getRootNode(); if (absPath.equals("/")) { return root; } else if (absPath.startsWith("[") && absPath.endsWith("]")) { return getNodeByIdentifier(absPath.substring(1, absPath.length() - 1)); } else { String relPath = toRelativePath(absPath); if (root.hasNode(relPath)) { return root.getNode(relPath);
/** * Logs in the same workspace with the given credentials. * <p> * The default implementation: * <ul> * <li>Retrieves the {@link Repository} instance using * {@link Session#getRepository()} * <li>Retrieves the current workspace using {@link Session#getWorkspace()} * <li>Retrieves the name of the current workspace using * {@link Workspace#getName()} * <li>Calls {@link Repository#login(Credentials, String)} on the * retrieved repository with the given credentials and the retrieved * workspace name. * </ul> * * @param credentials login credentials * @return logged in session * @throws RepositoryException if an error occurs */ public Session impersonate(Credentials credentials) throws RepositoryException { return getRepository().login(credentials, getWorkspace().getName()); }
/** * Returns the prefixes of all known namespace mappings. All global * mappings not already included in the local set of namespace mappings * are added there. * <p> * This behaviour is based on JSR 283 (JCR 2.0), but remains backwards * compatible with JCR 1.0. * * @return namespace prefixes * @throws RepositoryException if a repository error occurs */ public String[] getNamespacePrefixes() throws RepositoryException { for (String uri : getWorkspace().getNamespaceRegistry().getURIs()) { getNamespacePrefix(uri); } synchronized (namespaces) { return namespaces.keySet().toArray(new String[namespaces.size()]); } }
String prefix = getWorkspace().getNamespaceRegistry().getPrefix(uri);
/** * Parses the given input stream as an XML document and processes the * SAX events using the {@link ContentHandler} returned by * {@link Session#getImportContentHandler(String, int)}. * * @param parentAbsPath passed through * @param in input stream to be parsed as XML and imported * @param uuidBehavior passed through * @throws IOException if an I/O error occurs * @throws RepositoryException if another error occurs */ public void importXML( String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, RepositoryException { ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new DefaultContentHandler(handler).parse(in); }
try { ContentHandler handler = new ToXmlContentHandler(out); exportSystemView(absPath, handler, skipBinary, noRecurse); } catch (SAXException e) { Exception exception = e.getException();
try { ContentHandler handler = new ToXmlContentHandler(out); exportDocumentView(absPath, handler, skipBinary, noRecurse); } catch (SAXException e) { Exception exception = e.getException();
/** * Generates a system view export using a {@link SystemViewExporter} * instance. * * @param path of the node to be exported * @param handler handler for the SAX events of the export * @param skipBinary whether binary values should be skipped * @param noRecurse whether to export just the identified node * @throws PathNotFoundException if a node at the given path does not exist * @throws SAXException if the SAX event handler failed * @throws RepositoryException if another error occurs */ public void exportSystemView( String path, ContentHandler handler, boolean skipBinary, boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException { export(path, new SystemViewExporter( this, handler, !noRecurse, !skipBinary)); }
Node root = getRootNode(); String relPath = absPath.substring(1); if (relPath.length() == 0) {
/** * Checks whether a property with the given absolute path exists. * * @see Session#propertyExists(String) * @param absPath absolute path * @return <code>true</code> if a property with the given path exists, * <code>false</code> otherwise * @throws RepositoryException if the path is invalid */ public boolean propertyExists(String absPath) throws RepositoryException { if (absPath.equals("/")) { return false; } else { return getRootNode().hasProperty(toRelativePath(absPath)); } }
Node root = getRootNode(); if (absPath.equals("/")) { return root; } else if (absPath.startsWith("[") && absPath.endsWith("]")) { return getNodeByIdentifier(absPath.substring(1, absPath.length() - 1)); } else { String relPath = toRelativePath(absPath); if (root.hasNode(relPath)) { return root.getNode(relPath);
/** * Logs in the same workspace with the given credentials. * <p> * The default implementation: * <ul> * <li>Retrieves the {@link Repository} instance using * {@link Session#getRepository()} * <li>Retrieves the current workspace using {@link Session#getWorkspace()} * <li>Retrieves the name of the current workspace using * {@link Workspace#getName()} * <li>Calls {@link Repository#login(Credentials, String)} on the * retrieved repository with the given credentials and the retrieved * workspace name. * </ul> * * @param credentials login credentials * @return logged in session * @throws RepositoryException if an error occurs */ public Session impersonate(Credentials credentials) throws RepositoryException { return getRepository().login(credentials, getWorkspace().getName()); }
/** * Returns the prefixes of all known namespace mappings. All global * mappings not already included in the local set of namespace mappings * are added there. * <p> * This behaviour is based on JSR 283 (JCR 2.0), but remains backwards * compatible with JCR 1.0. * * @return namespace prefixes * @throws RepositoryException if a repository error occurs */ public String[] getNamespacePrefixes() throws RepositoryException { for (String uri : getWorkspace().getNamespaceRegistry().getURIs()) { getNamespacePrefix(uri); } synchronized (namespaces) { return namespaces.keySet().toArray(new String[namespaces.size()]); } }
String prefix = getWorkspace().getNamespaceRegistry().getPrefix(uri);
try { ContentHandler handler = getImportContentHandler(parentAbsPath, uuidBehavior); new ParsingContentHandler(handler).parse(in); } catch (SAXException e) {
try { ContentHandler handler = new ToXmlContentHandler(out); exportSystemView(absPath, handler, skipBinary, noRecurse); } catch (SAXException e) { Exception exception = e.getException();