Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of service-special when incorrect parameters are given. #583

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import javax.transaction.TransactionManager
import javax.transaction.Status

import org.moqui.impl.context.ExecutionContextFactoryImpl
import org.moqui.impl.service.ServiceCallAsyncImpl
import org.moqui.service.ServiceCallSpecial
import org.moqui.service.ServiceCallAsync

import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -68,16 +70,16 @@ class ServiceCallSpecialImpl extends ServiceCallImpl implements ServiceCallSpeci
protected final static Logger logger = LoggerFactory.getLogger(ServiceSynchronization.class)

protected ExecutionContextFactoryImpl ecfi
protected String serviceName
protected Map<String, Object> parameters
protected ServiceCallAsync asyncCall
protected boolean runOnCommit

protected Transaction tx = null

ServiceSynchronization(ServiceCallSpecialImpl scsi, ExecutionContextFactoryImpl ecfi, boolean runOnCommit) {
this.ecfi = ecfi
this.serviceName = scsi.getServiceName()
this.parameters = new HashMap(scsi.parameters)
String serviceName = scsi.getServiceName()
Map<String, Object> parameters = new HashMap(scsi.parameters)
this.asyncCall = ecfi.serviceFacade.async().name(serviceName).parameters(parameters)
this.runOnCommit = runOnCommit
}

Expand All @@ -93,14 +95,18 @@ class ServiceCallSpecialImpl extends ServiceCallImpl implements ServiceCallSpeci
}

@Override
void beforeCompletion() { }
void beforeCompletion() {
if (this.asyncCall instanceof ServiceCallAsyncImpl) {
((ServiceCallAsyncImpl) asyncCall).validateCall(this.ecfi.getEci())
}
}

@Override
void afterCompletion(int status) {
if (status == Status.STATUS_COMMITTED) {
if (runOnCommit) ecfi.serviceFacade.async().name(this.serviceName).parameters(this.parameters).call()
if (runOnCommit) asyncCall.call()
} else {
if (!runOnCommit) ecfi.serviceFacade.async().name(this.serviceName).parameters(this.parameters).call()
if (!runOnCommit) asyncCall.call()
}
}

Expand Down