openkm / document-management-system

OpenKM is a Open Source Document Management System
https://www.openkm.com/
GNU General Public License v2.0
708 stars 308 forks source link

var uuid / automation / overflow errors #273

Closed jvezinat closed 3 years ago

jvezinat commented 3 years ago

OpenKM 6.3.10 CE RHEL 7.9 Server Java-openjdk-1.8.0-272

When trying to use the built-in var "uuid" with automation scripts it always has an overflow error. Even with error it completes the action. Hardcoded String for the document uuid runs without issue. Please see below script:

`` package com.openkm; import com.openkm.api.; import com.openkm.core.; import com.openkm.bean.; import java.util.; import java.lang.*;

String id = "99fa07dc-5310-473f-8596-9736c44d147c"; //String s = OKMPropertyGroup.getInstance().getProperties(null, id, "okg:IandT").toString(); String [] a = s.split("\{");

//Get Project Name project = a[16]; String [] projsplit = project.split("="); String projsplit2 = projsplit[7]; String [] projsplit3 = projsplit2.split(","); String projectname = projsplit3[0].toUpperCase();

//Get Ticket Number ticket = a[15]; String [] ticksplit = ticket.split("="); String ticksplit2 = ticksplit[3]; String [] ticksplit3 = ticksplit2.split(","); String ticketnumber = ticksplit3[0].toUpperCase();

//Create html link to Jira http= "<a href=http://ip/browse/"+projectname+"/"+projectname+"+ticketnumber+">http://ip/browse/"+projectname+"/"+projectname+"-"+ticketnumber+"";

//Add link to metadata field OKMPropertyGroup.getInstance().setPropertySimple(null, uuid, "okg:IandT", "okp.IandT.link", http); Error: Sourced file: inline evaluation of: package com.openkm; import com.openkm.api.*; import com.openkm.core.*; import . . . '' : Method Invocation setPropertySimple : at Line: 38 : in file: inline evaluation of:package com.openkm; import com.openkm.api.; import com.openkm.core.; import . . . '' : .setPropertySimple ( null , uuid , "okg:IandT" , "okp.IandT.link" , http ) Target exception: Target exception: java.lang.StackOverflowError ``

darkman97i commented 3 years ago

What is the event linked with this automation script? try sharing complete configuration with screenshots for better understanding.

I suppose maybe caused by recursion ( event what the action into call the same event and at the end you have infinite loop ) -> consider take a look at https://docs.openkm.com/kcenter/view/okm-6.3-com/creating-your-own-automation-action-(-deprecated-).html#Preventingrecursion

jvezinat commented 3 years ago

Automation script. Set to add an html formatted line to a metadata field post "set metadata". With a hardcoded uuid it works great. Once I try and use the "uuid" injected variable via the automation script it causes the errors.

jvezinat commented 3 years ago

Hey that link you sent me explained it. I am changing metadata values when using the "set metadata" option which is causing the recursion. Thank you for the tip! Bookmarked the link and will work it on my end. Thanks again!