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 and design question
Date Tue, 25 Oct 2005 11:20:25 GMT
Hi, how to extends base behaviour of versioning ?
I need two more properties on Version :

comment (String) - simple description of something interesting with version
authorId (String) - id of user witch performed checkin.

With normal Node it's simple - custom node type. Is there any way to do 
something like that:

<nodeType name="type:version" isMixin="false" 
hasOrderableChildNodes="false" >
<supertypes>
<supertype>nt:version</supertype>
</supertypes>
<propertyDefinition name="ext:comment" requiredType="String" 
autoCreated="false" mandatory="false" onParentVersion="COPY" 
protected="false" multiple="false" />
<propertyDefinition name="ext:authorId" requiredType="String" 
autoCreated="false" mandatory="false" onParentVersion="COPY" 
protected="false" multiple="false" />
</nodeType>

Thanks,

Martin

Martin Koci wrote:
> 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
>>
>
>
>


-- 
Mgr. Martin Kočí
---------------------------------
AURA, s.r.o.
Úvoz 499/56; 602 00 Brno
ISO 9001 certifikovaná společnost
tel./fax: +420 5 43 24 51 11
e-mail:  martin.koci@aura.cz
internet: http://www.aura.cz
         http://www.j2ee.cz
--------------------------------- 


Mime
View raw message