public String readContent(List<String> elements, String rootPath, String element) { if(elements.contains(element)) { String path = format("%s%s/", rootPath, element); List<String> dirList = listResources(path); for (String file : dirList) { String contents = readFile(format("/%s%s", path, file)); return contents; } } return null; } }
/** * Gets all design documents from desk. * @see #getFromDesk(String) * @return a list of all design documents */ public List<DesignDocument> getAllFromDesk() { final List<DesignDocument> designDocsList = new ArrayList<DesignDocument>(); for (String docName : listResources(format("%s/", DESIGN_DOCS_DIR))) { designDocsList.add(getFromDesk(docName)); } return designDocsList; }
private Map<String, String> populateMap(String rootPath, List<String> elements, String element) { Map<String, String> functionsMap = null; if(elements.contains(element)) { functionsMap = new HashMap<String, String>(); String path = format("%s%s/", rootPath, element); for (String fileName : listResources(path)) { String contents = readFile(format("/%s%s", path, fileName)); functionsMap.put(removeExtension(fileName), contents); } } return functionsMap; }
final DesignDocument dd = new DesignDocument(); final String rootPath = format("%s/%s/", DESIGN_DOCS_DIR, id); final List<String> elements = listResources(rootPath); if(elements == null) { throw new IllegalArgumentException("Design docs directory cannot be empty."); views = new HashMap<String, MapReduce>(); final String viewsPath = format("%s%s/", rootPath, VIEWS); for (String viewDirName : listResources(viewsPath)) { // views sub-dirs final MapReduce mr = new MapReduce(); final String viewPath = format("%s%s/", viewsPath, viewDirName); final List<String> dirList = listResources(viewPath); for (String fileName : dirList) { // view files final String def = readFile(format("/%s%s", viewPath, fileName));