use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class EnunciateFileReader method loadServices.
private Map<String, ApiService> loadServices(Document document) {
Map<String, ApiClass> apiClasses = loadTypes(document);
Map<String, ApiService> apiServices = Maps.newHashMap();
NodeList resourceNodes = XMLUtils.getNodeList(document, EnunciateConstants.RESOURCES);
for (int f = 0; f < resourceNodes.getLength(); f++) {
Node resourceNode = resourceNodes.item(f);
String serviceClass = XMLUtils.getNodeText(resourceNode, EnunciateConstants.RESOURCE_SERVICE_CLASS);
ApiService apiService = null;
if (apiClasses.containsKey(serviceClass)) {
apiService = apiServices.get(serviceClass);
} else {
apiService = new ApiService();
apiService.javaClassName = serviceClass;
apiServices.put(serviceClass, apiService);
}
ApiMethod apiMethod = toApiMethod(resourceNode, apiClasses);
System.out.println("Loaded Method " + serviceClass + " " + apiMethod.httpMethod + " " + apiMethod.path);
apiService.addMethod(apiMethod);
}
return apiServices;
}
use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class ApiReferenceTocOrganizer method organizeServices.
public Map<String, List<ApiService>> organizeServices(List<ApiService> services) {
List<ApiService> allServices = Lists.newArrayList(services);
Map<String, List<ApiService>> sortedServices = Maps.newLinkedHashMap();
// Data Services appear in a different section
removeObjectDataServices(allServices);
for (Map.Entry<String, List<String>> entry : groups.entrySet()) {
List<ApiService> categoryServices = Lists.newArrayList();
List<ApiService> foundServices = Lists.newArrayList();
for (String serviceName : entry.getValue()) {
for (ApiService service : allServices) {
// Find the service in the list of services
if (service.getFqJavaClassName().equals(serviceName) || service.javaClassName.equals(serviceName)) {
foundServices.add(service);
categoryServices.add(service);
}
}
}
if (!categoryServices.isEmpty()) {
// Only include non-empty categories
sortedServices.put(entry.getKey(), categoryServices);
}
allServices.removeAll(foundServices);
}
// Generate an Exception for non-assigned services
if (!allServices.isEmpty()) {
String servicesLeft = "";
for (ApiService service : allServices) {
servicesLeft = servicesLeft + "\n" + service.getFqJavaClassName();
}
throw new RuntimeException(servicesLeft + " not assigned to any TOC category in ApiReferenceGrouping.txt");
}
return sortedServices;
}
use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class ApiPrimitiveMaker method makePrimitives.
/**
* Accept a list of ApiServices and make primitives for each HTTP method in
* the service
*
* @param services
* - a list of services
*
* @return a JavaFile representing java source code for the primitive
*/
public static Iterable<JavaFile> makePrimitives(final List<ApiService> services) {
final Builder<JavaFile> builder = ImmutableList.<JavaFile>builder();
final ApiReferenceTocOrganizer grouping = new ApiReferenceTocOrganizer(KnownPaths.getReferenceFile("ApiReferenceGrouping.txt"));
final Map<String, List<ApiService>> groups = grouping.organizeServices(services);
for (final Entry<String, List<ApiService>> groupEntry : groups.entrySet()) {
for (final ApiService service : groupEntry.getValue()) {
for (final ApiMethod method : service.methods) {
if (blackListed(method)) {
_log.info("Method " + method.apiService.getFqJavaClassName() + "::" + method.javaMethodName + " is black listed");
} else if (method.isDeprecated) {
_log.info("Method " + method.apiService.getFqJavaClassName() + "::" + method.javaMethodName + " is deprecated");
} else {
builder.add(makePrimitive(groupEntry.getKey(), method));
}
}
}
}
return builder.build();
}
use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.
the class ApiDoclet method start.
/**
* MAIN Entry Point into the Doclet
*/
public static boolean start(RootDoc root) {
KnownPaths.init(contentDirectory, outputDirectory);
init();
loadServiceBlackList();
loadMethodBlackList();
List<ApiService> apiServices = findApiServices(root.classes());
List<ApiErrorCode> errorCodes = findErrorCodes(root.classes());
cleanupMethods(apiServices);
saveMetaData(apiServices);
ApiDifferences apiDifferences = calculateDifferences(apiServices);
generateFiles(apiDifferences, apiServices, errorCodes);
return true;
}
Aggregations