public static final List<String> getLocations(String location, LocationType type) { return getLocations(location, type, null); }
@Override public List<String> getObject() throws Exception { return LocationUtils.getLocations(locationListings); }
public static final List<String> getLocations(List<String> locationListings) { return getLocations(locationListings, null); }
public static final List<String> getLocations(String locationListing) { return getLocations(Collections.singletonList(locationListing), null); }
public static final List<String> getLocations(String location, LocationType type, String encoding) { switch (type) { case LOCATION: return Collections.singletonList(location); case LOCATIONLIST: return getLocations(location, encoding); default: throw new IllegalArgumentException("Location type '" + type + "' is unknown"); } }
public static final List<String> getLocations(String locationListing, String encoding) { return getLocations(Collections.singletonList(locationListing), encoding); }
@Override public void execute() { logger.info("Copying [{}] -> [{}]", locationListing, LocationUtils.getCanonicalPath(directory)); List<String> locations = LocationUtils.getLocations(locationListing); List<File> files = getFiles(locations); LocationUtils.copyLocationsToFiles(locations, files); logger.info("Copied {} files", locations.size()); }
/** * Throw IllegalArgumentException if any of the locationListings do not exist, or if any of the locations inside any of the locationListings do not exist */ public static final void validateLocationListings(List<String> locationListings) { for (String locationListing : locationListings) { validateLocation(locationListing); List<String> locations = getLocations(locationListing); validateLocations(locations); } }
/** * Gets the list of XML documents to ingest. * * @param locationListings the locations to search for XML documents to ingest * * @return the list of XML documents to ingest */ private List<XmlDocCollection> getXmlDocCollectionList(List<String> locationListings) { List<XmlDocCollection> xmlDocCollectionList = Lists.newArrayList(); List<String> locations = LocationUtils.getLocations(locationListings); for (String location : locations) { Preconditions.checkState(StringUtils.endsWith(location.toLowerCase(), XML_SUFFIX), "[%s] is not an XML document", location); Preconditions.checkState(LocationUtils.exists(location), "[%s] does not exist", location); logger.info("[{}]", location); xmlDocCollectionList.add(new LocationXmlDocCollection(location)); } return xmlDocCollectionList; }
public List<SqlSupplier> getSuppliers(String resourcesLocation) { Assert.noBlanks(resourcesLocation); Assert.isTrue(isMatch(resourcesLocation)); List<String> resources = LocationUtils.getLocations(resourcesLocation); List<SqlSupplier> suppliers = new ArrayList<SqlSupplier>(); for (String resource : resources) { SqlSupplier supplier = getSupplier(resource); suppliers.add(supplier); } return suppliers; }
/** * Get all the resources (in order) for the propertyKey passed in. The value behind the */ protected List<String> getLocations(Environment env, String propertyKey, String resourcesSuffix) { // Extract the list of resources (comma delimited) String csv = SpringUtils.getProperty(env, propertyKey, NullUtils.NONE); // If no resources were provided, we are done if (NullUtils.isNullOrNone(csv)) { return new ArrayList<String>(); } // Parse the CSV into a list of resources List<String> resources = CollectionUtils.getTrimmedListFromCSV(csv); // Allocate some storage for the locations we find List<String> locations = new ArrayList<String>(); for (String resource : resources) { if (StringUtils.endsWithIgnoreCase(resource, resourcesSuffix)) { // If the resource file ends with .resources, it's a list of resources, it is not a resource itself locations.addAll(LocationUtils.getLocations(resource)); } else { // Otherwise it is a resource itself locations.add(resource); } } // Return the list of resources return locations; }
@Override public void execute() { if (NullUtils.isNullOrNone(locationListing)) { logger.info("Skipping execution. Location listing [{}]", locationListing); return; } Assert.notNull(locationListing); Assert.notNull(directory); Assert.isTrue(LocationUtils.exists(locationListing)); logger.info("Copying [{}] -> [{}]", locationListing, LocationUtils.getCanonicalPath(directory)); List<String> locations = LocationUtils.getLocations(locationListing); List<File> files = getFiles(locations); LocationUtils.copyLocationsToFiles(locations, files); logger.info("Copied {} files", locations.size()); }