Skip to content

Commit

Permalink
Add publisher rest API changes to support GW visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Naduni Pamudika committed Jan 3, 2025
1 parent 449eb3a commit f78fbae
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class APIRevisionDeployment implements Serializable {
private String deployedTime;
private String successDeployedTime;

private String visibility;

public int getId() {
return id;
}
Expand Down Expand Up @@ -96,4 +98,12 @@ public WorkflowStatus getStatus() {
public void setStatus(WorkflowStatus status) {
this.status = status;
}

public String getVisibility() {
return visibility;
}

public void setVisibility(String visibility) {
this.visibility = visibility;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18043,6 +18043,7 @@ public void addAPIRevisionDeployment(String apiRevisionId, List<APIRevisionDeplo
statement.setString(3, apiRevisionId);
statement.setBoolean(4, apiRevisionDeployment.isDisplayOnDevportal());
statement.setTimestamp(5, new Timestamp(System.currentTimeMillis()));
statement.setString(6, apiRevisionDeployment.getVisibility());
statement.addBatch();
}
statement.executeBatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3939,8 +3939,8 @@ public static class APIRevisionSqlConstants {
public static final String GET_REVISIONS_BY_API_UUID = "SELECT ID, REVISION_UUID, DESCRIPTION, CREATED_TIME, " +
"CREATED_BY FROM AM_REVISION WHERE API_UUID = ? ORDER BY ID";
public static final String ADD_API_REVISION_DEPLOYMENT_MAPPING =
" INSERT INTO AM_DEPLOYMENT_REVISION_MAPPING (NAME, VHOST, REVISION_UUID, DISPLAY_ON_DEVPORTAL, DEPLOYED_TIME)" +
" VALUES (?,?,?,?,?)";
" INSERT INTO AM_DEPLOYMENT_REVISION_MAPPING (NAME, VHOST, REVISION_UUID, DISPLAY_ON_DEVPORTAL, DEPLOYED_TIME, GW_VISIBILITY)" +
" VALUES (?,?,?,?,?,?)";
public static final String ADD_DEPLOYED_API_REVISION =
"INSERT INTO AM_DEPLOYED_REVISION (NAME, VHOST, REVISION_UUID, DEPLOYED_TIME)" +
" VALUES (?,?,?,?)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ public static APIRevisionDeployment mapAPIRevisionDeploymentWithValidation(Strin
throw new APIManagementException("Invalid Vhost: " + vhost, ExceptionCodes.INVALID_VHOST);
}

return mapApiRevisionDeployment(revisionId, vhost, displayOnDevportal, environment);
return mapApiRevisionDeployment(revisionId, vhost, displayOnDevportal, environment, environments.get(environment).getVisibility());
}

/**
Expand All @@ -919,13 +919,14 @@ public static APIRevisionDeployment mapAPIRevisionDeploymentWithValidation(Strin
* @return Mapped {@link APIRevisionDeployment}
*/
public static APIRevisionDeployment mapApiRevisionDeployment(String revisionId, String vhost, Boolean displayOnDevportal,
String deployment) {
String deployment, String visibility) {

APIRevisionDeployment apiRevisionDeployment = new APIRevisionDeployment();
apiRevisionDeployment.setRevisionUUID(revisionId);
apiRevisionDeployment.setDeployment(deployment);
apiRevisionDeployment.setVhost(vhost);
apiRevisionDeployment.setDisplayOnDevportal(displayOnDevportal);
apiRevisionDeployment.setVisibility(visibility);
return apiRevisionDeployment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10586,6 +10586,9 @@ components:
pattern: '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$'
type: string
example: mg.wso2.com
visibility:
type: string
example: Role1, Role2
displayOnDevportal:
type: boolean
example: true
Expand Down Expand Up @@ -11835,6 +11838,9 @@ components:
provider:
type: string
example: wso2
visibility:
type: string
example: Role1, Role2
showInApiConsole:
type: boolean
example: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static StatusEnum fromValue(String v) {
}
private StatusEnum status = StatusEnum.CREATED;
private String vhost = null;
private String visibility = null;
private Boolean displayOnDevportal = true;
private java.util.Date deployedTime = null;
private java.util.Date successDeployedTime = null;
Expand Down Expand Up @@ -128,6 +129,23 @@ public void setVhost(String vhost) {
this.vhost = vhost;
}

/**
**/
public APIRevisionDeploymentDTO visibility(String visibility) {
this.visibility = visibility;
return this;
}


@ApiModelProperty(example = "Role1, Role2", value = "")
@JsonProperty("visibility")
public String getVisibility() {
return visibility;
}
public void setVisibility(String visibility) {
this.visibility = visibility;
}

/**
**/
public APIRevisionDeploymentDTO displayOnDevportal(Boolean displayOnDevportal) {
Expand Down Expand Up @@ -193,14 +211,15 @@ public boolean equals(java.lang.Object o) {
Objects.equals(name, apIRevisionDeployment.name) &&
Objects.equals(status, apIRevisionDeployment.status) &&
Objects.equals(vhost, apIRevisionDeployment.vhost) &&
Objects.equals(visibility, apIRevisionDeployment.visibility) &&
Objects.equals(displayOnDevportal, apIRevisionDeployment.displayOnDevportal) &&
Objects.equals(deployedTime, apIRevisionDeployment.deployedTime) &&
Objects.equals(successDeployedTime, apIRevisionDeployment.successDeployedTime);
}

@Override
public int hashCode() {
return Objects.hash(revisionUuid, name, status, vhost, displayOnDevportal, deployedTime, successDeployedTime);
return Objects.hash(revisionUuid, name, status, vhost, visibility, displayOnDevportal, deployedTime, successDeployedTime);
}

@Override
Expand All @@ -212,6 +231,7 @@ public String toString() {
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" vhost: ").append(toIndentedString(vhost)).append("\n");
sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n");
sb.append(" displayOnDevportal: ").append(toIndentedString(displayOnDevportal)).append("\n");
sb.append(" deployedTime: ").append(toIndentedString(deployedTime)).append("\n");
sb.append(" successDeployedTime: ").append(toIndentedString(successDeployedTime)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class EnvironmentDTO {
private String gatewayType = "Regular";
private String serverUrl = null;
private String provider = null;
private String visibility = null;
private Boolean showInApiConsole = null;
private List<VHostDTO> vhosts = new ArrayList<VHostDTO>();
private List<GatewayEnvironmentProtocolURIDTO> endpointURIs = new ArrayList<GatewayEnvironmentProtocolURIDTO>();
Expand Down Expand Up @@ -160,6 +161,23 @@ public void setProvider(String provider) {
this.provider = provider;
}

/**
**/
public EnvironmentDTO visibility(String visibility) {
this.visibility = visibility;
return this;
}


@ApiModelProperty(example = "Role1, Role2", value = "")
@JsonProperty("visibility")
public String getVisibility() {
return visibility;
}
public void setVisibility(String visibility) {
this.visibility = visibility;
}

/**
**/
public EnvironmentDTO showInApiConsole(Boolean showInApiConsole) {
Expand Down Expand Up @@ -249,6 +267,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(gatewayType, environment.gatewayType) &&
Objects.equals(serverUrl, environment.serverUrl) &&
Objects.equals(provider, environment.provider) &&
Objects.equals(visibility, environment.visibility) &&
Objects.equals(showInApiConsole, environment.showInApiConsole) &&
Objects.equals(vhosts, environment.vhosts) &&
Objects.equals(endpointURIs, environment.endpointURIs) &&
Expand All @@ -257,7 +276,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(id, name, displayName, type, gatewayType, serverUrl, provider, showInApiConsole, vhosts, endpointURIs, additionalProperties);
return Objects.hash(id, name, displayName, type, gatewayType, serverUrl, provider, visibility, showInApiConsole, vhosts, endpointURIs, additionalProperties);
}

@Override
Expand All @@ -272,6 +291,7 @@ public String toString() {
sb.append(" gatewayType: ").append(toIndentedString(gatewayType)).append("\n");
sb.append(" serverUrl: ").append(toIndentedString(serverUrl)).append("\n");
sb.append(" provider: ").append(toIndentedString(provider)).append("\n");
sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n");
sb.append(" showInApiConsole: ").append(toIndentedString(showInApiConsole)).append("\n");
sb.append(" vhosts: ").append(toIndentedString(vhosts)).append("\n");
sb.append(" endpointURIs: ").append(toIndentedString(endpointURIs)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3437,6 +3437,7 @@ public static APIRevisionDeploymentDTO fromAPIRevisionDeploymenttoDTO(APIRevisio
+ model.getSuccessDeployedTime(), e);
}
}
apiRevisionDeploymentDTO.setVisibility(model.getVisibility());
return apiRevisionDeploymentDTO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static EnvironmentDTO fromEnvironmentToDTO(Environment environment) {
environmentDTO.setServerUrl(environment.getServerURL());
environmentDTO.setShowInApiConsole(environment.isShowInConsole());
environmentDTO.setProvider(environment.getProvider());
environmentDTO.setVisibility(environment.getVisibility());
environmentDTO.setVhosts(environment.getVhosts().stream().map(EnvironmentMappingUtil::fromVHostToVHostDTO)
.collect(Collectors.toList()));
environmentDTO.setAdditionalProperties(fromAdditionalPropertiesToAdditionalPropertiesDTO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4571,7 +4571,7 @@ private APIDTO importAsyncAPISpecification(InputStream definition, String defini
public Response updateAPIDeployment(String apiId, String deploymentId, APIRevisionDeploymentDTO
apIRevisionDeploymentDTO, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();

String organization = RestApiUtil.getValidatedOrganization(messageContext);
//validate if api exists
APIInfo apiInfo = CommonUtils.validateAPIExistence(apiId);
//validate API update operation permitted based on the LC state
Expand All @@ -4581,8 +4581,9 @@ public Response updateAPIDeployment(String apiId, String deploymentId, APIRevisi
String vhost = apIRevisionDeploymentDTO.getVhost();
Boolean displayOnDevportal = apIRevisionDeploymentDTO.isDisplayOnDevportal();
String decodedDeploymentName = ApisApiServiceImplUtils.getDecodedDeploymentName(deploymentId);
Map<String, Environment> environments = APIUtil.getEnvironments(organization);
APIRevisionDeployment apiRevisionDeployment = ApisApiServiceImplUtils.mapApiRevisionDeployment(revisionId, vhost,
displayOnDevportal, decodedDeploymentName);
displayOnDevportal, decodedDeploymentName, environments.get(decodedDeploymentName).getVisibility());
apiProvider.updateAPIDisplayOnDevportal(apiId, revisionId, apiRevisionDeployment);
APIRevisionDeployment apiRevisionDeploymentsResponse = apiProvider.
getAPIRevisionDeployment(decodedDeploymentName, revisionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10586,6 +10586,9 @@ components:
pattern: '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$'
type: string
example: mg.wso2.com
visibility:
type: string
example: Role1, Role2
displayOnDevportal:
type: boolean
example: true
Expand Down Expand Up @@ -11835,6 +11838,9 @@ components:
provider:
type: string
example: wso2
visibility:
type: string
example: Role1, Role2
showInApiConsole:
type: boolean
example: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2990,6 +2990,7 @@ CREATE TABLE AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL SMALLINT DEFAULT 0,
DEPLOYED_TIME TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON DELETE CASCADE)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2218,6 +2218,7 @@ CREATE TABLE IF NOT EXISTS AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL BOOLEAN DEFAULT 0,
DEPLOYED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON UPDATE CASCADE ON DELETE CASCADE
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2480,6 +2480,7 @@ CREATE TABLE AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL BIT DEFAULT 0,
DEPLOYED_TIME DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON UPDATE CASCADE ON DELETE CASCADE
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,7 @@ CREATE TABLE IF NOT EXISTS AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL BOOLEAN DEFAULT 0,
DEPLOYED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON UPDATE CASCADE ON DELETE CASCADE
)ENGINE INNODB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,7 @@ CREATE TABLE IF NOT EXISTS AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL BOOLEAN DEFAULT 0,
DEPLOYED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON UPDATE CASCADE ON DELETE CASCADE
)ENGINE=NDB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,7 @@ CREATE TABLE AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL INTEGER DEFAULT 0,
DEPLOYED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON DELETE CASCADE)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,7 @@ CREATE TABLE AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL INTEGER DEFAULT 0,
DEPLOYED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON DELETE CASCADE)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3449,6 +3449,7 @@ CREATE TABLE AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL INTEGER DEFAULT 0,
DEPLOYED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON DELETE CASCADE)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,7 @@ CREATE TABLE IF NOT EXISTS AM_DEPLOYMENT_REVISION_MAPPING (
REVISION_STATUS VARCHAR(255) NULL,
DISPLAY_ON_DEVPORTAL BOOLEAN DEFAULT '0',
DEPLOYED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
GW_VISIBILITY VARCHAR(2048) NULL,
PRIMARY KEY (NAME, REVISION_UUID),
FOREIGN KEY (REVISION_UUID) REFERENCES AM_REVISION(REVISION_UUID) ON UPDATE CASCADE ON DELETE CASCADE
);
Expand Down

0 comments on commit f78fbae

Please sign in to comment.