Author: mfortun Date: 2011-04-19 17:56:51 +0200 (Tue, 19 Apr 2011) New Revision: 820 Url: http://nuiton.org/repositories/revision/wikitty/820 Log: * add support for the search on wikittyFileSytem * add method to detect new file and create wikitty * add method to write wikitty property file * correct/merge method * code have to be cleaned. Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java =================================================================== --- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-04-19 14:39:07 UTC (rev 819) +++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-04-19 15:56:51 UTC (rev 820) @@ -30,26 +30,38 @@ import java.io.FileReader; import java.net.URI; 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; import java.util.Map; 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; import org.apache.commons.logging.LogFactory; import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.CollectionUtil; import org.nuiton.util.FileUtil; import org.nuiton.util.MD5InputStream; import org.nuiton.util.StringUtil; +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; @@ -57,10 +69,25 @@ import org.nuiton.wikitty.publication.entities.WikittyPubTextHelper; import org.nuiton.wikitty.publication.entities.WikittyPubTextImpl; import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.search.FacetTopic; + import org.nuiton.wikitty.search.PagedResult; -import org.nuiton.wikitty.search.Search; + 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; @@ -90,6 +117,8 @@ static public String WIKITTY_FILE_META_PROPERTIES_FILE = "meta.properties"; + static public String WIKITTY_FILE_SERVICE = "ws.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() @@ -452,61 +481,7 @@ FileSystemWIkittyId localisation = (FileSystemWIkittyId) value; - // create the wikitty with his id - Wikitty wikitty = new WikittyImpl(wikid); - // add label extension - wikitty.addExtension(WikittyLabelImpl.extensionWikittyLabel); - - // preparation for mime research and file research - String path = localisation.getPath(); - String completeName = localisation.getFileName(); - - // search for the file - File fileToTransform = new File(path + File.separator - + completeName); - - String extension = FileUtil.extension(fileToTransform); - String name = FileUtil.basename(completeName, "." - + extension); - // search for the mimetype - String mimeType = mimeTypeForExtension(extension); - - // load properties - File wikittyParentDir = new File(path); - PropertiesExtended props = getWikittyPublicationProperties( - wikittyParentDir, WIKITTY_FILE_META_PROPERTIES_FILE); - // re set the version - wikitty.setVersion(props - .getProperty(WikittyPublicationFileSystem.META_PREFIX_KEY_VERSION - + completeName)); - - // set the current label - WikittyLabelHelper - .addLabels( - wikitty, - props.getProperty(WikittyPublicationFileSystem.META_CURRENT_LABEL)); - - /* - * TODO mfortun-2011-04-12 need to merge part of this code - * with filetowikitty method 'cause it is basically the same - */ - - // create the correct wikittypubxxx - if (isMimeWikittyPubText(mimeType)) { - wikitty.addExtension(WikittyPubTextImpl.extensionWikittyPubText); - WikittyPubTextHelper.setName(wikitty, name); - WikittyPubTextHelper.setMimeType(wikitty, mimeType); - WikittyPubTextHelper.setContent(wikitty, - FileUtil.readAsString(fileToTransform)); - } else { - wikitty.addExtension(WikittyPubDataImpl.extensionWikittyPubData); - WikittyPubDataHelper.setName(wikitty, name); - WikittyPubDataHelper.setMimeType(wikitty, mimeType); - WikittyPubDataHelper.setContent(wikitty, - FileUtil.fileToByte(fileToTransform)); - } - - result.add(wikitty); + result.add(this.restore(wikid, localisation)); } } } catch (Exception e) { @@ -581,47 +556,453 @@ 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) { + 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); + //FIXME mfortun-2011-04-19 ici ça fait bugger plus loin + // vu que on met dans une collection la valeur du startwith + //et que plus loin on tente de caster cette collection en string + } + 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: + System.out.println(t.isCollection()); + 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()); + } + System.out.println(value.getClass()); + System.out.println(value); + 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(); + + 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) { - List<PagedResult<String>> result = new ArrayList<PagedResult<String>>(); - List<String> rr= new ArrayList<String>(); - Map<String, List<FacetTopic>> map= new HashMap<String, List<FacetTopic>>(); - PagedResult<String> pp= new PagedResult<String>(0,0, - "", map, rr); - result.add(pp); - - /* - * TODO mfortun-2011-04-18 ici faire une vrai gestion des critérias - * pas simple histoire de comparaison avec critéria préconstruit. - * voir avec jcouteau comment lui à faire pour son implémentation - * des critérias. - * Dans un premier temps s'occuper uniquement des types pub et sur label - * name = machin - */ - - for (Criteria cr: criteria){ - System.out.println(cr.getName()); - - - + Map<String, Wikitty> wikitties = new HashMap<String, Wikitty>(); + try { + harvestNew(homeFile, label); + BidiMap map = harvestLocalWikitties(homeFile, true); + + for (Object o : map.keySet()) { + String id = (String) o; + FileSystemWIkittyId location = (FileSystemWIkittyId) map + .get(id); + wikitties.put(id, restore(id, location)); + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - - - return result; + List<PagedResult<String>> result = new ArrayList<PagedResult<String>>(); + // for each criteria + for (Criteria cr : criteria) { + // prepare restriction on result + int firstIndex = cr.getFirstIndex(); + int endIndex = cr.getEndIndex(); + List<String> ids = new LinkedList<String>(); + int currentIndex = 0; + Restriction restriction = cr.getRestriction(); + // for each wikitty check if it match the resttriction + for (Entry<String, Wikitty> entry : wikitties.entrySet()) { + String id = entry.getKey(); + Wikitty w = entry.getValue(); + // if macth + System.out.println(restriction); + if (checkRestriction(restriction, w)) { + + // increment result number + currentIndex++; + if (currentIndex > firstIndex) { + ids.add(id); + } + // if the number of wikitty found is match + // stop the search for other wikitty + if (endIndex >= 0 && currentIndex >= endIndex) { + break; + } + } + } + result.add(new PagedResult<String>(firstIndex, ids.size(), + restriction.toString(), null, ids)); + } + return result; } @Override public List<String> findByCriteria(String securityToken, List<Criteria> criteria) { - List<String> result = new ArrayList<String>(); - result.add(""); - + List<String> result = new ArrayList<String>(); - System.out.println(criteria.get(0).getRestriction()); - return result; + Map<String, Wikitty> wikitties = new HashMap<String, Wikitty>(); + + // for each criteria + for (Criteria cr : criteria) { + // prepare restriction on result + int firstIndex = cr.getFirstIndex(); + int endIndex = cr.getEndIndex(); + List<String> ids = new LinkedList<String>(); + int currentIndex = 0; + Restriction restriction = cr.getRestriction(); + // for each wikitty check if it match the resttriction + for (Entry<String, Wikitty> entry : wikitties.entrySet()) { + String id = entry.getKey(); + Wikitty w = entry.getValue(); + // if macth + if (checkRestriction(restriction, w)) { + // increment result number + currentIndex++; + if (currentIndex > firstIndex) { + ids.add(id); + } + // if the number of wikitty found is match + // stop the search for other wikitty + if (endIndex >= 0 && currentIndex >= endIndex) { + break; + } + } + } + result.addAll(ids); + } + return result; } @Override @@ -673,8 +1054,8 @@ /* * TODO mfortun-2011-04-07 correct the Exception's type */ - static public Wikitty fileToWikitty(File fileToTransform, File starts) - throws Exception { + protected Wikitty fileToWikitty(File fileToTransform, File starts, + boolean writeProperties) throws Exception { String completeName = fileToTransform.getName(); // isolate extension and file name @@ -788,39 +1169,6 @@ } /** - * 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 = label.replace(".", File.separator); - label = label.replace(File.separator + File.separator, File.separator - + "."); - 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; - } - - /** * Method that create a list of the properties directory * * @param starts @@ -911,4 +1259,159 @@ return result; } + protected Wikitty restore(String id, FileSystemWIkittyId fileId) + throws Exception { + + Wikitty result = new WikittyImpl(id); + + result.addExtension(WikittyLabelImpl.extensionWikittyLabel); + + // preparation for mime research and file research + String path = fileId.getPath(); + String completeName = fileId.getFileName(); + + // search for the file + File fileToTransform = new File(path + File.separator + completeName); + + String extension = FileUtil.extension(fileToTransform); + String name = FileUtil.basename(completeName, "." + extension); + // search for the mimetype + String mimeType = mimeTypeForExtension(extension); + + // load properties + File wikittyParentDir = new File(path); + PropertiesExtended props = getWikittyPublicationProperties( + wikittyParentDir, WIKITTY_FILE_META_PROPERTIES_FILE); + // re set the version + result.setVersion(props + .getProperty(WikittyPublicationFileSystem.META_PREFIX_KEY_VERSION + + completeName)); + + // set the current label + WikittyLabelHelper.addLabels(result, props + .getProperty(WikittyPublicationFileSystem.META_CURRENT_LABEL)); + + // create the correct wikittypubxxx + if (isMimeWikittyPubText(mimeType)) { + result.addExtension(WikittyPubTextImpl.extensionWikittyPubText); + WikittyPubTextHelper.setName(result, name); + WikittyPubTextHelper.setMimeType(result, mimeType); + WikittyPubTextHelper.setContent(result, + FileUtil.readAsString(fileToTransform)); + } else { + result.addExtension(WikittyPubDataImpl.extensionWikittyPubData); + WikittyPubDataHelper.setName(result, name); + WikittyPubDataHelper.setMimeType(result, mimeType); + WikittyPubDataHelper.setContent(result, + FileUtil.fileToByte(fileToTransform)); + } + + return result; + } + + protected void harvestNew(File starts, String label) throws Exception { + + + + File propertyFile = new File(starts + File.separator + + PROPERTY_DIRECTORY); + + if (!propertyFile.exists() || !propertyFile.isDirectory()) { + propertyFile.mkdir(); + + } + + PropertiesExtended ids = getWikittyPublicationProperties(starts, + WIKITTY_ID_PROPERTIES_FILE); + PropertiesExtended meta = getWikittyPublicationProperties(starts, + WIKITTY_FILE_META_PROPERTIES_FILE); + + meta.put(META_CURRENT_LABEL, label); + for (File child : starts.listFiles()) { + if (child.isDirectory() + && !child.getName().equals(PROPERTY_DIRECTORY)) { + harvestNew(child, + label + WIKITTYLABEL_SEPARATOR + child.getName()); + } else if (!child.isDirectory()){ + + List<String> filesWikitty = new ArrayList<String>(); + filesWikitty.addAll(CollectionUtil.toGenericCollection( + ids.values(), String.class)); + // if file is not a wikitty create it. + if (!filesWikitty.contains(child.getName())) { + writeWikittyFileProperties(child, null); + } + } + } + + } + + protected void writeWikittyFileProperties(File towrite, String wikittyID) + throws Exception { + + if (towrite.exists() && !towrite.isDirectory()) { + Wikitty wikitty = new WikittyImpl(wikittyID); + + File parent = towrite.getParentFile(); + + PropertiesExtended id = getWikittyPublicationProperties(parent, + WIKITTY_ID_PROPERTIES_FILE); + PropertiesExtended meta = getWikittyPublicationProperties(parent, + WIKITTY_FILE_META_PROPERTIES_FILE); + + id.put(wikitty.getId(), towrite.getName()); + + BufferedInputStream input = new BufferedInputStream( + new FileInputStream(towrite)); + + byte[] byt = MD5InputStream.hash(input); + + String localMd5 = StringUtil.asHex(byt); + + meta.put(META_PREFIX_KEY_VERSION + towrite.getName(), + wikitty.getVersion()); + meta.put(META_PREFIX_KEY_CHECKSUM + towrite.getName(), localMd5); + + id.store(); + meta.store(); + } else { + // TODO mfortun-2011-04-19 set proper type of exception + throw new Exception(); + } + + } + + /** + * 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 = label.replace(".", File.separator); + label = label.replace(File.separator + File.separator, File.separator + + "."); + 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; + } + }