Search in sources :

Example 1 with StatusCoded

use of com.emc.storageos.svcs.errorhandling.model.StatusCoded in project coprhd-controller by CoprHD.

the class Documenter method createEntries.

public static Collection<DocumenterEntry> createEntries() {
    final List<Class<?>> list = getMessageBundleClasses();
    _log.info("found these classes to document: {}", list);
    final Collection<DocumenterEntry> entries = new ArrayList<DocumenterEntry>();
    for (final Class<?> interfaze : list) {
        final Object proxy = ExceptionMessagesProxy.create(interfaze);
        final Method[] methods = interfaze.getDeclaredMethods();
        for (final Method method : methods) {
            StatusType status;
            try {
                final Object[] parameters = sampleParameters(method);
                final ServiceCoded sce = (ServiceCoded) method.invoke(proxy, parameters);
                if (sce instanceof StatusCoded) {
                    status = ((StatusCoded) sce).getStatus();
                } else {
                    status = sce.isRetryable() ? Status.SERVICE_UNAVAILABLE : Status.INTERNAL_SERVER_ERROR;
                }
                entries.add(new DocumenterEntry(interfaze, method, status, sce, parameters));
            } catch (final Exception e) {
                _log.error(String.format("Fail to create document entry for method: %s", method), e);
            }
        }
    }
    return entries;
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) StatusType(javax.ws.rs.core.Response.StatusType) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) StatusCoded(com.emc.storageos.svcs.errorhandling.model.StatusCoded)

Aggregations

ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 StatusCoded (com.emc.storageos.svcs.errorhandling.model.StatusCoded)1 FileNotFoundException (java.io.FileNotFoundException)1 Method (java.lang.reflect.Method)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 StatusType (javax.ws.rs.core.Response.StatusType)1