Search in sources :

Example 1 with EndpointManager

use of org.wso2.carbon.governance.api.endpoints.EndpointManager in project carbon-apimgt by wso2.

the class APIUtil method createEndpoint.

/**
 * Create an Endpoint
 *
 * @param endpointUrl Endpoint url
 * @param registry    Registry space to save the endpoint
 * @return Path of the created resource
 * @throws APIManagementException If an error occurs while adding the endpoint
 */
public static String createEndpoint(String endpointUrl, Registry registry) throws APIManagementException {
    try {
        EndpointManager endpointManager = new EndpointManager(registry);
        Endpoint endpoint = endpointManager.newEndpoint(endpointUrl);
        endpointManager.addEndpoint(endpoint);
        return GovernanceUtils.getArtifactPath(registry, endpoint.getId());
    } catch (RegistryException e) {
        String msg = "Failed to import endpoint " + endpointUrl + " to registry ";
        log.error(msg, e);
        throw new APIManagementException(msg, e);
    }
}
Also used : Endpoint(org.wso2.carbon.governance.api.endpoints.dataobjects.Endpoint) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) EndpointManager(org.wso2.carbon.governance.api.endpoints.EndpointManager) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 EndpointManager (org.wso2.carbon.governance.api.endpoints.EndpointManager)1 Endpoint (org.wso2.carbon.governance.api.endpoints.dataobjects.Endpoint)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1