/** * Wraps the given {@link CommitFailedException} instance using the * appropriate {@link RepositoryException} subclass based on the * {@link CommitFailedException#getType() type} of the given exception. * * @param exception typed commit failure exception * @return matching repository exception */ private static RepositoryException newRepositoryException(CommitFailedException exception) { return exception.asRepositoryException(); }
/** * Wraps the given {@link CommitFailedException} instance using the * appropriate {@link RepositoryException} subclass based on the * {@link CommitFailedException#getType() type} of the given exception. * * @param exception typed commit failure exception * @return matching repository exception */ private static RepositoryException newRepositoryException(CommitFailedException exception) { return exception.asRepositoryException(); }
/** * Wraps the given {@link CommitFailedException} instance using the * appropriate {@link RepositoryException} subclass based on the * {@link CommitFailedException#getType() type} of the given exception. * * @param exception typed commit failure exception * @return matching repository exception */ private static RepositoryException newRepositoryException(CommitFailedException exception) { return exception.asRepositoryException(); }
/** * Wraps the given {@link CommitFailedException} instance using the * appropriate {@link javax.jcr.RepositoryException} subclass based on the * {@link CommitFailedException#getType() type} of the given exception. * * @return matching repository exception */ public RepositoryException asRepositoryException() { return asRepositoryException(this.getMessage()); }
/** * Wraps the given {@link CommitFailedException} instance using the * appropriate {@link javax.jcr.RepositoryException} subclass based on the * {@link CommitFailedException#getType() type} of the given exception. * * @return matching repository exception */ public RepositoryException asRepositoryException() { return asRepositoryException(this.getMessage()); }
/** * Wraps the given {@link CommitFailedException} instance using the * appropriate {@link javax.jcr.RepositoryException} subclass based on the * {@link CommitFailedException#getType() type} of the given exception. * * @return matching repository exception */ public RepositoryException asRepositoryException() { return asRepositoryException(this.getMessage()); }
void autosave() throws RepositoryException { if (autosave) { try { root.commit(); } catch (CommitFailedException e) { throw e.asRepositoryException(); } finally { root.refresh(); } } }
void autosave() throws RepositoryException { if (autosave) { try { root.commit(); } catch (CommitFailedException e) { throw e.asRepositoryException(); } finally { root.refresh(); } } }
void autosave() throws RepositoryException { if (autosave) { try { root.commit(); } catch (CommitFailedException e) { throw e.asRepositoryException(); } finally { root.refresh(); } } }
public void perform(@NotNull Root root, @NotNull String userId) throws RepositoryException { try { Tree typeRoot = root.getTree(NODE_TYPES_PATH); copy(source, destParent, destName, typeRoot, userId); updateReferences(source, destParent.getChild(destName)); Map<String, String> copyInfo = new HashMap<String, String>(); copyInfo.put("copy-source", source.getPath()); if (TreeUtil.isNodeType(source, JcrConstants.MIX_VERSIONABLE, typeRoot)) { String sourceBaseVersionId = source.getProperty(JcrConstants.JCR_BASEVERSION).getValue(Type.STRING); copyInfo.put(VersionConstants.JCR_COPIED_FROM, sourceBaseVersionId); } root.commit(ImmutableMap.<String, Object>copyOf(copyInfo)); } catch (CommitFailedException e) { throw e.asRepositoryException(); } }
public void perform(@NotNull Root root, @NotNull String userId) throws RepositoryException { try { Tree typeRoot = root.getTree(NODE_TYPES_PATH); copy(source, destParent, destName, typeRoot, userId); updateReferences(source, destParent.getChild(destName)); Map<String, String> copyInfo = new HashMap<String, String>(); copyInfo.put("copy-source", source.getPath()); if (TreeUtil.isNodeType(source, JcrConstants.MIX_VERSIONABLE, typeRoot)) { String sourceBaseVersionId = source.getProperty(JcrConstants.JCR_BASEVERSION).getValue(Type.STRING); copyInfo.put(VersionConstants.JCR_COPIED_FROM, sourceBaseVersionId); } root.commit(ImmutableMap.<String, Object>copyOf(copyInfo)); } catch (CommitFailedException e) { throw e.asRepositoryException(); } }
public void perform(@Nonnull Root root, @Nonnull String userId) throws RepositoryException { try { Tree typeRoot = root.getTree(NODE_TYPES_PATH); copy(source, destParent, destName, typeRoot, userId); updateReferences(source, destParent.getChild(destName)); Map<String, String> copyInfo = new HashMap<String, String>(); copyInfo.put("copy-source", source.getPath()); if (TreeUtil.isNodeType(source, JcrConstants.MIX_VERSIONABLE, typeRoot)) { String sourceBaseVersionId = source.getProperty(JcrConstants.JCR_BASEVERSION).getValue(Type.STRING); copyInfo.put(VersionConstants.JCR_COPIED_FROM, sourceBaseVersionId); } root.commit(ImmutableMap.<String, Object>copyOf(copyInfo)); } catch (CommitFailedException e) { throw e.asRepositoryException(); } }
public void removeVersionLabel(@NotNull VersionStorage versionStorage, @NotNull String versionHistoryOakRelPath, @NotNull String oakVersionLabel) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(checkNotNull(versionStorage.getTree()), checkNotNull(versionHistoryOakRelPath)); Tree labels = checkNotNull(versionHistory).getChild(JCR_VERSIONLABELS); if (!labels.hasProperty(oakVersionLabel)) { throw new VersionException("Version label " + oakVersionLabel + " does not exist on this version history"); } labels.removeProperty(oakVersionLabel); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
public void removeVersionLabel(@Nonnull VersionStorage versionStorage, @Nonnull String versionHistoryOakRelPath, @Nonnull String oakVersionLabel) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(checkNotNull(versionStorage.getTree()), checkNotNull(versionHistoryOakRelPath)); Tree labels = checkNotNull(versionHistory).getChild(JCR_VERSIONLABELS); if (!labels.hasProperty(oakVersionLabel)) { throw new VersionException("Version label " + oakVersionLabel + " does not exist on this version history"); } labels.removeProperty(oakVersionLabel); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
public void removeVersion(@NotNull VersionStorage versionStorage, @NotNull String versionHistoryOakRelPath, @NotNull String oakVersionName) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(versionStorage.getTree(), versionHistoryOakRelPath); if (versionHistory == null || !versionHistory.exists()) { throw new VersionException("Version history " + versionHistoryOakRelPath + " does not exist on this version storage"); } Tree version = versionHistory.getChild(oakVersionName); if (!version.exists()) { throw new VersionException("Version " + oakVersionName + " does not exist on this version history"); } version.remove(); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
public void removeVersion(@NotNull VersionStorage versionStorage, @NotNull String versionHistoryOakRelPath, @NotNull String oakVersionName) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(versionStorage.getTree(), versionHistoryOakRelPath); if (versionHistory == null || !versionHistory.exists()) { throw new VersionException("Version history " + versionHistoryOakRelPath + " does not exist on this version storage"); } Tree version = versionHistory.getChild(oakVersionName); if (!version.exists()) { throw new VersionException("Version " + oakVersionName + " does not exist on this version history"); } version.remove(); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
public void removeVersion(@Nonnull VersionStorage versionStorage, @Nonnull String versionHistoryOakRelPath, @Nonnull String oakVersionName) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(versionStorage.getTree(), versionHistoryOakRelPath); if (versionHistory == null || !versionHistory.exists()) { throw new VersionException("Version history " + versionHistoryOakRelPath + " does not exist on this version storage"); } Tree version = versionHistory.getChild(oakVersionName); if (!version.exists()) { throw new VersionException("Version " + oakVersionName + " does not exist on this version history"); } version.remove(); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
@Override public void unregisterNodeType(String name) throws RepositoryException { Root root = getWriteRoot(); Tree type = root.getTree(NODE_TYPES_PATH).getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } try { type.remove(); root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node type " + name; throw e.asRepositoryException(message); } }
@Override public void unregisterNodeType(String name) throws RepositoryException { Root root = getWriteRoot(); Tree type = root.getTree(NODE_TYPES_PATH).getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } try { type.remove(); root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node type " + name; throw e.asRepositoryException(message); } }
@Override public void unregisterNodeType(String name) throws RepositoryException { Root root = getWriteRoot(); Tree type = root.getTree(NODE_TYPES_PATH).getChild(getOakName(name)); if (!type.exists()) { throw new NoSuchNodeTypeException("Node type " + name + " can not be unregistered."); } try { type.remove(); root.commit(); refresh(); } catch (CommitFailedException e) { String message = "Failed to unregister node type " + name; throw e.asRepositoryException(message); } }