-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16667 from camunda/16663-client-user-task-assign
Support `Assign task` user task action
- Loading branch information
Showing
5 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ts/java/src/main/java/io/camunda/zeebe/client/api/command/AssignUserTaskCommandStep1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright © 2017 camunda services GmbH (info@camunda.com) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.camunda.zeebe.client.api.command; | ||
|
||
import io.camunda.zeebe.client.api.response.AssignUserTaskResponse; | ||
|
||
public interface AssignUserTaskCommandStep1 extends FinalCommandStep<AssignUserTaskResponse> { | ||
|
||
/** | ||
* Set the custom action to assign the user task with. | ||
* | ||
* @param action the action value | ||
* @return the builder for this command. Call {@link #send()} to complete the command and send it | ||
* to the broker. | ||
*/ | ||
AssignUserTaskCommandStep1 action(String action); | ||
|
||
/** | ||
* Set the assignee to set for the user task. | ||
* | ||
* @param assignee the assignee to set | ||
* @return the builder for this command. Call {@link #send()} to complete the command and send it | ||
* to the broker. | ||
*/ | ||
AssignUserTaskCommandStep1 assignee(String assignee); | ||
|
||
/** | ||
* Flag to allow overriding an existing assignee for the user task without unassigning it first. | ||
* | ||
* @param allowOverride allow overriding an existing assignee | ||
* @return the builder for this command. Call {@link #send()} to complete the command and send it | ||
* to the broker. | ||
*/ | ||
AssignUserTaskCommandStep1 allowOverride(boolean allowOverride); | ||
} |
18 changes: 18 additions & 0 deletions
18
...ients/java/src/main/java/io/camunda/zeebe/client/api/response/AssignUserTaskResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright © 2017 camunda services GmbH (info@camunda.com) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.camunda.zeebe.client.api.response; | ||
|
||
public interface AssignUserTaskResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...ts/java/src/main/java/io/camunda/zeebe/client/impl/command/AssignUserTaskCommandImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright © 2017 camunda services GmbH (info@camunda.com) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.camunda.zeebe.client.impl.command; | ||
|
||
import io.camunda.zeebe.client.api.JsonMapper; | ||
import io.camunda.zeebe.client.api.ZeebeFuture; | ||
import io.camunda.zeebe.client.api.command.AssignUserTaskCommandStep1; | ||
import io.camunda.zeebe.client.api.command.FinalCommandStep; | ||
import io.camunda.zeebe.client.api.response.AssignUserTaskResponse; | ||
import io.camunda.zeebe.client.impl.http.HttpClient; | ||
import io.camunda.zeebe.client.impl.http.HttpZeebeFuture; | ||
import io.camunda.zeebe.gateway.protocol.rest.UserTaskAssignmentRequest; | ||
import java.time.Duration; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.hc.client5.http.config.RequestConfig; | ||
|
||
public final class AssignUserTaskCommandImpl implements AssignUserTaskCommandStep1 { | ||
|
||
private final long userTaskKey; | ||
private final UserTaskAssignmentRequest request; | ||
private final JsonMapper jsonMapper; | ||
private final HttpClient httpClient; | ||
private final RequestConfig.Builder httpRequestConfig; | ||
|
||
public AssignUserTaskCommandImpl( | ||
final HttpClient httpClient, final JsonMapper jsonMapper, final long userTaskKey) { | ||
this.jsonMapper = jsonMapper; | ||
this.userTaskKey = userTaskKey; | ||
this.httpClient = httpClient; | ||
httpRequestConfig = httpClient.newRequestConfig(); | ||
request = new UserTaskAssignmentRequest(); | ||
} | ||
|
||
@Override | ||
public FinalCommandStep<AssignUserTaskResponse> requestTimeout(final Duration requestTimeout) { | ||
httpRequestConfig.setResponseTimeout(requestTimeout.toMillis(), TimeUnit.MILLISECONDS); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ZeebeFuture<AssignUserTaskResponse> send() { | ||
final HttpZeebeFuture<AssignUserTaskResponse> result = new HttpZeebeFuture<>(); | ||
httpClient.post( | ||
"/user-tasks/" + userTaskKey + "/assignment", | ||
jsonMapper.toJson(request), | ||
httpRequestConfig.build(), | ||
result); | ||
return result; | ||
} | ||
|
||
@Override | ||
public AssignUserTaskCommandStep1 action(final String action) { | ||
request.setAction(action); | ||
return this; | ||
} | ||
|
||
@Override | ||
public AssignUserTaskCommandStep1 assignee(final String assignee) { | ||
ArgumentUtil.ensureNotNull("assignee", assignee); | ||
request.setAssignee(assignee); | ||
return this; | ||
} | ||
|
||
@Override | ||
public AssignUserTaskCommandStep1 allowOverride(final boolean allowOverride) { | ||
request.setAllowOverride(allowOverride); | ||
return this; | ||
} | ||
} |