on 11-16-2011 3:26 AM
Hi guys,
I would like to change the phase in the Validation Script.When i added a script to change phase in validation target, it seems like the valistion script is run many times. I known it from the log file . So i'm not sure that the script is run multiple times or All document run the validation script again. Please see the log below. The first one are occured many times (more than 20 times) then the secound one come many times as well.
(J2EE6065300)ID0418420850DB01700983993475761232End z29 ------- Start Project Validation ------------
2011-11-15 23:42:02.612 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var docTypeName : Project Approval flow
2011-11-15 23:42:02.612 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var currentPhaseRef : null:1120:null
2011-11-15 23:42:02.612 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var currentPhaseName : null
2011-11-15 23:42:02.612 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Change phase to Draft for null
2011-11-15 23:42:02.893 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 ------- Start Project Validation ------------
2011-11-15 23:42:02.893 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var docTypeName : Project Approval flow
2011-11-15 23:42:02.893 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var currentPhaseRef : null:1120:null
2011-11-15 23:42:02.893 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var currentPhaseName : null
2011-11-15 23:42:02.893 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Change phase to Draft for null
2011-11-15 23:42:02.971 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 ------- Start Project Validation ------------
2011-11-15 23:42:02.987 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var docTypeName : Project Approval flow
2011-11-15 23:42:02.987 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var currentPhaseRef : null:1120:null
2011-11-15 23:42:02.987 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Var currentPhaseName : null
2011-11-15 23:42:02.987 INFO local4 Project Validation RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Change phase to Draft for null
2011-11-15 23:42:28.877 ERROR local4 ScriptEnvironment execute RequestHandler.RqThread: fullsave (J2EE6065300)ID0418420850DB01700983993475761232End z29 Sourced file: inline evaluation of: ``//'*** IMPORTS ************************************************************ impo . . . '' : target exception : at Line: 54 : in file: inline evaluation of: ``//'*** IMPORTS ************************************************************ impo . . . '' : .changePhase ( doc , "Draft" )
Target exception: java.lang.StackOverflowError
Sourced file: inline evaluation of: ``//'*** IMPORTS ************************************************************ impo . . . '' : target exception : at Line: 54 : in file: inline evaluation of: ``//'*** IMPORTS ************************************************************ impo . . . '' : .changePhase ( doc , "Draft" ) |Target exception: java.lang.StackOverflowError|
Thank you in advance,
Noppong
Edited by: Noppong Jinbunluphol on Nov 16, 2011 4:27 AM
Edited by: Noppong Jinbunluphol on Nov 16, 2011 4:30 AM
Edited by: Noppong Jinbunluphol on Nov 16, 2011 4:31 AM
Edited by: Noppong Jinbunluphol on Nov 16, 2011 5:29 AM
Edited by: Noppong Jinbunluphol on Nov 16, 2011 5:45 AM
I think the problem probably is when the document is changed the phase the validation script is run again. It may cause StackOverFlow exception. How can i handle this case?
Below is the code in validation script :
//'*** IMPORTS ************************************************************
import com.frictionless.api.ibean.IBeanIfc;
import com.frictionless.api.ibean.CollectionIfc;
import com.frictionless.api.common.platform.IapiSessionContextIfc;
import com.frictionless.api.doccommon;
import com.frictionless.api.projects.ProjectIBeanHomeIfc;
import com.frictionless.api.common.types.TypeFactory;
import com.frictionless.api.common.types;
import com.frictionless.api.ibean.HighLevelBizDocIBeanIfc;
import java.math.BigDecimal;
import com.frictionless.api.ibean;
import com.frictionless.api.common.platform.IapiDbHandleIfc;
import com.frictionless.api.ibean.ExtensionCollectionIfc;
//'*** END OF IMPORTS **************************************************
exception = new ApplicationException(session);
projectHome=IBeanHomeLocator.lookup(session, ProjectIBeanHomeIfc.sHOME_NAME);
log = Logger.createLogMessage(session);
log.setMethod("Project Validation");
logInfo(msg){
log.setLogMessage(msg);
Logger.info(log);
}
if(doc.isObjectAccessModeView()){
projectHome.upgradeToEdit(doc);
}
logInfo("------- Start Project Validation ------------ ");
docTypeRef = doc.getDocTypeReference();
docTypeHome = IBeanHomeLocator.lookup(session,docTypeRef );
docType = docTypeHome.find(docTypeRef);
docTypeName = docType.getDisplayName();
logInfo("Var docTypeName : "+ docTypeName);
currentPhaseRef = doc.getCurrentPhase();
logInfo("Var currentPhaseRef : "+ currentPhaseRef);
currentPhaseName = null;
if(hasValue(currentPhaseRef)){
currentPhase = IBeanHomeLocator.lookup(session,currentPhaseRef ).find(currentPhaseRef);
currentPhaseName = currentPhase.getDisplayName();
}
logInfo("Var currentPhaseName : "+ currentPhaseName);
if(docTypeName.equals("Project Approval flow") @and !hasValue(currentPhaseName)){
logInfo("Change phase to Draft for "+ doc.getDocumentId());
doc.getIBeanHomeIfc().upgradeToEdit(doc);
doc.getIBeanHomeIfc().changePhase(doc,"Draft");
//exception.chainAtEnd(doc.createApplicationException("CURR_CONFIG_PHASE","Please change phase"));
}
if(!hasValue(doc.getDocumentDescription())){
exception.chainAtEnd(doc.createApplicationException("DOCUMENT_DESCRIPTION","Please enter Document Description"));
}
//'*************************************************************************
if(exception.getChain() != null){
throw exception.getChain();
}
//'*** END *****************************************************************
Edited by: Noppong Jinbunluphol on Nov 16, 2011 6:51 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
ChangePhase() issues an implicit save and that should be the root cause of the stack overflow issue.
Validation call hapens before the save and in the mentioned validation script, a change phase is done, which issues an implicit save, which internally calls the validate script again and that goes in recursion infinitely.
Would suggest to look at other scripting exists (e.g. postCreate) considering the post Script behavior..
Thanks,
Baski
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.