Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/operation/Regexp.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/operation/Regexp.java?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/operation/Regexp.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/minilang/src/org/ofbiz/minilang/operation/Regexp.java Mon Dec 2 20:59:22 2013 @@ -23,10 +23,13 @@ import java.util.Locale; import java.util.Map; import org.apache.oro.text.regex.MalformedPatternException; -import org.ofbiz.base.util.CompilerMatcher; +import org.apache.oro.text.regex.Pattern; +import org.apache.oro.text.regex.PatternMatcher; +import org.apache.oro.text.regex.Perl5Matcher; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.PatternFactory; import org.w3c.dom.Element; /** @@ -35,13 +38,17 @@ import org.w3c.dom.Element; public class Regexp extends SimpleMapOperation { public static final String module = Regexp.class.getName(); - private transient static ThreadLocal<CompilerMatcher> compilerMatcher = CompilerMatcher.getThreadLocal(); - + private Pattern pattern = null; String expr; public Regexp(Element element, SimpleMapProcess simpleMapProcess) { super(element, simpleMapProcess); expr = element.getAttribute("expr"); + try { + pattern = PatternFactory.createOrGetPerl5CompiledPattern(expr, true); + } catch (MalformedPatternException e) { + Debug.logError(e, module); + } } @Override @@ -54,14 +61,12 @@ public class Regexp extends SimpleMapOpe messages.add("Could not convert field value for comparison: " + e.getMessage()); return; } - boolean matches = false; - try { - matches = compilerMatcher.get().matches(fieldValue, expr); - } catch (MalformedPatternException e) { - Debug.logError(e, "Regular Expression [" + this.expr + "] is mal-formed: " + e.toString(), module); + if (pattern == null) { + messages.add("Could not compile regular expression \"" + expr + "\" for validation"); return; } - if (!matches) { + PatternMatcher matcher = new Perl5Matcher(); + if (!matcher.matches(fieldValue, pattern)) { addMessage(messages, loader, locale); } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Mon Dec 2 20:59:22 2013 @@ -23,6 +23,8 @@ import static org.ofbiz.base.util.UtilGe import java.math.BigInteger; import java.security.cert.X509Certificate; import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.ServiceLoader; @@ -1058,35 +1060,70 @@ public class LoginWorker { "Y".equalsIgnoreCase(userLogin.getString("hasLoggedOut")) : false); } + /** + * Returns <code>true</code> if the specified user is authorized to access the specified web application. + * @param info + * @param security + * @param userLogin + * @return <code>true</code> if the specified user is authorized to access the specified web application + */ + public static boolean hasApplicationPermission(ComponentConfig.WebappInfo info, Security security, GenericValue userLogin) { + // New authorization attribute takes precedence. + String accessPermission = info.getAccessPermission(); + if (!accessPermission.isEmpty()) { + return security.hasPermission(accessPermission, userLogin); + } + for (String permission: info.getBasePermission()) { + if (!"NONE".equals(permission) && !security.hasEntityPermission(permission, "_VIEW", userLogin)) { + return false; + } + } + return true; + } + public static boolean hasBasePermission(GenericValue userLogin, HttpServletRequest request) { Security security = (Security) request.getAttribute("security"); if (security != null) { ServletContext context = (ServletContext) request.getAttribute("servletContext"); String serverId = (String) context.getAttribute("_serverId"); - // get a context path from the request, if it is empty then assume it is the root mount point String contextPath = request.getContextPath(); if (UtilValidate.isEmpty(contextPath)) { contextPath = "/"; } - ComponentConfig.WebappInfo info = ComponentConfig.getWebAppInfo(serverId, contextPath); if (info != null) { - for (String permission: info.getBasePermission()) { - if (!"NONE".equals(permission) && !security.hasEntityPermission(permission, "_VIEW", userLogin)) { - return false; - } - } + return hasApplicationPermission(info, security, userLogin); } else { Debug.logInfo("No webapp configuration found for : " + serverId + " / " + contextPath, module); } } else { Debug.logWarning("Received a null Security object from HttpServletRequest", module); } - return true; } + /** + * Returns a <code>Collection</code> of <code>WebappInfo</code> instances that the specified + * user is authorized to access. + * @param security + * @param userLogin + * @param serverName + * @param menuName + * @return A <code>Collection</code> <code>WebappInfo</code> instances that the specified + * user is authorized to access + */ + public static Collection<ComponentConfig.WebappInfo> getAppBarWebInfos(Security security, GenericValue userLogin, String serverName, String menuName) { + Collection<ComponentConfig.WebappInfo> allInfos = ComponentConfig.getAppBarWebInfos(serverName, menuName); + Collection<ComponentConfig.WebappInfo> allowedInfos = new ArrayList<ComponentConfig.WebappInfo>(allInfos.size()); + for (ComponentConfig.WebappInfo info : allInfos) { + if (hasApplicationPermission(info, security, userLogin)) { + allowedInfos.add(info); + } + } + return allowedInfos; + } + public static Map<String, Object> getUserLoginSession(GenericValue userLogin) { Delegator delegator = userLogin.getDelegator(); GenericValue userLoginSession; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java Mon Dec 2 20:59:22 2013 @@ -27,10 +27,13 @@ import java.util.TimeZone; import javolution.util.FastList; import org.apache.oro.text.regex.MalformedPatternException; -import org.ofbiz.base.util.CompilerMatcher; +import org.apache.oro.text.regex.Pattern; +import org.apache.oro.text.regex.PatternMatcher; +import org.apache.oro.text.regex.Perl5Matcher; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.PatternFactory; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; @@ -489,8 +492,6 @@ public class ModelMenuCondition { } public static class IfRegexp extends MenuCondition { - private transient static ThreadLocal<CompilerMatcher> compilerMatcher = CompilerMatcher.getThreadLocal(); - protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander exprExdr; @@ -504,6 +505,16 @@ public class ModelMenuCondition { @Override public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); + String expr = this.exprExdr.expandString(context); + Pattern pattern = null; + + try { + pattern = PatternFactory.createOrGetPerl5CompiledPattern(expr, true); + } catch (MalformedPatternException e) { + String errMsg = "Error in evaluation in if-regexp in screen: " + e.toString(); + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } String fieldString = null; try { @@ -514,13 +525,8 @@ public class ModelMenuCondition { // always use an empty string by default if (fieldString == null) fieldString = ""; - try { - return compilerMatcher.get().matches(fieldString, this.exprExdr.expandString(context)); - } catch (MalformedPatternException e) { - String errMsg = "Error in evaluation in if-regexp in screen: " + e.toString(); - Debug.logError(e, errMsg, module); - throw new IllegalArgumentException(errMsg); - } + PatternMatcher matcher = new Perl5Matcher(); + return matcher.matches(fieldString, pattern); } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java Mon Dec 2 20:59:22 2013 @@ -28,10 +28,13 @@ import java.util.TimeZone; import javolution.util.FastList; import org.apache.oro.text.regex.MalformedPatternException; -import org.ofbiz.base.util.CompilerMatcher; +import org.apache.oro.text.regex.Pattern; +import org.apache.oro.text.regex.PatternMatcher; +import org.apache.oro.text.regex.Perl5Matcher; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.PatternFactory; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; @@ -487,8 +490,6 @@ public class ModelScreenCondition implem } public static class IfRegexp extends ScreenCondition { - private transient static ThreadLocal<CompilerMatcher> compilerMatcher = CompilerMatcher.getThreadLocal(); - protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander exprExdr; @@ -502,6 +503,16 @@ public class ModelScreenCondition implem @Override public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); + String expr = this.exprExdr.expandString(context); + Pattern pattern; + + try { + pattern = PatternFactory.createOrGetPerl5CompiledPattern(expr, true); + } catch (MalformedPatternException e) { + String errMsg = "Error in evaluation in if-regexp in screen: " + e.toString(); + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } String fieldString = null; try { @@ -512,13 +523,8 @@ public class ModelScreenCondition implem // always use an empty string by default if (fieldString == null) fieldString = ""; - try { - return compilerMatcher.get().matches(fieldString, this.exprExdr.expandString(context)); - } catch (MalformedPatternException e) { - String errMsg = "Error in evaluation in if-regexp in screen: " + e.toString(); - Debug.logError(e, errMsg, module); - throw new IllegalArgumentException(errMsg); - } + PatternMatcher matcher = new Perl5Matcher(); + return matcher.matches(fieldString, pattern); } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java Mon Dec 2 20:59:22 2013 @@ -27,10 +27,13 @@ import java.util.TimeZone; import javolution.util.FastList; import org.apache.oro.text.regex.MalformedPatternException; -import org.ofbiz.base.util.CompilerMatcher; +import org.apache.oro.text.regex.Pattern; +import org.apache.oro.text.regex.PatternMatcher; +import org.apache.oro.text.regex.Perl5Matcher; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; +import org.ofbiz.base.util.PatternFactory; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; @@ -390,8 +393,6 @@ public class ModelTreeCondition { } public static class IfRegexp extends TreeCondition { - private transient static ThreadLocal<CompilerMatcher> compilerMatcher = CompilerMatcher.getThreadLocal(); - protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander exprExdr; @@ -405,6 +406,16 @@ public class ModelTreeCondition { @Override public boolean eval(Map<String, ? extends Object> context) { Object fieldVal = this.fieldAcsr.get(context); + String expr = this.exprExdr.expandString(context); + Pattern pattern = null; + + try { + pattern = PatternFactory.createOrGetPerl5CompiledPattern(expr, true); + } catch (MalformedPatternException e) { + String errMsg = "Error in evaluation in if-regexp in screen: " + e.toString(); + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } String fieldString = null; try { @@ -415,13 +426,8 @@ public class ModelTreeCondition { // always use an empty string by default if (fieldString == null) fieldString = ""; - try { - return compilerMatcher.get().matches(fieldString, this.exprExdr.expandString(context)); - } catch (MalformedPatternException e) { - String errMsg = "Error in evaluation in if-regexp in screen: " + e.toString(); - Debug.logError(e, errMsg, module); - throw new IllegalArgumentException(errMsg); - } + PatternMatcher matcher = new Perl5Matcher(); + return matcher.matches(fieldString, pattern); } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl Mon Dec 2 20:59:22 2013 @@ -248,8 +248,8 @@ under the License. <#list itemAdjustments as orderItemAdjustment> <tr> <td> - ${uiLabelMap.EcommerceAdjustment}: ${localOrderReadHelper.getAdjustmentType(orderItemAdjustment)} - <#if orderItemAdjustment.description?has_content>: ${orderItemAdjustment.description}</#if> + ${uiLabelMap.EcommerceAdjustment}: ${StringUtil.wrapString(localOrderReadHelper.getAdjustmentType(orderItemAdjustment))} + <#if orderItemAdjustment.description?has_content>: ${StringUtil.wrapString(orderItemAdjustment.description)}</#if> <#if orderItemAdjustment.orderAdjustmentTypeId == "SALES_TAX"> <#if orderItemAdjustment.primaryGeoId?has_content> <#assign primaryGeo = orderItemAdjustment.getRelatedOne("PrimaryGeo", true)/> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/src/org/ofbiz/content/search/ProductDocument.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/src/org/ofbiz/content/search/ProductDocument.java?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/src/org/ofbiz/content/search/ProductDocument.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/lucene/src/org/ofbiz/content/search/ProductDocument.java Mon Dec 2 20:59:22 2013 @@ -68,7 +68,7 @@ public class ProductDocument implements public Document prepareDocument(Delegator delegator) { String productId = getDocumentIdentifier().text(); try { - GenericValue product = delegator.findOne("Product", true, "productId", productId); + GenericValue product = delegator.findOne("Product", false, "productId", productId); if (product == null) { // Return a null document (we will remove the document from the index) return null; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/themes/flatgrey/includes/appbar.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/themes/flatgrey/includes/appbar.ftl?rev=1547192&r1=1547191&r2=1547192&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/themes/flatgrey/includes/appbar.ftl (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/themes/flatgrey/includes/appbar.ftl Mon Dec 2 20:59:22 2013 @@ -21,8 +21,8 @@ under the License. <#if (externalLoginKey)?exists><#assign externalKeyParam = "?externalLoginKey=" + requestAttributes.externalLoginKey?if_exists></#if> <#assign ofbizServerName = application.getAttribute("_serverId")?default("default-server")> <#assign contextPath = request.getContextPath()> -<#assign displayApps = Static["org.ofbiz.base.component.ComponentConfig"].getAppBarWebInfos(ofbizServerName, "main")> -<#assign displaySecondaryApps = Static["org.ofbiz.base.component.ComponentConfig"].getAppBarWebInfos(ofbizServerName, "secondary")> +<#assign displayApps = Static["org.ofbiz.webapp.control.LoginWorker"].getAppBarWebInfos(security, userLogin, ofbizServerName, "main")> +<#assign displaySecondaryApps = Static["org.ofbiz.webapp.control.LoginWorker"].getAppBarWebInfos(security, userLogin, ofbizServerName, "secondary")> <#if userLogin?has_content> <div id="main-navigation"> @@ -31,53 +31,34 @@ under the License. <#assign firstApp = true> <#list displayApps as display> <#assign thisApp = display.getContextRoot()> - <#assign permission = true> <#assign selected = false> - <#assign permissions = display.getBasePermission()> - <#list permissions as perm> - <#if (perm != "NONE" && !security.hasEntityPermission(perm, "_VIEW", session))> - <#-- User must have ALL permissions in the base-permission list --> - <#assign permission = false> - </#if> - </#list> - <#if permission == true> - <#if thisApp == contextPath || contextPath + "/" == thisApp> - <#assign selected = true> - </#if> - <#assign servletPath = Static["org.ofbiz.webapp.WebAppUtil"].getControlServletPath(display)> - <#assign thisURL = StringUtil.wrapString(servletPath)> - <#if thisApp != "/"> - <#assign thisURL = thisURL + "main"> - </#if> - <#if layoutSettings.suppressTab?exists && display.name == layoutSettings.suppressTab> - <#-- do not display this component--> - <#else> - <#if appCount % 4 == 0> - <#if firstApp> - <li class="first"> - <#assign firstApp = false> - <#else> - </li> - <li> - </#if> + <#if thisApp == contextPath || contextPath + "/" == thisApp> + <#assign selected = true> + </#if> + <#assign servletPath = Static["org.ofbiz.webapp.WebAppUtil"].getControlServletPath(display)> + <#assign thisURL = StringUtil.wrapString(servletPath)> + <#if thisApp != "/"> + <#assign thisURL = thisURL + "main"> + </#if> + <#if layoutSettings.suppressTab?exists && display.name == layoutSettings.suppressTab> + <#-- do not display this component--> + <#else> + <#if appCount % 4 == 0> + <#if firstApp> + <li class="first"> + <#assign firstApp = false> + <#else> + </li> + <li> </#if> - <a href="${thisURL}${externalKeyParam}"<#if selected> class="selected"</#if><#if uiLabelMap?exists> title="${uiLabelMap[display.description]}">${uiLabelMap[display.title]}<#else> title="${display.description}">${display.title}</#if></a> - <#assign appCount = appCount + 1> </#if> + <a href="${thisURL}${externalKeyParam}"<#if selected> class="selected"</#if><#if uiLabelMap?exists> title="${uiLabelMap[display.description]}">${uiLabelMap[display.title]}<#else> title="${display.description}">${display.title}</#if></a> + <#assign appCount = appCount + 1> </#if> </#list> <#list displaySecondaryApps as display> - <#assign thisApp = display.getContextRoot()> - <#assign permission = true> - <#assign selected = false> - <#assign permissions = display.getBasePermission()> - <#list permissions as perm> - <#if (perm != "NONE" && !security.hasEntityPermission(perm, "_VIEW", session))> - <#-- User must have ALL permissions in the base-permission list --> - <#assign permission = false> - </#if> - </#list> - <#if permission == true> + <#assign thisApp = display.getContextRoot()> + <#assign selected = false> <#if thisApp == contextPath || contextPath + "/" == thisApp> <#assign selected = true> </#if> @@ -97,12 +78,11 @@ under the License. </#if> <a href="${thisURL}${externalKeyParam}"<#if selected> class="selected"</#if><#if uiLabelMap?exists> title="${uiLabelMap[display.description]}">${uiLabelMap[display.title]}<#else> title="${display.description}">${display.title}</#if></a> <#assign appCount = appCount + 1> + </#list> + <#if appCount != 0> + </li> + <li class="last"></li> </#if> - </#list> - <#if appCount != 0> - </li> - <li class="last"></li> - </#if> </ul> </div> </#if> |
Free forum by Nabble | Edit this page |