Author: scabanovich
Date: 2012-02-10 17:48:07 -0500 (Fri, 10 Feb 2012)
New Revision: 38625
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/CreateFacesConfigSupport.java
Log:
JBIDE-10830
https://issues.jboss.org/browse/JBIDE-10830
Disabling wizard when target folder for new faces-config is outside the web root and check
box 'register in web.xml' is selected.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java 2012-02-10
22:17:06 UTC (rev 38624)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/JSFUIMessages.java 2012-02-10
22:48:07 UTC (rev 38625)
@@ -114,6 +114,7 @@
public static String CreateFacesConfigSupport_WebXMLIncorrect;
public static String CreateFacesConfigSupport_WebXMLNotFound;
public static String CreateFacesConfigSupport_WebXMLReadOnly;
+ public static String CreateFacesConfigSupport_WebXMLCannotRegister;
public static String DELETE_JAVA_SOURCE;
public static String DeleteFacesConfigHandler_DeleteFacesConfig;
public static String DeleteFacesConfigHandler_DeleteReferenceFromWebXML;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties 2012-02-10
22:17:06 UTC (rev 38624)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/messages/messages.properties 2012-02-10
22:48:07 UTC (rev 38625)
@@ -91,6 +91,7 @@
CreateFacesConfigSupport_WebXMLIncorrect=Faces config file cannot be registered because
web.xml is incorrect.
CreateFacesConfigSupport_WebXMLNotFound=Faces config cannot be registered because web.xml
is not found.
CreateFacesConfigSupport_WebXMLReadOnly=Faces config file cannot be registered because
web.xml is read only.
+CreateFacesConfigSupport_WebXMLCannotRegister=Cannot register faces config file located
outside of the Web root.
DELETE_JAVA_SOURCE = Delete Java Source
DeleteFacesConfigHandler_DeleteFacesConfig=Delete faces-config {0}
DeleteFacesConfigHandler_DeleteReferenceFromWebXML=Delete reference from web.xml
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/CreateFacesConfigSupport.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/CreateFacesConfigSupport.java 2012-02-10
22:17:06 UTC (rev 38624)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/CreateFacesConfigSupport.java 2012-02-10
22:48:07 UTC (rev 38625)
@@ -100,7 +100,8 @@
result = "/" + o.getAttributeValue("name") + result; //$NON-NLS-1$
//$NON-NLS-2$
o = o.getParent();
}
- if(o == null || !"WEB-ROOT".equals(o.getAttributeValue("name"))) {
//$NON-NLS-1$ //$NON-NLS-2$
+ String name = o == null ? null : o.getAttributeValue("name"); //$NON-NLS-1$
+ if(o == null || (!"WEB-ROOT".equals(name) &&
!name.startsWith("WEB-ROOT-") )) { //$NON-NLS-1$ //$NON-NLS-2$
result = "/WEB-INF" + result; //$NON-NLS-1$
}
return result;
@@ -114,7 +115,7 @@
public void validate(Properties data) {
super.validate(data);
if(message != null) return;
- message = checkRegister(getTarget(), data.getProperty("register in
web.xml")); //$NON-NLS-1$
+ message = checkRegister(getTargetFolder() == null ? getTarget() : getTargetFolder(),
data.getProperty("register in web.xml")); //$NON-NLS-1$
}
}
@@ -130,6 +131,16 @@
}
if("yes".equals(webxml.get("isIncorrect"))) return
JSFUIMessages.CreateFacesConfigSupport_WebXMLIncorrect; //$NON-NLS-1$ //$NON-NLS-2$
if(!webxml.isObjectEditable()) return
JSFUIMessages.CreateFacesConfigSupport_WebXMLReadOnly;
+
+ XModelObject fs = object;
+ while(fs != null && fs.getFileType() != XModelObject.SYSTEM) fs =
fs.getParent();
+ if(fs != null) {
+ String fsn = fs.getAttributeValue(XModelObjectConstants.ATTR_NAME);
+ if(!fsn.equals("WEB-INF") && !fsn.equals("WEB-ROOT")
&& !fsn.startsWith("WEB-ROOT-")) {
+ return JSFUIMessages.CreateFacesConfigSupport_WebXMLCannotRegister;
+ }
+ }
+
return null;
}