Author: mfortun Date: 2011-04-21 11:39:45 +0200 (Thu, 21 Apr 2011) New Revision: 827 Url: http://nuiton.org/repositories/revision/wikitty/827 Log: * correct wikittypublicationfilesystem for norecursion option * correct starts directory for search, restore, etc, starts file is determine by label and homedir Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-04-20 21:42:24 UTC (rev 826) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-04-21 09:39:45 UTC (rev 827) @@ -99,7 +99,6 @@ protected File homeFile; protected boolean recursion; protected String label; - static public String META_CURRENT_LABEL = "current.label"; @@ -125,8 +124,8 @@ static public String PROPERTY_DIRECTORY = ".wp"; - protected MimeTypePubHelper mimeHelper; + /** * Constructor with the working directory * @@ -141,9 +140,8 @@ */ try { - this.mimeHelper = new MimeTypePubHelper(); + this.mimeHelper = new MimeTypePubHelper(); - String url = app.getOption(WikittyPublication.WIKITTY_OPTION_URL); URI uri = new URI(url); @@ -330,7 +328,7 @@ File wikittyFile = null; if (w.hasExtension(WikittyPubData.EXT_WIKITTYPUBDATA)) { name = WikittyPubDataHelper.getName(w); - // String mime = WikittyPubDataHelper.getMimeType(w); + // String mime = WikittyPubDataHelper.getMimeType(w); byte[] content = WikittyPubDataHelper.getContent(w); extension = WikittyPubDataHelper.getFileExtension(w); @@ -345,7 +343,7 @@ } else if (w .hasExtension(WikittyPubText.EXT_WIKITTYPUBTEXT)) { name = WikittyPubTextHelper.getName(w); - //String mime = WikittyPubTextHelper.getMimeType(w); + // String mime = WikittyPubTextHelper.getMimeType(w); String content = WikittyPubTextHelper.getContent(w); extension = WikittyPubTextHelper.getFileExtension(w); @@ -457,16 +455,15 @@ List<Wikitty> result = new ArrayList<Wikitty>(); try { - BidiMap locations = harvestLocalWikitties(homeFile, recursion); + String labelToDir = this.labelToPath(label); + File starts = new File(homeFile.getAbsolutePath() + File.separator + + labelToDir); + BidiMap locations = harvestLocalWikitties(starts, recursion); + for (String wikid : id) { Object value = locations.get(wikid); - if (value == null) { - locations = locations.inverseBidiMap(); - value = locations.get(wikid); - } - if (value != null) { FileSystemWIkittyId localisation = (FileSystemWIkittyId) value; @@ -474,6 +471,7 @@ result.add(this.restore(wikid, localisation)); } } + } catch (Exception e) { e.printStackTrace(); // TODO mfortun-2011-01-12 really handle exception @@ -630,8 +628,8 @@ switch (restriction.getName()) { case EQUALS: + if (value instanceof String && o instanceof String) { - String pattern = (String) value; pattern = pattern.replace("*", "\\p{ASCII}*"); pattern = pattern.replace("?", "\\p{ASCII}"); @@ -926,12 +924,13 @@ List<Criteria> criteria) { Map<String, Wikitty> wikitties = new HashMap<String, Wikitty>(); try { - String labelToDir = this.labelToPath(label); - File starts = new File (homeFile.getAbsolutePath()+File.separator+labelToDir); - if (starts.exists()){ + String labelToDir = this.labelToPath(label); + File starts = new File(homeFile.getAbsolutePath() + File.separator + + labelToDir); + if (starts.exists()) { harvestNewCheckModifications(starts, label); } - + BidiMap map = harvestLocalWikitties(homeFile, true); for (Object o : map.keySet()) { @@ -947,6 +946,7 @@ e.printStackTrace(); } + List<PagedResult<String>> result = new ArrayList<PagedResult<String>>(); // for each criteria @@ -988,7 +988,28 @@ List<String> result = new ArrayList<String>(); Map<String, Wikitty> wikitties = new HashMap<String, Wikitty>(); + try { + String labelToDir = this.labelToPath(label); + File starts = new File(homeFile.getAbsolutePath() + File.separator + + labelToDir); + if (starts.exists()) { + harvestNewCheckModifications(starts, label); + } + BidiMap map = harvestLocalWikitties(homeFile, true); + + for (Object o : map.keySet()) { + String id = (String) o; + FileSystemWIkittyId location = (FileSystemWIkittyId) map + .get(id); + wikitties.put(id, restore(id, location)); + + } + + } catch (Exception e) { + // TODO mfortun-2011-04-21 really handle exception + e.printStackTrace(); + } // for each criteria for (Criteria cr : criteria) { // prepare restriction on result @@ -1054,8 +1075,6 @@ } - - /** * Method that create a list of the properties directory * @@ -1164,7 +1183,6 @@ String extension = FileUtil.extension(fileToTransform); String name = FileUtil.basename(completeName, "." + extension); - // search for the mimetype String mimeType = mimeHelper.getMimeForExtension(extension); @@ -1207,7 +1225,7 @@ File propertyFile = new File(starts + File.separator + PROPERTY_DIRECTORY); - + if (!propertyFile.exists() || !propertyFile.isDirectory()) { propertyFile.mkdir(); @@ -1359,17 +1377,16 @@ return result; } - - public String labelToPath (String label){ + public String labelToPath(String label) { String result = label; - + result = result.replace(".", File.separator); // correct the pb with directory name begin by . - result = result.replace(File.separator + File.separator, - File.separator + "."); - + result = result.replace(File.separator + File.separator, File.separator + + "."); + return result; } - + }