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

Generalize workflow request payload and call external mediator #70

Open
wants to merge 6 commits into
base: feature-workflow-externalization
Choose a base branch
from

Conversation

malithiperera
Copy link

@malithiperera malithiperera commented Apr 11, 2023

Proposed changes in this pull request

Generalize the workflow request payload which we send to the external workflow mediator and implement the call mediator service.

@CLAassistant
Copy link

CLAassistant commented Apr 11, 2023

CLA assistant check
All committers have signed the CLA.

@@ -87,10 +120,19 @@ public void execute(WorkflowRequest workFlowRequest) throws WorkflowException {
validateExecutionParams();
OMElement requestBody = WorkflowRequestBuilder.buildXMLRequest(workFlowRequest, this.parameterList);
try {
callService(requestBody);
String templateId = getTemplateIdByWorkflowId(parameterList.get(0).getWorkflowId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the parameterList is not empty by using CollectionUtils.isNotEmpty(this.parameterList) and then invoke the getTemplateIdByWorkflowId method

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed the comment ref:641aaf1

@@ -108,6 +150,97 @@ private void validateExecutionParams() throws InternalWorkflowException {
throw new InternalWorkflowException("Init params for the BPELExecutor is null.");
}
}
private String getExternalWorkflowId(String workflowId) throws WorkflowException {
Copy link
Contributor

@sadilchamishka sadilchamishka Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check new lines between methods, new line in the 1st line of the method body and remove unnecessary new lines. (Check all the places)


while (workflowDetails.hasNext()) {
OMElementImpl workflowDetail = (OMElementImpl) workflowDetails.next();
if (PROCESS_UUID.equals(workflowDetail.getLocalName())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve the code to use switch case statements instead of multiple if conditions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed the comment ref:641aaf1

package org.wso2.carbon.identity.workflow.impl.util.model;

public class Variable {
private String name;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new lines. check all the places in this class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed the comment ref:641aaf1

pom.xml Outdated
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's define the gson version under and refer here. Check how other dependencies do that.

@@ -0,0 +1,52 @@


Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove lines

@malithiperera malithiperera force-pushed the call-external-mediator branch from 7a805e8 to ec92736 Compare April 24, 2023 07:13
@@ -251,7 +256,7 @@
<commons-io.wso2.version>2.4.0.wso2v1</commons-io.wso2.version>
<commons-lang.wso2.version>2.6.0.wso2v1</commons-lang.wso2.version>

<carbon.identity.framework.version>5.25.36</carbon.identity.framework.version>
<carbon.identity.framework.version>5.25.145-SNAPSHOT</carbon.identity.framework.version>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update this once framework PR is merged : ref

generateAndDeployArtifacts();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert the change

@@ -0,0 +1,207 @@
/*
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the license header

import org.wso2.carbon.identity.workflow.mgt.util.WorkflowManagementUtil;
import org.wso2.carbon.identity.workflow.mgt.workflow.WorkFlowExecutor;

import java.io.*;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid star imports

import static javax.ws.rs.HttpMethod.POST;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

public class WorkflowMediatorRequestExecutor implements WorkFlowExecutor {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a class comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class has multiple formatting issues. please make sure these are addressed throughout the PR


public class WorkflowMediatorRequestExecutor implements WorkFlowExecutor {

private static final Log log = LogFactory.getLog(WorkflowMediatorRequestExecutor.class);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor the class name MediatorRequestExecutor


public class WorkflowMediatorRequestExecutor implements WorkFlowExecutor {

private static final Log log = LogFactory.getLog(WorkflowMediatorRequestExecutor.class);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log need to be uppercase

private static final String EXECUTOR_NAME = "Workflow Mediator Request Executor";

private static final Gson gson = new Gson();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unwanted new lines

bpsProfile = WorkflowImplServiceDataHolder.getInstance().getWorkflowImplService().getBPSProfile
(bpsProfileName, tenantId);
} catch (WorkflowImplException e) {
String errorMsg = "Error occurred while reading bps profile, " + e.getMessage();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed all bps references

Comment on lines +19 to +20


Copy link
Contributor

@dewniMW dewniMW May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unwanted new lines. check all applicable places

this.parameterList = parameterList;

Parameter bpsProfileParameter = WorkflowManagementUtil
.getParameter(parameterList, WFImplConstant.ParameterName.BPS_PROFILE, WFConstant.ParameterHolder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason to use WFImplConstant.ParameterName.BPS_PROFILE here?


con.setRequestMethod(POST);
con.setRequestProperty(CONTENT_TYPE, APPLICATION_JSON);
con.setRequestProperty(MEDIATOR_API_KEY, bpsProfile.getApiKey());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is getApiKey() defined?

Comment on lines +28 to +30
private String request_id;
private String workflow_iD;
private List<WorkflowVariable> workflow_Workflow_variables;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private String request_id;
private String workflow_iD;
private List<WorkflowVariable> workflow_Workflow_variables;
private String requestId;
private String workflowId;
private List<WorkflowVariable> workflowParameters;

Comment on lines +31 to +33



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format the file properly

Comment on lines +38 to +44
public static final String APPROVAL_TEMPLATE_NAME = "External Workflow Template";

public static final String TEMPLATE_ID = "ExternalWorkflowTemplate";

public static final String BPS_PROFILE = "BPSProfile";

public static final String HT_SUBJECT = "HTSubject";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are these constants used?

@@ -0,0 +1,68 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this new line

@@ -0,0 +1,46 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this new line

package org.wso2.carbon.identity.workflow.impl.util.model;

public class WorkFlowResponse {
private int statusCode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a new line


package org.wso2.carbon.identity.workflow.impl.util.model;

public class WorkFlowResponse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a class comment

public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format the file

Comment on lines +1 to +2


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these new lines. fix this in all places

* Define the Variable of the workflow request
*/

public class WorkflowVariable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class WorkflowVariable {
public class WorkflowParameter {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants