JobKey mutableJobKey,
final Set<Integer> shardIds,
@Nullable final Lock mutableLock,
SessionKey session) {
final IJobKey jobKey = JobKeys.assertValid(IJobKey.build(mutableJobKey));
checkNotBlank(shardIds);
requireNonNull(session);
final SessionContext context;
try {
context = sessionValidator.checkAuthenticated(session, ImmutableSet.of(jobKey.getRole()));
} catch (AuthFailedException e) {
return errorResponse(AUTH_FAILED, e);
}
return storage.write(new MutateWork.Quiet<Response>() {
@Override
public Response apply(MutableStoreProvider storeProvider) {
try {
lockManager.validateIfLocked(
ILockKey.build(LockKey.job(jobKey.newBuilder())),
Optional.fromNullable(mutableLock).transform(ILock.FROM_BUILDER));
} catch (LockException e) {
return errorResponse(LOCK_ERROR, e);
}