/** * Loads a set of {@link ExternalResource} based on their locations. * @param resourceLocations locations of external configuration resources. * @return a set of {@link ExternalResource}. */ private static Set<ExternalResource> loadExternalResources(Set<String> resourceLocations) { final Set<ExternalResource> resources = new HashSet<>(); for (String location : resourceLocations) { try { final byte[] content = loadExternalResource(location); final String contentHashSum = getHashCodeBasedOnObjectContent(content); resources.add(new ExternalResource(EXTERNAL_RESOURCE_KEY_PREFIX + location, contentHashSum)); } catch (CheckstyleException ex) { // if exception happened (configuration resource was not found, connection is not // available, resource is broken, etc), we need to calculate hash sum based on // exception object content in order to check whether problem is resolved later // and/or the configuration is changed. final String contentHashSum = getHashCodeBasedOnObjectContent(ex); resources.add(new ExternalResource(EXTERNAL_RESOURCE_KEY_PREFIX + location, contentHashSum)); } } return resources; }
/** * Loads a set of {@link ExternalResource} based on their locations. * @param resourceLocations locations of external configuration resources. * @return a set of {@link ExternalResource}. */ private static Set<ExternalResource> loadExternalResources(Set<String> resourceLocations) { final Set<ExternalResource> resources = new HashSet<>(); for (String location : resourceLocations) { try { final byte[] content = loadExternalResource(location); final String contentHashSum = getHashCodeBasedOnObjectContent(content); resources.add(new ExternalResource(EXTERNAL_RESOURCE_KEY_PREFIX + location, contentHashSum)); } catch (CheckstyleException ex) { // if exception happened (configuration resource was not found, connection is not // available, resource is broken, etc), we need to calculate hash sum based on // exception object content in order to check whether problem is resolved later // and/or the configuration is changed. final String contentHashSum = getHashCodeBasedOnObjectContent(ex); resources.add(new ExternalResource(EXTERNAL_RESOURCE_KEY_PREFIX + location, contentHashSum)); } } return resources; }