Wikitty-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
July 2011
- 4 participants
- 85 discussions
r1070 - in trunk: wikitty-api wikitty-api/src/test/java/org/nuiton/wikitty/entities wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by echatellier@users.nuiton.org 08 Jul '11
by echatellier@users.nuiton.org 08 Jul '11
08 Jul '11
Author: echatellier
Date: 2011-07-08 12:26:15 +0200 (Fri, 08 Jul 2011)
New Revision: 1070
Url: http://nuiton.org/repositories/revision/wikitty/1070
Log:
Disable purifier, break wikitty
Removed:
trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/BirdImpl.java
trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/HorseImpl.java
trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/PegasusImpl.java
Modified:
trunk/wikitty-api/pom.xml
trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java
Modified: trunk/wikitty-api/pom.xml
===================================================================
--- trunk/wikitty-api/pom.xml 2011-07-07 16:15:16 UTC (rev 1069)
+++ trunk/wikitty-api/pom.xml 2011-07-08 10:26:15 UTC (rev 1070)
@@ -171,7 +171,7 @@
<goal>smart-generate</goal>
</goals>
</execution>
- <execution>
+ <!-- <execution>
<id>test-generation</id>
<phase>generate-test-sources</phase>
<configuration>
@@ -188,7 +188,7 @@
<goals>
<goal>smart-generate</goal>
</goals>
- </execution>
+ </execution> -->
</executions>
</plugin>
@@ -257,7 +257,7 @@
http://www.nuiton.org/issues/show/1160
and http://www.nuiton.org/issues/show/1160-->
- <!--profile>
+ <profile>
<id>run-its</id>
<activation>
<property>
@@ -295,7 +295,7 @@
</plugin>
</plugins>
</build>
- </profile-->
+ </profile>
</profiles>
Deleted: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/BirdImpl.java
===================================================================
--- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/BirdImpl.java 2011-07-07 16:15:16 UTC (rev 1069)
+++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/BirdImpl.java 2011-07-08 10:26:15 UTC (rev 1070)
@@ -1,39 +0,0 @@
-/*
- * #%L
- *
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.wikitty.entities;
-
-/**
- * Bird impl.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class BirdImpl {
-
-}
Deleted: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/HorseImpl.java
===================================================================
--- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/HorseImpl.java 2011-07-07 16:15:16 UTC (rev 1069)
+++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/HorseImpl.java 2011-07-08 10:26:15 UTC (rev 1070)
@@ -1,39 +0,0 @@
-/*
- * #%L
- *
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.wikitty.entities;
-
-/**
- * Horse impl.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class HorseImpl {
-
-}
Deleted: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/PegasusImpl.java
===================================================================
--- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/PegasusImpl.java 2011-07-07 16:15:16 UTC (rev 1069)
+++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/PegasusImpl.java 2011-07-08 10:26:15 UTC (rev 1070)
@@ -1,84 +0,0 @@
-/*
- * #%L
- *
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.wikitty.entities;
-
-/**
- * Pegasus impl.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class PegasusImpl extends PegasusAbstract {
-
- /*
- * @see org.nuiton.wikitty.entities.Pegasus#scream()
- */
- @Override
- public void scream() {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * @see org.nuiton.wikitty.entities.Pegasus#walk()
- */
- @Override
- public void walk() {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * @see org.nuiton.wikitty.entities.Bird#fly()
- */
- @Override
- public void fly() {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * @see org.nuiton.wikitty.entities.Bird#getWingsCount()
- */
- @Override
- public int getWingsCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /*
- * @see org.nuiton.wikitty.entities.Bird#setWingsCount(int)
- */
- @Override
- public void setWingsCount(int wingsCount) {
- // TODO Auto-generated method stub
-
- }
-
-}
Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java
===================================================================
--- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java 2011-07-07 16:15:16 UTC (rev 1069)
+++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java 2011-07-08 10:26:15 UTC (rev 1070)
@@ -48,7 +48,7 @@
*/
@Test
public void testModelEntitiesCompilation() {
- Pegasus pegasus = new PegasusImpl();
- String pegasusRace = pegasus.getRaceFromPegasus();
+ //Pegasus pegasus = new PegasusImpl();
+ //String pegasusRace = pegasus.getRaceFromPegasus();
}
}
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java 2011-07-07 16:15:16 UTC (rev 1069)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java 2011-07-08 10:26:15 UTC (rev 1070)
@@ -67,7 +67,7 @@
//FIXME tchemit 2010-11-28 : still does not work with superclass inheritance, will not generate operation in Abstract classes
- setTransformerTypes(WikittyPurifierTransformer.class);
+ //setTransformerTypes(WikittyPurifierTransformer.class);
setTemplateTypes(
WikittyContractGenerator.class,
WikittyAbstractGenerator.class,
1
0
r1069 - trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize
by mfortun@users.nuiton.org 07 Jul '11
by mfortun@users.nuiton.org 07 Jul '11
07 Jul '11
Author: mfortun
Date: 2011-07-07 18:15:16 +0200 (Thu, 07 Jul 2011)
New Revision: 1069
Url: http://nuiton.org/repositories/revision/wikitty/1069
Log:
* simply handle wikittyPubtext as wikittyPubData
Modified:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-07 14:27:10 UTC (rev 1068)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-07 16:15:16 UTC (rev 1069)
@@ -103,6 +103,14 @@
// - write file
// - write property
// - write
+
+ /*
+ * Format des propriétés:
+ *
+ * id.property 18114-1811-181-18=/bob/truc/nuiton/Script
+ *
+ * metadata 18114-1811-181-18.version=1.0 18114-1811-181-18.exention=js
+ */
for (Wikitty wikit : allWikittyOnFS) {
if (!wikit.hasExtension(WikittyLabel.EXT_WIKITTYLABEL)) {
// non usable wikitty
@@ -133,6 +141,19 @@
if (wikit.hasExtension(WikittyPubText.EXT_WIKITTYPUBTEXT)) {
name = WikittyPubTextHelper.getName(wikit);
+ extension = WikittyPubTextHelper.getFileExtension(wikit);
+ String content = WikittyPubTextHelper.getContent(wikit);
+
+
+ // Write original file
+ wikittyFile = new File(
+ tempDirectory.getAbsolutePath()+File.separator+
+ labelPath + name + "." + extension);
+ wikittyFile.createNewFile();
+ FileUtil.writeString(wikittyFile,content );
+
+
+ // write properties
idProperties.put(id, labelPath + name);
metaProperties.put(id + EXTENSION_SUFFIX,
WikittyPubTextHelper.getFileExtension(wikit));
@@ -163,7 +184,6 @@
File jarFile = new File(currentFile + File.separator + DEFAULT_JAR_NAME
+ ".jar");
JarUtil.compressFiles(jarFile, tempDirectory);
- // JarUtil.compressFiles(jarFile, new File("/home/Manou/testWP/wp/") );
// delete tempfile
FileUtil.deleteRecursively(tempDirectory);
@@ -172,30 +192,30 @@
/*
* Algo fonctionnement
*
+ * done:
* Selectionner tout les wikitty sur le file system qui sont dans le dossier
* courant, en servant d'un wikitty publication fileSystem.
*
+ * done:
* On va créer un dossier pour le jar "tempJar" pour chaque wikitty en
* fonction du type: -wikittyPubData: on va l'écrire sous son label le
* fichier dans le dossier tempJar et on va le référencer dans l'index
* central du dossier
*
+ * stay:
* -WikittyPubText: .on va écrire le pub text sous son label le fichier
* correspondant .on va décorer le contenu du wikittyPubText avec les
* éléments script engine etc, on va écrire le .java correspondant .ensuite
* on va compiler le java et écrire le .class correspondant .on écrit les
* metadata et les élément d'index du wikitty pour le retrouver
*
+ *
+ *
+ * done:
* Une fois tout les wikitty traité on va packager le dossier tempJar en jar
* et on va supprimer le dossier tempJar
*/
- /*
- * Format des propriétés:
- *
- * id.property 18114-1811-181-18=/bob/truc/nuiton/Script
- *
- * metadata 18114-1811-181-18.version=1.0 18114-1811-181-18.exention=js
- */
+
}
1
0
r1068 - in trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication: externalize synchro
by mfortun@users.nuiton.org 07 Jul '11
by mfortun@users.nuiton.org 07 Jul '11
07 Jul '11
Author: mfortun
Date: 2011-07-07 16:27:10 +0200 (Thu, 07 Jul 2011)
New Revision: 1068
Url: http://nuiton.org/repositories/revision/wikitty/1068
Log:
* Util Class for wikitty stored as file
* WikittyPubData correctly handled in externalization
Added:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyFileUtil.java
Modified:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.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/externalize/WikittyPublicationExternalize.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-07 12:30:41 UTC (rev 1067)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-07 14:27:10 UTC (rev 1068)
@@ -4,6 +4,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
+import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
@@ -17,8 +18,14 @@
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyServiceFactory;
import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.entities.WikittyLabel;
+import org.nuiton.wikitty.entities.WikittyLabelHelper;
import org.nuiton.wikitty.publication.entities.WikittyPubData;
+import org.nuiton.wikitty.publication.entities.WikittyPubDataHelper;
import org.nuiton.wikitty.publication.entities.WikittyPubText;
+import org.nuiton.wikitty.publication.entities.WikittyPubTextHelper;
+import org.nuiton.wikitty.publication.synchro.PropertiesExtended;
+import org.nuiton.wikitty.publication.synchro.WikittyFileUtil;
import org.nuiton.wikitty.publication.synchro.WikittyPublicationFileSystem;
import org.nuiton.wikitty.search.Criteria;
import org.nuiton.wikitty.search.PagedResult;
@@ -35,13 +42,17 @@
public static String TEMPORARY_FILE_NAME = "tempBeforeJar";
public static String DEFAULT_JAR_NAME = "pub-externalized";
+ public static String VERSION_SUFFIX = ".version";
+ public static String EXTENSION_SUFFIX = ".extension";
+
/*
* Class don't have to be instantiate
*/
private WikittyPublicationExternalize() {
}
- static public void main(String[] args) throws ArgumentsParserException, IOException {
+ static public void main(String[] args) throws ArgumentsParserException,
+ IOException {
ApplicationConfig appconfig = new ApplicationConfig();
appconfig.parse(args);
@@ -60,8 +71,6 @@
String urlFileSystem = "file:///home/Manou/testWP#wp";
// String urlFileSystem = currentFile.getParent() + "#" + Label;
- System.out.println(urlFileSystem);
-
appconfig.setOption(WikittyConfigOption.WIKITTY_SERVER_URL.getKey(),
urlFileSystem);
@@ -77,34 +86,85 @@
File tempDirectory = new File(currentFile + File.separator
+ TEMPORARY_FILE_NAME);
tempDirectory.mkdir();
-
-
-
+
+ File filePropertiesId = new File(tempDirectory + File.separator
+ + WikittyFileUtil.WIKITTY_ID_PROPERTIES_FILE);
+ filePropertiesId.createNewFile();
+ PropertiesExtended idProperties = new PropertiesExtended(
+ filePropertiesId);
+
+ File filePropertiesMeta = new File(tempDirectory + File.separator
+ + WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
+ filePropertiesMeta.createNewFile();
+ PropertiesExtended metaProperties = new PropertiesExtended(
+ filePropertiesMeta);
+
// iterate wikitty
// - write file
// - write property
// - write
for (Wikitty wikit : allWikittyOnFS) {
+ if (!wikit.hasExtension(WikittyLabel.EXT_WIKITTYLABEL)) {
+ // non usable wikitty
+ continue;
+ }
-
-
+ // construct directory with labels
+
+ Set<String> labeles = WikittyLabelHelper.getLabels(wikit);
+ if (labeles.size() == 0) {
+ continue;
+ }
+
+ String label = labeles.toArray()[0].toString();
+
+ WikittyFileUtil.createFilesFromLabelPath(tempDirectory, label);
+
+ // preparation for properties
+ String labelPath = WikittyFileUtil.labelToPath(label);
+ labelPath += File.separator;
+
+ String id = wikit.getId();
+ metaProperties.put(id + VERSION_SUFFIX, wikit.getVersion());
+
+ String extension;
+ File wikittyFile;
+ String name;
+
if (wikit.hasExtension(WikittyPubText.EXT_WIKITTYPUBTEXT)) {
+ name = WikittyPubTextHelper.getName(wikit);
+ idProperties.put(id, labelPath + name);
+ metaProperties.put(id + EXTENSION_SUFFIX,
+ WikittyPubTextHelper.getFileExtension(wikit));
+ }
- } else if (wikit.hasExtension(WikittyPubData.EXT_WIKITTYPUBDATA)) {
+ if (wikit.hasExtension(WikittyPubData.EXT_WIKITTYPUBDATA)) {
+ byte[] content = WikittyPubDataHelper.getContent(wikit);
+ extension = WikittyPubDataHelper.getFileExtension(wikit);
+ name = WikittyPubDataHelper.getName(wikit);
+ // write file on the temporary directory
+ wikittyFile = new File(
+ tempDirectory.getAbsolutePath()+File.separator+
+ labelPath + name + "." + extension);
+ wikittyFile.createNewFile();
+ FileUtil.byteToFile(content, wikittyFile);
+
+ // write properties
+ metaProperties.put(id + EXTENSION_SUFFIX, extension);
+ idProperties.put(id, labelPath + name);
}
}
-
-
-
-
-
-
+
+ metaProperties.store();
+ idProperties.store();
+
// construct jar
- File jarFile = new File(currentFile + File.separator+DEFAULT_JAR_NAME+".jar");
- //JarUtil.compressFiles(jarFile, tempDirectory );
- JarUtil.compressFiles(jarFile, new File("/home/Manou/testWP/wp/") );
-
+ File jarFile = new File(currentFile + File.separator + DEFAULT_JAR_NAME
+ + ".jar");
+ JarUtil.compressFiles(jarFile, tempDirectory);
+ // JarUtil.compressFiles(jarFile, new File("/home/Manou/testWP/wp/") );
+
// delete tempfile
FileUtil.deleteRecursively(tempDirectory);
}
@@ -138,8 +198,4 @@
* metadata 18114-1811-181-18.version=1.0 18114-1811-181-18.exention=js
*/
- public static String getWikittyPubLocalName(Wikitty w) {
- return null;
- }
-
}
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java 2011-07-07 12:30:41 UTC (rev 1067)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java 2011-07-07 14:27:10 UTC (rev 1068)
@@ -1,5 +1,6 @@
package org.nuiton.wikitty.publication.synchro;
+import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -7,6 +8,11 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.StringUtil;
import org.nuiton.wikitty.WikittyException;
import org.nuiton.wikitty.WikittyService;
import org.nuiton.wikitty.WikittyUtil;
@@ -33,6 +39,9 @@
public abstract class AbstractWikittyFileService implements WikittyService{
+
+ final static Log log = LogFactory.getLog(AbstractWikittyFileService.class);
+
public AbstractWikittyFileService() {
super();
}
@@ -420,4 +429,5 @@
}
}
+
}
\ No newline at end of file
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyFileUtil.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyFileUtil.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyFileUtil.java 2011-07-07 14:27:10 UTC (rev 1068)
@@ -0,0 +1,88 @@
+package org.nuiton.wikitty.publication.synchro;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.StringUtil;
+
+public class WikittyFileUtil {
+
+ /**
+ * The file name of the meta property file
+ */
+ static public String WIKITTY_FILE_META_PROPERTIES_FILE = "meta.properties";
+
+ /*
+ * Need a different file for id and meta information about wikittiesFiles
+ * because with this solution we can simply read the ids with props.keySet()
+ */
+ /**
+ * The file Name of the id property file
+ */
+ static public String WIKITTY_ID_PROPERTIES_FILE = "ids.properties";
+
+
+
+ final static Log log = LogFactory.getLog(WikittyFileUtil.class);
+
+ /**
+ * Construct correctly the path from a label
+ *
+ * @param label
+ * the label
+ * @return the correct path
+ */
+ public static 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
+ + ".");
+
+ log.info("Convert label to path: " + label + " path:" + result);
+
+ return result;
+ }
+
+ /**
+ * Creates all the file system require from a label path in the working
+ * directory
+ *
+ * @param label
+ * the path string
+ * @return if all the path was created
+ * @throws IOException
+ */
+ public static boolean createFilesFromLabelPath(File homeFile, String label) throws IOException
+ {
+
+ label = labelToPath(label);
+
+ log.info("Create directory from path:" + label);
+
+ String[] pathElements = StringUtil.split(label, File.separator);
+
+ boolean result = false;
+
+ if (homeFile.exists() && homeFile.isDirectory()) {
+ String path = homeFile.getCanonicalPath();
+ result = true;
+ for (int i = 0; i < pathElements.length; i++) {
+
+ path = path + File.separator + pathElements[i];
+ File temp = new File(path);
+ FileUtil.createDirectoryIfNecessary(temp);
+ result = result && temp.exists();
+ }
+ }
+
+ return result;
+ }
+
+}
Property changes on: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyFileUtil.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-07-07 12:30:41 UTC (rev 1067)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublication.java 2011-07-07 14:27:10 UTC (rev 1068)
@@ -566,7 +566,7 @@
PropertiesExtended metaPropertiesExtended = WikittyPublicationFileSystem
.getWikittyPublicationProperties(
currentDir,
- WikittyPublicationFileSystem.WIKITTY_FILE_META_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
String labelCurrent = metaPropertiesExtended
.getProperty(WikittyPublicationFileSystem.META_CURRENT_LABEL);
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-07-07 12:30:41 UTC (rev 1067)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-07-07 14:27:10 UTC (rev 1068)
@@ -68,7 +68,9 @@
import org.nuiton.wikitty.search.operators.Restriction;
import org.nuiton.wikitty.services.WikittyEvent;
import org.nuiton.wikitty.services.WikittyListener;
+import org.nuiton.wikitty.publication.synchro.WikittyFileUtil;
+
public class WikittyPublicationFileSystem extends AbstractWikittyFileService {
/** to use log facility, just put in your code: log.info(\"...\"); */
@@ -121,21 +123,8 @@
*/
static public String META_PREFIX_KEY_ID = "id.";
- /**
- * The file name of the meta property file
- */
- static public String WIKITTY_FILE_META_PROPERTIES_FILE = "meta.properties";
- /*
- * Need a different file for id and meta information about wikittiesFiles
- * because with this solution we can simply read the ids with props.keySet()
- */
/**
- * The file Name of the id property file
- */
- static public String WIKITTY_ID_PROPERTIES_FILE = "ids.properties";
-
- /**
* The file name of the wikitty service property
*/
static public String WIKITTY_FILE_SERVICE = "ws.properties";
@@ -410,7 +399,7 @@
}
// create the directories from the label
- boolean pathFilecreated = createFilesFromLabelPath(ourDir);
+ boolean pathFilecreated = WikittyFileUtil.createFilesFromLabelPath(homeFile,ourDir);
if (pathFilecreated) {
// create the path with the label
@@ -478,7 +467,7 @@
// write current label
PropertiesExtended metaProperties = getWikittyPublicationProperties(
wikittyParenFile,
- WIKITTY_FILE_META_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
// update
metaProperties
.setProperty(
@@ -565,7 +554,7 @@
try {
// construct the starts file from the label and the working
// directory
- String labelToDir = this.labelToPath(label);
+ String labelToDir = WikittyFileUtil.labelToPath(label);
File starts = new File(homeFile.getAbsolutePath() + File.separator
+ labelToDir);
@@ -620,7 +609,7 @@
// load properties
PropertiesExtended propsProperties = getWikittyPublicationProperties(
new File(path),
- WikittyPublicationFileSystem.WIKITTY_FILE_META_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
// update remove properties
propsProperties.remove(META_PREFIX_KEY_CHECKSUM + fileName);
@@ -633,7 +622,7 @@
// load properties
PropertiesExtended idProperties = getWikittyPublicationProperties(
new File(path),
- WikittyPublicationFileSystem.WIKITTY_ID_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_ID_PROPERTIES_FILE);
// update
idProperties.remove(id);
// resave
@@ -665,7 +654,7 @@
try {
// construct properly with the working directory and the label
// the starts directory
- String labelToDir = this.labelToPath(label);
+ String labelToDir = WikittyFileUtil.labelToPath(label);
File starts = new File(homeFile.getAbsolutePath() + File.separator
+ labelToDir);
if (starts.exists()) {
@@ -739,7 +728,7 @@
try {
// construct properly with the working directory and the label
// the starts directory
- String labelToDir = this.labelToPath(label);
+ String labelToDir = WikittyFileUtil.labelToPath(label);
File starts = new File(homeFile.getAbsolutePath() + File.separator
+ labelToDir);
if (starts.exists()) {
@@ -882,7 +871,7 @@
Properties idProps = new Properties();
File idFile = new File(propsDir.getCanonicalPath() + File.separator
- + WikittyPublicationFileSystem.WIKITTY_ID_PROPERTIES_FILE);
+ + WikittyFileUtil.WIKITTY_ID_PROPERTIES_FILE);
if (idFile.exists()) {
idProps.load(new FileReader(idFile));
}
@@ -988,7 +977,7 @@
// load properties
File wikittyParentDir = new File(path);
PropertiesExtended props = getWikittyPublicationProperties(
- wikittyParentDir, WIKITTY_FILE_META_PROPERTIES_FILE);
+ wikittyParentDir, WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
// set the current label
WikittyLabelHelper.addLabels(result, props
@@ -1052,9 +1041,9 @@
// create/load property file
PropertiesExtended ids = getWikittyPublicationProperties(starts,
- WIKITTY_ID_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_ID_PROPERTIES_FILE);
PropertiesExtended meta = getWikittyPublicationProperties(starts,
- WIKITTY_FILE_META_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
// set label
meta.put(META_CURRENT_LABEL, label);
@@ -1087,7 +1076,7 @@
}
// after adding all new file, check for deleted wikitty
ids = getWikittyPublicationProperties(starts,
- WIKITTY_ID_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_ID_PROPERTIES_FILE);
List<String> filesWikitty = new ArrayList<String>();
filesWikitty.addAll(CollectionUtil.toGenericCollection(ids.values(),
@@ -1100,7 +1089,7 @@
log.info("remove wikitty informations for deleted file");
meta = getWikittyPublicationProperties(starts,
- WIKITTY_FILE_META_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
filesWikitty.removeAll(listChildFileNonDir);
@@ -1144,7 +1133,7 @@
String localMd5 = StringUtil.asHex(byt);
PropertiesExtended meta = getWikittyPublicationProperties(
- child.getParentFile(), WIKITTY_FILE_META_PROPERTIES_FILE);
+ child.getParentFile(),WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
String registeredMD5 = meta.getProperty(META_PREFIX_KEY_CHECKSUM
+ child.getName());
@@ -1193,9 +1182,9 @@
File parent = towrite.getParentFile();
PropertiesExtended id = getWikittyPublicationProperties(parent,
- WIKITTY_ID_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_ID_PROPERTIES_FILE);
PropertiesExtended meta = getWikittyPublicationProperties(parent,
- WIKITTY_FILE_META_PROPERTIES_FILE);
+ WikittyFileUtil.WIKITTY_FILE_META_PROPERTIES_FILE);
id.put(wikitty.getId(), towrite.getName());
@@ -1221,63 +1210,11 @@
}
- /**
- * Creates all the file system require from a label path in the working
- * directory
- *
- * @param label
- * the path string
- * @return if all the path was created
- * @throws Exception
- */
- protected boolean createFilesFromLabelPath(String label) throws Exception {
- label = labelToPath(label);
- log.info("Create directory from path:" + label);
- String[] pathElements = StringUtil.split(label, File.separator);
- boolean result = false;
-
- if (homeFile.exists() && homeFile.isDirectory()) {
- String path = homeFile.getCanonicalPath();
- result = true;
- for (int i = 0; i < pathElements.length; i++) {
-
- path = path + File.separator + pathElements[i];
- File temp = new File(path);
- FileUtil.createDirectoryIfNecessary(temp);
- result = result && temp.exists();
- }
- }
-
- return result;
- }
-
/**
- * Construct correctly the path from a label
- *
- * @param label
- * the label
- * @return the correct path
- */
- 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
- + ".");
-
- log.info("Convert label to path: " + label + " path:" + result);
-
- return result;
- }
-
- /**
* Use to search and return the home property that containt informations
* about wikitty service use to synchronise a wikitty publication file
* system
1
0
r1067 - trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize
by mfortun@users.nuiton.org 07 Jul '11
by mfortun@users.nuiton.org 07 Jul '11
07 Jul '11
Author: mfortun
Date: 2011-07-07 14:30:41 +0200 (Thu, 07 Jul 2011)
New Revision: 1067
Url: http://nuiton.org/repositories/revision/wikitty/1067
Log:
* JarUtil based on zip util but used to handle jar with manifest
Added:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java
Modified:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java 2011-07-07 12:30:41 UTC (rev 1067)
@@ -0,0 +1,584 @@
+package org.nuiton.wikitty.publication.externalize;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.MD5OutputStream;
+import org.nuiton.util.StringUtil;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+/**
+ * Opérations sur des fichiers Jar. Compression et décompression avec ou sans
+ * filtres, scan des fichiers créés ou écrasés lors de la décompression...
+ *
+ * Créée à partir de org.nuiton.util.ZipUtil
+ * <p/>
+ *
+ * @author mfortun
+ */
+public class JarUtil {
+
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(JarUtil.class);
+
+ /** Taille du buffer pour les lectures/écritures. */
+ private static final int BUFFER_SIZE = 8 * 1024;
+
+ /** Le séparateur de fichier en local. */
+ private static final String LOCAL_SEP = File.separator;
+
+ private static final String LOCAL_SEP_PATTERN = "\\".equals(LOCAL_SEP) ? LOCAL_SEP
+ + LOCAL_SEP
+ : LOCAL_SEP;
+
+ /** Le séparateur jar. */
+ private static final String JAR_SEP = "/";
+
+ private static final String ZIP_SEP_PATTERN = "/";
+
+ /** Accept all file pattern. */
+ protected static FileFilter ALL_FILE_FILTER = new FileFilter() {
+ public boolean accept(File pathname) {
+ return true;
+ }
+ };
+
+ /**
+ * Uncompress jarped file in targetDir.
+ *
+ * @param file
+ * the jar source file
+ * @param targetDir
+ * the destination directory
+ * @return return last entry name
+ * @throws IOException
+ * if any problem while uncompressing
+ */
+ public static String uncompress(File file, File targetDir)
+ throws IOException {
+ String result;
+ result = uncompressAndRename(file, targetDir, null, null);
+ return result;
+ }
+
+ /**
+ * Uncompress jarped file in targetDir, and rename uncompressed file if
+ * necessary. If renameFrom or renameTo is null no renaming is done
+ * <p/>
+ * file in jar use / to separate directory and not begin with / each
+ * directory ended with /
+ *
+ * @param file
+ * the jar source file
+ * @param targetDir
+ * the destination directory
+ * @param renameFrom
+ * pattern to permit rename file before uncompress it
+ * @param renameTo
+ * new name for file if renameFrom is applicable to it you can
+ * use $1, $2, ... if you have '(' ')' in renameFrom
+ * @return return last entry name
+ * @throws IOException
+ * if any problem while uncompressing
+ */
+ public static String uncompressAndRename(File file, File targetDir,
+ String renameFrom, String renameTo) throws IOException {
+ String result = "";
+ JarInputStream in = new JarInputStream(new FileInputStream(file));
+ JarEntry entry;
+ while ((entry = in.getNextJarEntry()) != null) {
+ String name = entry.getName();
+ if (renameFrom != null && renameTo != null) {
+ name = name.replaceAll(renameFrom, renameTo);
+ if (log.isDebugEnabled()) {
+ log.debug("rename " + entry.getName() + " -> " + name);
+ }
+ }
+ result = name;
+ File target = new File(targetDir, name);
+ if (entry.isDirectory()) {
+ target.mkdirs();
+ } else {
+ target.getParentFile().mkdirs();
+ OutputStream out = new BufferedOutputStream(
+ new FileOutputStream(target));
+ try {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int len;
+ while ((len = in.read(buffer, 0, BUFFER_SIZE)) != -1) {
+ out.write(buffer, 0, len);
+ }
+ } finally {
+ out.close();
+ }
+ }
+ }
+ in.close();
+ return result;
+ }
+
+ public static void compressFiles(File jarFile, File fileOrDirectory)
+ throws IOException {
+
+ FileFilter filter = ALL_FILE_FILTER;
+
+ List<File> files = new ArrayList<File>();
+ if (fileOrDirectory.isDirectory()) {
+ files = FileUtil.getFilteredElements(fileOrDirectory, filter, true);
+ } else if (filter.accept(fileOrDirectory)) {
+ files.add(fileOrDirectory);
+ }
+
+ compressFiles(jarFile, fileOrDirectory, null, files, false);
+
+ }
+
+ /**
+ * Compress 'includes' files in jarFile. If file in includes is directory
+ * only the directory is put in jarFile, not the file contained in directory
+ *
+ * @param jarFile
+ * the destination jar file
+ * @param root
+ * for all file in includes that is in this directory, then we
+ * remove this directory in jar entry name (aka -C for tar), can
+ * be null;
+ * @param includes
+ * the files to include in jar
+ * @throws IOException
+ * if any problem while compressing
+ */
+ public static void compressFiles(File jarFile, File root,
+ Collection<File> includes) throws IOException {
+ compressFiles(jarFile, root, null, includes, false);
+ }
+
+ /**
+ * Compress 'includes' files in jarFile. If file in includes is directory
+ * only the directory is put in jarFile, not the file contained in directory
+ *
+ * @param jarFile
+ * the destination jar file
+ * @param root
+ * for all file in includes that is in this directory, then we
+ * remove this directory in jar entry name (aka -C for tar), can
+ * be null;
+ * @param includes
+ * the files to include in jar
+ * @param createMD5
+ * also create a MD5 file (jar name + .md5). MD5 file is created
+ * after jar.
+ * @throws IOException
+ * if any problem while compressing
+ */
+ public static void compressFiles(File jarFile, File root, Manifest mf,
+ Collection<File> includes, boolean createMD5) throws IOException {
+
+ if (mf == null) {
+ mf = new Manifest();
+ }
+
+ OutputStream oStream = new FileOutputStream(jarFile);
+
+ // if md5 creation flag
+ if (createMD5) {
+ oStream = new MD5OutputStream(oStream);
+ }
+ try {
+ JarOutputStream jarOStream = new JarOutputStream(oStream, mf);
+
+ for (File file : includes) {
+ String entryName = toJarEntryName(root, file);
+
+ // Création d'une nouvelle entrée dans le jar
+ JarEntry entry = new JarEntry(entryName);
+ entry.setTime(file.lastModified());
+ jarOStream.putNextEntry(entry);
+
+ if (file.isFile() && file.canRead()) {
+ byte[] readBuffer = new byte[BUFFER_SIZE];
+ int bytesIn;
+ BufferedInputStream bis = new BufferedInputStream(
+ new FileInputStream(file), BUFFER_SIZE);
+ try {
+ while ((bytesIn = bis.read(readBuffer, 0, BUFFER_SIZE)) != -1) {
+ jarOStream.write(readBuffer, 0, bytesIn);
+ }
+ } finally {
+ bis.close();
+ }
+ }
+ jarOStream.closeEntry();
+ }
+ jarOStream.close();
+
+ // if md5 creation flag
+ if (createMD5) {
+ String md5hash = StringUtil.asHex(((MD5OutputStream) oStream)
+ .hash());
+ File md5File = new File(jarFile.getAbsoluteFile() + ".md5");
+ FileUtil.writeString(md5File, md5hash);
+ }
+ } finally {
+ oStream.close();
+ }
+ }
+
+ /**
+ * If fileOrDirectory is directory Compress recursively all file in this
+ * directory, else if is just file compress one file.
+ * <p/>
+ * Entry result name in jar start at fileOrDirectory. example: if we
+ * compress /etc/apache, entry will be apache/http.conf, ...
+ *
+ * @param jarFile
+ * the target jar file
+ * @param fileOrDirectory
+ * the file or directory to compress
+ * @throws IOException
+ * if any problem while compressing
+ */
+ public static void compress(File jarFile, File fileOrDirectory)
+ throws IOException {
+ compress(jarFile, fileOrDirectory, null, null, false);
+ }
+
+ public static void compress(File jarFile, File fileOrDirectory, Manifest mf)
+ throws IOException {
+ compress(jarFile, fileOrDirectory, mf, null, false);
+ }
+
+ /**
+ * If fileOrDirectory is directory Compress recursively all file in this
+ * directory, else if is just file compress one file.
+ * <p/>
+ * Entry result name in jar start at fileOrDirectory. example: if we
+ * compress /etc/apache, entry will be apache/http.conf, ...
+ *
+ * @param jarFile
+ * the target jar file
+ * @param fileOrDirectory
+ * the file or directory to compress
+ * @param filter
+ * used to accept file, if null, all file is accepted
+ * @throws IOException
+ * if any problem while compressing
+ */
+ public static void compress(File jarFile, File fileOrDirectory,
+ FileFilter filter) throws IOException {
+ compress(jarFile, fileOrDirectory, null, filter, false);
+ }
+
+ /**
+ * If fileOrDirectory is directory Compress recursively all file in this
+ * directory, else if is just file compress one file.
+ * <p/>
+ * Entry result name in jar start at fileOrDirectory. example: if we
+ * compress /etc/apache, entry will be apache/http.conf, ...
+ *
+ * @param jarFile
+ * the target jar file
+ * @param fileOrDirectory
+ * the file or directory to compress
+ * @param filter
+ * used to accept file, if null, all file is accepted
+ * @param createMD5
+ * also create a MD5 file (jar name + .md5). MD5 file is created
+ * after jar.
+ * @throws IOException
+ * if any problem while compressing
+ */
+ public static void compress(File jarFile, File fileOrDirectory,
+ Manifest mf, FileFilter filter, boolean createMD5)
+ throws IOException {
+
+ if (filter == null) {
+ filter = ALL_FILE_FILTER;
+ }
+ List<File> files = new ArrayList<File>();
+ if (fileOrDirectory.isDirectory()) {
+ files = FileUtil.getFilteredElements(fileOrDirectory, filter, true);
+ } else if (filter.accept(fileOrDirectory)) {
+ files.add(fileOrDirectory);
+ }
+
+ compressFiles(jarFile, fileOrDirectory.getParentFile(), mf, files,
+ createMD5);
+ }
+
+ /**
+ * <li>supprime le root du fichier <li>Converti les '\' en '/' car les jar
+ * entry utilise des '/' <li>ajoute un '/' a la fin pour les repertoires <li>
+ * supprime le premier '/' si la chaine commence par un '/'
+ *
+ * @param root
+ * the root directory
+ * @param file
+ * the file to treate
+ * @return the jar entry name corresponding to the given <code>file</code>
+ * from <code>root</code> dir.
+ */
+ private static String toJarEntryName(File root, File file) {
+ String result = file.getPath();
+
+ if (root != null) {
+ String rootPath = root.getPath();
+ if (result.startsWith(rootPath)) {
+ result = result.substring(rootPath.length());
+ }
+ }
+
+ result = result.replace('\\', '/');
+ if (file.isDirectory()) {
+ result += '/';
+ }
+ while (result.startsWith("/")) {
+ result = result.substring(1);
+ }
+ return result;
+ }
+
+ /**
+ * Scan a jarFile, and fill two lists of relative paths corresponding of jar
+ * entries. First list contains all entries to be added while a uncompress
+ * operation on the destination directory </code>targetDir</code>. Second
+ * list contains all entries to be overwritten while a uncompress operation
+ * on the destination directory <code>targetDir</code>. <br>
+ * If <code>targetDir</code> is <code>null</code> we don't fill
+ * <cide>existingFiles<code/> list.
+ *
+ * @param jarFile
+ * location of the jar to scanJar
+ * @param targetDir
+ * location of destination for a uncompress operation. If
+ * <code>null</code> we don't test to find overwritten files.
+ * @param newFiles
+ * list of files to be added while a uncompress
+ * @param existingFiles
+ * list of files to be overwritten while a uncompress if the
+ * <code>targetDir</code>, (only use if <code>targetDir</code> is
+ * not <code>null</code>)
+ * @param excludeFilter
+ * used to exclude some files
+ * @param renameFrom
+ * {@link #uncompressAndRename(File, File, String, String)}
+ * @param renameTo
+ * {@link #uncompressAndRename(File, File, String, String)}
+ * @throws IOException
+ * if any exception while dealing with jarfile
+ */
+ public static void scan(File jarFile, File targetDir,
+ List<String> newFiles, List<String> existingFiles,
+ FileFilter excludeFilter, String renameFrom, String renameTo)
+ throws IOException {
+ JarFile jar = null;
+ try {
+ jar = new JarFile(jarFile);
+ boolean findExisting = targetDir != null && targetDir.exists();
+ boolean filter = findExisting && excludeFilter != null;
+ boolean rename = renameFrom != null && renameTo != null;
+ Enumeration<? extends JarEntry> entries = jar.entries();
+ while (entries.hasMoreElements()) {
+ String entryName = entries.nextElement().getName();
+ if (rename) {
+ entryName = entryName.replaceAll(renameFrom, renameTo);
+ }
+ String name = convertToLocalEntryName(entryName);
+ if (findExisting || filter) {
+ File file = new File(targetDir, name);
+ if (filter && excludeFilter.accept(file))
+ continue;
+ if (file.exists()) {
+ existingFiles.add(name);
+ continue;
+ }
+ }
+ newFiles.add(name);
+ }
+ } finally {
+ if (jar != null) {
+ jar.close();
+ }
+ }
+ }
+
+ @SuppressWarnings({ "unchecked" })
+ public static List<String>[] scanAndExplodeJar(File source, File root,
+ FileFilter excludeFilter) throws IOException {
+
+ List<String> overwrittenFiles = new ArrayList<String>();
+ List<String> newFiles = new ArrayList<String>();
+
+ // obtain list of relative paths (to add or overwrite)
+ scan(source, root, newFiles, overwrittenFiles, excludeFilter, null,
+ null);
+
+ return new List[] { newFiles, overwrittenFiles };
+ }
+
+ /**
+ * uncompress jarped file in targetDir.
+ * <p/>
+ * If <code>toTreate</code> if not null nor empty, we use it to filter
+ * entries to uncompress : it contains a list of relative local path of
+ * files to uncompress. Otherwise just delegate to
+ * {@link JarUtil#uncompress(File,File)}.
+ *
+ * @param file
+ * location of jar file
+ * @param targetDir
+ * destination directory
+ * @param toTreate
+ * list of relative local path of entries to treate
+ * @param renameFrom
+ * {@link #uncompressAndRename(File, File, String, String)}
+ * @param renameTo
+ * {@link #uncompressAndRename(File, File, String, String)}
+ * @return return last entry name
+ * @throws IOException
+ * if nay exception while operation
+ */
+ public static String uncompress(File file, File targetDir,
+ List<String> toTreate, String renameFrom, String renameTo)
+ throws IOException {
+ if (toTreate == null || toTreate.isEmpty()) {
+ return uncompressAndRename(file, targetDir, renameFrom, renameTo);
+ }
+
+ boolean rename = renameFrom != null && renameTo != null;
+
+ String result = "";
+ JarEntry entry;
+ JarInputStream in = new JarInputStream(new FileInputStream(file));
+
+ try {
+ while ((entry = in.getNextJarEntry()) != null) {
+ String name = entry.getName();
+ if (rename) {
+ result = convertToLocalEntryName(name.replaceAll(
+ renameFrom, renameTo));
+ } else {
+ result = convertToLocalEntryName(name);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("open [" + name + "] : " + result);
+ }
+ if (!toTreate.contains(result)) {
+ continue;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("copy [" + name + "] : " + result);
+ }
+ File target = new File(targetDir, result);
+ if (entry.isDirectory()) {
+ target.mkdirs();
+ } else {
+ target.getParentFile().mkdirs();
+ OutputStream out = new BufferedOutputStream(
+ new FileOutputStream(target));
+ try {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int len;
+ while ((len = in.read(buffer, 0, BUFFER_SIZE)) != -1) {
+ out.write(buffer, 0, len);
+ }
+ } finally {
+ out.close();
+ }
+ }
+ }
+ } finally {
+ in.close();
+ }
+ return result;
+ }
+
+ /**
+ * Unjar compressed archive and keep non excluded patterns.
+ *
+ * @param file
+ * archive file
+ * @param targetDir
+ * destination file
+ * @param excludes
+ * excludes pattern (pattern must match complete entry name
+ * including root folder)
+ * @throws IOException
+ */
+ public static void uncompressFiltred(File file, File targetDir,
+ String... excludes) throws IOException {
+
+ JarFile jarFile = new JarFile(file);
+
+ Enumeration<? extends JarEntry> entries = jarFile.entries();
+
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+
+ String name = entry.getName();
+ // add continue to break loop
+ boolean excludeEntry = false;
+ if (excludes != null) {
+ for (String exclude : excludes) {
+ if (name.matches(exclude)) {
+ excludeEntry = true;
+ }
+ }
+ }
+
+ if (!excludeEntry) {
+ File target = new File(targetDir, name);
+ if (entry.isDirectory()) {
+ target.mkdirs();
+ } else {
+ // get inputstream only here
+ target.getParentFile().mkdirs();
+ InputStream in = jarFile.getInputStream(entry);
+ try {
+ OutputStream out = new BufferedOutputStream(
+ new FileOutputStream(target));
+ try {
+ byte[] buffer = new byte[8 * 1024];
+ int len;
+
+ while ((len = in.read(buffer, 0, 8 * 1024)) != -1) {
+ out.write(buffer, 0, len);
+ }
+ } finally {
+ out.close();
+ }
+ } finally {
+ in.close();
+ }
+ }
+ }
+ }
+ }
+
+ protected static String convertToLocalEntryName(String txt) {
+ String s = txt.replaceAll(ZIP_SEP_PATTERN, LOCAL_SEP_PATTERN);
+ if (s.endsWith(JAR_SEP)) {
+ s = s.substring(0, s.length() - 1);
+ }
+ return s;
+ }
+}
Property changes on: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-07 09:04:00 UTC (rev 1066)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-07 12:30:41 UTC (rev 1067)
@@ -1,12 +1,27 @@
package org.nuiton.wikitty.publication.externalize;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.ZipUtil;
import org.nuiton.wikitty.WikittyConfigOption;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyServiceFactory;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.publication.entities.WikittyPubData;
+import org.nuiton.wikitty.publication.entities.WikittyPubText;
import org.nuiton.wikitty.publication.synchro.WikittyPublicationFileSystem;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.PagedResult;
import org.nuiton.wikitty.search.Search;
/**
@@ -17,57 +32,81 @@
*/
public class WikittyPublicationExternalize {
+ public static String TEMPORARY_FILE_NAME = "tempBeforeJar";
+ public static String DEFAULT_JAR_NAME = "pub-externalized";
+
/*
* Class don't have to be instantiate
*/
private WikittyPublicationExternalize() {
-
}
- static public void main(String[] args) throws ArgumentsParserException {
+ static public void main(String[] args) throws ArgumentsParserException, IOException {
ApplicationConfig appconfig = new ApplicationConfig();
-
-
-
appconfig.parse(args);
+ // Set the correct service use to parse local file
+ appconfig.setOption(
+ WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS.getKey(),
+ WikittyPublicationFileSystem.class.getName());
- appconfig
- .setOption(
- WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS
- .getKey(),
- WikittyPublicationFileSystem.class.getName());
-
+ // construct the url for local repo
File currentFile = new File(".");
- currentFile = new File(currentFile.getAbsolutePath()).getParentFile();
-
+ // currentFile = new
+ // File(currentFile.getAbsolutePath()).getParentFile();
+ currentFile = new File("/home/Manou/testWP");
String Label = currentFile.getName();
- String urlFileSystem = "file:///home/Manou/testWP#wp";
- //currentFile.getParent() + "#" + Label;
+ String urlFileSystem = "file:///home/Manou/testWP#wp";
+ // String urlFileSystem = currentFile.getParent() + "#" + Label;
System.out.println(urlFileSystem);
-
-
appconfig.setOption(WikittyConfigOption.WIKITTY_SERVER_URL.getKey(),
urlFileSystem);
-
-
-
WikittyProxy proxy = new WikittyProxy(
WikittyServiceFactory.buildWikittyService(appconfig));
+ // Found all wikity on the file System
+ Criteria findAllCrit = Search.query().keyword("*").criteria();
+ PagedResult<Wikitty> allWikittyOnFS = proxy
+ .findAllByCriteria(findAllCrit);
+
+ // make tempfile
+ File tempDirectory = new File(currentFile + File.separator
+ + TEMPORARY_FILE_NAME);
+ tempDirectory.mkdir();
+
+
+ // iterate wikitty
+ // - write file
+ // - write property
+ // - write
+ for (Wikitty wikit : allWikittyOnFS) {
+
+
+ if (wikit.hasExtension(WikittyPubText.EXT_WIKITTYPUBTEXT)) {
+
+ } else if (wikit.hasExtension(WikittyPubData.EXT_WIKITTYPUBDATA)) {
+
+ }
+ }
- System.out.println(proxy.findAllByCriteria(Search.query().keyword("*").criteria()).size());
+ // construct jar
+ File jarFile = new File(currentFile + File.separator+DEFAULT_JAR_NAME+".jar");
+ //JarUtil.compressFiles(jarFile, tempDirectory );
+ JarUtil.compressFiles(jarFile, new File("/home/Manou/testWP/wp/") );
+
+ // delete tempfile
+ FileUtil.deleteRecursively(tempDirectory);
}
/*
@@ -90,21 +129,17 @@
* Une fois tout les wikitty traité on va packager le dossier tempJar en jar
* et on va supprimer le dossier tempJar
*/
-
-
-
+
/*
* Format des propriétés:
*
- * id.property
- * 18114-1811-181-18=/bob/truc/nuiton/Script
+ * id.property 18114-1811-181-18=/bob/truc/nuiton/Script
*
- * metadata
- * 18114-1811-181-18.version=1.0
- * 18114-1811-181-18.exention=js
+ * metadata 18114-1811-181-18.version=1.0 18114-1811-181-18.exention=js
*/
+
+ public static String getWikittyPubLocalName(Wikitty w) {
+ return null;
+ }
-
-
-
}
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java 2011-07-07 09:04:00 UTC (rev 1066)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java 2011-07-07 12:30:41 UTC (rev 1067)
@@ -2,10 +2,9 @@
import java.util.Collection;
import java.util.List;
-
-import org.nuiton.wikitty.WikittyService;
import org.nuiton.wikitty.entities.Wikitty;
import org.nuiton.wikitty.entities.WikittyExtension;
+import org.nuiton.wikitty.publication.synchro.AbstractWikittyFileService;
import org.nuiton.wikitty.search.Criteria;
import org.nuiton.wikitty.search.PagedResult;
import org.nuiton.wikitty.search.TreeNodeResult;
@@ -18,8 +17,7 @@
* @author mfortun
*
*/
-public class WikittyServiceJarLoader implements WikittyService {
-
+public class WikittyServiceJarLoader extends AbstractWikittyFileService {
/*
1
0
r1066 - trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro
by mfortun@users.nuiton.org 07 Jul '11
by mfortun@users.nuiton.org 07 Jul '11
07 Jul '11
Author: mfortun
Date: 2011-07-07 11:04:00 +0200 (Thu, 07 Jul 2011)
New Revision: 1066
Url: http://nuiton.org/repositories/revision/wikitty/1066
Log:
* new abstraction needed because some method will be shared by externalize and synchronisation like check constraints on wikitty
Added:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java
Modified:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java
Added: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java (rev 0)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java 2011-07-07 09:04:00 UTC (rev 1066)
@@ -0,0 +1,423 @@
+package org.nuiton.wikitty.publication.synchro;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.nuiton.wikitty.WikittyException;
+import org.nuiton.wikitty.WikittyService;
+import org.nuiton.wikitty.WikittyUtil;
+import org.nuiton.wikitty.entities.FieldType;
+import org.nuiton.wikitty.entities.FieldType.TYPE;
+import org.nuiton.wikitty.entities.Wikitty;
+import org.nuiton.wikitty.search.Criteria;
+import org.nuiton.wikitty.search.PagedResult;
+import org.nuiton.wikitty.search.operators.And;
+import org.nuiton.wikitty.search.operators.AssociatedRestriction;
+import org.nuiton.wikitty.search.operators.Between;
+import org.nuiton.wikitty.search.operators.BinaryOperator;
+import org.nuiton.wikitty.search.operators.Contains;
+import org.nuiton.wikitty.search.operators.Element;
+import org.nuiton.wikitty.search.operators.False;
+import org.nuiton.wikitty.search.operators.In;
+import org.nuiton.wikitty.search.operators.Keyword;
+import org.nuiton.wikitty.search.operators.Not;
+import org.nuiton.wikitty.search.operators.Null;
+import org.nuiton.wikitty.search.operators.Or;
+import org.nuiton.wikitty.search.operators.Restriction;
+import org.nuiton.wikitty.search.operators.RestrictionName;
+import org.nuiton.wikitty.search.operators.True;
+
+public abstract class AbstractWikittyFileService implements WikittyService{
+
+ public AbstractWikittyFileService() {
+ super();
+ }
+
+ /**
+ * Write by jcouteau, used to check if a wikitty check a restriction
+ *
+ * @see org.nuiton.wikitty.storage.WikittySearchEngineInMemory#checkRestriction
+ *
+ * @param restriction
+ * the restriction
+ * @param w
+ * the wikitty to check
+ * @return if the wikitty check the restriction
+ */
+ public boolean checkRestriction(Restriction restriction, Wikitty w) {
+
+
+ if (restriction instanceof BinaryOperator) {
+ BinaryOperator binOp = (BinaryOperator) restriction;
+
+ String fqfieldName = binOp.getElement().getName();
+
+ // Checks on extensions
+ if (Element.ELT_EXTENSION.equals(fqfieldName)) {
+ boolean checked = false;
+
+ switch (restriction.getName()) {
+ case NOT_EQUALS:
+ checked = !w.getExtensionNames().contains(binOp.getValue());
+ break;
+ case EQUALS:
+ checked = w.getExtensionNames().contains(binOp.getValue());
+ break;
+ }
+
+ return checked;
+
+ // Checks on id
+ } else if (Element.ELT_ID.equals(fqfieldName)) {
+
+ boolean checked = false;
+
+ switch (restriction.getName()) {
+ case NOT_EQUALS:
+ checked = !w.getId().equals(binOp.getValue());
+ break;
+ case EQUALS:
+ checked = w.getId().equals(binOp.getValue());
+ break;
+ }
+
+ return checked;
+ }
+
+ // si les wikitty n'ont meme pas l'extension concerné
+ // Le check restriction, ne doit pas tester les champs
+ // si les wikitty n'ont meme pas l'extension concerné
+ String[] extName = fqfieldName.split("\\.");
+ if (!w.hasField(extName[0], extName[1])) {
+
+ // return true in case of not equals
+ if (RestrictionName.NOT_EQUALS == restriction.getName()) {
+ return true;
+ }
+
+ return false;
+ }
+ // recupere la valeur dans le wikitty
+ Object o = w.getFqField(fqfieldName);
+
+ // recupere le type de la valeur
+ FieldType t = w.getFieldType(fqfieldName);
+ // convertie la valeur a verifier dans le meme type que la valeur
+ // du wikitty
+ Object value = binOp.getValue();
+ if (!(value instanceof Collection) && t.isCollection()) {
+ // on doit encapsuler dans une collection, car la creation
+ // de la requete ajoute autant de v == o && ... que de valeurs
+ // dans la collection (champs multi-value solr). Mais
+ // dans le inmemory on doit retrouve des collections et non pas
+ // des objets seuls :(
+ value = Collections.singleton(value);
+ }
+ value = t.getValidValue(value);
+
+ boolean checked = false;
+
+ 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}");
+
+ Pattern p = Pattern.compile(pattern);
+ Matcher m = p.matcher((String) o);
+ checked = m.matches();
+ } else {
+ checked = value.equals(o);
+ }
+ break;
+ case LESS:
+ checked = ((Comparable) o).compareTo(value) < 0;
+ break;
+ case LESS_OR_EQUAL:
+ checked = ((Comparable) o).compareTo(value) <= 0;
+ break;
+ case GREATER:
+ checked = ((Comparable) o).compareTo(value) > 0;
+ break;
+ case GREATER_OR_EQUAL:
+ checked = ((Comparable) o).compareTo(value) >= 0;
+ break;
+ case NOT_EQUALS:
+ checked = !value.equals(o);
+ break;
+ case ENDS_WITH:
+ if (t.getType() != TYPE.STRING) {
+ throw new WikittyException(
+ "Can't search for contents that 'ends with' on attribute type different of String. "
+ + "Attribute "
+ + fqfieldName
+ + " is "
+ + t.getType().name());
+ }
+ checked = ((String) o).endsWith((String) value);
+ break;
+ case STARTS_WITH:
+ if (t.getType() != TYPE.STRING) {
+ throw new WikittyException(
+ "Can't search for contents that 'starts with' on attribute type different of String. "
+ + "Attribute "
+ + fqfieldName
+ + " is "
+ + t.getType().name());
+ }
+
+ // FIXME mfortun-2011-04-20 rustine pour champs multivalué de
+ // type string
+ // et restriction startwith dessus. ça marche mais faudrait
+ // quelque chose de plus
+ // propre, et surtout généraliser pour toutes les restrictions
+
+ if (o instanceof Collection<?>
+ && value instanceof Collection<?>) {
+
+ for (Object val : (Collection) value) {
+
+ String valu = (String) val;
+
+ for (Object oo : (Collection) o) {
+ String cotainedO = (String) oo;
+ if (cotainedO != null) {
+ checked = checked || cotainedO.startsWith(valu);
+ }
+ }
+
+ }
+
+ } else {
+
+ checked = ((String) o).startsWith((String) value);
+ }
+ break;
+ }
+ return checked;
+ } else if (restriction instanceof Null) {
+ Null nullRes = (Null) restriction;
+
+ String fqfieldName = nullRes.getFieldName();
+
+ // check my wikitty got the right extension before doing anything.
+ String[] extName = fqfieldName.split("\\.");
+ if (!w.hasField(extName[0], extName[1])) {
+ return false;
+ }
+ // get the value in the wikitty
+ Object o = w.getFqField(fqfieldName);
+
+ // No null on extensions, always return false
+ if (fqfieldName.equals(Element.ELT_EXTENSION)) {
+ return false;
+ }
+
+ // No null on ids, always return false
+ if (fqfieldName.equals(Element.ELT_ID)) {
+ return false;
+ }
+
+ boolean checked = false;
+
+ switch (nullRes.getName()) {
+ case IS_NULL:
+ checked = (o == null);
+ break;
+ case IS_NOT_NULL:
+ checked = (o != null);
+ break;
+ }
+
+ return checked;
+
+ } else if (restriction instanceof In) {
+ In in = (In) restriction;
+ String fqfieldName = in.getElement().getName();
+ String testedValue = String.valueOf(w.getFqField(fqfieldName));
+ for (String value : in.getValue()) {
+ if (testedValue.equals(value)) {
+ return true;
+ }
+ }
+
+ return false;
+
+ } else if (restriction instanceof True) {
+ return true;
+ } else if (restriction instanceof False) {
+ return false;
+ } else if (restriction instanceof Contains) {
+ Contains contains = (Contains) restriction;
+
+ String fqfieldName = contains.getElement().getName();
+ List<String> values = contains.getValue();
+
+ String extension = WikittyUtil
+ .getExtensionNameFromFQFieldName(fqfieldName);
+ String fieldName = WikittyUtil
+ .getFieldNameFromFQFieldName(fqfieldName);
+
+ if (!w.hasField(extension, fieldName)) {
+ return false;
+ }
+
+ // Get field as string and then split it to take into account not
+ // multivalued fields.
+ String testedValuesAsString = w.getFieldAsString(extension,
+ fieldName);
+
+ if ('[' == testedValuesAsString.charAt(0)) {
+ testedValuesAsString = testedValuesAsString.substring(1,
+ testedValuesAsString.length());
+ }
+
+ List<String> testedValues = Arrays.asList(testedValuesAsString
+ .split(","));
+
+ for (Object value : values) {
+ if (!testedValues.contains(String.valueOf(value))) {
+ return false;
+ }
+ }
+
+ return true;
+
+ } else if (restriction instanceof And) {
+ And and = (And) restriction;
+ for (Restriction sub : and.getRestrictions()) {
+ if (!checkRestriction(sub, w)) {
+ return false;
+ }
+ }
+ return true;
+ } else if (restriction instanceof Or) {
+ Or or = (Or) restriction;
+ for (Restriction sub : or.getRestrictions()) {
+ if (checkRestriction(sub, w)) {
+ return true;
+ }
+ }
+ return false;
+ } else if (restriction instanceof Keyword) {
+ Keyword keyword = (Keyword) restriction;
+
+ String value = keyword.getValue();
+
+ //TODO mfortun-2011-07-06 hack to ensure that * is intepreted as
+ // the real meaning aka any
+ if (value.equals("*")){
+ return true;
+ }
+
+ for (String fieldName : w.getAllFieldNames()) {
+ String testedValue = String.valueOf(w.getFqField(fieldName));
+ if (testedValue.contains(value)) {
+ return true;
+ }
+ }
+ return false;
+ } else if (restriction instanceof Not) {
+ Not or = (Not) restriction;
+ Restriction sub = or.getRestriction();
+ return !checkRestriction(sub, w);
+ } else if (restriction instanceof AssociatedRestriction) {
+
+ AssociatedRestriction ass = (AssociatedRestriction) restriction;
+
+ String fqfieldName = ass.getElement().getName();
+
+ // check my wikitty got the right extension before doing anything.
+ String[] extName = fqfieldName.split("\\.");
+ if (!w.hasField(extName[0], extName[1])) {
+ return false;
+ }
+ // get the value in the wikitty, it is a wikitty's id
+ Object o = w.getFqField(fqfieldName);
+
+ // Get sub-restriction
+ Restriction sub = ass.getRestriction();
+
+ Criteria associatedSearch = new Criteria();
+ associatedSearch.setRestriction(sub);
+
+ // find everything that validate the sub-restriction
+
+ List<Criteria> dummyList = new ArrayList<Criteria>();
+ dummyList.add(associatedSearch);
+ // same as proxy for "fix" unique param to list param
+ PagedResult<String> associatedResult = findAllByCriteria("",
+ dummyList).get(0);
+
+ List<String> associatedList = associatedResult.getAll();
+
+ // Check that my field is contained in the sub-restriction results.
+ return associatedList.contains(String.valueOf(o));
+ } else if (restriction instanceof Between) {
+
+ Between op = (Between) restriction;
+
+ Object max = op.getMax();
+ Object min = op.getMin();
+
+ // No between on extensions, always return false
+ if (op.getElement().getName().equals(Element.ELT_EXTENSION)) {
+ return false;
+ }
+
+ // No between on ids, always return false
+ if (op.getElement().getName().equals(Element.ELT_ID)) {
+ return false;
+ }
+
+ String fqfieldName = op.getElement().getName();
+
+ // si les wikitty n'ont meme pas l'extension concerné
+ // Le check restriction, ne doit pas tester les champs
+ // si les wikitty n'ont meme pas l'extension concerné
+ String[] extName = fqfieldName.split("\\.");
+ if (!w.hasField(extName[0], extName[1])) {
+ return false;
+ }
+
+ // recupere la valeur dans le wikitty
+ Object o = w.getFqField(fqfieldName);
+
+ // recupere le type de la valeur
+ FieldType t = w.getFieldType(fqfieldName);
+
+ if (!(min instanceof Collection) && t.isCollection()) {
+ // on doit encapsuler dans une collection, car la creation
+ // de la requete ajoute autant de v == o && ... que de valeurs
+ // dans la collection (champs multi-value solr). Mais
+ // dans le inmemory on doit retrouve des collections et non pas
+ // des objets seuls :(
+ min = Collections.singleton(min);
+ }
+ min = t.getValidValue(min);
+
+ if (!(max instanceof Collection) && t.isCollection()) {
+ // on doit encapsuler dans une collection, car la creation
+ // de la requete ajoute autant de v == o && ... que de valeurs
+ // dans la collection (champs multi-value solr). Mais
+ // dans le inmemory on doit retrouve des collections et non pas
+ // des objets seuls :(
+ max = Collections.singleton(max);
+ }
+ max = t.getValidValue(max);
+
+ return ((Comparable) o).compareTo(min) >= 0
+ && ((Comparable) o).compareTo(max) <= 0;
+ } else {
+ throw new UnsupportedOperationException(restriction.getName()
+ + " Search Not yet implemented");
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/AbstractWikittyFileService.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-07-06 15:28:09 UTC (rev 1065)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-07-07 09:04:00 UTC (rev 1066)
@@ -32,9 +32,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -42,8 +40,6 @@
import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.commons.collections.BidiMap;
import org.apache.commons.collections.bidimap.DualHashBidiMap;
import org.apache.commons.logging.Log;
@@ -54,16 +50,12 @@
import org.nuiton.util.MD5InputStream;
import org.nuiton.util.StringUtil;
import org.nuiton.wikitty.WikittyConfigOption;
-import org.nuiton.wikitty.WikittyException;
-import org.nuiton.wikitty.WikittyService;
import org.nuiton.wikitty.WikittyUtil;
-import org.nuiton.wikitty.entities.FieldType;
import org.nuiton.wikitty.entities.Wikitty;
import org.nuiton.wikitty.entities.WikittyExtension;
import org.nuiton.wikitty.entities.WikittyImpl;
import org.nuiton.wikitty.entities.WikittyLabelHelper;
import org.nuiton.wikitty.entities.WikittyLabelImpl;
-import org.nuiton.wikitty.entities.FieldType.TYPE;
import org.nuiton.wikitty.publication.entities.WikittyPubData;
import org.nuiton.wikitty.publication.entities.WikittyPubDataHelper;
import org.nuiton.wikitty.publication.entities.WikittyPubDataImpl;
@@ -73,28 +65,14 @@
import org.nuiton.wikitty.search.Criteria;
import org.nuiton.wikitty.search.PagedResult;
import org.nuiton.wikitty.search.TreeNodeResult;
-import org.nuiton.wikitty.search.operators.And;
-import org.nuiton.wikitty.search.operators.AssociatedRestriction;
-import org.nuiton.wikitty.search.operators.Between;
-import org.nuiton.wikitty.search.operators.BinaryOperator;
-import org.nuiton.wikitty.search.operators.Contains;
-import org.nuiton.wikitty.search.operators.Element;
-import org.nuiton.wikitty.search.operators.False;
-import org.nuiton.wikitty.search.operators.In;
-import org.nuiton.wikitty.search.operators.Keyword;
-import org.nuiton.wikitty.search.operators.Not;
-import org.nuiton.wikitty.search.operators.Null;
-import org.nuiton.wikitty.search.operators.Or;
import org.nuiton.wikitty.search.operators.Restriction;
-import org.nuiton.wikitty.search.operators.RestrictionName;
-import org.nuiton.wikitty.search.operators.True;
import org.nuiton.wikitty.services.WikittyEvent;
import org.nuiton.wikitty.services.WikittyListener;
-public class WikittyPublicationFileSystem implements WikittyService {
+public class WikittyPublicationFileSystem extends AbstractWikittyFileService {
/** to use log facility, just put in your code: log.info(\"...\"); */
- final static private Log log = LogFactory
+ final static Log log = LogFactory
.getLog(WikittyPublicationFileSystem.class);
static public String WIKITTYLABEL_SEPARATOR = ".";
@@ -679,389 +657,6 @@
return result;
}
- /**
- * Write by jcouteau, used to check if a wikitty check a restriction
- *
- * @see org.nuiton.wikitty.storage.WikittySearchEngineInMemory#checkRestriction
- *
- * @param restriction
- * the restriction
- * @param w
- * the wikitty to check
- * @return if the wikitty check the restriction
- */
- public boolean checkRestriction(Restriction restriction, Wikitty w) {
- log.debug("Check restriction for : "+ w + " restriction: " + restriction);
-
- if (restriction instanceof BinaryOperator) {
- BinaryOperator binOp = (BinaryOperator) restriction;
-
- String fqfieldName = binOp.getElement().getName();
-
- // Checks on extensions
- if (Element.ELT_EXTENSION.equals(fqfieldName)) {
- boolean checked = false;
-
- switch (restriction.getName()) {
- case NOT_EQUALS:
- checked = !w.getExtensionNames().contains(binOp.getValue());
- break;
- case EQUALS:
- checked = w.getExtensionNames().contains(binOp.getValue());
- break;
- }
-
- return checked;
-
- // Checks on id
- } else if (Element.ELT_ID.equals(fqfieldName)) {
-
- boolean checked = false;
-
- switch (restriction.getName()) {
- case NOT_EQUALS:
- checked = !w.getId().equals(binOp.getValue());
- break;
- case EQUALS:
- checked = w.getId().equals(binOp.getValue());
- break;
- }
-
- return checked;
- }
-
- // si les wikitty n'ont meme pas l'extension concerné
- // Le check restriction, ne doit pas tester les champs
- // si les wikitty n'ont meme pas l'extension concerné
- String[] extName = fqfieldName.split("\\.");
- if (!w.hasField(extName[0], extName[1])) {
-
- // return true in case of not equals
- if (RestrictionName.NOT_EQUALS == restriction.getName()) {
- return true;
- }
-
- return false;
- }
- // recupere la valeur dans le wikitty
- Object o = w.getFqField(fqfieldName);
-
- // recupere le type de la valeur
- FieldType t = w.getFieldType(fqfieldName);
- // convertie la valeur a verifier dans le meme type que la valeur
- // du wikitty
- Object value = binOp.getValue();
- if (!(value instanceof Collection) && t.isCollection()) {
- // on doit encapsuler dans une collection, car la creation
- // de la requete ajoute autant de v == o && ... que de valeurs
- // dans la collection (champs multi-value solr). Mais
- // dans le inmemory on doit retrouve des collections et non pas
- // des objets seuls :(
- value = Collections.singleton(value);
- }
- value = t.getValidValue(value);
-
- boolean checked = false;
-
- 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}");
-
- Pattern p = Pattern.compile(pattern);
- Matcher m = p.matcher((String) o);
- checked = m.matches();
- } else {
- checked = value.equals(o);
- }
- break;
- case LESS:
- checked = ((Comparable) o).compareTo(value) < 0;
- break;
- case LESS_OR_EQUAL:
- checked = ((Comparable) o).compareTo(value) <= 0;
- break;
- case GREATER:
- checked = ((Comparable) o).compareTo(value) > 0;
- break;
- case GREATER_OR_EQUAL:
- checked = ((Comparable) o).compareTo(value) >= 0;
- break;
- case NOT_EQUALS:
- checked = !value.equals(o);
- break;
- case ENDS_WITH:
- if (t.getType() != TYPE.STRING) {
- throw new WikittyException(
- "Can't search for contents that 'ends with' on attribute type different of String. "
- + "Attribute "
- + fqfieldName
- + " is "
- + t.getType().name());
- }
- checked = ((String) o).endsWith((String) value);
- break;
- case STARTS_WITH:
- if (t.getType() != TYPE.STRING) {
- throw new WikittyException(
- "Can't search for contents that 'starts with' on attribute type different of String. "
- + "Attribute "
- + fqfieldName
- + " is "
- + t.getType().name());
- }
-
- // FIXME mfortun-2011-04-20 rustine pour champs multivalué de
- // type string
- // et restriction startwith dessus. ça marche mais faudrait
- // quelque chose de plus
- // propre, et surtout généraliser pour toutes les restrictions
-
- if (o instanceof Collection<?>
- && value instanceof Collection<?>) {
-
- for (Object val : (Collection) value) {
-
- String valu = (String) val;
-
- for (Object oo : (Collection) o) {
- String cotainedO = (String) oo;
- if (cotainedO != null) {
- checked = checked || cotainedO.startsWith(valu);
- }
- }
-
- }
-
- } else {
-
- checked = ((String) o).startsWith((String) value);
- }
- break;
- }
- return checked;
- } else if (restriction instanceof Null) {
- Null nullRes = (Null) restriction;
-
- String fqfieldName = nullRes.getFieldName();
-
- // check my wikitty got the right extension before doing anything.
- String[] extName = fqfieldName.split("\\.");
- if (!w.hasField(extName[0], extName[1])) {
- return false;
- }
- // get the value in the wikitty
- Object o = w.getFqField(fqfieldName);
-
- // No null on extensions, always return false
- if (fqfieldName.equals(Element.ELT_EXTENSION)) {
- return false;
- }
-
- // No null on ids, always return false
- if (fqfieldName.equals(Element.ELT_ID)) {
- return false;
- }
-
- boolean checked = false;
-
- switch (nullRes.getName()) {
- case IS_NULL:
- checked = (o == null);
- break;
- case IS_NOT_NULL:
- checked = (o != null);
- break;
- }
-
- return checked;
-
- } else if (restriction instanceof In) {
- In in = (In) restriction;
- String fqfieldName = in.getElement().getName();
- String testedValue = String.valueOf(w.getFqField(fqfieldName));
- for (String value : in.getValue()) {
- if (testedValue.equals(value)) {
- return true;
- }
- }
-
- return false;
-
- } else if (restriction instanceof True) {
- return true;
- } else if (restriction instanceof False) {
- return false;
- } else if (restriction instanceof Contains) {
- Contains contains = (Contains) restriction;
-
- String fqfieldName = contains.getElement().getName();
- List<String> values = contains.getValue();
-
- String extension = WikittyUtil
- .getExtensionNameFromFQFieldName(fqfieldName);
- String fieldName = WikittyUtil
- .getFieldNameFromFQFieldName(fqfieldName);
-
- if (!w.hasField(extension, fieldName)) {
- return false;
- }
-
- // Get field as string and then split it to take into account not
- // multivalued fields.
- String testedValuesAsString = w.getFieldAsString(extension,
- fieldName);
-
- if ('[' == testedValuesAsString.charAt(0)) {
- testedValuesAsString = testedValuesAsString.substring(1,
- testedValuesAsString.length());
- }
-
- List<String> testedValues = Arrays.asList(testedValuesAsString
- .split(","));
-
- for (Object value : values) {
- if (!testedValues.contains(String.valueOf(value))) {
- return false;
- }
- }
-
- return true;
-
- } else if (restriction instanceof And) {
- And and = (And) restriction;
- for (Restriction sub : and.getRestrictions()) {
- if (!checkRestriction(sub, w)) {
- return false;
- }
- }
- return true;
- } else if (restriction instanceof Or) {
- Or or = (Or) restriction;
- for (Restriction sub : or.getRestrictions()) {
- if (checkRestriction(sub, w)) {
- return true;
- }
- }
- return false;
- } else if (restriction instanceof Keyword) {
- Keyword keyword = (Keyword) restriction;
-
- String value = keyword.getValue();
-
- //TODO mfortun-2011-07-06 hack to ensure that * is intepreted as
- // the real meaning aka any
- if (value.equals("*")){
- return true;
- }
-
- for (String fieldName : w.getAllFieldNames()) {
- String testedValue = String.valueOf(w.getFqField(fieldName));
- if (testedValue.contains(value)) {
- return true;
- }
- }
- return false;
- } else if (restriction instanceof Not) {
- Not or = (Not) restriction;
- Restriction sub = or.getRestriction();
- return !checkRestriction(sub, w);
- } else if (restriction instanceof AssociatedRestriction) {
-
- AssociatedRestriction ass = (AssociatedRestriction) restriction;
-
- String fqfieldName = ass.getElement().getName();
-
- // check my wikitty got the right extension before doing anything.
- String[] extName = fqfieldName.split("\\.");
- if (!w.hasField(extName[0], extName[1])) {
- return false;
- }
- // get the value in the wikitty, it is a wikitty's id
- Object o = w.getFqField(fqfieldName);
-
- // Get sub-restriction
- Restriction sub = ass.getRestriction();
-
- Criteria associatedSearch = new Criteria();
- associatedSearch.setRestriction(sub);
-
- // find everything that validate the sub-restriction
-
- List<Criteria> dummyList = new ArrayList<Criteria>();
- dummyList.add(associatedSearch);
- // same as proxy for "fix" unique param to list param
- PagedResult<String> associatedResult = findAllByCriteria("",
- dummyList).get(0);
-
- List<String> associatedList = associatedResult.getAll();
-
- // Check that my field is contained in the sub-restriction results.
- return associatedList.contains(String.valueOf(o));
- } else if (restriction instanceof Between) {
-
- Between op = (Between) restriction;
-
- Object max = op.getMax();
- Object min = op.getMin();
-
- // No between on extensions, always return false
- if (op.getElement().getName().equals(Element.ELT_EXTENSION)) {
- return false;
- }
-
- // No between on ids, always return false
- if (op.getElement().getName().equals(Element.ELT_ID)) {
- return false;
- }
-
- String fqfieldName = op.getElement().getName();
-
- // si les wikitty n'ont meme pas l'extension concerné
- // Le check restriction, ne doit pas tester les champs
- // si les wikitty n'ont meme pas l'extension concerné
- String[] extName = fqfieldName.split("\\.");
- if (!w.hasField(extName[0], extName[1])) {
- return false;
- }
-
- // recupere la valeur dans le wikitty
- Object o = w.getFqField(fqfieldName);
-
- // recupere le type de la valeur
- FieldType t = w.getFieldType(fqfieldName);
-
- if (!(min instanceof Collection) && t.isCollection()) {
- // on doit encapsuler dans une collection, car la creation
- // de la requete ajoute autant de v == o && ... que de valeurs
- // dans la collection (champs multi-value solr). Mais
- // dans le inmemory on doit retrouve des collections et non pas
- // des objets seuls :(
- min = Collections.singleton(min);
- }
- min = t.getValidValue(min);
-
- if (!(max instanceof Collection) && t.isCollection()) {
- // on doit encapsuler dans une collection, car la creation
- // de la requete ajoute autant de v == o && ... que de valeurs
- // dans la collection (champs multi-value solr). Mais
- // dans le inmemory on doit retrouve des collections et non pas
- // des objets seuls :(
- max = Collections.singleton(max);
- }
- max = t.getValidValue(max);
-
- return ((Comparable) o).compareTo(min) >= 0
- && ((Comparable) o).compareTo(max) <= 0;
- } else {
- throw new UnsupportedOperationException(restriction.getName()
- + " Search Not yet implemented");
- }
- }
-
@Override
public List<PagedResult<String>> findAllByCriteria(String securityToken,
List<Criteria> criteria) {
1
0
r1065 - in trunk: wikitty-api/src/test/java/org/nuiton/wikitty/entities wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by echatellier@users.nuiton.org 06 Jul '11
by echatellier@users.nuiton.org 06 Jul '11
06 Jul '11
Author: echatellier
Date: 2011-07-06 17:28:09 +0200 (Wed, 06 Jul 2011)
New Revision: 1065
Url: http://nuiton.org/repositories/revision/wikitty/1065
Log:
Fix tests (readd wikitty purifier)
Modified:
trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java
Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java
===================================================================
--- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java 2011-07-06 14:38:05 UTC (rev 1064)
+++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java 2011-07-06 15:28:09 UTC (rev 1065)
@@ -25,8 +25,6 @@
package org.nuiton.wikitty.entities;
-import junit.framework.Assert;
-
import org.junit.Ignore;
import org.junit.Test;
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java 2011-07-06 14:38:05 UTC (rev 1064)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyMetaTransformer.java 2011-07-06 15:28:09 UTC (rev 1065)
@@ -67,7 +67,7 @@
//FIXME tchemit 2010-11-28 : still does not work with superclass inheritance, will not generate operation in Abstract classes
-// setTransformerTypes(WikittyPurifierTransformer.class);
+ setTransformerTypes(WikittyPurifierTransformer.class);
setTemplateTypes(
WikittyContractGenerator.class,
WikittyAbstractGenerator.class,
1
0
r1064 - in trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication: externalize synchro
by mfortun@users.nuiton.org 06 Jul '11
by mfortun@users.nuiton.org 06 Jul '11
06 Jul '11
Author: mfortun
Date: 2011-07-06 16:38:05 +0200 (Wed, 06 Jul 2011)
New Revision: 1064
Url: http://nuiton.org/repositories/revision/wikitty/1064
Log:
* correct bug inside publication sync
Modified:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.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/externalize/WikittyPublicationExternalize.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-06 14:15:34 UTC (rev 1063)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-07-06 14:38:05 UTC (rev 1064)
@@ -1,13 +1,12 @@
package org.nuiton.wikitty.publication.externalize;
import java.io.File;
-
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
-import org.nuiton.util.FileUtil;
import org.nuiton.wikitty.WikittyConfigOption;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.WikittyServiceFactory;
+import org.nuiton.wikitty.publication.synchro.WikittyPublicationFileSystem;
import org.nuiton.wikitty.search.Search;
/**
@@ -29,13 +28,15 @@
ApplicationConfig appconfig = new ApplicationConfig();
+
+
appconfig.parse(args);
appconfig
.setOption(
WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS
.getKey(),
- "org.nuiton.wikitty.publication.synchro.WikittyPublicationFileSystem");
+ WikittyPublicationFileSystem.class.getName());
File currentFile = new File(".");
currentFile = new File(currentFile.getAbsolutePath()).getParentFile();
@@ -59,9 +60,8 @@
WikittyServiceFactory.buildWikittyService(appconfig));
+
-
-
System.out.println(proxy.findAllByCriteria(Search.query().keyword("*").criteria()).size());
@@ -90,5 +90,21 @@
* Une fois tout les wikitty traité on va packager le dossier tempJar en jar
* et on va supprimer le dossier tempJar
*/
+
+
+
+ /*
+ * Format des propriétés:
+ *
+ * id.property
+ * 18114-1811-181-18=/bob/truc/nuiton/Script
+ *
+ * metadata
+ * 18114-1811-181-18.version=1.0
+ * 18114-1811-181-18.exention=js
+ */
+
+
+
}
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-07-06 14:15:34 UTC (rev 1063)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublication.java 2011-07-06 14:38:05 UTC (rev 1064)
@@ -450,7 +450,7 @@
result.setOption(
WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS
.getKey(),
- "org.nuiton.wikitty.publication.synchro.WikittyPublicationFileSystem");
+ WikittyPublicationFileSystem.class.getName());
} else if (uri.getScheme().equals("cajo")) {
result.setOption(
WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS
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-07-06 14:15:34 UTC (rev 1063)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-07-06 14:38:05 UTC (rev 1064)
@@ -237,17 +237,22 @@
// the service use to update or commit
String uriService = app
.getOption(WikittyPublication.WIKITTY_SERVICE_INTERLOCUTEUR);
+ if (uriService !=null) {
log.debug("Writing home property service on:"
+ propertyWikittyService.getOrigin() + " uri" + uriService);
propertyWikittyService.setProperty(
WikittyPublication.WIKITTY_SERVICE_INTERLOCUTEUR, uriService);
-
+ }
+
propertyWikittyService.store();
+ recursion = true;
+ if (app.getOptions().containsKey(WikittyPublication.IS_RECURSION_OPTION)) {
+
this.recursion = app
.getOptionAsBoolean(WikittyPublication.IS_RECURSION_OPTION);
-
+ }
// TODO mfotun-2011-04-28 add a support for filtered file with a
// property file
this.directoryNameBlackList = new ArrayList<String>();
@@ -576,6 +581,7 @@
* restore file as wikitty
*/
public List<Wikitty> restore(String securityToken, List<String> id) {
+
List<Wikitty> result = new ArrayList<Wikitty>();
log.info("restore wikitty, number: " + id.size());
try {
@@ -591,9 +597,9 @@
// register wikitty in the result
for (String wikid : id) {
Object value = locations.get(wikid);
+
if (value != null) {
-
FileSystemWIkittyId localisation = (FileSystemWIkittyId) value;
result.add(this.restore(wikid, localisation));
@@ -604,6 +610,7 @@
e.printStackTrace();
// TODO mfortun-2011-01-12 really handle exception
}
+
return result;
}
@@ -684,6 +691,8 @@
* @return if the wikitty check the restriction
*/
public boolean checkRestriction(Restriction restriction, Wikitty w) {
+ log.debug("Check restriction for : "+ w + " restriction: " + restriction);
+
if (restriction instanceof BinaryOperator) {
BinaryOperator binOp = (BinaryOperator) restriction;
@@ -942,6 +951,12 @@
Keyword keyword = (Keyword) restriction;
String value = keyword.getValue();
+
+ //TODO mfortun-2011-07-06 hack to ensure that * is intepreted as
+ // the real meaning aka any
+ if (value.equals("*")){
+ return true;
+ }
for (String fieldName : w.getAllFieldNames()) {
String testedValue = String.valueOf(w.getFqField(fieldName));
@@ -1050,6 +1065,7 @@
@Override
public List<PagedResult<String>> findAllByCriteria(String securityToken,
List<Criteria> criteria) {
+
Map<String, Wikitty> wikitties = new HashMap<String, Wikitty>();
try {
// construct properly with the working directory and the label
@@ -1080,7 +1096,7 @@
// TODO mfortun-2011-04-20 really handle exception
e.printStackTrace();
}
-
+
List<PagedResult<String>> result = new ArrayList<PagedResult<String>>();
// for each criteria
@@ -1097,8 +1113,6 @@
Wikitty w = entry.getValue();
// if macth
- log.debug("Check restriction for wikitty: " + w
- + " Restriction:" + restriction);
if (checkRestriction(restriction, w)) {
@@ -1116,6 +1130,7 @@
}
result.add(new PagedResult<String>(firstIndex, ids.size(),
restriction.toString(), null, ids));
+
}
return result;
}
1
0
r1063 - in trunk/wikitty-struts/src/main: java/org/nuiton/wikitty/struts/component java/org/nuiton/wikitty/struts/tag resources/template/wikitty tld
by sletellier@users.nuiton.org 06 Jul '11
by sletellier@users.nuiton.org 06 Jul '11
06 Jul '11
Author: sletellier
Date: 2011-07-06 16:15:34 +0200 (Wed, 06 Jul 2011)
New Revision: 1063
Url: http://nuiton.org/repositories/revision/wikitty/1063
Log:
Debug select tag
Modified:
trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/SelectBean.java
trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/tag/SelectTag.java
trunk/wikitty-struts/src/main/resources/template/wikitty/ws-select.ftl
trunk/wikitty-struts/src/main/resources/template/wikitty/ws-selectassociation.ftl
trunk/wikitty-struts/src/main/tld/wikitty-struts.tld
Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/SelectBean.java
===================================================================
--- trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/SelectBean.java 2011-07-06 12:26:44 UTC (rev 1062)
+++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/component/SelectBean.java 2011-07-06 14:15:34 UTC (rev 1063)
@@ -33,7 +33,7 @@
protected Integer size;
protected String descField;
protected Collection<Wikitty> wikittyValues;
- protected Collection<BusinessEntity> entityValues;
+ protected Collection<? extends BusinessEntity> entityValues;
@@ -115,7 +115,7 @@
}
}
- addParameter("values", resultList);
+ addParameter("value", resultList);
}
@@ -154,11 +154,11 @@
this.wikittyValues = wikittyValues;
}
- public Collection<BusinessEntity> getEntityValues() {
+ public Collection<? extends BusinessEntity> getEntityValues() {
return entityValues;
}
- public void setEntityValues(Collection<BusinessEntity> entityValues) {
+ public void setEntityValues(Collection<? extends BusinessEntity> entityValues) {
this.entityValues = entityValues;
}
}
Modified: trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/tag/SelectTag.java
===================================================================
--- trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/tag/SelectTag.java 2011-07-06 12:26:44 UTC (rev 1062)
+++ trunk/wikitty-struts/src/main/java/org/nuiton/wikitty/struts/tag/SelectTag.java 2011-07-06 14:15:34 UTC (rev 1063)
@@ -17,7 +17,7 @@
protected Integer size;
protected String descField;
protected Collection<Wikitty> wikittyValues;
- protected Collection<BusinessEntity> entityValues;
+ protected Collection<? extends BusinessEntity> entityValues;
/**
*
@@ -72,11 +72,11 @@
this.wikittyValues = wikittyValues;
}
- public Collection<BusinessEntity> getEntityValues() {
+ public Collection<? extends BusinessEntity> getEntityValues() {
return entityValues;
}
- public void setEntityValues(Collection<BusinessEntity> entityValues) {
+ public void setEntityValues(Collection<? extends BusinessEntity> entityValues) {
this.entityValues = entityValues;
}
Modified: trunk/wikitty-struts/src/main/resources/template/wikitty/ws-select.ftl
===================================================================
--- trunk/wikitty-struts/src/main/resources/template/wikitty/ws-select.ftl 2011-07-06 12:26:44 UTC (rev 1062)
+++ trunk/wikitty-struts/src/main/resources/template/wikitty/ws-select.ftl 2011-07-06 14:15:34 UTC (rev 1063)
@@ -1,9 +1,8 @@
-<#if parameters.included?? && parameters.included==true >
-<#include "/${parameters.templateDir}/${parameters.theme}/ws-label-commons.ftl" />
+<#include "/${parameters.templateDir}/${parameters.theme}/ws-label-commons.ftl" />
<select
<#include "/${parameters.templateDir}/${parameters.theme}/ws-commons.ftl" />
size="${parameters.selectSize}">
-<#assign optionKeys = parameters.values><#t/>
+<#assign optionKeys = parameters.value/><#t/>
<#list optionKeys as optionKey><#t/>
<option value="${optionKey.valeur}" <#t/>
<#if optionKey.valeur==parameters.value >
@@ -11,5 +10,4 @@
</#if> <#t/>
> ${optionKey.description} </option>
</#list>
-</select><#t/>
-</#if>
\ No newline at end of file
+</select><#t/>
\ No newline at end of file
Modified: trunk/wikitty-struts/src/main/resources/template/wikitty/ws-selectassociation.ftl
===================================================================
--- trunk/wikitty-struts/src/main/resources/template/wikitty/ws-selectassociation.ftl 2011-07-06 12:26:44 UTC (rev 1062)
+++ trunk/wikitty-struts/src/main/resources/template/wikitty/ws-selectassociation.ftl 2011-07-06 14:15:34 UTC (rev 1063)
@@ -7,7 +7,7 @@
multiple
</#if>
>
-<#assign optionKeys = parameters.value><#t/>
+<#assign optionKeys = parameters.value/><#t/>
<#list optionKeys as optionKey>
<option value="${optionKey.valeur}">
${optionKey.description} </option>
Modified: trunk/wikitty-struts/src/main/tld/wikitty-struts.tld
===================================================================
--- trunk/wikitty-struts/src/main/tld/wikitty-struts.tld 2011-07-06 12:26:44 UTC (rev 1062)
+++ trunk/wikitty-struts/src/main/tld/wikitty-struts.tld 2011-07-06 14:15:34 UTC (rev 1063)
@@ -127,7 +127,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
- <description><![CDATA[the name of the field that have to be specialize, it will be the name of the html element]]></description>
+ <description><![CDATA[the name of the field that have to be specialize]]></description>
<name>fqFieldName</name>
<rtexprvalue>true</rtexprvalue>
<required>true</required>
1
0
r1062 - trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities
by echatellier@users.nuiton.org 06 Jul '11
by echatellier@users.nuiton.org 06 Jul '11
06 Jul '11
Author: echatellier
Date: 2011-07-06 14:26:44 +0200 (Wed, 06 Jul 2011)
New Revision: 1062
Url: http://nuiton.org/repositories/revision/wikitty/1062
Log:
In developpement
Modified:
trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java
Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java
===================================================================
--- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java 2011-07-06 12:24:32 UTC (rev 1061)
+++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/entities/WikittyGenerationTest.java 2011-07-06 12:26:44 UTC (rev 1062)
@@ -27,6 +27,7 @@
import junit.framework.Assert;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -40,6 +41,7 @@
* Last update : $Date$
* By : $Author$
*/
+@Ignore
public class WikittyGenerationTest {
/**
1
0
r1061 - trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by echatellier@users.nuiton.org 06 Jul '11
by echatellier@users.nuiton.org 06 Jul '11
06 Jul '11
Author: echatellier
Date: 2011-07-06 14:24:32 +0200 (Wed, 06 Jul 2011)
New Revision: 1061
Url: http://nuiton.org/repositories/revision/wikitty/1061
Log:
Fix no requieres needed
Modified:
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java 2011-07-06 10:38:11 UTC (rev 1060)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java 2011-07-06 12:24:32 UTC (rev 1061)
@@ -278,8 +278,11 @@
addImport(abstractClass, superClass);
addImport(abstractClass, superClass.getQualifiedName() + "Abstract");
requires += requiresSep + WikittyTransformerUtil.classToExtensionVariableName(superClass, true);
- requiresSep = ",";
+ requiresSep = " + \",\" + ";
}
+ if (requires.isEmpty()) {
+ requires = null;
+ }
String buildFieldMapExtensionParametersInLine = StringUtils.join(buildFieldMapExtensionParameters, ", \n");
String extensionVariableName = WikittyTransformerUtil.classToExtensionVariableName(businessEntity, false);
1
0