@RequestMapping public @ResponseBody FileModel function() throws Exception { byte[] bytes = serviceToGetTheFile.getFile(); return new FileModel("Filename", "application/pdf", bytes); }
public void setObject(Object object) { String location = (String) object; File dataDirectory = canonicalize(GeoserverDataDirectory.getGeoserverDataDirectory()); File file = canonicalize(new File(location)); if(isSubfile(dataDirectory, file)) { File curr = file; String path = null; // paranoid check to avoid infinite loops while(curr != null && !curr.equals(dataDirectory)){ if(path == null) { path = curr.getName(); } else { path = curr.getName() + "/" + path; } curr = curr.getParentFile(); } location = "file:" + path; } else if(!GeoserverDataDirectory.findDataFile(location).equals(file)) { // relative to the data directory, does not need fixing } else { location = "file://" + file.getAbsolutePath(); } delegate.setObject(location); }
private boolean isSubfile(File root, File selection) { if (selection == null || "".equals(selection.getPath())) return false; if (selection.equals(root)) return true; return isSubfile(root, selection.getParentFile()); }
private boolean isSubfile(File root, File selection) { if(selection == null || "".equals(selection.getPath())) return false; if(selection.equals(root)) return true; return isSubfile(root, selection.getParentFile()); }
for (Map.Entry<String, Map<String, Set<String>>> entry : treeMap .entrySet()) { if (!entry.getValue().isEmpty()) { LibraryModel libraryModel = new LibraryModel(entry.getKey()); root.addLibrary(libraryModel); for (Map.Entry<String, Set<String>> methodToFileEntry : entry .getValue().entrySet()) { MethodModel methodModel = new MethodModel( methodToFileEntry.getKey()); libraryModel.addMethod(methodModel); for (String fileName : methodToFileEntry.getValue()) { FileModel fileModel = new FileModel(fileName, fileName); methodModel.addFile(fileModel); } } } }
public void setObject(String location) { if (location != null) { File dataDirectory = canonicalize(rootDir); File file = canonicalize(new File(location)); if (isSubfile(dataDirectory, file)) { File curr = file; String path = null; // paranoid check to avoid infinite loops while (curr != null && !curr.equals(dataDirectory)) { if (path == null) { path = curr.getName(); } else { path = curr.getName() + "/" + path; } curr = curr.getParentFile(); } location = "file:" + path; } else { File dataFile = Files.url(rootDir, location); if (dataFile != null && !dataFile.equals(file)) { // relative to the data directory, does not need fixing } else { location = "file://" + file.getAbsolutePath(); } } } delegate.setObject(location); }
textField = new TextField("paramValue", new FileModel(paramValue)); textField.setRequired(required); textField.setOutputMarkupId(true);
new AutoCompleteTextField<String>("paramValue", new FileModel(paramValue)) { @Override protected Iterator<String> getChoices(String input) {
new TextField( "watermark.uRL", new FileModel(new PropertyModel<String>(form.getModel(), "watermark.URL"))); watermarkUrlField.add(new FileExistsValidator(true)); watermarkUrlField.setOutputMarkupId(true);