use of org.wso2.carbon.apimgt.api.model.APIProduct in project carbon-apimgt by wso2.
the class APIProviderImpl method removeFromGateway.
protected void removeFromGateway(APIProduct apiProduct, String tenantDomain, Set<APIRevisionDeployment> gatewaysToRemove, Set<String> gatewaysToAdd) throws APIManagementException {
APIGatewayManager gatewayManager = APIGatewayManager.getInstance();
Set<API> associatedAPIs = getAssociatedAPIs(apiProduct);
Set<String> environmentsToRemove = new HashSet<>();
for (APIRevisionDeployment apiRevisionDeployment : gatewaysToRemove) {
environmentsToRemove.add(apiRevisionDeployment.getDeployment());
}
environmentsToRemove.removeAll(gatewaysToAdd);
gatewayManager.unDeployFromGateway(apiProduct, tenantDomain, associatedAPIs, environmentsToRemove);
}
use of org.wso2.carbon.apimgt.api.model.APIProduct in project carbon-apimgt by wso2.
the class APIProviderImpl method createAPIProduct.
/**
* Create an Api Product
*
* @param apiProduct API Product
* @throws APIManagementException if failed to create APIProduct
*/
protected String createAPIProduct(APIProduct apiProduct) throws APIManagementException {
String apiProductUUID = null;
// Validate Transports and Security
validateAndSetTransports(apiProduct);
validateAndSetAPISecurity(apiProduct);
PublisherAPIProduct publisherAPIProduct = APIProductMapper.INSTANCE.toPublisherApiProduct(apiProduct);
PublisherAPIProduct addedAPIProduct;
try {
publisherAPIProduct.setApiProductName(apiProduct.getId().getName());
publisherAPIProduct.setProviderName(apiProduct.getId().getProviderName());
publisherAPIProduct.setVersion(apiProduct.getId().getVersion());
addedAPIProduct = apiPersistenceInstance.addAPIProduct(new Organization(CarbonContext.getThreadLocalCarbonContext().getTenantDomain()), publisherAPIProduct);
apiProductUUID = addedAPIProduct.getId();
} catch (APIPersistenceException e) {
throw new APIManagementException("Error while creating API product ", e);
}
return apiProductUUID;
}
use of org.wso2.carbon.apimgt.api.model.APIProduct in project carbon-apimgt by wso2.
the class APIGatewayManager method unDeployFromGateway.
public void unDeployFromGateway(APIProduct apiProduct, String tenantDomain, Set<API> associatedAPIs, Set<String> gatewaysToRemove) throws APIManagementException {
String apiProductUuid = apiProduct.getUuid();
APIProductIdentifier apiProductIdentifier = apiProduct.getId();
try {
if (artifactSaver != null) {
artifactSaver.removeArtifact(apiProductUuid, apiProductIdentifier.getName(), apiProductIdentifier.getVersion(), APIConstants.API_PRODUCT_REVISION, tenantDomain);
}
GatewayArtifactsMgtDAO.getInstance().deleteGatewayArtifact(apiProductUuid, APIConstants.API_PRODUCT_REVISION);
GatewayArtifactsMgtDAO.getInstance().removePublishedGatewayLabels(apiProductUuid, APIConstants.API_PRODUCT_REVISION);
} catch (ArtifactSynchronizerException e) {
throw new APIManagementException("API " + apiProductIdentifier + "couldn't get unDeployed", e);
}
if (debugEnabled) {
log.debug("Status of " + apiProductIdentifier + " has been updated to DB");
}
sendUnDeploymentEvent(apiProduct, tenantDomain, gatewaysToRemove, associatedAPIs);
}
use of org.wso2.carbon.apimgt.api.model.APIProduct in project carbon-apimgt by wso2.
the class APIProviderImpl method getAPIProductbyUUID.
public APIProduct getAPIProductbyUUID(String uuid, String organization) throws APIManagementException {
try {
Organization org = new Organization(organization);
PublisherAPIProduct publisherAPIProduct = apiPersistenceInstance.getPublisherAPIProduct(org, uuid);
if (publisherAPIProduct != null) {
APIProduct product = APIProductMapper.INSTANCE.toApiProduct(publisherAPIProduct);
product.setID(new APIProductIdentifier(publisherAPIProduct.getProviderName(), publisherAPIProduct.getApiProductName(), publisherAPIProduct.getVersion(), uuid));
checkAccessControlPermission(userNameWithoutChange, product.getAccessControl(), product.getAccessControlRoles());
populateRevisionInformation(product, uuid);
populateAPIProductInformation(uuid, organization, product);
populateAPIStatus(product);
populateAPITier(product);
return product;
} else {
String msg = "Failed to get API Product. API Product artifact corresponding to artifactId " + uuid + " does not exist";
throw new APIMgtResourceNotFoundException(msg);
}
} catch (APIPersistenceException | OASPersistenceException | ParseException e) {
String msg = "Failed to get API Product";
throw new APIManagementException(msg, e);
}
}
use of org.wso2.carbon.apimgt.api.model.APIProduct in project carbon-apimgt by wso2.
the class APIProviderImpl method deleteAPIProduct.
@Override
public void deleteAPIProduct(APIProductIdentifier identifier, String apiProductUUID, String organization) throws APIManagementException {
if (StringUtils.isEmpty(apiProductUUID)) {
if (identifier.getUUID() != null) {
apiProductUUID = identifier.getUUID();
} else {
apiProductUUID = apiMgtDAO.getUUIDFromIdentifier(identifier, organization);
}
}
APIProduct apiProduct = getAPIProductbyUUID(apiProductUUID, organization);
apiProduct.setOrganization(organization);
deleteAPIProduct(apiProduct);
}
Aggregations