adding existing API check before publishing

revert-70aa11f8
inosh-perera 10 years ago
parent d242b3ffe1
commit 2002c92032

@ -172,17 +172,19 @@ public final class DeviceManagerUtil {
APIIdentifier id = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion()); APIIdentifier id = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
API api = new API(id); API api = new API(id);
try { try {
api.setContext(config.getContext()); if(!provider.isAPIAvailable(id)) {
api.setUrl(config.getEndpoint()); api.setContext(config.getContext());
api.setUriTemplates(getURITemplates(config.getEndpoint(), api.setUrl(config.getEndpoint());
APIConstants.AUTH_APPLICATION_OR_USER_LEVEL_TOKEN)); api.setUriTemplates(getURITemplates(config.getEndpoint(),
api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY); APIConstants.AUTH_APPLICATION_OR_USER_LEVEL_TOKEN));
api.addAvailableTiers(provider.getTiers()); api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY);
api.setEndpointSecured(false); api.addAvailableTiers(provider.getTiers());
api.setStatus(APIStatus.PUBLISHED); api.setEndpointSecured(false);
api.setTransports(config.getTransports()); api.setStatus(APIStatus.PUBLISHED);
api.setTransports(config.getTransports());
provider.addAPI(api);
provider.addAPI(api);
}
} catch (APIManagementException e) { } catch (APIManagementException e) {
throw new DeviceManagementException("Error occurred while registering the API", e); throw new DeviceManagementException("Error occurred while registering the API", e);
} }

@ -21,7 +21,7 @@
<API> <API>
<Name>appmanager</Name> <Name>appmanager</Name>
<Owner>admin</Owner> <Owner>admin</Owner>
<Context>devices</Context> <Context>/devices</Context>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint> <Endpoint>http://localhost:9763/</Endpoint>
<Transports>http,https</Transports> <Transports>http,https</Transports>

Loading…
Cancel
Save