public void addVersionLabel(@NotNull VersionStorage versionStorage, @NotNull String versionHistoryOakRelPath, @NotNull String versionIdentifier, @NotNull String oakVersionLabel, boolean moveLabel) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(checkNotNull(versionStorage.getTree()), checkNotNull(versionHistoryOakRelPath)); Tree labels = checkNotNull(versionHistory).getChild(JCR_VERSIONLABELS); PropertyState existing = labels.getProperty(checkNotNull(oakVersionLabel)); if (existing != null) { if (moveLabel) { labels.removeProperty(existing.getName()); } else { throw new LabelExistsVersionException("Version label '" + oakVersionLabel + "' already exists on this version history"); } } labels.setProperty(oakVersionLabel, versionIdentifier, Type.REFERENCE); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
public void addVersionLabel(@NotNull VersionStorage versionStorage, @NotNull String versionHistoryOakRelPath, @NotNull String versionIdentifier, @NotNull String oakVersionLabel, boolean moveLabel) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(checkNotNull(versionStorage.getTree()), checkNotNull(versionHistoryOakRelPath)); Tree labels = checkNotNull(versionHistory).getChild(JCR_VERSIONLABELS); PropertyState existing = labels.getProperty(checkNotNull(oakVersionLabel)); if (existing != null) { if (moveLabel) { labels.removeProperty(existing.getName()); } else { throw new LabelExistsVersionException("Version label '" + oakVersionLabel + "' already exists on this version history"); } } labels.setProperty(oakVersionLabel, versionIdentifier, Type.REFERENCE); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
public void addVersionLabel(@Nonnull VersionStorage versionStorage, @Nonnull String versionHistoryOakRelPath, @Nonnull String versionIdentifier, @Nonnull String oakVersionLabel, boolean moveLabel) throws RepositoryException { Tree versionHistory = TreeUtil.getTree(checkNotNull(versionStorage.getTree()), checkNotNull(versionHistoryOakRelPath)); Tree labels = checkNotNull(versionHistory).getChild(JCR_VERSIONLABELS); PropertyState existing = labels.getProperty(checkNotNull(oakVersionLabel)); if (existing != null) { if (moveLabel) { labels.removeProperty(existing.getName()); } else { throw new LabelExistsVersionException("Version label '" + oakVersionLabel + "' already exists on this version history"); } } labels.setProperty(oakVersionLabel, versionIdentifier, Type.REFERENCE); try { sessionDelegate.commit(versionStorage.getRoot()); refresh(); } catch (CommitFailedException e) { versionStorage.refresh(); throw e.asRepositoryException(); } }
@Override public void addVersionLabel( String versionName, String label, boolean moveLabel ) throws VersionException, RepositoryException { AbstractJcrNode versionLabels = versionLabels(); JcrVersionNode version = getVersion(versionName); try { // This throws a PNFE if the named property doesn't already exist versionLabels.getProperty(label); if (!moveLabel) throw new LabelExistsVersionException(JcrI18n.versionLabelAlreadyExists.text(label)); } catch (PathNotFoundException pnfe) { // This gets thrown if the label doesn't already exist } // Use a separate system session to set the REFERENCE property on the 'nt:versionLabels' child node ... SessionCache system = session.createSystemCache(false); Reference labelReference = session.referenceFactory().create(version.key(), true); Property ref = session.propertyFactory().create(nameFrom(label), labelReference); system.mutable(versionLabels.key()).setProperty(system, ref); system.save(); }
@Override public void addVersionLabel( String versionName, String label, boolean moveLabel ) throws VersionException, RepositoryException { AbstractJcrNode versionLabels = versionLabels(); JcrVersionNode version = getVersion(versionName); try { // This throws a PNFE if the named property doesn't already exist versionLabels.getProperty(label); if (!moveLabel) throw new LabelExistsVersionException(JcrI18n.versionLabelAlreadyExists.text(label)); } catch (PathNotFoundException pnfe) { // This gets thrown if the label doesn't already exist } // Use a separate system session to set the REFERENCE property on the 'nt:versionLabels' child node ... SessionCache system = session.createSystemCache(false); Reference labelReference = session.referenceFactory().create(version.key(), true); Property ref = session.propertyFactory().create(nameFrom(label), labelReference); system.mutable(versionLabels.key()).setProperty(system, ref); system.save(); }
return new VersionException(message, this); } else if (isOfType(LABEL_EXISTS)) { return new LabelExistsVersionException(message, this); } else if (isOfType(LOCK)) { return new LockException(message, this);
return new VersionException(message, this); } else if (isOfType(LABEL_EXISTS)) { return new LabelExistsVersionException(message, this); } else if (isOfType(LOCK)) { return new LockException(message, this);
return new VersionException(message, this); } else if (isOfType(LABEL_EXISTS)) { return new LabelExistsVersionException(message, this); } else if (isOfType(LOCK)) { return new LockException(message, this);