Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Turn off event handler script logs in Confluence

Aileen October 2, 2017

Hey,

We have an event handler script, and a rest API script in confluence that call on this script that changes the string of the macro.

import com.atlassian.confluence.core.DefaultSaveContext
import com.atlassian.confluence.core.SaveContext
import com.atlassian.confluence.pages.Comment
import com.atlassian.confluence.pages.CommentManager
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import java.time.format.DateTimeFormatter
class StatusChanger {
static void changeStatus(Page currentPage, String newStatus, String commentText,
String currentUser, PageManager pageManager, CommentManager commentManager) {
// Verify the new status is not the same as the current status and then set the status property on the page.
def contentProperties = currentPage.getProperties()
def currentStatus = contentProperties.getStringProperty("Status")
assert newStatus!=currentStatus: "The status is already \"" + currentStatus + "\""
if (newStatus != currentStatus) {
contentProperties.setStringProperty("Status", newStatus)
// Add a comment with information about the status change.
Comment comment = new Comment()
comment.setBodyAsString("Changed status of <i>Version " + currentPage.getVersion() +
"</i> from <b>" + currentStatus + "</b> to <b>" + newStatus + "</b><p>" + commentText + "</p>")
comment.container = currentPage
commentManager.saveContentEntity(comment, null)
currentPage.addComment(comment)
}
// If the status is changed to ACCEPTED we store the below values as properties in the page.
else if ("ACCEPTED".equals(newStatus)) {
contentProperties.setStringProperty("Accepted Version", "" + currentPage.version)
contentProperties.setStringProperty("Accepted Date", "" + java.time.LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE))
contentProperties.setStringProperty("Accepted By", currentUser)
}
// Save the context but don't update last modifier and suppress events in order to not trigger pageUpdateEvent
//(DefaultSaveContext(boolean suppressNotifications, boolean updateLastModifier, boolean suppressEvents))
SaveContext saveContext = new DefaultSaveContext(false, false, true)
pageManager.saveContentEntity(currentPage, saveContext)
}
}

This script is causing a ton of error messages when (newStatus = currentStatus), for the PageUpdateEvent handler script.

2017-10-02 16:44:50,178 ERROR [http-nio-8443-exec-33] [atlassian.confluence.event.ConfluenceEventDispatcher] run There was an exception thrown trying to dispatch event [com.atlassian.confluence.event.events.con
tent.page.PageUpdateEvent@18c277b9[originalPage=page: Setting an new sequence v.2 (27852810),updateTrigger=EDIT_PAGE,page=page: Setting an new sequence v.3 (26706907),suppressNotifications=false,timestamp=15069
55490151]] from the invoker [com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1@6f591c96]
 -- referer: https://confluence.com/pages/resumedraft.action?draftId=26706912&draftShareId=5a84de35-5338-4cce-9e78-2d83311fd087 | url: /rest/api/content/26706907 | traceId: 73b53dfb9a16b688 | userN
ame: aileen
java.lang.RuntimeException: The status is already "IN PROGRESS". Expression: (newStatus != currentStatus). Values: newStatus = IN PROGRESS, currentStatus = IN PROGRESS
        at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:41)
        at com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1.invoke(ConfluenceListenerHandlersConfiguration.java:69)
        at com.atlassian.confluence.event.ConfluenceEventDispatcher$VCacheRequestContextRunnableFactory$1.lambda$run$0(ConfluenceEventDispatcher.java:93)
        at com.atlassian.confluence.vcache.VCacheRequestContextOperations.lambda$doInRequestContext$0(VCacheRequestContextOperations.java:50)
        at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContextInternal(VCacheRequestContextManager.java:87)
        at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:71)
        at com.atlassian.confluence.vcache.VCacheRequestContextOperations.doInRequestContext(VCacheRequestContextOperations.java:49)
        at com.atlassian.confluence.event.ConfluenceEventDispatcher$VCacheRequestContextRunnableFactory$1.run(ConfluenceEventDispatcher.java:93)
        at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:299)
        at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:88)
        at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:203)
        at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:114)
        at com.atlassian.confluence.event.TimingEventPublisher.publish(TimingEventPublisher.java:64)
        at com.atlassian.confluence.pages.DefaultPageManager.publishUpdateEvent(DefaultPageManager.java:1628)
        at com.atlassian.confluence.core.DefaultContentEntityManager.saveContentEntity(DefaultContentEntityManager.java:179)
        at com.atlassian.confluence.pages.DefaultPageManager.saveContentEntity(DefaultPageManager.java:1433)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:16)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at com.atlassian.confluence.util.profiling.ConfluenceMonitoringMethodInterceptor.invoke(ConfluenceMonitoringMethodInterceptor.java:34)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
        at com.sun.proxy.$Proxy105.saveContentEntity(Unknown Source)
        at com.atlassian.confluence.content.apisupport.ContentCreator.saveNewVersion(ContentCreator.java:501)
        at com.atlassian.confluence.content.apisupport.ContentCreator.update(ContentCreator.java:559)
        at com.atlassian.confluence.api.impl.service.content.typebinding.PageContentTypeApiSupport.update(PageContentTypeApiSupport.java:220)
        at com.atlassian.confluence.api.impl.service.content.typebinding.PageContentTypeApiSupport.update(PageContentTypeApiSupport.java:47)
        at com.atlassian.confluence.api.impl.service.content.ContentServiceImpl.updateUsingApiSupport(ContentServiceImpl.java:118)
        at com.atlassian.confluence.api.impl.service.content.ContentServiceImpl.update(ContentServiceImpl.java:155)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.... etc. etc.
Caused by: java.lang.AssertionError: The status is already "IN PROGRESS". Expression: (newStatus != currentStatus). Values: newStatus = IN PROGRESS, currentStatus = IN PROGRESS
        at StatusChanger.changeStatus(StatusChanger.groovy:18)
        at StatusChanger$changeStatus.call(Unknown Source)
        at PageChangedEventHandler.run(PageChangedEventHandler.groovy:16)

 

1 answer

0 votes
Dar Kronenblum
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2018

Hi Aileen

we are facing similar issue- did you manage to resolve this?

thanks

Dar

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events