Author: ludovic Date: 2007-09-07 12:31:36 +0200 (Fri, 07 Sep 2007) New Revision: 4754
Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/VisitStats.java xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/XWikiStatsServiceImpl.java Log: XWIKI-1721 Statistics exception Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/VisitStats.java =================================================================== --- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/VisitStats.java 2007-09-07 10:28:43 UTC (rev 4753) +++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/VisitStats.java 2007-09-07 10:31:36 UTC (rev 4754) @@ -1,23 +1,23 @@ -/* - * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated - * by the contributors.txt. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - * - */ +/* + * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated + * by the contributors.txt. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + * + */ package com.xpn.xwiki.stats.impl; @@ -45,6 +45,10 @@ oldObject = vobject; } + public void unrememberOldObject() { + oldObject=null; + } + public VisitStats getOldObject() { return oldObject; } Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/XWikiStatsServiceImpl.java =================================================================== --- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/XWikiStatsServiceImpl.java 2007-09-07 10:28:43 UTC (rev 4753) +++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/stats/impl/XWikiStatsServiceImpl.java 2007-09-07 10:31:36 UTC (rev 4754) @@ -197,10 +197,11 @@ if (store == null) return; VisitStats vobject = findVisit(context); + synchronized(vobject) { // We count page views in the sessions only for the "view" action if (action.equals("view")) vobject.incPageViews(); - // We count "save" and "download" actions separately + // We count "save" and "download" actions separately else if (action.equals("save")) vobject.incPageSaves(); else if (action.equals("download")) @@ -216,7 +217,8 @@ if (oldObject!=null) { // Catch exception to not fail here try { - store.deleteXWikiCollection(oldObject, context, true, true); + store.deleteXWikiCollection(oldObject, context, true, true); + vobject.unrememberOldObject(); } catch (Exception e) {} } @@ -226,12 +228,13 @@ e.printStackTrace(); } - addPageView(doc.getFullName(), action, XWikiStats.PERIOD_MONTH, store, context, vobject); - addPageView(doc.getSpace(), action, XWikiStats.PERIOD_MONTH, store, context, vobject); - addPageView("", action, XWikiStats.PERIOD_MONTH, store, context, vobject); - addPageView(doc.getFullName(), action, XWikiStats.PERIOD_DAY, store, context, vobject); - addPageView(doc.getSpace(), action, XWikiStats.PERIOD_DAY, store, context, vobject); - addPageView("", action, XWikiStats.PERIOD_DAY, store, context, vobject); + addPageView(doc.getFullName(), action, XWikiStats.PERIOD_MONTH, store, context, vobject); + addPageView(doc.getSpace(), action, XWikiStats.PERIOD_MONTH, store, context, vobject); + addPageView("", action, XWikiStats.PERIOD_MONTH, store, context, vobject); + addPageView(doc.getFullName(), action, XWikiStats.PERIOD_DAY, store, context, vobject); + addPageView(doc.getSpace(), action, XWikiStats.PERIOD_DAY, store, context, vobject); + addPageView("", action, XWikiStats.PERIOD_DAY, store, context, vobject); + } // In case of a "view" action we want to store referer info if (action.equals("view")) { @@ -239,19 +242,20 @@ if ((referer !=null)&&(!referer.equals(""))) { // Visits of the web RefererStats robject = new RefererStats(doc.getFullName(), referer, new Date(), XWikiStats.PERIOD_MONTH); - try { - store.loadXWikiCollection(robject, context, true); - } catch (XWikiException e) { - } + synchronized(robject) { + try { + store.loadXWikiCollection(robject, context, true); + } catch (XWikiException e) { + } - robject.incPageViews(); - try { - store.saveXWikiCollection(robject, context, true); - } catch (XWikiException e) { - // Statistics should never make xwiki fail ! - e.printStackTrace(); + robject.incPageViews(); + try { + store.saveXWikiCollection(robject, context, true); + } catch (XWikiException e) { + // Statistics should never make xwiki fail ! + e.printStackTrace(); + } } - } } _______________________________________________ notifications mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/notifications
