Java Code Examples for org.wso2.carbon.apimgt.impl.utils.APIUtil#getAPI()
The following examples show how to use
org.wso2.carbon.apimgt.impl.utils.APIUtil#getAPI() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 6 votes |
public API getAPI(APIIdentifier identifier, APIIdentifier oldIdentifier, String oldContext) throws APIManagementException { String apiPath = APIUtil.getAPIPath(identifier); try { GenericArtifactManager artifactManager = getAPIGenericArtifactManagerFromUtil(registry, APIConstants.API_KEY); Resource apiResource = registry.get(apiPath); String artifactId = apiResource.getUUID(); if (artifactId == null) { throw new APIManagementException("artifact id is null for : " + apiPath); } GenericArtifact apiArtifact = artifactManager.getGenericArtifact(artifactId); return APIUtil.getAPI(apiArtifact, registry, oldIdentifier, oldContext); } catch (RegistryException e) { String msg = "Failed to get API from : " + apiPath; throw new APIManagementException(msg, e); } }
Example 2
Source File: APIKeyMgtUtil.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * This returns API object for given APIIdentifier. Reads from registry entry for given APIIdentifier * creates API object * * @param identifier APIIdentifier object for the API * @return API object for given identifier * @throws APIManagementException on error in getting API artifact */ public static API getAPI(APIIdentifier identifier) throws APIManagementException { String apiPath = APIUtil.getAPIPath(identifier); try { Registry registry = APIKeyMgtDataHolder.getRegistryService().getGovernanceSystemRegistry(); GenericArtifactManager artifactManager = APIUtil.getArtifactManager(registry, APIConstants.API_KEY); if (artifactManager == null) { String errorMessage = "Artifact manager is null when retrieving API " + identifier.getApiName(); log.error(errorMessage); throw new APIManagementException(errorMessage); } Resource apiResource = registry.get(apiPath); String artifactId = apiResource.getUUID(); if (artifactId == null) { throw new APIManagementException("artifact id is null for : " + apiPath); } GenericArtifact apiArtifact = artifactManager.getGenericArtifact(artifactId); return APIUtil.getAPI(apiArtifact, registry); } catch (RegistryException e) { return null; } }
Example 3
Source File: UserAwareAPIProvider.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Override protected API getAPI(GenericArtifact apiArtifact) throws APIManagementException { API api = APIUtil.getAPI(apiArtifact, registry); if (api != null) { APIUtil.updateAPIProductDependencies(api, registry); checkAccessControlPermission(api.getId()); } return api; }
Example 4
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 4 votes |
protected API getApi(GovernanceArtifact artifact) throws APIManagementException { return APIUtil.getAPI(artifact); }
Example 5
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 2 votes |
/** * To get the API from generic artifact, if the user is authorized to view it. * * @param apiArtifact API Artifact. * @return API if the user is authorized to view this. */ protected API getAPI(GenericArtifact apiArtifact) throws APIManagementException { return APIUtil.getAPI(apiArtifact, registry); }