briansolo1985 commented on code in PR #8898:
URL: https://github.com/apache/nifi/pull/8898#discussion_r1629271463


##########
c2/c2-client-bundle/c2-client-http/src/main/java/org/apache/nifi/c2/client/http/C2HttpClient.java:
##########
@@ -95,6 +102,26 @@ public Optional<byte[]> retrieveUpdateAssetContent(String 
callbackUrl) {
         return retrieveContent(callbackUrl, Map.of());
     }
 
+    @Override
+    public Optional<Path> retrieveResourceItem(String callbackUrl, 
Function<InputStream, Optional<Path>> resourceConsumer) {
+        Request request = new Request.Builder()
+            .get()
+            .url(callbackUrl)
+            .build();
+
+        try (Response response = 
httpClientReference.get().newCall(request).execute()) {
+            ResponseBody responseBody = response.body();
+            if (!response.isSuccessful() || responseBody == null) {
+                throw new C2ServerException(
+                    format("Resource content retrieval failed with HTTP return 
code %d and body:\n%s", response.code(), responseBody == null ? EMPTY : 
responseBody.toString()));

Review Comment:
   Remove the body from the exception



##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/operation/C2OperationHandler.java:
##########
@@ -63,4 +68,43 @@ default boolean requiresRestart() {
      * @return the result of the operation handling
      */
     C2OperationAck handle(C2Operation operation);
+
+    /**
+     * Commonly used logic for creating an C2OperationState object
+     *
+     * @param operationState the state of the operation
+     * @param details        additional status info to detail the state
+     * @return the created state
+     */
+    default C2OperationState operationState(C2OperationState.OperationState 
operationState, String details) {
+        C2OperationState state = new C2OperationState();
+        state.setState(operationState);
+        state.setDetails(details);
+        return state;
+    }
+
+    /**
+     * Commonly used logic for creating an C2OperationAck object
+     *
+     * @param operationId    the identifier of the operation
+     * @param operationState the state of the operation
+     * @return the created operation ack object
+     */
+    default C2OperationAck operationAck(String operationId, C2OperationState 
operationState) {
+        C2OperationAck operationAck = new C2OperationAck();
+        operationAck.setOperationState(operationState);
+        operationAck.setOperationId(operationId);
+        return operationAck;
+    }
+
+    /**
+     * Commonly used logic for retrieving a string value from the operation 
arguments' map
+     *
+     * @param operation the operation with arguments
+     * @param argument  the name of the argument to retrieve
+     * @return the retrieved argument value
+     */
+    default String getOperationArg(C2Operation operation, String argument) {

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to