On 10/05/21 14:05, Martin van Es wrote:
On Mon, May 10, 2021 at 9:07 AM Francesco Chicchiriccò <[email protected]
<mailto:[email protected]>> wrote:
On 07/05/21 19:50, Martin van Es wrote:
Another question.
How would I print debug (core.log) statements in a Groovy propagation
action script?
Not very related to the subject, but you can find a relevant example here:
https://github.com/apache/syncope/blob/2_1_X/fit/core-reference/src/test/resources/rest/SearchScript.groovy#L104
<https://github.com/apache/syncope/blob/2_1_X/fit/core-reference/src/test/resources/rest/SearchScript.groovy#L104>
Thx for your input!
This is the output when I blindly add log.info <http://log.info>() to a test
Groovy propagation action script:
11:57:53.811 DEBUG org.apache.syncope.core.provisioning.java.ConnectorManager -
Connector to be registered:
ConnectorFacadeProxy{connector=org.identityconnectors.framework.impl.api.local.LocalConnectorFacadeImpl@63b8
d810
capabitilies=[UPDATE, DELETE, CREATE, SEARCH, AUTHENTICATE]}
11:57:53.811 DEBUG org.apache.syncope.core.provisioning.java.ConnectorManager -
Successfully registered bean
connInstance-Master-3229BE00-2A72-4A78-A9BE-002A729A784D-service-cloud
11:57:53.813 DEBUG
org.apache.syncope.core.provisioning.api.job.SchedTaskJobDelegate - Executing
push on JPAExternalResource[service-cloud]
11:57:54.063 DEBUG
org.apache.syncope.core.provisioning.api.pushpull.SyncopeResultHandler -
Pushing USER with key 89b4b6da-1ef3-4720-b4b6-da1ef3072081 towards
JPAExternalResource[service-cloud]
11:57:56.666 ERROR
org.apache.syncope.core.provisioning.java.pushpull.OutboundMatcher - While
building JPAImplementation[My_Groovy_PropagationAction]
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script_591aa0a4f0c025faabe5fd7f86d74fb0.groovy: 39: [Static type checking] -
The variable [log] is undeclared.
@ line 39, column 5.
log.info <http://log.info>("Entering " + action + " Script");
^
The main problem here probably is that I'm not a hard-core Java developer and
I'm trying to create a maximum flexibility, zero-compilation identity
synchronisation setup for the team to work with. Simple syncope-console
editable Groovy scripts would help tremendously with that goal!
Sorry, I did not read well that you were not interested in Groovy scripts for
connectors but in Groovy Propagation Actions classes.
You can use Groovy's @Slf4j then:
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.apache.syncope.core.persistence.api.entity.task.PropagationTask
import org.apache.syncope.core.provisioning.api.propagation.PropagationActions
import org.identityconnectors.framework.common.objects.ConnectorObject
@Slf4j
@CompileStatic
class MyPropagationActions implements PropagationActions {
@Override
void before(PropagationTask task, ConnectorObject beforeObj) {
log.error("About to run {}", task)
}
}
Logging statements will be sent to core.log.
Regards.
--
Francesco Chicchiriccò
Tirasa - Open Source Excellence
http://www.tirasa.net/
Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/