Java Code Examples for org.wso2.carbon.registry.core.Resource#getUUID()
The following examples show how to use
org.wso2.carbon.registry.core.Resource#getUUID() .
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(String apiPath) throws APIManagementException { 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 getApi(apiArtifact); } catch (RegistryException e) { String msg = "Failed to get API from : " + apiPath; throw new APIManagementException(msg, e); } }
Example 2
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 3
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 6 votes |
public APIProduct getAPIProduct(String productPath) throws APIManagementException { try { GenericArtifactManager artifactManager = getAPIGenericArtifactManagerFromUtil(registry, APIConstants.API_KEY); Resource productResource = registry.get(productPath); String artifactId = productResource.getUUID(); if (artifactId == null) { throw new APIManagementException("artifact id is null for : " + productPath); } GenericArtifact productArtifact = artifactManager.getGenericArtifact(artifactId); return APIUtil.getAPIProduct(productArtifact, registry); } catch (RegistryException e) { String msg = "Failed to get API Product from : " + productPath; throw new APIManagementException(msg, e); } }
Example 4
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 5
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Returns list of wsdls * * @return list of wsdl objects or null * @throws APIManagementException If unable to return satisfied wsdl object list */ @Override public List<Wsdl> getAllWsdls() throws APIManagementException { List<Wsdl> wsdlList = new ArrayList<Wsdl>(); String resourcePath = APIConstants.API_WSDL_RESOURCE; try { if (registry.resourceExists(resourcePath)) { Resource wsdlResource = registry.get(resourcePath); if (wsdlResource instanceof Collection) { String[] wsdlCollection = ((Collection) wsdlResource).getChildren(); if (wsdlCollection.length > 0) { for (String wsdlFile : wsdlCollection) { Resource wsdlResourceFile = registry.get(wsdlFile); String uuid = wsdlResourceFile.getUUID(); Wsdl wsdl = new Wsdl(); String wsdlName = wsdlFile.substring(wsdlFile.lastIndexOf("/") + 1); wsdl.setUuid(uuid); wsdl.setName(wsdlName); wsdlList.add(wsdl); } } } } } catch (RegistryException e) { String msg = "Failed to get wsdl list"; throw new APIManagementException(msg, e); } return wsdlList; }
Example 6
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Returns the wsdl registry resource correspond to the given identifier * * @param wsdlId uuid of the wsdl resource * @return Registry resource of given identifier or null * @throws APIManagementException If failed to get the registry resource of given uuid */ @Override public Resource getWsdlResourceFromUuid(String wsdlId) throws APIManagementException { String resourcePath = APIConstants.API_WSDL_RESOURCE; try { if (registry.resourceExists(resourcePath)) { Resource resource = registry.get(resourcePath); //resource : /_system/governance/apimgt/applicationdata/wsdls if (resource instanceof Collection) { Collection wsdlCollection = (Collection) resource; String[] wsdlArray = wsdlCollection.getChildren(); for (String wsdl : wsdlArray) { Resource wsdlResource = registry.get(wsdl); String resourceId = wsdlResource.getUUID(); if (resourceId.equals(wsdlId)) { return wsdlResource; } } } } } catch (RegistryException e) { String msg = "Error while accessing registry objects"; throw new APIManagementException(msg, e); } return null; }
Example 7
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Returns the uuid of the updated/created mediation policy * * @param mediationPolicyPath path to the registry resource * @return uuid of the given registry resource or null */ @Override public String getCreatedResourceUuid(String mediationPolicyPath) { try { Resource resource = registry.get(mediationPolicyPath); return resource.getUUID(); } catch (RegistryException e) { log.error("error occurred while getting created mediation policy uuid", e); } return null; }
Example 8
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Returns the mediation policy registry resource correspond to the given identifier * * @param mediationPolicyId uuid of the mediation resource * @return Registry resource of given identifier or null * @throws APIManagementException If failed to get the registry resource of given uuid */ @Override public Resource getCustomMediationResourceFromUuid(String mediationPolicyId) throws APIManagementException { String resourcePath = APIConstants.API_CUSTOM_SEQUENCE_LOCATION; try { Resource resource = registry.get(resourcePath); //resource : customsequences if (resource instanceof Collection) { Collection typeCollection = (Collection) resource; String[] typeArray = typeCollection.getChildren(); for (String type : typeArray) { Resource typeResource = registry.get(type); //typeResource: in/ out/ fault if (typeResource instanceof Collection) { String[] policyArray = ((Collection) typeResource).getChildren(); if (policyArray.length > 0) { for (String policy : policyArray) { Resource mediationResource = registry.get(policy); //mediationResource: eg .log_in_msg.xml String resourceId = mediationResource.getUUID(); if (resourceId.equals(mediationPolicyId)) { //If registry resource id matches given identifier returns that // registry resource return mediationResource; } } } } } } } catch (RegistryException e) { String msg = "Error while accessing registry objects"; throw new APIManagementException(msg, e); } return null; }
Example 9
Source File: AbstractAPIManager.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Returns Registry resource matching given mediation policy identifier * * @param identifier API identifier * @param uuid mediation policy identifier * @param resourcePath registry path to the API resource * @return Registry resource matches given identifier or null * @throws APIManagementException If fails to get the resource matching given identifier */ @Override public Resource getApiSpecificMediationResourceFromUuid(Identifier identifier, String uuid, String resourcePath) throws APIManagementException { try { Resource resource = registry.get(resourcePath); if (resource instanceof Collection) { Collection typeCollection = (Collection) resource; String[] typeArray = typeCollection.getChildren(); for (String type : typeArray) { //Check for mediation policy resource if ((type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR + APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN)) || (type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR + APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT)) || (type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR + APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT))) { Resource sequenceType = registry.get(type); //sequenceType eg: in / out /fault if (sequenceType instanceof Collection) { String[] mediationPolicyArr = ((Collection) sequenceType).getChildren(); for (String mediationPolicy : mediationPolicyArr) { Resource mediationResource = registry.get(mediationPolicy); String resourceId = mediationResource.getUUID(); if (resourceId.equalsIgnoreCase(uuid)) { return mediationResource; } } } } } } } catch (RegistryException e) { String msg = "Error while obtaining registry objects"; throw new APIManagementException(msg, e); } return null; }