use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.
the class ApiMgtDAO method removeAPIRevisionDeployment.
/**
* Remove an API revision Deployment mapping record to the database
*
* @param apiUUID uuid of the revision
* @param deployments content of the revision deployment mapping objects
* @throws APIManagementException if an error occurs when adding a new API revision
*/
public void removeAPIRevisionDeployment(String apiUUID, Set<APIRevisionDeployment> deployments) throws APIManagementException {
try (Connection connection = APIMgtDBUtil.getConnection()) {
try {
connection.setAutoCommit(false);
// Remove an entry from AM_DEPLOYMENT_REVISION_MAPPING table
PreparedStatement statement = connection.prepareStatement(SQLConstants.APIRevisionSqlConstants.REMOVE_API_REVISION_DEPLOYMENT_MAPPING);
for (APIRevisionDeployment deployment : deployments) {
statement.setString(1, deployment.getDeployment());
statement.setString(2, deployment.getRevisionUUID());
statement.addBatch();
}
statement.executeBatch();
connection.commit();
} catch (SQLException e) {
connection.rollback();
throw e;
}
} catch (SQLException e) {
handleException("Failed to remove API Revision Deployment Mapping entry for API UUID " + apiUUID, e);
}
}
use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.
the class ApiMgtDAO method removeAPIRevisionDeployment.
/**
* Remove an API revision Deployment mapping record to the database
*
* @param apiRevisionId uuid of the revision
* @param apiRevisionDeployments content of the revision deployment mapping objects
* @throws APIManagementException if an error occurs when adding a new API revision
*/
public void removeAPIRevisionDeployment(String apiRevisionId, List<APIRevisionDeployment> apiRevisionDeployments) throws APIManagementException {
try (Connection connection = APIMgtDBUtil.getConnection()) {
try {
connection.setAutoCommit(false);
// Remove an entry from AM_DEPLOYMENT_REVISION_MAPPING table
PreparedStatement statement = connection.prepareStatement(SQLConstants.APIRevisionSqlConstants.REMOVE_API_REVISION_DEPLOYMENT_MAPPING);
for (APIRevisionDeployment apiRevisionDeployment : apiRevisionDeployments) {
statement.setString(1, apiRevisionDeployment.getDeployment());
statement.setString(2, apiRevisionId);
statement.addBatch();
}
statement.executeBatch();
connection.commit();
} catch (SQLException e) {
connection.rollback();
handleException("Failed to remove API Revision Deployment Mapping entry for Revision UUID " + apiRevisionId, e);
}
} catch (SQLException e) {
handleException("Failed to remove API Revision Deployment Mapping entry for Revision UUID " + apiRevisionId, e);
}
}
use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.
the class APIMappingUtil method fromAPIRevisionDeploymenttoDTO.
public static APIRevisionDeploymentDTO fromAPIRevisionDeploymenttoDTO(APIRevisionDeployment model) throws APIManagementException {
APIRevisionDeploymentDTO apiRevisionDeploymentDTO = new APIRevisionDeploymentDTO();
apiRevisionDeploymentDTO.setName(model.getDeployment());
apiRevisionDeploymentDTO.setVhost(model.getVhost());
if (model.getRevisionUUID() != null) {
apiRevisionDeploymentDTO.setRevisionUuid(model.getRevisionUUID());
}
apiRevisionDeploymentDTO.setDisplayOnDevportal(model.isDisplayOnDevportal());
if (model.getDeployedTime() != null) {
try {
apiRevisionDeploymentDTO.setDeployedTime(parseStringToDate(model.getDeployedTime()));
} catch (java.text.ParseException e) {
throw new APIManagementException("Error while parsing the deployed time:" + model.getDeployedTime(), e);
}
}
if (model.getSuccessDeployedTime() != null) {
try {
apiRevisionDeploymentDTO.setSuccessDeployedTime(parseStringToDate(model.getSuccessDeployedTime()));
} catch (java.text.ParseException e) {
throw new APIManagementException("Error while parsing the successfully deployed time:" + model.getSuccessDeployedTime(), e);
}
}
return apiRevisionDeploymentDTO;
}
use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.
the class APIMappingUtil method fromAPIRevisiontoDTO.
public static APIRevisionDTO fromAPIRevisiontoDTO(APIRevision model) throws APIManagementException {
APIRevisionDTO apiRevisionDTO = new APIRevisionDTO();
apiRevisionDTO.setId(model.getRevisionUUID());
String key = "Revision " + model.getId();
apiRevisionDTO.setDisplayName(key);
apiRevisionDTO.setDescription(model.getDescription());
if (model.getCreatedTime() != null) {
try {
apiRevisionDTO.setCreatedTime(parseStringToDate(model.getCreatedTime()));
} catch (java.text.ParseException e) {
throw new APIManagementException("Error while parsing the created time:" + model.getCreatedTime(), e);
}
}
APIRevisionAPIInfoDTO apiRevisionAPIInfoDTO = new APIRevisionAPIInfoDTO();
apiRevisionAPIInfoDTO.setId(model.getApiUUID());
apiRevisionDTO.setApiInfo(apiRevisionAPIInfoDTO);
List<APIRevisionDeploymentDTO> apiRevisionDeploymentDTOS = new ArrayList<>();
if (model.getApiRevisionDeploymentList() != null) {
for (APIRevisionDeployment apiRevisionDeployment : model.getApiRevisionDeploymentList()) {
apiRevisionDeploymentDTOS.add(fromAPIRevisionDeploymenttoDTO(apiRevisionDeployment));
}
}
apiRevisionDTO.setDeploymentInfo(apiRevisionDeploymentDTOS);
return apiRevisionDTO;
}
use of org.wso2.carbon.apimgt.api.model.APIRevisionDeployment in project carbon-apimgt by wso2.
the class SolaceNotifierUtils method getThirdPartySolaceBrokerEnvironmentNameOfAPIDeployment.
/**
* Get third party Solace broker environment Name for API deployment
*
* @param api Name of the API
* @return String of the name of environment in Solace broker
* @throws APIManagementException is error occurs when getting the name of the environment name
*/
private String getThirdPartySolaceBrokerEnvironmentNameOfAPIDeployment(API api) throws APIManagementException {
apiMgtDAO = ApiMgtDAO.getInstance();
Map<String, Environment> gatewayEnvironments = APIUtil.getReadOnlyGatewayEnvironments();
List<APIRevisionDeployment> deployments = apiMgtDAO.getAPIRevisionDeploymentsByApiUUID(api.getUuid());
for (APIRevisionDeployment deployment : deployments) {
String environmentName = deployment.getDeployment();
if (gatewayEnvironments.containsKey(environmentName)) {
Environment deployedEnvironment = gatewayEnvironments.get(environmentName);
if (SolaceConstants.SOLACE_ENVIRONMENT.equalsIgnoreCase(deployedEnvironment.getProvider())) {
return environmentName;
}
}
}
return null;
}
Aggregations