Author: mfortun Date: 2011-04-22 15:47:11 +0200 (Fri, 22 Apr 2011) New Revision: 831 Url: http://nuiton.org/repositories/revision/wikitty/831 Log: * correction of the version manipulation in the sync part * correct home directory used to find wikitties on file system. Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/FileSystemWIkittyId.java trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublication.java 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/FileSystemWIkittyId.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/FileSystemWIkittyId.java 2011-04-21 15:18:04 UTC (rev 830) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/FileSystemWIkittyId.java 2011-04-22 13:47:11 UTC (rev 831) @@ -73,4 +73,10 @@ return true; } + @Override + public String toString() { + return "FileSystemWIkittyId [fileName=" + fileName + ", path=" + path + + "]"; + } + } Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublication.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublication.java 2011-04-21 15:18:04 UTC (rev 830) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublication.java 2011-04-22 13:47:11 UTC (rev 831) @@ -131,6 +131,9 @@ boolean isRecur = applicationConfig .getOptionAsBoolean(IS_RECURSION_OPTION); + + + /* * TODO mfortun-2011-04-14 handle exception if uri format does not match */ @@ -161,11 +164,7 @@ WikittyProxy proxyTarget = new WikittyProxy( WikittyServiceFactory.buildWikittyService(temp2)); - /* - * TODO mfortun-2011-04-14 voir comment on fait quand les deux uris - * déclare des labels en fragment, si on les composent ensemble ou un - * truc du genre ? - */ + String labelOrigin = uriOrigin.getFragment(); String labelTarget = uriOrigin.getFragment(); @@ -223,18 +222,29 @@ } + // save the version before reset label + String wikittyVersionLocal = wikittyNew.getVersion(); WikittyLabelHelper.setLabels(wikittyNew, targetLabels); - + // restore the version + wikittyNew.setVersion(wikittyVersionLocal); proxyTarget.store(wikittyNew); - String versionSave = wikittyNew.getVersion(); + String versionSaveTarget = wikittyNew.getVersion(); WikittyLabelHelper.setLabels(wikittyNew, saveLabelOrigin); - wikittyNew.setVersion(versionSave); + wikittyNew.setVersion(versionSaveTarget); // we re store on the origin to ensure wikitty version - proxyOrigin.store(wikittyNew); + try { + proxyOrigin.store(wikittyNew); + } catch (Exception e) { + + // FIXME when a wikitty service store a + // wikitty that he does'nt know + // he set the version to 1.0 + e.printStackTrace(); + } } } @@ -242,7 +252,11 @@ * if option delete remove those who are on the target but not on origin */ if (isDelete) { + for (String id : existOnlyOnTarget) { + + + Wikitty w = proxyTarget.restore(id); WikittyLabelHelper.removeLabels(w, labelTarget); @@ -265,8 +279,7 @@ // check version for update /* - * TODO mfortun-2011-14-18 do something for labels at this time - * we replace origin labels y target's labels if we udpate. + * we replace origin labels by target's labels if we udpate. */ if (WikittyUtil .versionGreaterThan(versionOrigin, versionTarget)) { @@ -276,8 +289,12 @@ Set<String> setLabelOrigin = WikittyLabelHelper .getLabels(fromOrigin); + // save version before reset the label + String versionLocalSave = fromOrigin.getVersion(); // replace labels origins, by targets label WikittyLabelHelper.setLabels(fromOrigin, setLabelTarget); + // restore the version + fromOrigin.setVersion(versionLocalSave); // send modified origin to target wikitty service proxyTarget.store(fromOrigin); // re store on origin to ensure version is the same on both 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-21 15:18:04 UTC (rev 830) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-04-22 13:47:11 UTC (rev 831) @@ -144,6 +144,9 @@ this.mimeHelper = new MimeTypePubHelper(); + + + String url = app.getOption(WikittyPublication.WIKITTY_OPTION_URL); URI uri = new URI(url); @@ -163,6 +166,9 @@ this.recursion = app .getOptionAsBoolean(WikittyPublication.IS_RECURSION_OPTION); + + + } catch (Exception e) { e.printStackTrace(); } @@ -286,7 +292,7 @@ @Override public WikittyEvent store(String securityToken, Collection<Wikitty> wikitties, boolean force) { - + WikittyEvent result = new WikittyEvent(this); try { for (Wikitty w : wikitties) { @@ -303,6 +309,27 @@ } } + if ("".equals(ourDir)) { + + // remove file if the wikitty already exist + + BidiMap location = harvestLocalWikitties(homeFile, true); + + FileSystemWIkittyId idSystem = (FileSystemWIkittyId) location + .get(w.getId()); + + if (idSystem != null) { + File wikittyFile = new File(idSystem.getPath() + + File.separator + idSystem.getFileName()); + + if (wikittyFile.exists()) { + wikittyFile.delete(); + } + } + + return result; + } + // create the directories from the label boolean pathFilecreated = createFilesFromLabelPath(ourDir); @@ -383,8 +410,6 @@ // TODO mfortun-2011-04-12 really handle exceptions } - WikittyEvent result = new WikittyEvent(this); - return result; } @@ -933,12 +958,18 @@ harvestNewCheckModificationsAndDeleted(starts, label); } - BidiMap map = harvestLocalWikitties(homeFile, true); + BidiMap map = harvestLocalWikitties(starts, true); + + + for (Object o : map.keySet()) { String id = (String) o; FileSystemWIkittyId location = (FileSystemWIkittyId) map .get(id); + + + wikitties.put(id, restore(id, location)); } @@ -997,7 +1028,7 @@ harvestNewCheckModificationsAndDeleted(starts, label); } - BidiMap map = harvestLocalWikitties(homeFile, true); + BidiMap map = harvestLocalWikitties(starts, true); for (Object o : map.keySet()) { String id = (String) o; @@ -1271,7 +1302,7 @@ filesWikitty.addAll(CollectionUtil.toGenericCollection(ids.values(), String.class)); - //remove property of deleted wikitties + // remove property of deleted wikitties if (filesWikitty.size() != listChildFileNonDir.size()) { meta = getWikittyPublicationProperties(starts,
participants (1)
-
mfortun@users.nuiton.org