Tech ValidationSpecificationClass
package aaaia.xwiki;
import com.xpn.xwiki.validation.*;
import com.xpn.xwiki.*;
import com.xpn.xwiki.doc.*;
import com.xpn.xwiki.objects.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SpecificationValidation implements XWikiValidationInterface {
private static final Logger log = LoggerFactory.getLogger(SpecificationValidation.class);
private static String CLAZZ_NAME = "Species.SpecificationClass";
private Object aiautil = null;
public boolean validateDocument(XWikiDocument doc, XWikiContext context) {
def res = true;
try {
aiautil = context.getWiki().parseGroovyFromPage("Species.Tech IkonotekaScripts",context);
def obj = doc.getObject(CLAZZ_NAME);
title interception
def pSpecType = obj.getStringValue("pSpecType")
def pSpecValue = obj.getStringValue("pSpecValue")
def properTitle
properTitle = "$pSpecType $pSpecValue"
if (doc.getTitle() != properTitle){
doc.setTitle(properTitle)
}
parent interception
def interceptParentName = context.getRequest().getParameter("myinput")
if (doc.getParent() != interceptParentName){
log.debug("Setting parent[$interceptParentName] for page[${doc.title}]")
doc.setParent(interceptParentName)
}
} catch (e) {
log.error(e.message)
res = false;
}
return res;
}
public boolean validateObject(BaseObject object, XWikiContext context) {
return true;
}
}