vrNrd.setProperty( (NodeProperty)i.next() );
// Copy dead properties VCR -> VR
j = rNrd.enumerateProperties();
while( j.hasMoreElements() ) {
NodeProperty p = (NodeProperty)j.nextElement();
if( p.isLiveProperty() )
continue;
if( !vrNrd.exists(p.getName()) )
vrNrd.setProperty( p );
}
// Copy properties VCR->VR
NodeRevisionContent rNrc = content.retrieve( sToken, rNrds, rNrd );
vrNrd.setContentType(rNrd.getContentType()); // P_GETCONTENTTYPE
vrNrd.setContentLength(rNrd.getContentLength()); // P_GETCONTENTLENGTH
vrNrd.setContentLanguage(rNrd.getContentLanguage()); // P_GETCONTENTLANGUAGE
String comment = "INITIAL VERSION. ";
if( rNrd.exists(P_COMMENT) )
comment += (String)rNrd.getProperty(P_COMMENT).getValue();
vrNrd.setProperty(
new NodeProperty(P_COMMENT, comment) );
// Set initial VHR properties
Vector vhrLabels = new Vector();
Hashtable vhrProps = new Hashtable();
String vhrBranch = NodeRevisionDescriptors.MAIN_BRANCH;
NodeRevisionDescriptor vhrNrd =
new NodeRevisionDescriptor( NodeRevisionNumber.HIDDEN_0_0, vhrBranch, vhrLabels, vhrProps );
i = pHelp.createInitialProperties(VersionHistoryImpl.getInstance()).iterator();
while( i.hasNext() )
vhrNrd.setProperty( (NodeProperty)i.next() );
// Set initial VCR properties (do not overwrite existing!!)
i = pHelp.createInitialProperties(VersionControlledImpl.getInstance()).iterator();
while( i.hasNext() ) {
NodeProperty p = (NodeProperty)i.next();
if( !rNrd.exists(p.getName()) )
rNrd.setProperty( p );
}
// Create VHR/VR
UriHandler vhrUh = UriHandler.createNextHistoryUri( sToken, nsaToken, rUh );
String vhrUri = String.valueOf( vhrUh );
SubjectNode vhrNode = new SubjectNode();
structure.create( sToken, vhrNode, String.valueOf(vhrUh) );
content.create( sToken, vhrUri, true ); //isVersioned=true
content.create( sToken, vhrUri, vrNrd, rNrc );
NodeRevisionDescriptors vhrNrds =
content.retrieve( sToken, vhrUri );
content.create(
sToken, vhrUri, null, vhrNrd, null ); //branch=null, revisionContent=null
// Create VR node
NodeRevisionNumber vrVersion = vrNrd.getRevisionNumber();
SubjectNode vrNode = new SubjectNode();
UriHandler vrUh =
UriHandler.createVersionUri( vhrUh, String.valueOf(vrVersion) );
String vrUri = String.valueOf( vrUh );
structure.create( sToken, vrNode, String.valueOf(vrUh) );
// Set specific properties
vrNrd.setName(rUh.getName()); // P_DISPLAYNAME
rNrd.setProperty(
new NodeProperty(P_CHECKED_IN, pHelp.createHrefValue(vrUri)) );
vhrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
setCreationUser(vhrNrd);
vhrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
vhrNrd.setContentLength( 0 ); // P_GETCONTENTLENGTH
vhrNrd.setETag( PropertyHelper.computeEtag(vhrUri, vhrNrd) ); // P_GETETAG
vhrNrd.setName( vhrUh.getHistoryName() ); // P_DISPLAYNAME
vhrNrd.setProperty(
new NodeProperty(P_VERSION_SET, pHelp.createHrefValue(vrUri)) );
vrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
setCreationUser(vrNrd);
vrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
vrNrd.setETag( PropertyHelper.computeEtag(vrUri, vrNrd)); // P_GETETAG
vrNrd.setProperty(
new NodeProperty(P_VERSION_NAME, vrUh.getVersionName()) );
// Store changes
content.store( sToken, resourcePath, rNrd, null ); //revisionContent=null
content.store( sToken, vhrUri, vhrNrd, null ); //revisionContent=null
content.store( sToken, vhrUri, vrNrd, null ); //revisionContent=null