incubator-graffito-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Koci <martin.k...@aura.cz>
Subject Re: Content Version support in Graffito
Date Sun, 23 Oct 2005 20:22:26 GMT
Hi,
 suggested API:
    void checkin(String absPath, Object versionableEntity, String[] 
newVersionNumbers) throws LockedException;
    void checkout(String absPath, Object versionableEntity) throws 
LockedException;
    String[] getVersionLabels(String absPath, Object cmsObject);
    void addVersionLabel(String absPath, Object entity, String 
versionLabel);

and (maybe) working implementation:

 public void checkin(final String absPath, final Object 
versionableEntity, final  String[] newVersionNumbers) throws 
LockedException {
        try {
            Node node = getNode(absPath);
            checkIfNodeLocked(absPath);
            Version newVersion = node.checkin();
            VersionHistory versionHistory = node.getVersionHistory();

            if (newVersionNumbers != null) {
                for (int i = 0; i < newVersionNumbers.length; i++) {
                    String versionLabel = newVersionNumbers[i];
                    versionHistory.addVersionLabel(newVersion.getName(), 
versionLabel, false);
                }
            }
        } catch (UnsupportedRepositoryOperationException e) {
            // This catch UnsupportedRepositoryOperationException 
potentionally throwed with Node.checkout()
            // indicates that node is not versionable - it means coding 
bug in jcrmapping.xml/custom_nodes_types.xml
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException("Node is 
not mix:versionable. Path: " + absPath, e);
        } catch (RepositoryException e) {
            // This typically 'If another error occurs'.
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException("Unknown 
error on checkin: ", e);
        }

    }

    public void checkout(final String absPath, final Object 
versionableEntity) throws LockedException {
        Node node;
        try {
            checkIfNodeLocked(absPath);
            node = getNode(absPath);
            node.checkout();
        } catch (UnsupportedRepositoryOperationException e) {
            // This catch UnsupportedRepositoryOperationException 
potentionally throwed with Node.checkout()
            // indicates that node is not versionable - it means coding 
bug in jcrmapping.xml
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException("Node is 
not mix:versionable. Path: " + absPath, e);
        } catch (RepositoryException e) {
            // This eventually catch LockException e, but
            // this colud never happen - see upper code
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException("Unknown 
error on checkout: ", e);
        }
    }

 
    public String[] getVersionLabels(final String absPath, final Object 
cmsObject) {
        try {
            Node node = getNode(absPath);
            VersionHistory vh = node.getVersionHistory();
            VersionIterator versionIterator = vh.getAllVersions();
            versionIterator.skip(1);
            vh.getBaseVersion();
            Version version = versionIterator.nextVersion();
            String[] versionLabels = vh.getVersionLabels(version);
            return versionLabels;
        } catch (UnsupportedRepositoryOperationException e) {
            // node.getVersionHistory() throws 
UnsupportedRepositoryOperationException if this node is not versionable.
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException("Node is 
not versionable: " + absPath);
        } catch (RepositoryException e) {
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException(e.getMessage(), 
e);
        }

    }

    public void addVersionLabel(final String absPath, final Object 
entity, final String versionLabel) {
        try {
            final Node node = getNode(absPath);
            final VersionHistory versionHistory = node.getVersionHistory();
            final boolean moveLabel = false;
            
versionHistory.addVersionLabel(node.getBaseVersion().getName(), 
versionLabel, moveLabel);
        } catch (UnsupportedRepositoryOperationException e) {
            // node.getVersionHistory() throws 
UnsupportedRepositoryOperationException if this node is not versionable.
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException("Node is 
not versionable: " + absPath);
        } catch (RepositoryException e) {
            throw new 
org.apache.portals.graffito.jcr.exception.RepositoryException("Unknown 
error on addVersionLabel: ", e);
        }
    }


Christophe Lombart wrote:
> Hi all,
>
> I'm still working on the JCR integration and I'm wondering what are our
> needs in point of view content versionning ?
> I would like to start with simple use cases but I want to know if someone
> has specific requirements.
>
> Furthermore, how do you see the versionning API in the JCR-mapping
> subproject ?
> Do we create a new component (like the QueryManager) or add new methods in
> the PersistenceManager ?
>
> All ideas, comments, thoughts are welcome.
>
> kind regards,
> Christophe
>
>   


Mime
View raw message