Thanks Aditya for review and feedback. Will take care of it soon.

--
Rishi Solanki
Sr Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com
www.hotwax.co


On Sat, Nov 10, 2018 at 10:24 AM Aditya Sharma <
[email protected]> wrote:

> Hi Rishi,
>
> I think you missed the import with a wildcard in UtilCacheEvents.java.
>
> >+import java.util.*;
>
> Though I think it may have been slipped in due to IDE. Using the wildcard
> may clutter local namespace with all the classes of util package.
>
> Thanks and Regards,
>
> *Aditya Sharma* | Enterprise Software Engineer
> HotWax Commerce <http://www.hotwax.co/> by HotWax Systems
> <http://www.hotwaxsystems.com/>
> [image: https://www.linkedin.com/in/aditya-p-sharma/]
> <https://www.linkedin.com/in/aditya-p-sharma/>
>
>
> On Fri, Nov 2, 2018 at 4:48 PM <[email protected]> wrote:
>
> > Author: rishi
> > Date: Fri Nov  2 11:18:52 2018
> > New Revision: 1845572
> >
> > URL: http://svn.apache.org/viewvc?rev=1845572&view=rev
> > Log:
> > Improved: Introduce ability to clear specific cache from cache
> > maintenance. After this user can bulk select the caches and clear them.
> > Single clear and all clear caches works as is.
> > (OFBIZ-10402)
> > Thanks to Yogesh Naroliya for providing the patch and Suraj Khurana for
> > reporting the ticket.
> >
> > Modified:
> >
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/config/WebtoolsUiLabels.xml
> >
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/UtilCacheEvents.java
> >
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
> >     ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheForms.xml
> >
>  ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheScreens.xml
> >     ofbiz/ofbiz-framework/trunk/framework/webtools/widget/Menus.xml
> >
> > Modified:
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/config/WebtoolsUiLabels.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/config/WebtoolsUiLabels.xml?rev=1845572&r1=1845571&r2=1845572&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/config/WebtoolsUiLabels.xml
> > (original)
> > +++
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/config/WebtoolsUiLabels.xml
> > Fri Nov  2 11:18:52 2018
> > @@ -1150,6 +1150,9 @@
> >          <value xml:lang="zh">清除这个缓存</value>
> >          <value xml:lang="zh-TW">æ¸…é™¤é€™å€‹å¿«å –</value>
> >      </property>
> > +    <property key="WebtoolsClearSelectedCaches">
> > +        <value xml:lang="en">Clear Selected Caches</value>
> > +    </property>
> >      <property key="WebtoolsCompanyName">
> >          <value xml:lang="de">OFBiz: Web Tools</value>
> >          <value xml:lang="en">OFBiz: Web Tools</value>
> >
> > Modified:
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/UtilCacheEvents.java
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/UtilCacheEvents.java?rev=1845572&r1=1845571&r2=1845572&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/UtilCacheEvents.java
> > (original)
> > +++
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/UtilCacheEvents.java
> > Fri Nov  2 11:18:52 2018
> > @@ -17,10 +17,7 @@
> >   * under the License.
> >
> >
> *******************************************************************************/
> >  package org.apache.ofbiz.webtools;
> > -
> > -import java.util.Iterator;
> > -import java.util.Locale;
> > -
> > +import java.util.*;
> >  import javax.servlet.http.HttpServletRequest;
> >  import javax.servlet.http.HttpServletResponse;
> >
> > @@ -170,6 +167,56 @@ public final class UtilCacheEvents {
> >          request.setAttribute("_EVENT_MESSAGE_", errMsg + " (" +
> > UtilDateTime.nowDateString("yyyy-MM-dd HH:mm:ss")  + ").");
> >          return "success";
> >      }
> > +
> > +    /** An HTTP WebEvent handler that clears the selected caches
> > +     * @param request The HTTP request object for the current JSP or
> > Servlet request.
> > +     * @param response The HTTP response object for the current JSP or
> > Servlet request.
> > +     * @return return an HTTP WebEvent handler that clears all caches
> > +     */
> > +    public static String clearSelectedCachesEvent(HttpServletRequest
> > request, HttpServletResponse response) {
> > +
> > +        String errMsg = "";
> > +        Locale locale = UtilHttp.getLocale(request);
> > +
> > +        Security security = (Security) request.getAttribute("security");
> > +        if (!security.hasPermission("UTIL_CACHE_EDIT",
> > request.getSession())) {
> > +            errMsg = UtilProperties.getMessage(err_resource,
> > "utilCacheEvents.permissionEdit", locale) + ".";
> > +            request.setAttribute("_ERROR_MESSAGE_", errMsg);
> > +            return "error";
> > +        }
> > +
> > +        Map<String, Object> ctx = UtilHttp.getParameterMap(request);
> > +        boolean isSelected;
> > +        List<String> eventList = new LinkedList<>();
> > +        int rowCount = UtilHttp.getMultiFormRowCount(ctx);
> > +        for (int i = 0; i < rowCount; i++) {
> > +            String suffix = UtilHttp.getMultiRowDelimiter() + i;
> > +            isSelected = (ctx.containsKey("_rowSubmit" + suffix) &&
> > "Y".equalsIgnoreCase((String)ctx.get("_rowSubmit" + suffix)));
> > +            if (!isSelected) {
> > +                continue;
> > +            }
> > +
> > +            String name = request.getParameter("cacheName"+suffix);
> > +
> > +            if (name == null) {
> > +                errMsg = UtilProperties.getMessage(err_resource,
> > "utilCache.couldNotClearCache", locale) + ".";
> > +                eventList.add(errMsg);
> > +            }
> > +
> > +            UtilCache<?, ?> utilCache = UtilCache.findCache(name);
> > +
> > +            if (utilCache != null) {
> > +                utilCache.clear();
> > +                errMsg = UtilProperties.getMessage(err_resource,
> > "utilCache.clearCache", UtilMisc.toMap("name", name), locale) + ".";
> > +                eventList.add(errMsg);
> > +            } else {
> > +                errMsg = UtilProperties.getMessage(err_resource,
> > "utilCache.couldNotClearCacheNotFoundName", UtilMisc.toMap("name", name),
> > locale) + ".";
> > +                eventList.add(errMsg);
> > +            }
> > +        }
> > +        request.setAttribute("_EVENT_MESSAGE_LIST_", eventList);
> > +        return "success";
> > +    }
> >
> >      /** An HTTP WebEvent handler that updates the named cache
> >       * @param request The HTTP request object for the current JSP or
> > Servlet request.
> >
> > Modified:
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml?rev=1845572&r1=1845571&r2=1845572&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
> > (original)
> > +++
> >
> ofbiz/ofbiz-framework/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
> > Fri Nov  2 11:18:52 2018
> > @@ -179,6 +179,12 @@ under the License.
> >          <response name="success" type="view" value="FindUtilCache"/>
> >          <response name="error" type="view" value="FindUtilCache"/>
> >      </request-map>
> > +    <request-map uri="ClearSelectedCaches">
> > +        <security https="true" auth="true"/>
> > +        <event type="java"
> > path="org.apache.ofbiz.webtools.UtilCacheEvents"
> > invoke="clearSelectedCachesEvent"/>
> > +        <response name="success" type="view" value="FindUtilCache"/>
> > +        <response name="error" type="view" value="FindUtilCache"/>
> > +    </request-map>
> >      <request-map uri="ForceGarbageCollection">
> >          <security https="true" auth="true"/>
> >          <event type="service" invoke="forceGarbageCollection"/>
> >
> > Modified:
> > ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheForms.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheForms.xml?rev=1845572&r1=1845571&r2=1845572&view=diff
> >
> >
> ==============================================================================
> > --- ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheForms.xml
> > (original)
> > +++ ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheForms.xml
> > Fri Nov  2 11:18:52 2018
> > @@ -28,7 +28,10 @@ under the License.
> >          <field name="usedMemory"
> > title="${uiLabelMap.WebtoolsUsedMemory}"><display/></field>
> >          <field name="totalCacheMemory"
> > title="${uiLabelMap.WebtoolsCacheMemory}"><display/></field>
> >      </form>
> > -    <grid name="ListCache" list-name="cacheList"
> > paginate-target="FindUtilCache" separate-columns="true"
> > odd-row-style="alternate-row" default-table-style="basic-table hover-bar"
> > header-row-style="header-row-2">
> > +
> > +    <form name="ListCache" type="multi" title="" list-name="cacheList"
> > target="ClearSelectedCaches" paginate-target="FindUtilCache"
> > +          odd-row-style="alternate-row" default-table-style="basic-table
> > hover-bar" >
> > +        <field name="_rowSubmit" use-when="hasUtilCacheEdit"
> > title="${uiLabelMap.CommonSelectAll}"><check/></field>
> >          <field name="cacheName" title="${uiLabelMap.WebtoolsCacheName}"
> > sort-field="true"><display/></field>
> >          <field name="cacheSize" title="${uiLabelMap.WebtoolsSize}"
> > sort-field="true"><display/></field>
> >          <field name="hitCount" title="${uiLabelMap.WebtoolsHits}"
> > sort-field="true"><display/></field>
> > @@ -38,8 +41,22 @@ under the License.
> >          <field name="expireTime"
> title="${uiLabelMap.WebtoolsExpireTime}"
> > sort-field="true"><display/></field>
> >          <field name="useSoftReference"
> > title="${uiLabelMap.WebtoolsUseSoftRef}"
> > sort-field="true"><display/></field>
> >          <field name="cacheMemory"
> > title="${uiLabelMap.WebtoolsCacheMemory}"
> > sort-field="true"><display/></field>
> > -        <field name="cacheMenu" title=" "
> > use-when="hasUtilCacheEdit"><include-menu name="ListCacheForm"
> > location="component://webtools/widget/Menus.xml"/></field>
> > -    </grid>
> > +        <field name="findUtilCacheElements" title=" "
> > use-when="hasUtilCacheEdit" widget-style="buttontext">
> > +            <hyperlink description="${uiLabelMap.WebtoolsElements}"
> > target="FindUtilCacheElements" >
> > +                <parameter param-name="UTIL_CACHE_NAME"
> > from-field="cacheName"/>
> > +            </hyperlink>
> > +        </field>
> > +        <field name="EditUtilCache" title=" "
> use-when="hasUtilCacheEdit"
> > widget-style="buttontext" >
> > +            <hyperlink description="${uiLabelMap.CommonEdit}"
> > target="EditUtilCache" >
> > +                <parameter param-name="UTIL_CACHE_NAME"
> > from-field="cacheName"/>
> > +            </hyperlink>
> > +        </field>
> > +        <field name="FindUtilCacheClear" title=" "
> > use-when="hasUtilCacheEdit" widget-style="buttontext">
> > +            <hyperlink description="${uiLabelMap.CommonClear}"
> > target="FindUtilCacheClear" >
> > +                <parameter param-name="UTIL_CACHE_NAME"
> > from-field="cacheName"/>
> > +            </hyperlink>
> > +        </field>
> > +    </form>
> >
> >      <grid name="ListCacheElements" list-name="cacheElementsList"
> > paginate-target="FindUtilCacheElements" separate-columns="true"
> > odd-row-style="alternate-row" default-table-style="basic-table hover-bar"
> > header-row-style="header-row-2">
> >          <field name="elementKey"
> > title="${uiLabelMap.WebtoolsCacheElementKey}"
> > sort-field="true"><display/></field>
> >
> > Modified:
> > ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheScreens.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheScreens.xml?rev=1845572&r1=1845571&r2=1845572&view=diff
> >
> >
> ==============================================================================
> > ---
> ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheScreens.xml
> > (original)
> > +++
> ofbiz/ofbiz-framework/trunk/framework/webtools/widget/CacheScreens.xml
> > Fri Nov  2 11:18:52 2018
> > @@ -41,7 +41,7 @@ under the License.
> >                                  </screenlet>
> >                                  <screenlet>
> >                                      <include-menu name="FindCache"
> > location="component://webtools/widget/Menus.xml"/>
> > -                                    <include-grid name="ListCache"
> > location="component://webtools/widget/CacheForms.xml"/>
> > +                                    <include-form name="ListCache"
> > location="component://webtools/widget/CacheForms.xml"/>
> >                                      <include-menu name="FindCache"
> > location="component://webtools/widget/Menus.xml"/>
> >                                  </screenlet>
> >                              </widgets>
> >
> > Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/widget/Menus.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/widget/Menus.xml?rev=1845572&r1=1845571&r2=1845572&view=diff
> >
> >
> ==============================================================================
> > --- ofbiz/ofbiz-framework/trunk/framework/webtools/widget/Menus.xml
> > (original)
> > +++ ofbiz/ofbiz-framework/trunk/framework/webtools/widget/Menus.xml Fri
> > Nov  2 11:18:52 2018
> > @@ -144,23 +144,6 @@ under the License.
> >              <link target="FindUtilCache"/>
> >          </menu-item>
> >      </menu>
> > -    <menu name="ListCacheForm" extends="CommonInlineBarMenu"
> > extends-resource="component://common/widget/CommonMenus.xml">
> > -        <menu-item name="findUtilCacheElements"
> > title="${uiLabelMap.WebtoolsElements}">
> > -            <link target="FindUtilCacheElements">
> > -                <parameter param-name="UTIL_CACHE_NAME"
> > from-field="cacheName"/>
> > -            </link>
> > -        </menu-item>
> > -        <menu-item name="EditUtilCache"
> title="${uiLabelMap.CommonEdit}">
> > -            <link target="EditUtilCache">
> > -                <parameter param-name="UTIL_CACHE_NAME"
> > from-field="cacheName"/>
> > -            </link>
> > -        </menu-item>
> > -        <menu-item name="FindUtilCacheClear"
> > title="${uiLabelMap.CommonClear}">
> > -            <link target="FindUtilCacheClear" link-type="hidden-form">
> > -                <parameter param-name="UTIL_CACHE_NAME"
> > from-field="cacheName"/>
> > -            </link>
> > -        </menu-item>
> > -    </menu>
> >
> >      <menu name="ArtifactTabBar" extends="CommonTabBarMenu"
> > extends-resource="component://common/widget/CommonMenus.xml"
> >            selected-menuitem-context-field-name="tabButtonItem">
> > @@ -287,6 +270,9 @@ under the License.
> >          <menu-item name="forceGarbageCollection"
> > title="${uiLabelMap.WebtoolsRunGC}">
> >              <link target="ForceGarbageCollection"/>
> >          </menu-item>
> > +        <menu-item name="clearSelectedCaches"
> > title="${uiLabelMap.WebtoolsClearSelectedCaches}">
> > +            <link target="javascript: document.ListCache.submit()"
> > url-mode="plain"/>
> > +        </menu-item>
> >      </menu>
> >
> >      <menu name="CacheElements" extends="CommonButtonBarMenu"
> > extends-resource="component://common/widget/CommonMenus.xml">
> >
> >
> >
>

Reply via email to