因为需要调用OOTB 的 wt.vc包下的一些受保护的方法, ToolHelper 类必须放在wt.vc包下
WTPart part = null; //需要设置的对象,可以是任何有大版本的对象Iterated
WTPrincipalReference principal = null; //需要设置的参与者对象
ToolHelper.setIterationCreator(part, principal);
ToolHelper.setIterationModifier(part, principal);
package wt.vc;
import wt.org.WTPrincipalReference;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import wt.vc.Iterated;
import wt.vc.IterationInfo;
import wt.vc.VersionControlException;
/**
* 设置修改者和创建者
*
* @author "SK-LingYi"
* @data 2021年1月10日 下午5:40:43
*/
public class ToolHelper {
/**
* 设置修改者
*
* @param iterated
* @param wtprincipalreference
* @throws WTException
* @throws WTPropertyVetoException
*
* @author "SK-LingYi"
* @data 2021年1月10日 下午5:45:55
*/
public static void setIterationModifier(Iterated iterated, WTPrincipalReference wtprincipalreference)
throws WTException, WTPropertyVetoException {
if (iterated != null) {
if (iterated.getIterationInfo() == null)
iterated.setIterationInfo(IterationInfo.newIterationInfo());
iterated.getIterationInfo().setModifier(wtprincipalreference);
} else {
throw new VersionControlException("wt.vc.vcResource", "0", null);
}
}
/**
* 设置创建者
*
* @param iterated
* @param wtprincipalreference
* @throws WTException
* @throws WTPropertyVetoException
*
* @author "SK-LingYi"
* @data 2021年1月10日 下午5:50:03
*/
public static void setIterationCreator(Iterated iterated, WTPrincipalReference wtprincipalreference)
throws WTException, WTPropertyVetoException {
if (iterated != null) {
if (iterated.getIterationInfo() == null)
iterated.setIterationInfo(IterationInfo.newIterationInfo());
iterated.getIterationInfo().setCreator(wtprincipalreference);
} else {
throw new VersionControlException("wt.vc.vcResource", "0", null);
}
}
}