protected boolean fileHasChanged(FeatureFile file, long lastModified) { return file.lastModified() > lastModified; }
protected String getFileContent(FeatureFile file) { try { return file.getContent(); } catch (IOException e) { // This is fine; errors happen downstream. return null; } }
private void loadFile(FeatureFile file, Map<String,FeatureNode> featureMapBuilder) throws GadgetException, IOException { if (!file.exists() || !file.canRead()) { throw new GadgetException(GadgetException.Code.INVALID_CONFIG, "Feature file '" + file.getPath() + "' doesn't exist or can't be read"); } FeatureFile[] toLoad = file.isDirectory() ? file.listFiles() : new FeatureFile[] { file }; for (FeatureFile featureFile : toLoad) { if (featureFile.isDirectory()) { // Traverse into subdirectories. loadFile(featureFile, featureMapBuilder); } else if (featureFile.getName().toLowerCase(Locale.ENGLISH).endsWith(".xml")) { String content = featureFile.getContent(); Uri parent = Uri.fromJavaUri(featureFile.toURI()); loadFeature(parent, content, featureMapBuilder); } else { if (LOG.isLoggable(Level.FINEST)) { LOG.finest(featureFile.getAbsolutePath() + " doesn't seem to be an XML file."); } } } }
@Override protected boolean fileHasChanged(org.apache.shindig.gadgets.features.FeatureFile file, long lastModified) { // TODO: Update test to use a mocked file and file system instead of real files Boolean changeOverride = forceFileChanged.get(file.getAbsolutePath()); return file.lastModified() > lastModified ? true : changeOverride != null && changeOverride; } }
@Override protected boolean fileHasChanged(org.apache.shindig.gadgets.features.FeatureFile file, long lastModified) { // TODO: Update test to use a mocked file and file system instead of real files Boolean changeOverride = forceFileChanged.get(file.getAbsolutePath()); return file.lastModified() > lastModified ? true : changeOverride != null && changeOverride; } }
if (newContent != null) { content = newContent; lastModified = file.lastModified(); } else if (content != null) {