From dev-return-111311-archive-asf-public=cust-asf.ponee.io@ofbiz.apache.org Mon Aug 20 06:25:57 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id A4B77180663 for ; Mon, 20 Aug 2018 06:25:55 +0200 (CEST) Received: (qmail 55416 invoked by uid 500); 20 Aug 2018 04:25:53 -0000 Mailing-List: contact dev-help@ofbiz.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ofbiz.apache.org Delivered-To: mailing list dev@ofbiz.apache.org Received: (qmail 55403 invoked by uid 99); 20 Aug 2018 04:25:52 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Aug 2018 04:25:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 4020DC0115 for ; Mon, 20 Aug 2018 04:25:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.138 X-Spam-Level: *** X-Spam-Status: No, score=3.138 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_REPLY=1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_DKIMWL_WL_MED=-0.01] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id HQ2lHyHzoO8I for ; Mon, 20 Aug 2018 04:25:37 +0000 (UTC) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 0F5B15F2AC for ; Mon, 20 Aug 2018 04:25:37 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id e23-v6so4516425lfc.13 for ; Sun, 19 Aug 2018 21:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=urxil0feDQJLxrZrLEpASOoU0i4bdjvHViaxlauf7os=; b=dsqKygtGrzvPgIOM0PLUAi6ltKrhAd0Pfhrsk8JUEHyFVb0aht7C3MhT2YFNNI/u4k Oyet86j3SDN39Kgd7o7JaMwtVwZUwUAYq8fIIeu5vrnePEG40gFiUSoG0BAJWe6Id2l9 jzGh6YOcDvQfdGPxo0UPgQu3Ta1k4KajPpHVbGulKQXJwW0GuIeQidNLfgQTo6nraqhX 3w0rw8+GsKymrQbOvKAoUe8uU/DnqammlErKRPsgyr83qKnVzidLemJe8Tkm6x3waYHT 5cgd6vrAzruBRvvLyupGXhnbqndoDQdkdqJ4IDFaq2Q1EKV2SOpyMgugK0ipWYNZmN3Q MwBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=urxil0feDQJLxrZrLEpASOoU0i4bdjvHViaxlauf7os=; b=WTTjtlZjv8C4IcitVbe784TzrPCiZg7tY/b32Uvn6BqyXT81cnnFCk6O5hEZB6iYmQ FKBOEr+jtSdmNknRij2asan2Ut5u9Bbgw1oqWViMU+yL6dtdqe8JZBVJ1Loma9jU2ScL NA3FiLOLTrMhQPImi3ZQmARbDQeMW7vKQuJ0agZg3y0TCw/ovGhsORJV4ULpnFxfukTz Y3iGcRvD/Ee2Q2g61rhgg7XcbnAQ8MgACcHCYHlKBHXLuTUkzRYVbCK6LSvclqvjs6eW qbo3HMtpwwR0C3Rrr8o1YA42x9rfBvNcRUzik8eQukqV66PN6r8IqLXMOHtOVdCgWClb Bc9Q== X-Gm-Message-State: AOUpUlGjsPkMIZ8psl2+TBKvQme0oUkC03/s6E1rHRXnTh2rDepmRQAB FYpIDeiAA9MBKiPdHDSskX4bGAZMwlBOgR3YsjlUmzI3 X-Google-Smtp-Source: AA+uWPwdAmEp8sDqB8qfXavdNmtiS1j2OnKs9iOSJ+8nQ1IJgEpgjl1ilSvGKG7H97N1oXy48ETeHuX+gvttx050Tio= X-Received: by 2002:a19:4ed1:: with SMTP id u78-v6mr7074190lfk.0.1534739135022; Sun, 19 Aug 2018 21:25:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: deepak nigam Date: Mon, 20 Aug 2018 09:55:22 +0530 Message-ID: Subject: Re: svn commit: r1838081 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/util/collections/ base/src/test/java/org/apache/ofbiz/base/collections/ webapp/config/ webapp/dtd/ webapp/src/main/java/org/apache/ofbiz/weba... To: dev@ofbiz.apache.org Content-Type: multipart/alternative; boundary="000000000000f749990573d64cd7" --000000000000f749990573d64cd7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Shi/Rishi, I was using the trunk downloaded from GitHub ( https://github.com/apache/ofbiz-framework). I will reverify this issue on SVN trunk and will let you know the details. On Mon, Aug 20, 2018 at 1:37 AM Shi Jinghai wrote: > Hi Deepak, > > As Rishi suggested, could you please reopen OFBIZ-10438 or create a new > jira for the bug you mentioned here? > > I cannot reproduce it in my local and online trunk demo environments, I > guess my test case is not the same as yours. > > Thanks, > > Shi Jinghai > > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: Rishi Solanki [mailto:rishisolankii@gmail.co= m] > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2018=E5=B9=B48=E6=9C=8817=E6=97=A5 = 21:24 > =E6=94=B6=E4=BB=B6=E4=BA=BA: dev@ofbiz.apache.org > =E6=8A=84=E9=80=81: commits@ofbiz.apache.org > =E4=B8=BB=E9=A2=98: Re: svn commit: r1838081 - in /ofbiz/ofbiz-framework/= trunk/framework: > base/src/main/java/org/apache/ofbiz/base/util/collections/ > base/src/test/java/org/apache/ofbiz/base/collections/ webapp/config/ > webapp/dtd/ webapp/src/main/java/org/apache/ofbiz/weba... > > Deepak, > > Thanks for reporting the issue, can you please create Jira ticket and add > details (images are not coming at mailing list) with logs if possible? > > > > Rishi Solanki > Sr Manager, Enterprise Software Development > HotWax Systems Pvt. Ltd. > Direct: +91-9893287847 > http://www.hotwaxsystems.com > www.hotwax.co > > On Fri, Aug 17, 2018 at 6:32 PM, deepak nigam > wrote: > > > I am using OFBiz trunk and on creating an order from backend and gettin= g > > error screens while adding an item to cart and selecting shipping > methods. > > Please find the attached images for your reference. > > > > On further investigation, I found that on reverting this commit things > are > > working fine. Can we verify this commit once more? > > > > On Wed, Aug 15, 2018 at 5:15 PM wrote: > > > >> Author: shijh > >> Date: Wed Aug 15 11:45:45 2018 > >> New Revision: 1838081 > >> > >> URL: http://svn.apache.org/viewvc?rev=3D1838081&view=3Drev > >> Log: > >> Implemented: Add method attribute to request-map to controll a uri can > be > >> called GET or POST only > >> OFBIZ-10438 > >> > >> Thanks: Mathieu Lirzin for the contribution. > >> > >> Added: > >> ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContext.java > >> (with props) > >> ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContextAdapter.ja= va > >> (with props) > >> ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/ > >> ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.ja= va > >> (with props) > >> ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextTests.java > >> (with props) > >> ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/MethodNotAllowedException.java > >> (with props) > >> ofbiz/ofbiz-framework/trunk/framework/webapp/src/test/ > >> java/org/apache/ofbiz/webapp/control/RequestHandlerTests.java (with > >> props) > >> Modified: > >> ofbiz/ofbiz-framework/trunk/framework/webapp/config/ > >> WebappUiLabels.xml > >> ofbiz/ofbiz-framework/trunk/framework/webapp/dtd/site-conf.xsd > >> ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java > >> ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ControlServlet.java > >> ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/RequestHandler.java > >> > >> Added: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContext.java > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ > >> MultivaluedMapContext.java?rev=3D1838081&view=3Dauto > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContext.java > (added) > >> +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContext.java Wed > >> Aug 15 11:45:45 2018 > >> @@ -0,0 +1,87 @@ > >> +/********************************************************** > >> ********************* > >> + * Licensed to the Apache Software Foundation (ASF) under one > >> + * or more contributor license agreements. See the NOTICE file > >> + * distributed with this work for additional information > >> + * regarding copyright ownership. The ASF licenses this file > >> + * to you under the Apache License, Version 2.0 (the > >> + * "License"); you may not use this file except in compliance > >> + * with the License. You may obtain a copy of the License at > >> + * > >> + * http://www.apache.org/licenses/LICENSE-2.0 > >> + * > >> + * Unless required by applicable law or agreed to in writing, > >> + * software distributed under the License is distributed on an > >> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > >> + * KIND, either express or implied. See the License for the > >> + * specific language governing permissions and limitations > >> + * under the License. > >> + ************************************************************ > >> *******************/ > >> +package org.apache.ofbiz.base.util.collections; > >> + > >> +import java.util.LinkedList; > >> +import java.util.List; > >> + > >> +/** > >> + * MultivaluedMap Context > >> + * > >> + * A MapContext which handles multiple values for the same key. > >> + */ > >> +public class MultivaluedMapContext extends MapContext List> { > >> + > >> + public static final String module =3D MultivaluedMapContext.class= . > >> getName(); > >> + > >> + /** > >> + * Create a multi-value map initialized with one context > >> + */ > >> + public MultivaluedMapContext() { > >> + push(); > >> + } > >> + > >> + /** > >> + * Associate {@code key} with the single value {@code value}. > >> + * If other values are already associated with {@code key} then > >> override them. > >> + * > >> + * @param key the key to associate {@code value} with > >> + * @param value the value to add to the context > >> + */ > >> + public void putSingle(K key, V value) { > >> + List box =3D new LinkedList<>(); > >> + box.add(value); > >> + put(key, box); > >> + } > >> + > >> + /** > >> + * Associate {@code key} with the single value {@code value}. > >> + * If other values are already associated with {@code key}, > >> + * then add {@code value} to them. > >> + * > >> + * @param key the key to associate {@code value} with > >> + * @param value the value to add to the context > >> + */ > >> + public void add(K key, V value) { > >> + List cur =3D contexts.getFirst().get(key); > >> + if (cur =3D=3D null) { > >> + cur =3D new LinkedList<>(); > >> + /* if this method is called after a context switch, copy > the > >> previous values > >> + in current context to not mask them. */ > >> + List old =3D get(key); > >> + if (old !=3D null) { > >> + cur.addAll(old); > >> + } > >> + } > >> + cur.add(value); > >> + put(key, cur); > >> + } > >> + > >> + /** > >> + * Get the first value contained in the list of values associated > >> with {@code key}. > >> + * > >> + * @param key a candidate key > >> + * @return the first value associated with {@code key} or null if > no > >> value > >> + * is associated with it. > >> + */ > >> + public V getFirst(Object key) { > >> + List res =3D get(key); > >> + return res =3D=3D null ? null : res.get(0); > >> + } > >> +} > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContext.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:eol-style =3D native > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContext.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:keywords =3D Date Rev Author URL Id > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContext.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:mime-type =3D text/plain > >> > >> Added: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContextAdapter.ja= va > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ > >> MultivaluedMapContextAdapter.java?rev=3D1838081&view=3Dauto > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContextAdapter.ja= va > >> (added) > >> +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContextAdapter.ja= va > >> Wed Aug 15 11:45:45 2018 > >> @@ -0,0 +1,103 @@ > >> +/********************************************************** > >> ********************* > >> + * Licensed to the Apache Software Foundation (ASF) under one > >> + * or more contributor license agreements. See the NOTICE file > >> + * distributed with this work for additional information > >> + * regarding copyright ownership. The ASF licenses this file > >> + * to you under the Apache License, Version 2.0 (the > >> + * "License"); you may not use this file except in compliance > >> + * with the License. You may obtain a copy of the License at > >> + * > >> + * http://www.apache.org/licenses/LICENSE-2.0 > >> + * > >> + * Unless required by applicable law or agreed to in writing, > >> + * software distributed under the License is distributed on an > >> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > >> + * KIND, either express or implied. See the License for the > >> + * specific language governing permissions and limitations > >> + * under the License. > >> + ************************************************************ > >> *******************/ > >> +package org.apache.ofbiz.base.util.collections; > >> + > >> +import java.util.Collection; > >> +import java.util.Map; > >> +import java.util.Set; > >> +import java.util.stream.Collectors; > >> + > >> +// Adapter which allows viewing a multi-value map as a single-value > map. > >> +public class MultivaluedMapContextAdapter implements Map = { > >> + private MultivaluedMapContext adaptee; > >> + > >> + public MultivaluedMapContextAdapter(MultivaluedMapContext > >> adaptee) { > >> + this.adaptee =3D adaptee; > >> + } > >> + > >> + @Override > >> + public int size() { > >> + return adaptee.size(); > >> + } > >> + > >> + @Override > >> + public boolean isEmpty() { > >> + return adaptee.isEmpty(); > >> + } > >> + > >> + @Override > >> + public boolean containsKey(Object key) { > >> + return adaptee.containsKey(key); > >> + } > >> + > >> + @Override > >> + public boolean containsValue(Object value) { > >> + return adaptee.values().stream() > >> + .map(l -> l.get(0)) > >> + .anyMatch(value::equals); > >> + } > >> + > >> + @Override > >> + public V get(Object key) { > >> + return adaptee.getFirst(key); > >> + } > >> + > >> + @Override > >> + public V put(K key, V value) { > >> + V prev =3D get(key); > >> + adaptee.putSingle(key, value); > >> + return prev; > >> + } > >> + > >> + @Override > >> + public V remove(Object key) { > >> + V prev =3D get(key); > >> + adaptee.remove(key); > >> + return prev; > >> + } > >> + > >> + @Override > >> + public void putAll(Map m) { > >> + m.forEach(adaptee::putSingle); > >> + } > >> + > >> + @Override > >> + public void clear() { > >> + adaptee.clear(); > >> + } > >> + > >> + @Override > >> + public Set keySet() { > >> + return adaptee.keySet(); > >> + } > >> + > >> + @Override > >> + public Collection values() { > >> + return adaptee.values().stream() > >> + .map(l -> l.get(0)) > >> + .collect(Collectors.toList()); > >> + } > >> + > >> + @Override > >> + public Set> entrySet() { > >> + return adaptee.keySet().stream() > >> + .collect(Collectors.toMap(k -> k, k -> get(k))) > >> + .entrySet(); > >> + } > >> +} > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContextAdapter.ja= va > >> ------------------------------------------------------------ > >> ------------------ > >> svn:eol-style =3D native > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContextAdapter.ja= va > >> ------------------------------------------------------------ > >> ------------------ > >> svn:keywords =3D Date Rev Author URL Id > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/ > >> org/apache/ofbiz/base/util/collections/MultivaluedMapContextAdapter.ja= va > >> ------------------------------------------------------------ > >> ------------------ > >> svn:mime-type =3D text/plain > >> > >> Added: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.ja= va > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/base/src/test/java/org/apache/ofbiz/base/collections/ > >> MultivaluedMapContextAdapterTests.java?rev=3D1838081&view=3Dauto > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.ja= va > >> (added) > >> +++ ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.ja= va > >> Wed Aug 15 11:45:45 2018 > >> @@ -0,0 +1,70 @@ > >> +/********************************************************** > >> ********************* > >> + * Licensed to the Apache Software Foundation (ASF) under one > >> + * or more contributor license agreements. See the NOTICE file > >> + * distributed with this work for additional information > >> + * regarding copyright ownership. The ASF licenses this file > >> + * to you under the Apache License, Version 2.0 (the > >> + * "License"); you may not use this file except in compliance > >> + * with the License. You may obtain a copy of the License at > >> + * > >> + * http://www.apache.org/licenses/LICENSE-2.0 > >> + * > >> + * Unless required by applicable law or agreed to in writing, > >> + * software distributed under the License is distributed on an > >> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > >> + * KIND, either express or implied. See the License for the > >> + * specific language governing permissions and limitations > >> + * under the License. > >> + ************************************************************ > >> *******************/ > >> +package org.apache.ofbiz.base.collections; > >> + > >> +import static org.hamcrest.CoreMatchers.hasItems; > >> +import static org.hamcrest.CoreMatchers.is; > >> +import static org.junit.Assert.assertEquals; > >> +import static org.junit.Assert.assertFalse; > >> +import static org.junit.Assert.assertThat; > >> +import static org.junit.Assert.assertTrue; > >> + > >> +import java.util.HashMap; > >> + > >> +import org.apache.ofbiz.base.util.collections.MultivaluedMapContext; > >> +import org.apache.ofbiz.base.util.collections. > >> MultivaluedMapContextAdapter; > >> +import org.junit.Before; > >> +import org.junit.Test; > >> + > >> +public class MultivaluedMapContextAdapterTests { > >> + private MultivaluedMapContext adaptee; > >> + private MultivaluedMapContextAdapter adapter; > >> + > >> + @Before > >> + public void setUp() throws Exception { > >> + adaptee =3D new MultivaluedMapContext<>(); > >> + adaptee.add("foo", 0); > >> + adaptee.add("foo", 1); > >> + adaptee.add("foo", 2); > >> + adaptee.add("bar", 3); > >> + adapter =3D new MultivaluedMapContextAdapter<>(adaptee); > >> + } > >> + > >> + @Test > >> + public void containsValueBasic() { > >> + assertTrue(adapter.containsValue(0)); > >> + assertFalse(adapter.containsValue(1)); > >> + assertFalse(adapter.containsValue(2)); > >> + assertTrue(adapter.containsValue(3)); > >> + } > >> + > >> + @Test > >> + public void valuesBasic() { > >> + assertThat(adapter.values(), hasItems(0, 3)); > >> + assertThat(adapter.values().size(), is(2)); > >> + } > >> + > >> + @Test > >> + public void entrySetBasic() { > >> + HashMap expected =3D new HashMap<>(); > >> + expected.put("foo", 0); > >> + expected.put("bar", 3); > >> + assertEquals(expected.entrySet(), adapter.entrySet()); > >> + } > >> +} > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.ja= va > >> ------------------------------------------------------------ > >> ------------------ > >> svn:eol-style =3D native > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.ja= va > >> ------------------------------------------------------------ > >> ------------------ > >> svn:keywords =3D Date Rev Author URL Id > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.ja= va > >> ------------------------------------------------------------ > >> ------------------ > >> svn:mime-type =3D text/plain > >> > >> Added: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextTests.java > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/base/src/test/java/org/apache/ofbiz/base/collections/ > >> MultivaluedMapContextTests.java?rev=3D1838081&view=3Dauto > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextTests.java > (added) > >> +++ ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextTests.java Wed > >> Aug 15 11:45:45 2018 > >> @@ -0,0 +1,82 @@ > >> +/********************************************************** > >> ********************* > >> + * Licensed to the Apache Software Foundation (ASF) under one > >> + * or more contributor license agreements. See the NOTICE file > >> + * distributed with this work for additional information > >> + * regarding copyright ownership. The ASF licenses this file > >> + * to you under the Apache License, Version 2.0 (the > >> + * "License"); you may not use this file except in compliance > >> + * with the License. You may obtain a copy of the License at > >> + * > >> + * http://www.apache.org/licenses/LICENSE-2.0 > >> + * > >> + * Unless required by applicable law or agreed to in writing, > >> + * software distributed under the License is distributed on an > >> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > >> + * KIND, either express or implied. See the License for the > >> + * specific language governing permissions and limitations > >> + * under the License. > >> + ************************************************************ > >> *******************/ > >> +package org.apache.ofbiz.base.collections; > >> + > >> +import static org.hamcrest.CoreMatchers.both; > >> +import static org.hamcrest.CoreMatchers.hasItem; > >> +import static org.hamcrest.CoreMatchers.hasItems; > >> +import static org.hamcrest.CoreMatchers.is; > >> +import static org.hamcrest.CoreMatchers.not; > >> +import static org.hamcrest.CoreMatchers.nullValue; > >> +import static org.junit.Assert.assertThat; > >> + > >> +import org.apache.ofbiz.base.util.collections.MultivaluedMapContext; > >> +import org.junit.Before; > >> +import org.junit.Test; > >> + > >> +public class MultivaluedMapContextTests { > >> + private MultivaluedMapContext m; > >> + > >> + @Before > >> + public void setUp() throws Exception { > >> + m =3D new MultivaluedMapContext<>(); > >> + } > >> + > >> + @Test > >> + public void getEmpty() { > >> + assertThat(m.get("foo"), is(nullValue())); > >> + } > >> + > >> + @Test > >> + public void putSingleBasic() { > >> + m.putSingle("foo", 0); > >> + assertThat(m.get("foo"), hasItem(0)); > >> + m.putSingle("foo", 1); > >> + assertThat(m.get("foo"), > both(hasItem(1)).and(not(hasItem(0)))); > >> + } > >> + > >> + @Test > >> + public void addBasic() { > >> + m.add("foo", 0); > >> + assertThat(m.get("foo"), hasItem(0)); > >> + m.add("foo", 1); > >> + assertThat(m.get("foo"), hasItems(0, 1)); > >> + } > >> + > >> + @Test > >> + public void addWithPreviousContext() { > >> + m.add("foo", 0); > >> + m.push(); > >> + assertThat(m.get("foo"), hasItem(0)); > >> + m.add("foo", 1); > >> + assertThat(m.get("foo"), hasItems(0, 1)); > >> + } > >> + > >> + @Test > >> + public void getFirstBasic() { > >> + m.add("foo", 0); > >> + m.add("foo", 1); > >> + assertThat(m.getFirst("foo"), is(0)); > >> + } > >> + > >> + @Test > >> + public void getFirstEmpty() { > >> + assertThat(m.getFirst("foo"), is(nullValue())); > >> + } > >> +} > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextTests.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:eol-style =3D native > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextTests.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:keywords =3D Date Rev Author URL Id > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/ > >> org/apache/ofbiz/base/collections/MultivaluedMapContextTests.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:mime-type =3D text/plain > >> > >> Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/config/ > >> WebappUiLabels.xml > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/webapp/config/WebappUiLabels.xml?rev=3D > >> 1838081&r1=3D1838080&r2=3D1838081&view=3Ddiff > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- > ofbiz/ofbiz-framework/trunk/framework/webapp/config/WebappUiLabels.xml > >> (original) > >> +++ > ofbiz/ofbiz-framework/trunk/framework/webapp/config/WebappUiLabels.xml > >> Wed Aug 15 11:45:45 2018 > >> @@ -339,4 +339,8 @@ > >> =C3=A6=C2=B2=C2=A1=C3=A6=C5=93=E2=80= =B0=C3=A5=C2=AE=C5=92=C3=A6=CB=86 =C3=A4=C2=BA=E2=80=B9=C3=A4=C2=BB=C2=B6 > >> =C3=A6=C2=B2=E2=80=99=C3=A6=C5=93= =E2=80=B0=C3=A5=C2=AE=C5=92=C3=A6=CB=86 =C3=A4=C2=BA=E2=80=B9=C3=A4=C2=BB= =C2=B6 > >> > >> + > >> + [{0}] cannot be called by [{1}] > >> method. > >> + [{0}]=C3=A4=C2=B8 =C3=A8=C6=92=C2=BD= =C3=A7=E2=80=9D=C2=A8[{1}]=C3=A6=E2=80=93=C2=B9=C3=A6=C2=B3=E2=80=A2=C3=A8= =C2=AF=C2=B7=C3=A6=C2=B1=E2=80=9A=C3=A3=E2=82=AC=E2=80=9A > >> + > >> > >> > >> Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/dtd/site-conf.x= sd > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/webapp/dtd/site-conf.xsd?rev=3D1838081&r1=3D > >> 1838080&r2=3D1838081&view=3Ddiff > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/webapp/dtd/site-conf.xsd > >> (original) > >> +++ ofbiz/ofbiz-framework/trunk/framework/webapp/dtd/site-conf.xsd Wed > >> Aug 15 11:45:45 2018 > >> @@ -216,6 +216,24 @@ under the License. > >> > >> > >> > >> + > >> + > >> + > >> + The HTTP of this request. This will be the HTTP > >> method used to access the request. > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> + > >> > >> > >> > >> > >> Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/webapp/src/main/java/org/apache/ofbiz/webapp/ > >> control/ConfigXMLReader.java?rev=3D1838081&r1=3D1838080&r2=3D1838081&v= iew=3Ddiff > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (original) > >> +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Wed Aug 15 > >> 11:45:45 2018 > >> @@ -49,6 +49,8 @@ import org.apache.ofbiz.base.util.UtilVa > >> import org.apache.ofbiz.base.util.UtilXml; > >> import org.apache.ofbiz.base.util.cache.UtilCache; > >> import org.apache.ofbiz.base.util.collections.MapContext; > >> +import org.apache.ofbiz.base.util.collections.MultivaluedMapContext; > >> +import org.apache.ofbiz.base.util.collections. > >> MultivaluedMapContextAdapter; > >> import org.w3c.dom.Document; > >> import org.w3c.dom.Element; > >> > >> @@ -192,7 +194,7 @@ public class ConfigXMLReader { > >> private Map beforeLogoutEventList =3D new > >> LinkedHashMap(); > >> private Map eventHandlerMap =3D new > >> HashMap(); > >> private Map viewHandlerMap =3D new > HashMap >> String>(); > >> - private Map requestMapMap =3D new > >> HashMap(); > >> + private MultivaluedMapContext requestMapM= ap > >> =3D new MultivaluedMapContext<>(); > >> private Map viewMapMap =3D new HashMap >> ViewMap>(); > >> > >> public ControllerConfig(URL url) throws > >> WebAppConfigurationException { > >> @@ -276,11 +278,16 @@ public class ConfigXMLReader { > >> return getIncludes(ccfg -> ccfg.protectView); > >> } > >> > >> + // XXX: Keep it for backward compatibility until moving > >> everything to =C3=A9=CB=86=C2=A5=C3=A6=C2=A6=C5=BEetRequestMapMultiMap= =C3=A9=CB=86=C2=A5=C3=AF=C2=BF=C2=BD. > >> public Map getRequestMapMap() throws > >> WebAppConfigurationException { > >> - MapContext result =3D new MapContext<= >(); > >> + return new MultivaluedMapContextAdapter<> > >> (getRequestMapMultiMap()); > >> + } > >> + > >> + public MultivaluedMapContext > >> getRequestMapMultiMap() throws WebAppConfigurationException { > >> + MultivaluedMapContext result =3D new > >> MultivaluedMapContext<>(); > >> for (URL includeLocation : includes) { > >> ControllerConfig controllerConfig =3D > getControllerConfig( > >> includeLocation); > >> - result.push(controllerConfig.getRequestMapMap()); > >> + result.push(controllerConfig.getRequestMapMultiMap())= ; > >> } > >> result.push(requestMapMap); > >> return result; > >> @@ -403,7 +410,7 @@ public class ConfigXMLReader { > >> private void loadRequestMap(Element root) { > >> for (Element requestMapElement : > >> UtilXml.childElementList(root, "request-map")) { > >> RequestMap requestMap =3D new > >> RequestMap(requestMapElement); > >> - this.requestMapMap.put(requestMap.uri, requestMap); > >> + this.requestMapMap.add(requestMap.uri, requestMap); > >> } > >> } > >> > >> @@ -450,6 +457,7 @@ public class ConfigXMLReader { > >> > >> public static class RequestMap { > >> public String uri; > >> + public String method; > >> public boolean edit =3D true; > >> public boolean trackVisit =3D true; > >> public boolean trackServerHit =3D true; > >> @@ -466,6 +474,7 @@ public class ConfigXMLReader { > >> public RequestMap(Element requestMapElement) { > >> // Get the URI info > >> this.uri =3D requestMapElement.getAttribute("uri"); > >> + this.method =3D requestMapElement.getAttribute("method"); > >> this.edit =3D !"false".equals(requestMapElement. > >> getAttribute("edit")); > >> this.trackServerHit =3D !"false".equals(requestMapElement= . > >> getAttribute("track-serverhit")); > >> this.trackVisit =3D !"false".equals(requestMapElement. > >> getAttribute("track-visit")); > >> > >> Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ControlServlet.java > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/webapp/src/main/java/org/apache/ofbiz/webapp/ > >> control/ControlServlet.java?rev=3D1838081&r1=3D1838080&r2=3D1838081&vi= ew=3Ddiff > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ControlServlet.java (original) > >> +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/ControlServlet.java Wed Aug 15 > >> 11:45:45 2018 > >> @@ -211,6 +211,12 @@ public class ControlServlet extends Http > >> try { > >> // the ServerHitBin call for the event is done inside the > >> doRequest method > >> requestHandler.doRequest(request, response, null, > >> userLogin, delegator); > >> + } catch (MethodNotAllowedException e) { > >> + response.setContentType("text/plain"); > >> + > response.setCharacterEncoding(request.getCharacterEncoding() > >> ); > >> + response.setStatus(HttpServletResponse.SC_METHOD_ > >> NOT_ALLOWED); > >> + response.getWriter().print(e.getMessage()); > >> + Debug.logError(e.getMessage(), module); > >> } catch (RequestHandlerException e) { > >> Throwable throwable =3D e.getNested() !=3D null ? e.getNe= sted() > >> : e; > >> if (throwable instanceof IOException) { > >> > >> Added: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/MethodNotAllowedException.java > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ > >> MethodNotAllowedException.java?rev=3D1838081&view=3Dauto > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/MethodNotAllowedException.java > >> (added) > >> +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/MethodNotAllowedException.java We= d > >> Aug 15 11:45:45 2018 > >> @@ -0,0 +1,26 @@ > >> +/********************************************************** > >> ********************* > >> + * Licensed to the Apache Software Foundation (ASF) under one > >> + * or more contributor license agreements. See the NOTICE file > >> + * distributed with this work for additional information > >> + * regarding copyright ownership. The ASF licenses this file > >> + * to you under the Apache License, Version 2.0 (the > >> + * "License"); you may not use this file except in compliance > >> + * with the License. You may obtain a copy of the License at > >> + * > >> + * http://www.apache.org/licenses/LICENSE-2.0 > >> + * > >> + * Unless required by applicable law or agreed to in writing, > >> + * software distributed under the License is distributed on an > >> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > >> + * KIND, either express or implied. See the License for the > >> + * specific language governing permissions and limitations > >> + * under the License. > >> + ************************************************************ > >> *******************/ > >> +package org.apache.ofbiz.webapp.control; > >> + > >> +@SuppressWarnings("serial") > >> +public class MethodNotAllowedException extends RequestHandlerExceptio= n > { > >> + MethodNotAllowedException(String str) { > >> + super(str); > >> + } > >> +} > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/MethodNotAllowedException.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:eol-style =3D native > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/MethodNotAllowedException.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:keywords =3D Date Rev Author URL Id > >> > >> Propchange: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/MethodNotAllowedException.java > >> ------------------------------------------------------------ > >> ------------------ > >> svn:mime-type =3D text/plain > >> > >> Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/RequestHandler.java > >> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/ > >> framework/webapp/src/main/java/org/apache/ofbiz/webapp/ > >> control/RequestHandler.java?rev=3D1838081&r1=3D1838080&r2=3D1838081&vi= ew=3Ddiff > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> --- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/RequestHandler.java (original) > >> +++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/ > >> java/org/apache/ofbiz/webapp/control/RequestHandler.java Wed Aug 15 > >> 11:45:45 2018 > >> @@ -24,11 +24,15 @@ import java.io.IOException; > >> import java.io.Serializable; > >> import java.net.URL; > >> import java.security.cert.X509Certificate; > >> + > >> +import java.util.Collection; > >> +import java.util.Collections; > >> import java.util.Enumeration; > >> import java.util.HashMap; > >> import java.util.List; > >> import java.util.Locale; > >> import java.util.Map; > >> +import java.util.Optional; > >> > >> import javax.servlet.ServletContext; > >> import javax.servlet.http.HttpServletRequest; > >> @@ -45,12 +49,14 @@ import org.apache.ofbiz.base.util.UtilMi > >> import org.apache.ofbiz.base.util.UtilObject; > >> import org.apache.ofbiz.base.util.UtilProperties; > >> import org.apache.ofbiz.base.util.UtilValidate; > >> +import org.apache.ofbiz.base.util.collections.MultivaluedMapContext; > >> import org.apache.ofbiz.entity.Delegator; > >> import org.apache.ofbiz.entity.GenericEntityException; > >> import org.apache.ofbiz.entity.GenericValue; > >> import org.apache.ofbiz.entity.util.EntityQuery; > >> import org.apache.ofbiz.entity.util.EntityUtilProperties; > >> import org.apache.ofbiz.webapp.OfbizUrlBuilder; > >> +import org.apache.ofbiz.webapp.control.ConfigXMLReader.RequestMap; > >> import org.apache.ofbiz.webapp.event.EventFactory; > >> import org.apache.ofbiz.webapp.event.EventHandler; > >> import org.apache.ofbiz.webapp.event.EventHandlerException; > >> @@ -68,12 +74,74 @@ import org.apache.ofbiz.widget.model.The > >> public class RequestHandler { > >> > >> public static final String module =3D RequestHandler.class.getNam= e(); > >> - private final String defaultStatusCodeString =3D UtilProperties. > >> getPropertyValue("requestHandler", "status-code", "302"); > >> + private final static String defaultStatusCodeString =3D > >> + UtilProperties.getPropertyValue("requestHandler", > >> "status-code", "302"); > >> private final ViewFactory viewFactory; > >> private final EventFactory eventFactory; > >> private final URL controllerConfigURL; > >> private final boolean trackServerHit; > >> private final boolean trackVisit; > >> + private ControllerConfig ccfg; > >> + > >> + static class ControllerConfig { > >> + private final MultivaluedMapContext > >> requestMapMap; > >> + private final Map viewMapMap= ; > >> + private String statusCodeString; > >> + private final String defaultRequest; > >> + private final Map > >> firstVisitEventList; > >> + private final Map > >> preprocessorEventList; > >> + private final Map > >> postprocessorEventList; > >> + private final String protectView; > >> + > >> + ControllerConfig(ConfigXMLReader.ControllerConfig ccfg) throw= s > >> WebAppConfigurationException { > >> + preprocessorEventList =3D ccfg.getPreprocessorEventList()= ; > >> + postprocessorEventList =3D ccfg.getPostprocessorEventList= (); > >> + requestMapMap =3D ccfg.getRequestMapMultiMap(); > >> + viewMapMap =3D ccfg.getViewMapMap(); > >> + defaultRequest =3D ccfg.getDefaultRequest(); > >> + firstVisitEventList =3D ccfg.getFirstVisitEventList(); > >> + protectView =3D ccfg.getProtectView(); > >> + > >> + String status =3D ccfg.getStatusCode(); > >> + statusCodeString =3D UtilValidate.isEmpty(status) ? > >> defaultStatusCodeString : status; > >> + } > >> + > >> + public MultivaluedMapContext > >> getRequestMapMap() { > >> + return requestMapMap; > >> + } > >> + > >> + public Map getViewMapMap() { > >> + return viewMapMap; > >> + } > >> + > >> + public String getStatusCodeString() { > >> + return statusCodeString; > >> + } > >> + > >> + public String getDefaultRequest() { > >> + return defaultRequest; > >> + } > >> + > >> + public void setStatusCodeString(String statusCodeString) { > >> + this.statusCodeString =3D statusCodeString; > >> + } > >> + > >> + public Map > >> getFirstVisitEventList() { > >> + return firstVisitEventList; > >> + } > >> + > >> + public Map > >> getPreprocessorEventList() { > >> + return preprocessorEventList; > >> + } > >> + > >> + public Map > >> getPostprocessorEventList() { > >> + return postprocessorEventList; > >> + } > >> + > >> + public String getProtectView() { > >> + return protectView; > >> + } > >> + } > >> > >> public static RequestHandler getRequestHandler(ServletContext > >> servletContext) { > >> RequestHandler rh =3D (RequestHandler) > >> servletContext.getAttribute("_REQUEST_HANDLER_"); > >> @@ -110,6 +178,56 @@ public class RequestHandler { > >> return null; > >> } > >> > >> + /** > >> + * Find a collection of request maps in {@code ccfg} matching > {@code > >> req}. > >> + * Otherwise fall back to matching the {@code defaultReq} field i= n > >> {@code ccfg}. > >> + * > >> + * @param ccfg The controller containing the current configuratio= n > >> + * @param req The HTTP request to match > >> + * @return a collection of request maps which might be empty > >> + */ > >> + static Collection resolveURI(ControllerConfig ccfg, > >> HttpServletRequest req) { > >> + Map> requestMapMap =3D > >> ccfg.getRequestMapMap(); > >> + Map viewMapMap =3D > >> ccfg.getViewMapMap(); > >> + String defaultRequest =3D ccfg.getDefaultRequest(); > >> + String path =3D req.getPathInfo(); > >> + String requestUri =3D getRequestUri(path); > >> + String viewUri =3D getOverrideViewUri(path); > >> + Collection rmaps; > >> + if (requestMapMap.containsKey(requestUri) && > >> !viewMapMap.containsKey(viewUri)) { > >> + rmaps =3D requestMapMap.get(requestUri); > >> + } else if (defaultRequest !=3D null) { > >> + rmaps =3D requestMapMap.get(defaultRequest); > >> + } else { > >> + rmaps =3D null; > >> + } > >> + return rmaps !=3D null ? rmaps : Collections.emptyList(); > >> + } > >> + > >> + /** > >> + * Find the request map matching {@code method}. > >> + * Otherwise fall back to the one matching the "all" and "" speci= al > >> methods > >> + * in that respective order. > >> + * > >> + * @param method the HTTP method to match > >> + * @param rmaps the collection of request map candidates > >> + * @return a request map {@code Optional} > >> + */ > >> + static Optional resolveMethod(String method, > >> Collection rmaps) { > >> + for (RequestMap map : rmaps) { > >> + if (map.method.equalsIgnoreCase(method)) { > >> + return Optional.of(map); > >> + } > >> + } > >> + if (method.isEmpty()) { > >> + return Optional.empty(); > >> + } else if (method.equals("all")) { > >> + return resolveMethod("", rmaps); > >> + } else { > >> + return resolveMethod("all", rmaps); > >> + } > >> + } > >> + > >> public void doRequest(HttpServletRequest request, > >> HttpServletResponse response, String requestUri) throws > >> RequestHandlerException, RequestHandlerExceptionAllowExternalRequests = { > >> HttpSession session =3D request.getSession(); > >> Delegator delegator =3D (Delegator) request.getAttribute(" > >> delegator"); > >> @@ -125,20 +243,13 @@ public class RequestHandler { > >> long startTime =3D System.currentTimeMillis(); > >> HttpSession session =3D request.getSession(); > >> > >> - // get the controllerConfig once for this method so we don't > >> have to get it over and over inside the method > >> - ConfigXMLReader.ControllerConfig controllerConfig =3D > >> this.getControllerConfig(); > >> - Map requestMapMap =3D nul= l; > >> - String statusCodeString =3D null; > >> + // Parse controller config. > >> try { > >> - requestMapMap =3D controllerConfig.getRequestMapMap(); > >> - statusCodeString =3D controllerConfig.getStatusCode(); > >> + ccfg =3D new ControllerConfig(getControllerConfig()); > >> } catch (WebAppConfigurationException e) { > >> Debug.logError(e, "Exception thrown while parsing > >> controller.xml file: ", module); > >> throw new RequestHandlerException(e); > >> } > >> - if (UtilValidate.isEmpty(statusCodeString)) { > >> - statusCodeString =3D defaultStatusCodeString; > >> - } > >> > >> // workaround if we are in the root webapp > >> String cname =3D UtilHttp.getApplicationName(request); > >> @@ -153,50 +264,29 @@ public class RequestHandler { > >> } > >> } > >> > >> - String overrideViewUri =3D RequestHandler. > >> getOverrideViewUri(request.getPathInfo()); > >> - > >> - String requestMissingErrorMessage =3D "Unknown request [" + > >> defaultRequestUri + "]; this request does not exist or cannot be calle= d > >> directly."; > >> - ConfigXMLReader.RequestMap requestMap =3D null; > >> - if (defaultRequestUri !=3D null) { > >> - requestMap =3D requestMapMap.get(defaultRequestUri); > >> - } > >> - // check for default request > >> - if (requestMap =3D=3D null) { > >> - String defaultRequest; > >> - try { > >> - defaultRequest =3D controllerConfig.getDefaultRequest= (); > >> - } catch (WebAppConfigurationException e) { > >> - Debug.logError(e, "Exception thrown while parsing > >> controller.xml file: ", module); > >> - throw new RequestHandlerException(e); > >> - } > >> - if (defaultRequest !=3D null) { // required! to avoid a n= ull > >> pointer exception and generate a requesthandler exception if default > >> request not found. > >> - requestMap =3D requestMapMap.get(defaultRequest); > >> - } > >> - } > >> - > >> - // check for override view > >> - if (overrideViewUri !=3D null) { > >> - ConfigXMLReader.ViewMap viewMap; > >> - try { > >> - viewMap =3D getControllerConfig().getViewMapMap().get= ( > >> overrideViewUri); > >> - if (viewMap =3D=3D null) { > >> - String defaultRequest =3D controllerConfig. > >> getDefaultRequest(); > >> - if (defaultRequest !=3D null) { // required! to a= void > >> a null pointer exception and generate a requesthandler exception if > default > >> request not found. > >> - requestMap =3D requestMapMap.get(defaultReque= st); > >> - } > >> - } > >> - } catch (WebAppConfigurationException e) { > >> - Debug.logError(e, "Exception thrown while parsing > >> controller.xml file: ", module); > >> - throw new RequestHandlerException(e); > >> + String requestMissingErrorMessage =3D "Unknown request [" > >> + + defaultRequestUri > >> + + "]; this request does not exist or cannot be called > >> directly."; > >> + > >> + String path =3D request.getPathInfo(); > >> + String requestUri =3D getRequestUri(path); > >> + String overrideViewUri =3D getOverrideViewUri(path); > >> + > >> + Collection rmaps =3D resolveURI(ccfg, request); > >> + if (rmaps.isEmpty()) { > >> + if (throwRequestHandlerExceptionOnMissingLocalRequest) { > >> + throw new RequestHandlerException( > >> requestMissingErrorMessage); > >> + } else { > >> + throw new RequestHandlerExceptionAllowExternalRequests(= ); > >> } > >> } > >> > >> - // if no matching request is found in the controller, dependi= ng > >> on throwRequestHandlerExceptionOnMissingLocalRequest > >> - // we throw a RequestHandlerException or > >> RequestHandlerExceptionAllowExternalRequests > >> - if (requestMap =3D=3D null) { > >> - if (throwRequestHandlerExceptionOnMissingLocalRequest) > >> throw new RequestHandlerException(requestMissingErrorMessage); > >> - else throw new RequestHandlerExceptionAllowEx > >> ternalRequests(); > >> - } > >> + String method =3D request.getMethod(); > >> + RequestMap requestMap =3D resolveMethod(method, > >> rmaps).orElseThrow(() -> { > >> + String msg =3D UtilProperties.getMessage("WebappUiLabels"= , > >> "RequestMethodNotMatchConfig", > >> + UtilMisc.toList(requestUri, method), > >> UtilHttp.getLocale(request)); > >> + return new MethodNotAllowedException(msg); > >> + }); > >> > >> String eventReturn =3D null; > >> if (requestMap.metrics !=3D null && > requestMap.metrics.getThreshold() > >> !=3D 0.0 && requestMap.metrics.getTotalEvents() > 3 && > requestMap.metrics.getThreshold() > >> < requestMap.metrics.getServiceRate()) { > >> @@ -210,7 +300,7 @@ public class RequestHandler { > >> // Check for chained request. > >> if (chain !=3D null) { > >> String chainRequestUri =3D RequestHandler.getRequestUri( > >> chain); > >> - requestMap =3D requestMapMap.get(chainRequestUri); > >> + requestMap =3D ccfg.getRequestMapMap(). > >> getFirst(chainRequestUri); > >> if (requestMap =3D=3D null) { > >> throw new RequestHandlerException("Unknown chained > >> request [" + chainRequestUri + "]; this request does not exist"); > >> } > >> @@ -234,18 +324,11 @@ public class RequestHandler { > >> // Check to make sure we are allowed to access this reque= st > >> directly. (Also checks if this request is defined.) > >> // If the request cannot be called, or is not defined, > check > >> and see if there is a default-request we can process > >> if (!requestMap.securityDirectRequest) { > >> - String defaultRequest; > >> - try { > >> - defaultRequest =3D controllerConfig. > >> getDefaultRequest(); > >> - } catch (WebAppConfigurationException e) { > >> - Debug.logError(e, "Exception thrown while parsing > >> controller.xml file: ", module); > >> - throw new RequestHandlerException(e); > >> - } > >> - if (defaultRequest =3D=3D null || !requestMapMap.get( > >> defaultRequest).securityDirectRequest) { > >> + if (ccfg.getDefaultRequest() =3D=3D null || > >> > !ccfg.getRequestMapMap().getFirst(ccfg.getDefaultRequest()).securityDirec= tRequest) > >> { > >> // use the same message as if it was missing for > >> security reasons, ie so can't tell if it is missing or direct request = is > >> not allowed > >> throw new RequestHandlerException( > >> requestMissingErrorMessage); > >> } else { > >> - requestMap =3D requestMapMap.get(defaultRequest); > >> + requestMap =3D ccfg.getRequestMapMap().getFirst(c= cfg. > >> getDefaultRequest()); > >> } > >> } > >> // Check if we SHOULD be secure and are not. > >> @@ -288,7 +371,7 @@ public class RequestHandler { > >> String newUrl =3D RequestHandler.makeUrl(request, > >> response, urlBuf.toString()); > >> if (newUrl.toUpperCase().startsWith("HTTPS")) { > >> // if we are supposed to be secure, redirect > >> secure. > >> - callRedirect(newUrl, response, request, > >> statusCodeString); > >> + callRedirect(newUrl, response, request, > >> ccfg.getStatusCodeString()); > >> return; > >> } > >> } > >> @@ -333,63 +416,52 @@ public class RequestHandler { > >> if (Debug.infoOn()) > >> Debug.logInfo("This is the first request in this > >> visit." + showSessionId(request), module); > >> session.setAttribute("_FIRST_VISIT_EVENTS_", > >> "complete"); > >> - try { > >> - for (ConfigXMLReader.Event event: controllerConfi= g. > >> getFirstVisitEventList().values()) { > >> - try { > >> - String returnString =3D > this.runEvent(request, > >> response, event, null, "firstvisit"); > >> - if (returnString =3D=3D null || > >> "none".equalsIgnoreCase(returnString)) { > >> - interruptRequest =3D true; > >> - } else if > (!"success".equalsIgnoreCase(returnString)) > >> { > >> - throw new > EventHandlerException("First-Visit > >> event did not return 'success'."); > >> - } > >> - } catch (EventHandlerException e) { > >> - Debug.logError(e, module); > >> + for (ConfigXMLReader.Event event: > >> ccfg.getFirstVisitEventList().values()) { > >> + try { > >> + String returnString =3D this.runEvent(request= , > >> response, event, null, "firstvisit"); > >> + if (returnString =3D=3D null || > >> "none".equalsIgnoreCase(returnString)) { > >> + interruptRequest =3D true; > >> + } else if > (!"success".equalsIgnoreCase(returnString)) > >> { > >> + throw new > EventHandlerException("First-Visit > >> event did not return 'success'."); > >> } > >> + } catch (EventHandlerException e) { > >> + Debug.logError(e, module); > >> } > >> - } catch (WebAppConfigurationException e) { > >> - Debug.logError(e, "Exception thrown while parsing > >> controller.xml file: ", module); > >> - throw new RequestHandlerException(e); > >> } > >> } > >> > >> // Invoke the pre-processor (but NOT in a chain) > >> - try { > >> - for (ConfigXMLReader.Event event: controllerConfig. > >> getPreprocessorEventList().values()) { > >> - try { > >> - String returnString =3D this.runEvent(request= , > >> response, event, null, "preprocessor"); > >> - if (returnString =3D=3D null || > >> "none".equalsIgnoreCase(returnString)) { > >> - interruptRequest =3D true; > >> - } else if > (!"success".equalsIgnoreCase(returnString)) > >> { > >> - if (!returnString.contains(":_protect_:")= ) > { > >> - throw new > EventHandlerException("Pre-Processor > >> event [" + event.invoke + "] did not return 'success'."); > >> - } else { // protect the view normally > >> rendered and redirect to error response view > >> - returnString =3D > returnString.replace(":_protect_:", > >> ""); > >> - if (returnString.length() > 0) { > >> - > request.setAttribute("_ERROR_MESSAGE_", > >> returnString); > >> - } > >> - eventReturn =3D null; > >> - // check to see if there is a "protec= t" > >> response, if so it's ok else show the default_error_response_view > >> - if > (!requestMap.requestResponseMap.containsKey("protect")) > >> { > >> - String protectView =3D > >> controllerConfig.getProtectView(); > >> - if (protectView !=3D null) { > >> - overrideViewUri =3D protectVi= ew; > >> - } else { > >> - overrideViewUri =3D > >> EntityUtilProperties.getPropertyValue("security", > >> "default.error.response.view", delegator); > >> - overrideViewUri =3D > >> overrideViewUri.replace("view:", ""); > >> - if > ("none:".equals(overrideViewUri)) > >> { > >> - interruptRequest =3D true= ; > >> - } > >> + for (ConfigXMLReader.Event event: > >> ccfg.getPreprocessorEventList().values()) { > >> + try { > >> + String returnString =3D this.runEvent(request, > >> response, event, null, "preprocessor"); > >> + if (returnString =3D=3D null || > "none".equalsIgnoreCase(returnString)) > >> { > >> + interruptRequest =3D true; > >> + } else if > (!"success".equalsIgnoreCase(returnString)) > >> { > >> + if (!returnString.contains(":_protect_:")) { > >> + throw new > EventHandlerException("Pre-Processor > >> event [" + event.invoke + "] did not return 'success'."); > >> + } else { // protect the view normally rendere= d > >> and redirect to error response view > >> + returnString =3D > returnString.replace(":_protect_:", > >> ""); > >> + if (returnString.length() > 0) { > >> + request.setAttribute("_ERROR_MESSAGE_= ", > >> returnString); > >> + } > >> + eventReturn =3D null; > >> + // check to see if there is a "protect" > >> response, if so it's ok else show the default_error_response_view > >> + if > (!requestMap.requestResponseMap.containsKey("protect")) > >> { > >> + if (ccfg.getProtectView() !=3D null) = { > >> + overrideViewUri =3D > >> ccfg.getProtectView(); > >> + } else { > >> + overrideViewUri =3D > >> EntityUtilProperties.getPropertyValue("security", > >> "default.error.response.view", delegator); > >> + overrideViewUri =3D > >> overrideViewUri.replace("view:", ""); > >> + if > ("none:".equals(overrideViewUri)) > >> { > >> + interruptRequest =3D true; > >> } > >> } > >> } > >> } > >> - } catch (EventHandlerException e) { > >> - Debug.logError(e, module); > >> } > >> + } catch (EventHandlerException e) { > >> + Debug.logError(e, module); > >> } > >> - } catch (WebAppConfigurationException e) { > >> - Debug.logError(e, "Exception thrown while parsing > >> controller.xml file: ", module); > >> - throw new RequestHandlerException(e); > >> } > >> } > >> > >> @@ -409,7 +481,7 @@ public class RequestHandler { > >> // Invoke the security handler > >> // catch exceptions and throw RequestHandlerException if > >> failed. > >> if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler]= : > >> AuthRequired. Running security check. " + showSessionId(request), > module); > >> - ConfigXMLReader.Event checkLoginEvent =3D > >> requestMapMap.get("checkLogin").event; > >> + ConfigXMLReader.Event checkLoginEvent =3D > >> ccfg.getRequestMapMap().getFirst("checkLogin").event; > >> String checkLoginReturnString =3D null; > >> > >> try { > >> @@ -422,9 +494,9 @@ public class RequestHandler { > >> eventReturn =3D checkLoginReturnString; > >> // if the request is an ajax request we don't want to > >> return the default login check > >> if > (!"XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) > >> { > >> - requestMap =3D requestMapMap.get("checkLogin"); > >> + requestMap =3D ccfg.getRequestMapMap(). > >> getFirst("checkLogin"); > >> } else { > >> - requestMap =3D requestMapMap.get("ajaxCheckLogin"= ); > >> + requestMap =3D ccfg.getRequestMapMap(). > >> getFirst("ajaxCheckLogin"); > >> } > >> } > >> } > >> @@ -556,7 +628,7 @@ public class RequestHandler { > >> redirectTarget +=3D "?" + queryString; > >> } > >> > >> - callRedirect(makeLink(request, response, > >> redirectTarget), response, request, statusCodeString); > >> + callRedirect(makeLink(request, response, > >> redirectTarget), response, request, ccfg.getStatusCodeString()); > >> --000000000000f749990573d64cd7--