Commit 9ebb9d56 authored by Vincent Calame's avatar Vincent Calame

Renommage de fichiers

parent e68883a8
......@@ -36,7 +36,7 @@ import net.scrutari.datauri.ThesaurusURI;
import net.scrutari.xml.xmlpull.AttrHandler;
import net.scrutari.xml.xmlpull.CorpusHandler;
import net.scrutari.xml.xmlpull.ThesaurusHandler;
import net.scrutari.xml.xmlpull.XmlPullUtils;
import net.scrutari.xml.xmlpull.SctXmlUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
......@@ -169,12 +169,12 @@ public class BaseXmlEngine {
case "corpus":
String corpusName = getAttributeString(attributeMap, "corpus-name");
if (corpusName == null) {
XmlPullUtils.xml(messageHandler, "_ error.empty.xml.attribute", "/base/corpus", "corpus-name");
SctXmlUtils.xml(messageHandler, "_ error.empty.xml.attribute", "/base/corpus", "corpus-name");
return null;
}
CorpusURI corpusURI = CorpusURI.check(parameters.getBaseURI(), corpusName);
if (corpusURI == null) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", "/base/corpus", "corpus-name", corpusName);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", "/base/corpus", "corpus-name", corpusName);
return null;
}
try {
......@@ -185,12 +185,12 @@ public class BaseXmlEngine {
case "thesaurus":
String thesaurusName = getAttributeString(attributeMap, "thesaurus-name");
if (thesaurusName == null) {
XmlPullUtils.xml(messageHandler, "_ error.empty.xml.attribute", "/base/thesaurus", "thesaurus-name");
SctXmlUtils.xml(messageHandler, "_ error.empty.xml.attribute", "/base/thesaurus", "thesaurus-name");
return null;
}
ThesaurusURI thesaurusURI = ThesaurusURI.check(parameters.getBaseURI(), thesaurusName);
if (thesaurusURI == null) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", "/base/thesaurus", "thesaurus-name", thesaurusName);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", "/base/thesaurus", "thesaurus-name", thesaurusName);
return null;
}
try {
......@@ -249,9 +249,9 @@ public class BaseXmlEngine {
case "langs-ui":
return new AvailableLangHandler(baseDataBuilder, messageHandler, tagXpath);
case "attr":
AttributeKey attributeKey = XmlPullUtils.parseAttributeKey(attributeMap, messageHandler, tagXpath);
AttributeKey attributeKey = SctXmlUtils.parseAttributeKey(attributeMap, messageHandler, tagXpath);
if (attributeKey != null) {
return new AttrHandler(attributeKey, messageHandler, XmlPullUtils.toXpath(tagXpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
return new AttrHandler(attributeKey, messageHandler, SctXmlUtils.toXpath(tagXpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
} else {
return null;
}
......@@ -266,11 +266,11 @@ public class BaseXmlEngine {
case BASE_ICON:
boolean done = false;
try {
done = baseDataBuilder.setBaseIcon(XmlPullUtils.testURI(text));
done = baseDataBuilder.setBaseIcon(SctXmlUtils.testURI(text));
} catch (MalformedURLException | URISyntaxException e) {
}
if (!done) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", xpath + "/base-icon", text);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", xpath + "/base-icon", text);
}
break;
}
......@@ -307,7 +307,7 @@ public class BaseXmlEngine {
try {
return new LabelElementHandler(attributeMap, xpath + "/" + tagname);
} catch (ErrorMessageException eme) {
XmlPullUtils.lang(messageHandler, eme.getErrorMessage());
SctXmlUtils.lang(messageHandler, eme.getErrorMessage());
return null;
}
}
......@@ -316,7 +316,7 @@ public class BaseXmlEngine {
@Override
public void endSubElement(XmlPullElementHandler elementHandler) {
baseDataBuilder.addLabel(name, XmlPullUtils.testLabel(elementHandler));
baseDataBuilder.addLabel(name, SctXmlUtils.testLabel(elementHandler));
}
}
......@@ -348,7 +348,7 @@ public class BaseXmlEngine {
Lang lang = Lang.parse(text);
baseDataBuilder.addAvailableLang(lang);
} catch (ParseException ile) {
XmlPullUtils.lang(messageHandler, "_ error.wrong.xml.tagvalue", xpath + "/lang", text);
SctXmlUtils.lang(messageHandler, "_ error.wrong.xml.tagvalue", xpath + "/lang", text);
}
}
......
......@@ -28,7 +28,7 @@ import net.scrutari.datauri.URIParseException;
import net.scrutari.datauri.URIParser;
import net.scrutari.db.api.DataCoder;
import net.scrutari.db.api.caches.DataCacheWriter;
import net.scrutari.xml.xmlpull.XmlPullUtils;
import net.scrutari.xml.xmlpull.SctXmlUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
......@@ -237,11 +237,11 @@ public class IndexationXmlEngine {
}
private void reference(String key, Object... values) {
XmlPullUtils.reference(messageHandler, key, values);
SctXmlUtils.reference(messageHandler, key, values);
}
private void format(String key, Object... values) {
XmlPullUtils.format(messageHandler, key, values);
SctXmlUtils.format(messageHandler, key, values);
}
private void xml(String key, Object... values) {
......
......@@ -7,7 +7,7 @@
*/
package net.scrutari.xml.xmlpull;
package net.scrutari.xml;
import java.io.IOException;
import java.io.InputStream;
......
......@@ -80,7 +80,7 @@ public class AttrHandler extends DefaultElementHandler {
String orignalText = cs.toString();
String checkedText = stringChecker.check(orignalText);
if (checkedText == null) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", xpath + "/val", orignalText);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", xpath + "/val", orignalText);
return null;
} else if (!checkedText.equals(orignalText)) {
return CleanedString.newInstance(checkedText);
......
......@@ -71,7 +71,7 @@ public class CorpusHandler extends DefaultElementHandler {
this.dataCacheWriter = parameters.getDataCacheWriter();
this.dataCoder = parameters.getDataCoder();
if (dataCoder.checkCode(corpusURI) != -1) {
XmlPullUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", corpusxpath, "corpus-name", corpusName);
SctXmlUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", corpusxpath, "corpus-name", corpusName);
throw new IllegalArgumentException();
}
this.codecorpus = dataCoder.getCode(corpusURI);
......@@ -86,24 +86,24 @@ public class CorpusHandler extends DefaultElementHandler {
metadataDone = true;
return new MetadataHandler();
} else {
XmlPullUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", corpusxpath, "corpus-metadata");
SctXmlUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", corpusxpath, "corpus-metadata");
return null;
}
} else {
if (tagname.equals("fiche")) {
String ficheId = getAttributeString(attributeMap, "fiche-id");
if (ficheId == null) {
XmlPullUtils.xml(messageHandler, "_ error.empty.xml.attribute", corpusxpath + "/fiche", "fiche-id");
SctXmlUtils.xml(messageHandler, "_ error.empty.xml.attribute", corpusxpath + "/fiche", "fiche-id");
return null;
}
String ficheXpath = corpusxpath + "/fiche[@fiche-id='" + ficheId + "']";
FicheURI ficheURI = FicheURI.check(corpusURI, ficheId);
if (ficheURI == null) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", corpusxpath + "/fiche", "fiche-id", ficheId);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", corpusxpath + "/fiche", "fiche-id", ficheId);
return null;
}
if (dataCoder.checkCode(ficheURI) != -1) {
XmlPullUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", ficheXpath, "fiche-id", ficheId);
SctXmlUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", ficheXpath, "fiche-id", ficheId);
return null;
}
ficheHandler.newFiche(ficheURI, ficheXpath);
......@@ -163,9 +163,9 @@ public class CorpusHandler extends DefaultElementHandler {
case "corpus-icon":
return null;
case "attr":
AttributeKey attributeKey = XmlPullUtils.parseAttributeKey(attributeMap, messageHandler, xpath);
AttributeKey attributeKey = SctXmlUtils.parseAttributeKey(attributeMap, messageHandler, xpath);
if (attributeKey != null) {
return new AttrHandler(attributeKey, messageHandler, XmlPullUtils.toXpath(xpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
return new AttrHandler(attributeKey, messageHandler, SctXmlUtils.toXpath(xpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
} else {
return null;
}
......@@ -180,12 +180,12 @@ public class CorpusHandler extends DefaultElementHandler {
case HREF_PARENT:
boolean hrefParentDone = false;
try {
hrefParentDone = corpusDataBuilder.setHrefParent(XmlPullUtils.testURI(text));
hrefParentDone = corpusDataBuilder.setHrefParent(SctXmlUtils.testURI(text));
} catch (MalformedURLException | URISyntaxException e) {
}
if (!hrefParentDone) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", corpusxpath + "/corpus-metadata/href-parent", text);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", corpusxpath + "/corpus-metadata/href-parent", text);
}
break;
}
......@@ -245,9 +245,9 @@ public class CorpusHandler extends DefaultElementHandler {
case "geoloc":
return new GeolocHandler();
case "attr":
AttributeKey attributeKey = XmlPullUtils.parseAttributeKey(attributeMap, messageHandler, ficheXpath + "/attr");
AttributeKey attributeKey = SctXmlUtils.parseAttributeKey(attributeMap, messageHandler, ficheXpath + "/attr");
if (attributeKey != null) {
return new AttrHandler(attributeKey, messageHandler, XmlPullUtils.toXpath(ficheXpath + "/attr", attributeKey), dataValidator.getFormatChecker(attributeKey));
return new AttrHandler(attributeKey, messageHandler, SctXmlUtils.toXpath(ficheXpath + "/attr", attributeKey), dataValidator.getFormatChecker(attributeKey));
} else {
return null;
}
......@@ -271,7 +271,7 @@ public class CorpusHandler extends DefaultElementHandler {
ficheDataBuilder.setDate(FuzzyDate.parse(text));
}
} catch (ParseException pe) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/date", text);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/date", text);
}
break;
case LANG:
......@@ -280,35 +280,35 @@ public class CorpusHandler extends DefaultElementHandler {
ficheDataBuilder.setLang(Lang.parse(text));
}
} catch (ParseException pe) {
XmlPullUtils.lang(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/lang", text);
SctXmlUtils.lang(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/lang", text);
}
break;
case HREF:
boolean hrefDone = false;
try {
hrefDone = ficheDataBuilder.setHref(XmlPullUtils.testURI(text));
hrefDone = ficheDataBuilder.setHref(SctXmlUtils.testURI(text));
} catch (MalformedURLException | URISyntaxException e) {
}
if (!hrefDone) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/href", text);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/href", text);
}
break;
case COMPLEMENT:
boolean done = ficheDataBuilder.addComplement(text);
if (!done) {
XmlPullUtils.xml(messageHandler, "_ error.unsupported.xml.toomanytags", ficheXpath + "/complement");
SctXmlUtils.xml(messageHandler, "_ error.unsupported.xml.toomanytags", ficheXpath + "/complement");
}
break;
case FICHE_ICON:
boolean ficheIconDone = false;
try {
ficheIconDone = ficheDataBuilder.setFicheIcon(XmlPullUtils.testURI(text));
ficheIconDone = ficheDataBuilder.setFicheIcon(SctXmlUtils.testURI(text));
} catch (MalformedURLException | URISyntaxException e) {
}
if (!ficheIconDone) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/fiche-icon", text);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/fiche-icon", text);
}
break;
}
......@@ -323,16 +323,16 @@ public class CorpusHandler extends DefaultElementHandler {
boolean done = true;
if (latitude == null) {
done = false;
XmlPullUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", ficheXpath + "/geoloc", "lat");
SctXmlUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", ficheXpath + "/geoloc", "lat");
}
if (longitude == null) {
done = false;
XmlPullUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", ficheXpath + "/geoloc", "lon");
SctXmlUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", ficheXpath + "/geoloc", "lon");
}
if (done) {
done = ficheDataBuilder.setGeoloc(latitude, longitude);
if (!done) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/geoloc/[lat OR lon]", latitude + " / " + longitude);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.tagvalue", ficheXpath + "/geoloc/[lat OR lon]", latitude + " / " + longitude);
}
}
} else if (elementHandler instanceof AttrHandler) {
......@@ -360,7 +360,7 @@ public class CorpusHandler extends DefaultElementHandler {
try {
return new LabelElementHandler(attributeMap, xpath + "/lib");
} catch (ErrorMessageException eme) {
XmlPullUtils.lang(messageHandler, eme.getErrorMessage());
SctXmlUtils.lang(messageHandler, eme.getErrorMessage());
return null;
}
}
......@@ -369,7 +369,7 @@ public class CorpusHandler extends DefaultElementHandler {
@Override
public void endSubElement(XmlPullElementHandler elementHandler) {
corpusDataBuilder.addLabel(name, XmlPullUtils.testLabel(elementHandler));
corpusDataBuilder.addLabel(name, SctXmlUtils.testLabel(elementHandler));
}
}
......
......@@ -30,9 +30,9 @@ import net.scrutari.data.SctSpace;
*
* @author Vincent Calame
*/
public final class XmlPullUtils {
public final class SctXmlUtils {
private XmlPullUtils() {
private SctXmlUtils() {
}
public static Label testLabel(XmlPullElementHandler elementHandler) {
......
......@@ -54,7 +54,7 @@ public class ThesaurusHandler extends DefaultElementHandler {
this.dataCacheWriter = parameters.getDataCacheWriter();
this.dataCoder = parameters.getDataCoder();
if (dataCoder.checkCode(thesaurusURI) != -1) {
XmlPullUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", thesaurusxpath, "thesaurus-name", thesaurusName);
SctXmlUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", thesaurusxpath, "thesaurus-name", thesaurusName);
throw new IllegalArgumentException();
}
this.codethesaurus = dataCoder.getCode(thesaurusURI);
......@@ -78,23 +78,23 @@ public class ThesaurusHandler extends DefaultElementHandler {
metadataDone = true;
return new MetadataHandler();
} else {
XmlPullUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", thesaurusxpath, "thesaurus-metadata");
SctXmlUtils.xml(messageHandler, "_ error.unsupported.xml.missingtag", thesaurusxpath, "thesaurus-metadata");
return null;
}
} else {
if (tagname.equals("motcle")) {
String motcleId = getAttributeString(attributeMap, "motcle-id");
if (motcleId == null) {
XmlPullUtils.xml(messageHandler, "_ error.empty.xml.attribute", thesaurusxpath + "/motcle", "motcle-id");
SctXmlUtils.xml(messageHandler, "_ error.empty.xml.attribute", thesaurusxpath + "/motcle", "motcle-id");
return null;
}
MotcleURI motcleURI = MotcleURI.check(thesaurusURI, motcleId);
if (motcleURI == null) {
XmlPullUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", thesaurusxpath + "/motcle", "motcle-id", motcleId);
SctXmlUtils.format(messageHandler, "_ error.wrong.xml.attributevalue", thesaurusxpath + "/motcle", "motcle-id", motcleId);
return null;
}
if (dataCoder.checkCode(motcleURI) != -1) {
XmlPullUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", thesaurusxpath + "/motcle[motcle-id='" + motcleId + "']", "motcle-id", motcleId);
SctXmlUtils.reference(messageHandler, "_ error.existing.xml.attributevalue", thesaurusxpath + "/motcle[motcle-id='" + motcleId + "']", "motcle-id", motcleId);
return null;
}
int codemotcle = dataCoder.getCode(motcleURI);
......@@ -132,9 +132,9 @@ public class ThesaurusHandler extends DefaultElementHandler {
case "intitule-thesaurus":
return new PhraseHandler(DataConstants.THESAURUS_TITLE, xpath);
case "attr":
AttributeKey attributeKey = XmlPullUtils.parseAttributeKey(attributeMap, messageHandler, xpath);
AttributeKey attributeKey = SctXmlUtils.parseAttributeKey(attributeMap, messageHandler, xpath);
if (attributeKey != null) {
return new AttrHandler(attributeKey, messageHandler, XmlPullUtils.toXpath(xpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
return new AttrHandler(attributeKey, messageHandler, SctXmlUtils.toXpath(xpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
} else {
return null;
}
......@@ -170,7 +170,7 @@ public class ThesaurusHandler extends DefaultElementHandler {
try {
return new LabelElementHandler(attributeMap, xpath + "/lib");
} catch (ErrorMessageException eme) {
XmlPullUtils.lang(messageHandler, eme.getErrorMessage());
SctXmlUtils.lang(messageHandler, eme.getErrorMessage());
return null;
}
}
......@@ -179,7 +179,7 @@ public class ThesaurusHandler extends DefaultElementHandler {
@Override
public void endSubElement(XmlPullElementHandler elementHandler) {
thesaurusDataBuilder.addLabel(name, XmlPullUtils.testLabel(elementHandler));
thesaurusDataBuilder.addLabel(name, SctXmlUtils.testLabel(elementHandler));
}
}
......@@ -216,13 +216,13 @@ public class ThesaurusHandler extends DefaultElementHandler {
try {
return new LabelElementHandler(attributeMap, thesaurusxpath + "/motcle[motcle-id='" + motcleURI.getMotcleId() + "']/lib");
} catch (ErrorMessageException eme) {
XmlPullUtils.lang(messageHandler, eme.getErrorMessage());
SctXmlUtils.lang(messageHandler, eme.getErrorMessage());
return null;
}
case "attr":
AttributeKey attributeKey = XmlPullUtils.parseAttributeKey(attributeMap, messageHandler, xpath);
AttributeKey attributeKey = SctXmlUtils.parseAttributeKey(attributeMap, messageHandler, xpath);
if (attributeKey != null) {
return new AttrHandler(attributeKey, messageHandler, XmlPullUtils.toXpath(xpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
return new AttrHandler(attributeKey, messageHandler, SctXmlUtils.toXpath(xpath, attributeKey), dataValidator.getFormatChecker(attributeKey));
} else {
return null;
}
......@@ -233,7 +233,7 @@ public class ThesaurusHandler extends DefaultElementHandler {
@Override
public void endSubElement(XmlPullElementHandler elementHandler) {
if (elementHandler instanceof LabelElementHandler) {
motcleDataBuilder.addLabel(XmlPullUtils.testLabel(elementHandler));
motcleDataBuilder.addLabel(SctXmlUtils.testLabel(elementHandler));
} else if (elementHandler instanceof AttrHandler) {
AttrHandler attrHandler = (AttrHandler) elementHandler;
motcleDataBuilder.addAttribute(attrHandler.getAttributeKey(), attrHandler.getValueList());
......
......@@ -58,8 +58,8 @@ import net.scrutari.xml.BaseURIXmlEngine;
import net.scrutari.xml.BaseXmlEngine;
import net.scrutari.xml.IndexationXmlEngine;
import net.scrutari.xml.Parameters;
import net.scrutari.xml.xmlpull.XmlChecker;
import net.scrutari.xml.xmlpull.XmlPullUtils;
import net.scrutari.xml.XmlChecker;
import net.scrutari.xml.xmlpull.SctXmlUtils;
import org.xml.sax.SAXException;
import org.xmlpull.v1.XmlPullParserException;
......@@ -292,7 +292,7 @@ public final class SctEngineImpl implements SctEngine {
if (baseURI != null) {
String existingSourceName = aliasManagerBuilder.getSourceName(baseURI);
if ((existingSourceName != null) && (!existingSourceName.equals(scrutariSourceName))) {
XmlPullUtils.reference(updateLogHandler, "_ error.existing.baseuri", baseURI);
SctXmlUtils.reference(updateLogHandler, "_ error.existing.baseuri", baseURI);
} else {
BaseURI currentMain = aliasManagerBuilder.getMainBaseURI(scrutariSourceName);
if (currentMain == null) {
......@@ -443,14 +443,14 @@ public final class SctEngineImpl implements SctEngine {
BaseURI mainBaseURI = scrutariSourceDef.getMainBaseURI();
if (mainBaseURI != null) {
if (aliasManagerBuilder.containsBaseURI(mainBaseURI)) {
XmlPullUtils.reference(messageHandler, "_ error.existing.baseuri", mainBaseURI);
SctXmlUtils.reference(messageHandler, "_ error.existing.baseuri", mainBaseURI);
} else {
aliasManagerBuilder.putMainBaseURI(scrutariSourceName, mainBaseURI);
}
}
for (BaseURI baseURI : scrutariSourceDef.getAliasList()) {
if (aliasManagerBuilder.containsBaseURI(baseURI)) {
XmlPullUtils.reference(messageHandler, "_ error.existing.baseuri", mainBaseURI);
SctXmlUtils.reference(messageHandler, "_ error.existing.baseuri", mainBaseURI);
} else {
aliasManagerBuilder.putAliasBaseURI(scrutariSourceName, baseURI);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment