Public Static voidSetversion (Finalversioned versioned, String version)throwswtexception {Try { if(Version = =NULL|| Version.trim (). Length () = = 0) { //If The version ID string is null and the load file did not//specify it.Version =NULL; if(Versioned.getversioninfo ()! =NULL) { //If The object already have a Versioninfo object then//assume it is correct//and no further action is needed. Otherwise, make a//default Versioninfo object. return; } } //Get The version series of the object.Multilevelseries MLS =NULL; FinalMastered master =Versioned.getmaster (); if(Master! =NULL) { FinalString Masterseriesname =master.getseries (); if(Masterseriesname = =NULL) { if(versionedinstanceofwtcontained&& ((wtcontained) versioned). GetContainer ()! =NULL) { //Retrieve the series based on the OIR in effect for//The container and object Type/soft type.MLS =versioncontrolhelper. getversionidentifierseries (versioned); Wt.vc.VersionControlServerHelper.changeSeries (Master, Mls.getuniqueseriesname ()); } } Else { //Series name is already set in the master, just use it.MLS =multilevelseries. newmultilevelseries (Masterseriesname); } } if(MLS = =NULL) { //Unable to get the series from the master, just use the//default series.MLS =Multilevelseries.newmultilevelseries ("Wt.vc.VersionIdentifier", version); } if(Version! =NULL) { //Set The revision ID value if it is given in the load file.mls.setvaluewithoutvalidating (Version.trim ()); } //Replace The default VID object (if there is one) with the correct//One .Versionidentifier vid =Versionidentifier.newversionidentifier (MLS); Versioncontrolserverhelper.setversionidentifier (versioned, vid,false /*validateincreasing*/); } Catch(wtpropertyvetoexception e) {loadserverhelper.printmessage ("\nsetversion:" +e.getmessage ()); E.printstacktrace (); Throw Newwtexception (e); } Catch(Exception e) {Throw Newwtexception (e); } }
The code is provided by Kaka great God, Special records.