public static APICancelLongJobMsg __example__() { APICancelLongJobMsg msg = new APICancelLongJobMsg(); msg.setUuid(uuid()); return msg; }
@Override public String getSyncSignature() { return "longjob-" + msg.getUuid(); }
@Override public void run(SyncTaskChain chain) { final APICancelLongJobEvent evt = new APICancelLongJobEvent(msg.getId()); cancelLongJob(msg.getUuid(), new Completion(chain) { @Override public void success() { bus.publish(evt); chain.next(); } @Override public void fail(ErrorCode errorCode) { evt.setError(errorCode); bus.publish(evt); chain.next(); } }); chain.next(); }
private void validate(APICancelLongJobMsg msg) { LongJobState state = Q.New(LongJobVO.class) .select(LongJobVO_.state) .eq(LongJobVO_.uuid, msg.getUuid()) .findValue(); if (state == LongJobState.Succeeded) { throw new ApiMessageInterceptionException(argerr("cannot cancel longjob that is succeeded")); } if (state == LongJobState.Canceled) { throw new ApiMessageInterceptionException(argerr("cannot cancel longjob that is already canceled")); } if (state == LongJobState.Failed) { throw new ApiMessageInterceptionException(argerr("cannot cancel longjob that is failed")); } }