Author: scabanovich
Date: 2007-07-20 09:10:16 -0400 (Fri, 20 Jul 2007)
New Revision: 2542
Modified:
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsConfigLoader.java
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/webprj/model/helpers/sync/SyncProjectContext.java
Log:
EXIN-86
Modified:
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsConfigLoader.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsConfigLoader.java 2007-07-20
13:09:26 UTC (rev 2541)
+++
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/StrutsConfigLoader.java 2007-07-20
13:10:16 UTC (rev 2542)
@@ -18,7 +18,10 @@
import org.jboss.tools.common.model.filesystems.impl.*;
import org.jboss.tools.common.model.loaders.impl.SimpleWebFileLoader;
import org.jboss.tools.common.model.util.*;
+
import java.io.*;
+import java.util.Set;
+
import org.w3c.dom.*;
public class StrutsConfigLoader implements WebProcessLoader, StrutsConstants {
@@ -45,8 +48,11 @@
// String encoding = XModelObjectLoaderUtil.getEncoding(body);
// body = FileUtil.encode(body, encoding);
- String[] errors = XMLUtil.getXMLErrors(new StringReader(body));
- if(errors != null && errors.length > 0) {
+ String[] errors =
+ //XMLUtil.getXMLErrors(new StringReader(body));
+ XMLUtil.getXMLErrors(new StringReader(body), false, false);
+ boolean hasErrors = (errors != null && errors.length > 0);
+ if(hasErrors) {
object.setAttributeValue("isIncorrect", "yes");
object.setAttributeValue("incorrectBody", body);
object.set("actualBodyTimeStamp", "-1");
@@ -76,11 +82,19 @@
}
if (version != 10) {
- util.load(element, object.getChildren(ENT_MSGRES_FOLDER +
VER_SUFFIX_11)[0]);
- util.load(element, object.getChildren(ENT_PLUGIN_FOLDER +
VER_SUFFIX_11)[0]);
+ util.loadChildren(element, object.getChildren(ENT_MSGRES_FOLDER +
VER_SUFFIX_11)[0]);
+ util.loadChildren(element, object.getChildren(ENT_PLUGIN_FOLDER +
VER_SUFFIX_11)[0]);
}
+ String loadingError = util.getError();
reloadProcess(object);
object.set("actualBodyTimeStamp", "" + object.getTimeStamp());
+
+ ((AbstractXMLFileImpl)object).setLoaderError(loadingError);
+ if(!hasErrors && loadingError != null) {
+ object.setAttributeValue("isIncorrect", "yes");
+ object.setAttributeValue("incorrectBody", body);
+ object.set("actualBodyTimeStamp", "" + object.getTimeStamp());
+ }
}
protected void setEncoding(XModelObject object, String body) {
@@ -209,8 +223,9 @@
}
-class SPUtil extends XModelObjectLoaderUtil {
+class SPUtil extends XModelObjectLoaderUtil implements StrutsConstants {
static String CODE = "UTF-8";
+
public void loadAttributes(Element element, XModelObject o) {
super.loadAttributes(element, o);
if(o.getModelEntity().getName().equals("StrutsProcessComment")) {
@@ -256,7 +271,12 @@
}
-class SCUtil extends XModelObjectLoaderUtil {
+class SCUtil extends XModelObjectLoaderUtil implements StrutsConstants {
+ protected Set<String> getAllowedChildren(XModelEntity entity) {
+ Set<String> children = super.getAllowedChildren(entity);
+ return children;
+ }
+
protected boolean isSaveable(XModelEntity entity, String n, String v, String dv) {
if(v == null) return false;
if(v.length() == 0 || v.equals(dv)) {
Modified:
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/webprj/model/helpers/sync/SyncProjectContext.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/webprj/model/helpers/sync/SyncProjectContext.java 2007-07-20
13:09:26 UTC (rev 2541)
+++
trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/webprj/model/helpers/sync/SyncProjectContext.java 2007-07-20
13:10:16 UTC (rev 2542)
@@ -337,7 +337,7 @@
boolean is12 = s.indexOf(StrutsConstants.DOC_PUBLICID_12) >= 0;
if(!is11 && !is12)
throw new Exception("File is not Struts Configuration 1.1 or 1.2.");
//$NON-NLS-1$
- String[] es = XMLUtil.getXMLErrors(new StringReader(s));
+ String[] es = XMLUtil.getXMLErrors(new StringReader(s), false); //never validate
dtd
if(es != null && es.length > 0) {
String version = (is11) ? "1.1" : "1.2"; //$NON-NLS-1$
//$NON-NLS-2$
throw new Exception("Struts Configuration " + version + " file
is not correct:\n" + es[0]); //$NON-NLS-1$ //$NON-NLS-2$