diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWiki.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWiki.java 2006-08-08 21:27:28.000000000 +0300 @@ -35,13 +35,10 @@ import com.xpn.xwiki.api.Document; import com.xpn.xwiki.api.User; import com.xpn.xwiki.cache.api.XWikiCacheService; -import com.xpn.xwiki.cache.api.XWikiCache; -import com.xpn.xwiki.cache.api.XWikiCacheNeedsRefreshException; import com.xpn.xwiki.cache.impl.OSCacheService; import com.xpn.xwiki.cache.impl.XWikiCacheListener; import com.xpn.xwiki.doc.XWikiAttachment; import com.xpn.xwiki.doc.XWikiDocument; -import com.xpn.xwiki.doc.XWikiDocumentArchive; import com.xpn.xwiki.notify.*; import com.xpn.xwiki.objects.BaseObject; import com.xpn.xwiki.objects.PropertyInterface; @@ -113,7 +110,6 @@ private XWikiConfig config; private XWikiStoreInterface store; private XWikiAttachmentStoreInterface attachmentStore; - private XWikiVersioningStoreInterface versioningStore; private XWikiRenderingEngine renderingEngine; private XWikiPluginManager pluginManager; private XWikiNotificationManager notificationManager; @@ -121,15 +117,8 @@ private XWikiRightService rightService; private XWikiGroupService groupService; private XWikiStatsService statsService; + private XWikiCacheService cacheService; private XWikiURLFactoryService urlFactoryService; - private static XWikiCacheService cacheService; - - private final Object AUTH_SERVICE_LOCK = new Object(); - private final Object RIGHT_SERVICE_LOCK = new Object(); - private final Object GROUP_SERVICE_LOCK = new Object(); - private final Object STATS_SERVICE_LOCK = new Object(); - private final Object URLFACTORY_SERVICE_LOCK = new Object(); - private static final Object CACHE_SERVICE_LOCK = new Object(); private MetaClass metaclass = MetaClass.getMetaClass(); private boolean test = false; @@ -142,7 +131,7 @@ // These are caches in order to improve finding virtual wikis private List virtualWikiList = new ArrayList(); - private XWikiCache virtualWikiMap; + private static Map virtualWikiMap = new HashMap(); private static Map threadMap = new HashMap(); private boolean isReadOnly = false; @@ -171,7 +160,7 @@ return configPath; } - public static XWiki getMainXWiki(XWikiContext context) throws XWikiException { + public synchronized static XWiki getMainXWiki(XWikiContext context) throws XWikiException { String xwikicfg = null; String xwikiname = "xwiki"; XWiki xwiki = null; @@ -189,22 +178,20 @@ try { xwikicfg = getConfigPath(); - synchronized (XWiki.class) { - xwiki = (XWiki) econtext.getAttribute(xwikiname); - if (xwiki == null) { - InputStream xwikicfgis = null; - - // first try to load the file pointed by the given path - // if it does not exist, look for it relative to the classpath - File f = new File(xwikicfg); - if (f.exists()) { - xwikicfgis = new FileInputStream(f); - } else { - xwikicfgis = econtext.getResourceAsStream(xwikicfg); - } - xwiki = new XWiki(xwikicfgis, context, context.getEngineContext()); - econtext.setAttribute(xwikiname, xwiki); + xwiki = (XWiki) econtext.getAttribute(xwikiname); + if (xwiki == null) { + InputStream xwikicfgis = null; + + // first try to load the file pointed by the given path + // if it does not exist, look for it relative to the classpath + File f = new File(xwikicfg); + if (f.exists()) { + xwikicfgis = new FileInputStream(f); + } else { + xwikicfgis = econtext.getResourceAsStream(xwikicfg); } + xwiki = new XWiki(xwikicfgis, context, context.getEngineContext()); + econtext.setAttribute(xwikiname, xwiki); } context.setWiki(xwiki); xwiki.setDatabase(context.getDatabase()); @@ -231,58 +218,47 @@ return null; } - public void updateDatabase(String appname, XWikiContext context) throws HibernateException, XWikiException { + public synchronized void updateDatabase(String appname, XWikiContext context) throws HibernateException, XWikiException { updateDatabase(appname, false, context); } - public void updateDatabase(String appname, boolean force, XWikiContext context) throws HibernateException, XWikiException { - updateDatabase(appname, force, true, context); - } + public synchronized void updateDatabase(String appname, boolean force, XWikiContext context) throws HibernateException, XWikiException { + String database = context.getDatabase(); - public void updateDatabase(String appname, boolean force, boolean initClasses, XWikiContext context) throws HibernateException, XWikiException { - synchronized (appname) { - String database = context.getDatabase(); - - try { - List wikilist = getVirtualWikiList(); - context.setDatabase(appname); - if (!wikilist.contains(appname)) { - wikilist.add(appname); - XWikiHibernateStore store = getHibernateStore(); - if (store != null) - store.updateSchema(context, force); - } - - // Make sure these classes exists - if (initClasses) { - getPrefsClass(context); - getUserClass(context); - getGroupClass(context); - getRightsClass(context); - getCommentsClass(context); - getSkinClass(context); - getGlobalRightsClass(context); - getPluginManager().virtualInit(context); - } - - // Add initdone which will allow to - // bypass some initializations - context.put("initdone", "1"); - } finally { - context.setDatabase(database); + try { + List wikilist = getVirtualWikiList(); + context.setDatabase(appname); + if (!wikilist.contains(appname)) { + wikilist.add(appname); + XWikiHibernateStore store = getHibernateStore(); + if (store != null) + store.updateSchema(context, force); } + + // Make sure these classes exists + getPrefsClass(context); + getUserClass(context); + getGroupClass(context); + getRightsClass(context); + getCommentsClass(context); + getSkinClass(context); + getGlobalRightsClass(context); + getPluginManager().virtualInit(context); + + // Add initdone which will allow to + // bypass some initializations + context.put("initdone", "1"); + } finally { + context.setDatabase(database); } + } public List getVirtualWikiList() { return virtualWikiList; } - public XWikiCache getVirtualWikiMap() { - return virtualWikiMap; - } - - public static XWiki getXWiki(XWikiContext context) throws XWikiException { + public synchronized static XWiki getXWiki(XWikiContext context) throws XWikiException { XWiki xwiki = getMainXWiki(context); if (xwiki.isVirtual()) { @@ -298,9 +274,9 @@ if (host.equals("")) return xwiki; - String appname = xwiki.findWikiServer(host, context); + String appname = findWikiServer(host, context); - if (appname.equals("")) { + if (appname == null) { String uri = request.getRequestURI(); int i1 = host.indexOf("."); String servername = (i1 != -1) ? host.substring(0, i1) : host; @@ -326,32 +302,30 @@ } } - synchronized (appname) { - // Check if this appname exists in the Database - String serverwikipage = getServerWikiPage(appname); - XWikiDocument doc = xwiki.getDocument(serverwikipage, context); - if (doc.isNew()) { - throw new XWikiException(XWikiException.MODULE_XWIKI, - XWikiException.ERROR_XWIKI_DOES_NOT_EXIST, - "The wiki " + appname + " does not exist"); - } - - // Set the wiki owner - String wikiOwner = doc.getStringValue("XWiki.XWikiServerClass", "owner"); - if (wikiOwner.indexOf(":") == -1) - wikiOwner = xwiki.getDatabase() + ":" + wikiOwner; - context.setWikiOwner(wikiOwner); - context.setWikiServer(doc); - context.setVirtual(true); - context.setDatabase(appname); - context.setOriginalDatabase(appname); - try { - // Let's make sure the virtaul wikis are upgraded to the latest database version - xwiki.updateDatabase(appname, false, context); - } catch (HibernateException e) { - // Just to report it - e.printStackTrace(); - } + // Check if this appname exists in the Database + String serverwikipage = getServerWikiPage(appname); + XWikiDocument doc = xwiki.getDocument(serverwikipage, context); + if (doc.isNew()) { + throw new XWikiException(XWikiException.MODULE_XWIKI, + XWikiException.ERROR_XWIKI_DOES_NOT_EXIST, + "The wiki " + appname + " does not exist"); + } + + // Set the wiki owner + String wikiOwner = doc.getStringValue("XWiki.XWikiServerClass", "owner"); + if (wikiOwner.indexOf(":") == -1) + wikiOwner = xwiki.getDatabase() + ":" + wikiOwner; + context.setWikiOwner(wikiOwner); + context.setWikiServer(doc); + context.setVirtual(true); + context.setDatabase(appname); + context.setOriginalDatabase(appname); + try { + // Let's make sure the virtaul wikis are upgraded to the latest database version + xwiki.updateDatabase(appname, false, context); + } catch (HibernateException e) { + // Just to report it + e.printStackTrace(); } } return xwiki; @@ -372,43 +346,26 @@ } } - private String findWikiServer(String host, XWikiContext context) throws XWikiException { - synchronized (this) { - if (virtualWikiMap==null) { - int iCapacity = 1000; - try { - String capacity = Param("xwiki.virtual.cache.capacity"); - if (capacity != null) - iCapacity = Integer.parseInt(capacity); - } catch (Exception e) { - } - virtualWikiMap = getCacheService().newCache("xwiki.virtual.cache", iCapacity); - } - } - synchronized (host) { - String wikiserver = ""; - try { - wikiserver = (String) virtualWikiMap.getFromCache(host); - return wikiserver; - } catch (XWikiCacheNeedsRefreshException e) { - virtualWikiMap.cancelUpdate(host); - String hql = ", BaseObject as obj, StringProperty as prop where obj.name=doc.fullName" - + " and obj.className='XWiki.XWikiServerClass' and prop.id.id = obj.id " - + "and prop.id.name = 'server' and prop.value='" + host + "'"; - try { - List list = context.getWiki().getStore().searchDocumentsNames(hql, context); - if ((list != null) && (list.size() > 0)) - { - String docname = (String) list.get(0); - if (docname.startsWith("XWiki.XWikiServer")) - wikiserver = docname.substring("XWiki.XWikiServer".length()).toLowerCase(); - } - virtualWikiMap.putInCache(host, wikiserver); - return wikiserver; - } catch (XWikiException e2) { - return null; - } - } + private static String findWikiServer(String host, XWikiContext context) { + String wikiserver = (String) virtualWikiMap.get(host); + if (wikiserver != null) + return wikiserver; + + String hql = ", BaseObject as obj, StringProperty as prop where obj.name=doc.fullName" + + " and obj.className='XWiki.XWikiServerClass' and prop.id.id = obj.id " + + "and prop.id.name = 'server' and prop.value='" + host + "'"; + try { + List list = context.getWiki().getStore().searchDocumentsNames(hql, context); + if ((list == null) || (list.size() == 0)) + return null; + String docname = (String) list.get(0); + if (!docname.startsWith("XWiki.XWikiServer")) + return null; + wikiserver = docname.substring("XWiki.XWikiServer".length()).toLowerCase(); + virtualWikiMap.put(host, wikiserver); + return wikiserver; + } catch (XWikiException e) { + return null; } } @@ -485,6 +442,18 @@ boolean nocache = "0".equals(Param("xwiki.store.cache", "1")); if (!nocache) { XWikiCacheStoreInterface cachestore = new XWikiCacheStore(basestore, context); + try { + String capacity = Param("xwiki.store.cache.capacity"); + if (capacity != null) + cachestore.setCacheCapacity(Integer.parseInt(capacity)); + } catch (Exception e) { + } + try { + String capacity = Param("xwiki.store.cache.pageexistcapacity"); + if (capacity != null) + cachestore.setPageExistCacheCapacity(Integer.parseInt(capacity)); + } catch (Exception e) { + } setStore(cachestore); } else setStore(basestore); @@ -495,32 +464,15 @@ Object[] args = new Object[]{this, context}; setAttachmentStore( (XWikiAttachmentStoreInterface) Class.forName(attachmentStoreclass).getConstructor(classes).newInstance(args)); } catch (InvocationTargetException e) { - Object[] args = {attachmentStoreclass}; - throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, - XWikiException.ERROR_XWIKI_STORE_CLASSINVOCATIONERROR, - "Cannot load attachment store class {0}", e.getTargetException(), args); - } catch (Exception e) { - Object[] args = {attachmentStoreclass}; - throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, - XWikiException.ERROR_XWIKI_STORE_CLASSINVOCATIONERROR, - "Cannot load attachment store class {0}", e, args); - } - - String versioningStoreclass = Param("xwiki.store.versioning.class", "com.xpn.xwiki.store.XWikiHibernateVersioningStore"); - try { - Class[] classes = new Class[]{this.getClass(), context.getClass()}; - Object[] args = new Object[]{this, context}; - setVersioningStore( (XWikiVersioningStoreInterface) Class.forName(versioningStoreclass).getConstructor(classes).newInstance(args)); - } catch (InvocationTargetException e) { - Object[] args = {versioningStoreclass}; + Object[] args = {storeclass}; throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_CLASSINVOCATIONERROR, - "Cannot load versioning store class {0}", e.getTargetException(), args); + "Cannot load store class {0}", e.getTargetException(), args); } catch (Exception e) { - Object[] args = {versioningStoreclass}; + Object[] args = {storeclass}; throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_CLASSINVOCATIONERROR, - "Cannot load versioning store class {0}", e, args); + "Cannot load store class {0}", e, args); } resetRenderingEngine(context); @@ -547,12 +499,10 @@ getStatsService(context); } - // Add a notification for notifications + // Add a notification rule if the preference property plugin is modified getNotificationManager().addGeneralRule( new XWikiActionRule(new XWikiPageNotification())); - // Add rule to get informed of new servers - getNotificationManager().addGeneralRule(new DocObjectChangedRule(this, "XWiki.XWikiServerClass")); String ro = Param("xwiki.readonly", "no"); isReadOnly = ("yes".equalsIgnoreCase(ro) || "true".equalsIgnoreCase(ro) || "1".equalsIgnoreCase(ro)); @@ -717,10 +667,6 @@ return attachmentStore; } - public XWikiVersioningStoreInterface getVersioningStore() { - return versioningStore; - } - public void saveDocument(XWikiDocument doc, XWikiContext context) throws XWikiException { getStore().saveXWikiDoc(doc, context); } @@ -742,7 +688,7 @@ } else if (revision.equals(doc.getVersion())) { newdoc = doc; } else { - newdoc = getVersioningStore().loadXWikiDoc(doc, revision, context); + newdoc = getStore().loadXWikiDoc(doc, revision, context); } } catch (XWikiException e) { if (revision.equals("1.1") || revision.equals("1.0")) @@ -1097,7 +1043,6 @@ // Read XWikiAttachment XWikiAttachment attachment = null; - List list = doc.getAttachmentList(); String shortname = filename.substring(0, filename.indexOf(".")); attachment = doc.getAttachment(shortname); @@ -1239,13 +1184,17 @@ XWikiDocument doc = getDocument(currentdoc.getWeb() + ".WebPreferences", context); // First we try to get a translated preference object - BaseObject object = doc.getObject("XWiki.XWikiPreferences", "language", context.getLanguage(), true); + BaseObject object = doc.getObject("XWiki.XWikiPreferences", "language", context.getLanguage()); String result = ""; try { result = object.getStringValue(prefname); + // If empty we take it from the default pref object } catch (Exception e) { } + if (result.equals("")) + result = doc.getxWikiObject().getStringValue(prefname); + if (!result.equals("")) return result; } catch (Exception e) { @@ -1297,6 +1246,8 @@ } public String getLanguagePreference(XWikiContext context) { + return getDocLanguagePreference(context); + /* // First we get the language from the request String language; @@ -1378,6 +1329,186 @@ context.setLanguage(""); return ""; + */ + } + + public String getDocLanguagePreference(XWikiContext context) { + String language = "", requestLanguage = "", userPreferenceLanguage = "", navigatorLanguage = "", cookieLanguage = "", contextLanguage = ""; + boolean setCookie = false; + + if (!context.getWiki().isMultiLingual(context)) { + language = context.getWiki().getXWikiPreference("language", "", context); + context.setInterfaceLanguage(language); + return language; + } + + // Get request language + try{ + requestLanguage = context.getRequest().getParameter("language"); + } + catch (Exception ex){ + } + + // Get context language + contextLanguage = context.getLanguage(); + + // Get user preference + try { + String user = context.getUser(); + XWikiDocument userdoc = getDocument(user, context); + if (userdoc != null) { + userPreferenceLanguage = userdoc.getStringValue("XWiki.XWikiUsers", "default_language"); + } + } catch (XWikiException e) { + } + + // Get navigator language setting + if (context.getRequest() != null) { + String accept = context.getRequest().getHeader("Accept-Language"); + if ((accept != null) && (!accept.equals(""))) { + String[] alist = StringUtils.split(accept, ",;-"); + if ((alist != null) && !(alist.length == 0)) { + context.setLanguage(alist[0]); + navigatorLanguage = alist[0]; + } + } + } + + // Get language from cookie + try { + cookieLanguage = getUserPreferenceFromCookie("language", context); + } catch (Exception e) { + } + + // Determine which language to use + // First we get the language from the request + if ((requestLanguage != null) && (!requestLanguage.equals(""))) { + if (requestLanguage.equals("default")) { + setCookie = true; + } else { + language = requestLanguage; + context.setLanguage(language); + Cookie cookie = new Cookie("language", language); + cookie.setMaxAge(60 * 60 * 24 * 365 * 10); + cookie.setPath("/"); + context.getResponse().addCookie(cookie); + return language; + } + } + // Next we get the language from the context + if(contextLanguage != null && contextLanguage != ""){ + language = contextLanguage; + } + // Next we get the language from the cookie + else if(cookieLanguage != null && cookieLanguage != ""){ + language = cookieLanguage; + } + // Next from the default user preference + else if(userPreferenceLanguage != null && userPreferenceLanguage != ""){ + language = userPreferenceLanguage; + } + // Then from the navigator language setting + else if(navigatorLanguage != null && navigatorLanguage != ""){ + language = navigatorLanguage; + } + context.setLanguage(language); + if(setCookie){ + Cookie cookie = new Cookie("language", language); + cookie.setMaxAge(60 * 60 * 24 * 365 * 10); + cookie.setPath("/"); + context.getResponse().addCookie(cookie); + } + return language; + } + + public String getInterfaceLanguagePreference(XWikiContext context) { + String language = "", requestLanguage = "", userPreferenceLanguage = "", navigatorLanguage = "", cookieLanguage = "", contextLanguage = ""; + boolean setCookie = false; + + if (!context.getWiki().isMultiLingual(context)) { + language = context.getWiki().getXWikiPreference("language", "", context); + context.setInterfaceLanguage(language); + return language; + } + + // Get request language + try{ + requestLanguage = context.getRequest().getParameter("interfacelanguage"); + } + catch (Exception ex){ + } + + // Get context language + contextLanguage = context.getInterfaceLanguage(); + + // Get user preference + try { + String user = context.getUser(); + XWikiDocument userdoc = null; + userdoc = getDocument(user, context); + if (userdoc != null) { + userPreferenceLanguage = userdoc.getStringValue("XWiki.XWikiUsers", "default_interface_language"); + } + } catch (XWikiException e) { + } + + // Get navigator language setting + if (context.getRequest() != null) { + String accept = context.getRequest().getHeader("Accept-Language"); + if ((accept != null) && (!accept.equals(""))) { + String[] alist = StringUtils.split(accept, ",;-"); + if ((alist != null) && !(alist.length == 0)) { + context.setLanguage(alist[0]); + navigatorLanguage = alist[0]; + } + } + } + + // Get language from cookie + try { + cookieLanguage = getUserPreferenceFromCookie("interfacelanguage", context); + } catch (Exception e) { + } + + // Determine which language to use + // First we get the language from the request + if ((requestLanguage != null) && (!requestLanguage.equals(""))) { + if (requestLanguage.equals("default")) { + setCookie = true; + } else { + language = requestLanguage; + context.setLanguage(language); + Cookie cookie = new Cookie("interfacelanguage", language); + cookie.setMaxAge(60 * 60 * 24 * 365 * 10); + cookie.setPath("/"); + context.getResponse().addCookie(cookie); + return language; + } + } + // Next we get the language from the context + if(contextLanguage != null && contextLanguage != ""){ + language = contextLanguage; + } + // Next we get the language from the cookie + else if(cookieLanguage != null && cookieLanguage != ""){ + language = cookieLanguage; + } + // Next from the default user preference + else if(userPreferenceLanguage != null && userPreferenceLanguage != ""){ + language = userPreferenceLanguage; + } + // Then from the navigator language setting + else if(navigatorLanguage != null && navigatorLanguage != ""){ + language = navigatorLanguage; + } + context.setLanguage(language); + if(setCookie){ + Cookie cookie = new Cookie("interfacelanguage", language); + cookie.setMaxAge(60 * 60 * 24 * 365 * 10); + cookie.setPath("/"); + context.getResponse().addCookie(cookie); + } + return language; } public long getXWikiPreferenceAsLong(String prefname, XWikiContext context) { @@ -1440,10 +1571,7 @@ // We need to flush the virtual wiki list virtualWikiList = new ArrayList(); // We need to flush the server Cache - if (virtualWikiMap!=null) { - virtualWikiMap.flushAll(); - virtualWikiMap = null; - } + virtualWikiMap = new HashMap(); // We need to flush the group service cache if (groupService != null) @@ -1485,10 +1613,6 @@ this.attachmentStore = attachmentStore; } - public void setVersioningStore(XWikiVersioningStoreInterface versioningStore) { - this.versioningStore = versioningStore; - } - public void setVersion(String version) { this.version = version; } @@ -1507,33 +1631,9 @@ preparePlugins(context); } } - - flushVirtualWikis(olddoc); - flushVirtualWikis(newdoc); } - private void flushVirtualWikis(XWikiDocument doc) { - List bobjects = doc.getObjects("XWiki.XWikiServerClass"); - if (bobjects!=null) { - Iterator it = bobjects.iterator(); - while (it.hasNext()) { - BaseObject bobj = (BaseObject) it.next(); - if (bobj!=null) { - String host = bobj.getStringValue("server"); - if ((host!=null)&&(!"".equals(host))) { - try { - if (virtualWikiMap.getFromCache(host)!=null) - virtualWikiMap.flushEntry(host); - } catch (XWikiCacheNeedsRefreshException e) { - virtualWikiMap.cancelUpdate(host); - } - } - } - } - } - } - - public BaseClass getUserClass(XWikiContext context) throws XWikiException { + public synchronized BaseClass getUserClass(XWikiContext context) throws XWikiException { XWikiDocument doc; boolean needsUpdate = false; @@ -1572,7 +1672,7 @@ } - public BaseClass getPrefsClass(XWikiContext context) throws XWikiException { + public synchronized BaseClass getPrefsClass(XWikiContext context) throws XWikiException { XWikiDocument doc; boolean needsUpdate = false; @@ -1650,7 +1750,7 @@ return bclass; } - public BaseClass getGroupClass(XWikiContext context) throws XWikiException { + public synchronized BaseClass getGroupClass(XWikiContext context) throws XWikiException { XWikiDocument doc; boolean needsUpdate = false; @@ -1679,7 +1779,7 @@ } - public BaseClass getRightsClass(String pagename, XWikiContext context) throws XWikiException { + public synchronized BaseClass getRightsClass(String pagename, XWikiContext context) throws XWikiException { XWikiDocument doc; boolean needsUpdate = false; @@ -1739,15 +1839,15 @@ return bclass; } - public BaseClass getRightsClass(XWikiContext context) throws XWikiException { + public synchronized BaseClass getRightsClass(XWikiContext context) throws XWikiException { return getRightsClass("XWikiRights", context); } - public BaseClass getGlobalRightsClass(XWikiContext context) throws XWikiException { + public synchronized BaseClass getGlobalRightsClass(XWikiContext context) throws XWikiException { return getRightsClass("XWikiGlobalRights", context); } - public BaseClass getCommentsClass(XWikiContext context) throws XWikiException { + public synchronized BaseClass getCommentsClass(XWikiContext context) throws XWikiException { XWikiDocument doc; boolean needsUpdate = false; @@ -1780,7 +1880,7 @@ return bclass; } - public BaseClass getSkinClass(XWikiContext context) throws XWikiException { + public synchronized BaseClass getSkinClass(XWikiContext context) throws XWikiException { XWikiDocument doc; boolean needsUpdate = false; @@ -2054,8 +2154,8 @@ } try { - XWikiGroupService gservice = (XWikiGroupService) getGroupService(context); - gservice.addUserToGroup(fullwikiname, context.getDatabase(), "XWiki.XWikiAllGroup", context); + XWikiGroupService gservice = (XWikiGroupService) getGroupService(); + gservice.addUserToGroup(fullwikiname, context.getDatabase(), "XWiki.XWikiAllGroup"); } catch (Exception e) { e.printStackTrace(); } @@ -2089,7 +2189,7 @@ public void prepareResources(XWikiContext context) { if (context.get("msg") == null) { - String language = getLanguagePreference(context); + String language = getInterfaceLanguagePreference(context); if (context.getResponse() != null) context.getResponse().setLocale(new Locale(language)); ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources", new Locale(language)); @@ -2231,7 +2331,6 @@ public void deleteDocument(XWikiDocument doc, XWikiContext context) throws XWikiException { getStore().deleteXWikiDoc(doc, context); - getNotificationManager().verify(doc, new XWikiDocument(doc.getWeb(), doc.getName()), XWikiDocChangeNotificationInterface.EVENT_CHANGE, context); } public String getDatabase() { @@ -2306,11 +2405,11 @@ } public boolean copyDocument(String docname, String targetdocname, XWikiContext context) throws XWikiException { - return copyDocument(docname, targetdocname, null, null, null, true, context); + return copyDocument(docname, targetdocname, null, null, null, false, context); } public boolean copyDocument(String docname, String targetdocname, String wikilanguage, XWikiContext context) throws XWikiException { - return copyDocument(docname, targetdocname, null, null, wikilanguage, true, context); + return copyDocument(docname, targetdocname, null, null, wikilanguage, false, context); } public boolean copyDocument(String docname, String sourceWiki, String targetWiki, String wikilanguage, XWikiContext context) throws XWikiException { @@ -2353,19 +2452,10 @@ // forget past versions if (reset) { tdoc.setVersion("1.1"); + tdoc.setRCSArchive(null); } saveDocument(tdoc, context); - if (!reset) { - if (sourceWiki != null) - context.setDatabase(sourceWiki); - XWikiDocumentArchive txda = getVersioningStore().getXWikiDocumentArchive(sdoc, context); - if (targetWiki != null) - context.setDatabase(targetWiki); - txda.setId(tdoc.getId()); - getVersioningStore().saveXWikiDocArchive(txda, true, context); - } - List attachlist = tdoc.getAttachmentList(); if (attachlist.size() > 0) { for (int i = 0; i < attachlist.size(); i++) { @@ -2403,19 +2493,9 @@ // forget past versions if (reset) { ttdoc.setVersion("1.1"); + ttdoc.setRCSArchive(null); } saveDocument(ttdoc, context); - - if (!reset) { - if (sourceWiki != null) - context.setDatabase(sourceWiki); - XWikiDocumentArchive txda = getVersioningStore().getXWikiDocumentArchive(sdoc, context); - if (targetWiki != null) - context.setDatabase(targetWiki); - txda.setId(ttdoc.getId()); - getVersioningStore().saveXWikiDocArchive(txda, true, context); - } - } } else { // We want only one language in the end @@ -2438,20 +2518,9 @@ // forget past versions if (reset) { tdoc.setVersion("1.1"); + tdoc.setRCSArchive(null); } - saveDocument(tdoc, context); - - if (!reset) { - if (sourceWiki != null) - context.setDatabase(sourceWiki); - XWikiDocumentArchive txda = getVersioningStore().getXWikiDocumentArchive(sdoc, context); - if (targetWiki != null) - context.setDatabase(targetWiki); - txda.setId(tdoc.getId()); - getVersioningStore().saveXWikiDocArchive(txda, true, context); - } - List attachlist = tdoc.getAttachmentList(); if (attachlist.size() > 0) { for (int i = 0; i < attachlist.size(); i++) { @@ -2550,9 +2619,6 @@ // Verify is server page already exist XWikiDocument serverdoc = getDocument("XWiki", wikiServerPage, context); if (serverdoc.isNew()) { - // clear entry in virtual wiki cache - virtualWikiMap.flushEntry(wikiUrl); - // Create Wiki Server page serverdoc.setStringValue("XWiki.XWikiServerClass", "server", wikiUrl); serverdoc.setLargeStringValue("XWiki.XWikiServerClass", "owner", wikiAdmin); @@ -2593,7 +2659,7 @@ } try { - updateDatabase(wikiName, true, false, context); + updateDatabase(wikiName, true, context); } catch (Exception e) { log.error("Wiki creation (" + wikiName + "," + wikiUrl + "," + wikiAdmin + ") failed: " + "wiki database shema update threw exception", e); return -6; @@ -2611,12 +2677,11 @@ // Modify rights in user wiki context.setDatabase(wikiName); - /*XWikiDocument wikiprefdoc = getDocument("XWiki.XWikiPreferences", context); + XWikiDocument wikiprefdoc = getDocument("XWiki.XWikiPreferences", context); wikiprefdoc.setStringValue("XWiki.XWikiGlobalRights", "users", wikiAdmin); wikiprefdoc.setStringValue("XWiki.XWikiGlobalRights", "levels", "admin, edit"); wikiprefdoc.setIntValue("XWiki.XWikiGlobalRights", "allow", 1); saveDocument(wikiprefdoc, context); - */ return 1; } catch (Exception e) { log.error("Wiki creation (" + wikiName + "," + wikiUrl + "," + wikiAdmin + ") failed: " + "wiki creation threw exception", e); @@ -2627,7 +2692,7 @@ } public String getEncoding() { - return Param("xwiki.encoding", "ISO-8859-1"); + return Param("xwiki.encoding", "UTF-8"); } @@ -2843,28 +2908,26 @@ this.rightService = rightService; } - public XWikiGroupService getGroupService(XWikiContext context) throws XWikiException { - synchronized (GROUP_SERVICE_LOCK) { - if (groupService == null) { - String groupClass; + public XWikiGroupService getGroupService() { + if (groupService == null) { + String groupClass; + if (isExo()) + groupClass = Param("xwiki.authentication.groupclass", "com.xpn.xwiki.user.impl.exo.ExoGroupServiceImpl"); + else + groupClass = Param("xwiki.authentication.groupclass", "com.xpn.xwiki.user.impl.xwiki.XWikiGroupServiceImpl"); + + try { + groupService = (XWikiGroupService) Class.forName(groupClass).newInstance(); + groupService.init(this); + } catch (Exception e) { + e.printStackTrace(); if (isExo()) - groupClass = Param("xwiki.authentication.groupclass", "com.xpn.xwiki.user.impl.exo.ExoGroupServiceImpl"); + groupService = new ExoGroupServiceImpl(); else - groupClass = Param("xwiki.authentication.groupclass", "com.xpn.xwiki.user.impl.xwiki.XWikiGroupServiceImpl"); - - try { - groupService = (XWikiGroupService) Class.forName(groupClass).newInstance(); - } catch (Exception e) { - e.printStackTrace(); - if (isExo()) - groupService = new ExoGroupServiceImpl(); - else - groupService = new XWikiGroupServiceImpl(); - } - groupService.init(this, context); + groupService = new XWikiGroupServiceImpl(); } - return groupService; } + return groupService; } public void setGroupService(XWikiGroupService groupService) { @@ -2873,144 +2936,135 @@ // added some log statements to make debugging easier - LBlaze 2005.06.02 public XWikiAuthService getAuthService() { - synchronized (AUTH_SERVICE_LOCK) { - if (authService == null) { + if (authService == null) { - log.info("Initializing AuthService..."); + log.info("Initializing AuthService..."); - String authClass = Param("xwiki.authentication.authclass"); - if (authClass != null) { - if (log.isDebugEnabled()) log.debug("Using custom AuthClass " + authClass + "."); - } else { + String authClass = Param("xwiki.authentication.authclass"); + if (authClass != null) { + if (log.isDebugEnabled()) log.debug("Using custom AuthClass " + authClass + "."); + } else { - if (isExo()) - authClass = "com.xpn.xwiki.user.impl.exo.ExoAuthServiceImpl"; - else if (isLDAP()) - authClass = "com.xpn.xwiki.user.impl.LDAP.LDAPAuthServiceImpl"; - else - authClass = "com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl"; + if (isExo()) + authClass = "com.xpn.xwiki.user.impl.exo.ExoAuthServiceImpl"; + else if (isLDAP()) + authClass = "com.xpn.xwiki.user.impl.LDAP.LDAPAuthServiceImpl"; + else + authClass = "com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl"; - if (log.isDebugEnabled()) log.debug("Using default AuthClass " + authClass + "."); + if (log.isDebugEnabled()) log.debug("Using default AuthClass " + authClass + "."); - } + } - try { + try { - authService = (XWikiAuthService) Class.forName(authClass).newInstance(); + authService = (XWikiAuthService) Class.forName(authClass).newInstance(); - log.debug("Initialized AuthService using Relfection."); + log.debug("Initialized AuthService using Relfection."); - } catch (Exception e) { + } catch (Exception e) { - log.warn("Failed to initialize AuthService " + authClass + " using Reflection, trying default implementations using 'new'.", e); + log.warn("Failed to initialize AuthService " + authClass + " using Reflection, trying default implementations using 'new'.", e); - // e.printStackTrace(); - not needed? -LBlaze + // e.printStackTrace(); - not needed? -LBlaze - // LDAP support wasn't here before, I assume it should be? -LBlaze + // LDAP support wasn't here before, I assume it should be? -LBlaze - if (isExo()) - authService = new ExoAuthServiceImpl(); - else if (isLDAP()) - authService = new LDAPAuthServiceImpl(); - else - authService = new XWikiAuthServiceImpl(); + if (isExo()) + authService = new ExoAuthServiceImpl(); + else if (isLDAP()) + authService = new LDAPAuthServiceImpl(); + else + authService = new XWikiAuthServiceImpl(); - if (log.isDebugEnabled()) - log.debug("Initialized AuthService " + authService.getClass().getName() + " using 'new'."); + if (log.isDebugEnabled()) + log.debug("Initialized AuthService " + authService.getClass().getName() + " using 'new'."); - } } - return authService; } + return authService; } // added some log statements to make debugging easier - LBlaze 2005.06.02 public XWikiRightService getRightService() { - synchronized (RIGHT_SERVICE_LOCK) { + if (rightService == null) { - if (rightService == null) { + log.info("Initializing RightService..."); - log.info("Initializing RightService..."); - - String rightsClass = Param("xwiki.authentication.rightsclass"); - if (rightsClass != null) { - if (log.isDebugEnabled()) log.debug("Using custom RightsClass " + rightsClass + "."); - } else { - rightsClass = "com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl"; - if (log.isDebugEnabled()) log.debug("Using default RightsClass " + rightsClass + "."); - } + String rightsClass = Param("xwiki.authentication.rightsclass"); + if (rightsClass != null) { + if (log.isDebugEnabled()) log.debug("Using custom RightsClass " + rightsClass + "."); + } else { + rightsClass = "com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl"; + if (log.isDebugEnabled()) log.debug("Using default RightsClass " + rightsClass + "."); + } - try { + try { - rightService = (XWikiRightService) Class.forName(rightsClass).newInstance(); - log.debug("Initialized RightService using Reflection."); + rightService = (XWikiRightService) Class.forName(rightsClass).newInstance(); + log.debug("Initialized RightService using Reflection."); - } catch (Exception e) { + } catch (Exception e) { - log.warn("Failed to initialize RightService " + rightsClass + " using Reflection, trying default implementation using 'new'.", e); + log.warn("Failed to initialize RightService " + rightsClass + " using Reflection, trying default implementation using 'new'.", e); - //e.printStackTrace(); - not needed? -LBlaze + //e.printStackTrace(); - not needed? -LBlaze - rightService = new XWikiRightServiceImpl(); + rightService = new XWikiRightServiceImpl(); - if (log.isDebugEnabled()) - log.debug("Initialized RightService " + authService.getClass().getName() + " using 'new'."); + if (log.isDebugEnabled()) + log.debug("Initialized RightService " + authService.getClass().getName() + " using 'new'."); - } } - return rightService; } + return rightService; } public XWikiStatsService getStatsService(XWikiContext context) { - synchronized (STATS_SERVICE_LOCK) { - if (statsService == null) { - if ("1".equals(Param("xwiki.stats", "1"))) { - String storeClass = Param("xwiki.stats.class", "com.xpn.xwiki.stats.impl.XWikiStatsServiceImpl"); - try { - statsService = (XWikiStatsService) Class.forName(storeClass).newInstance(); - } catch (Exception e) { - e.printStackTrace(); - statsService = new XWikiStatsServiceImpl(); - } - statsService.init(context); + if (statsService == null) { + if ("1".equals(Param("xwiki.stats", "1"))) { + String storeClass = Param("xwiki.stats.class", "com.xpn.xwiki.stats.impl.XWikiStatsServiceImpl"); + try { + statsService = (XWikiStatsService) Class.forName(storeClass).newInstance(); + } catch (Exception e) { + e.printStackTrace(); + statsService = new XWikiStatsServiceImpl(); } + statsService.init(context); } - return statsService; } + return statsService; } public XWikiURLFactoryService getURLFactoryService() { - synchronized (URLFACTORY_SERVICE_LOCK) { - if (urlFactoryService == null) { + if (urlFactoryService == null) { - log.info("Initializing URLFactory Service..."); + log.info("Initializing URLFactory Service..."); - String urlFactoryServiceClass = Param("xwiki.urlfactory.serviceclass"); + String urlFactoryServiceClass = Param("xwiki.urlfactory.serviceclass"); - if (urlFactoryServiceClass != null) { - try { - if (log.isDebugEnabled()) - log.debug("Using custom URLFactory Service Class " + urlFactoryServiceClass + "."); - urlFactoryService = (XWikiURLFactoryService) Class.forName(urlFactoryServiceClass).newInstance(); - urlFactoryService.init(this); - log.debug("Initialized URLFactory Service using Reflection."); - } - catch (Exception e) { - urlFactoryService = null; - log.warn("Failed to initialize URLFactory Service " + urlFactoryServiceClass + " using Reflection, trying default implementation using 'new'.", e); - } - } - if (urlFactoryService == null) { + if (urlFactoryServiceClass != null) { + try { if (log.isDebugEnabled()) - log.debug("Using default URLFactory Service Class " + urlFactoryServiceClass + "."); - urlFactoryService = new XWikiURLFactoryServiceImpl(); + log.debug("Using custom URLFactory Service Class " + urlFactoryServiceClass + "."); + urlFactoryService = (XWikiURLFactoryService) Class.forName(urlFactoryServiceClass).newInstance(); urlFactoryService.init(this); + log.debug("Initialized URLFactory Service using Reflection."); + } + catch (Exception e) { + urlFactoryService = null; + log.warn("Failed to initialize URLFactory Service " + urlFactoryServiceClass + " using Reflection, trying default implementation using 'new'.", e); } } - return urlFactoryService; + if (urlFactoryService == null) { + if (log.isDebugEnabled()) + log.debug("Using default URLFactory Service Class " + urlFactoryServiceClass + "."); + urlFactoryService = new XWikiURLFactoryServiceImpl(); + urlFactoryService.init(this); + } } + return urlFactoryService; } public Object getService(String className) throws XWikiException { @@ -3302,21 +3356,19 @@ */ public XWikiCacheService getCacheService() { - synchronized (CACHE_SERVICE_LOCK) { - if (cacheService == null) { - String cacheClass; - cacheClass = Param("xwiki.cache.cacheclass", "com.xpn.xwiki.cache.impl.OSCacheService"); + if (cacheService == null) { + String cacheClass; + cacheClass = Param("xwiki.cache.cacheclass", "com.xpn.xwiki.cache.impl.OSCacheService"); - try { - cacheService = (XWikiCacheService) Class.forName(cacheClass).newInstance(); - cacheService.init(this); - } catch (Exception e) { - e.printStackTrace(); - cacheService = new OSCacheService(); - } + try { + cacheService = (XWikiCacheService) Class.forName(cacheClass).newInstance(); + cacheService.init(this); + } catch (Exception e) { + e.printStackTrace(); + cacheService = new OSCacheService(); } - return cacheService; } + return cacheService; } public String getURLContent(String surl) throws IOException { @@ -3576,15 +3628,14 @@ } public BaseClass getClass(String fullName, XWikiContext context) throws XWikiException { - // Used to avoid recursive loading of documents if there are recursives usage of classes - BaseClass bclass = context.getBaseClass(fullName); - if (bclass!=null) - return bclass; return getDocument(fullName, context).getxWikiClass(); } public String getEditorPreference(XWikiContext context) { String pref = getUserPreference("editor", context); + if (pref.equals("---")){ + pref = getWebPreference("editor", context); + } if (pref.equals("")) pref = Param("xwiki.editor", ""); return pref.toLowerCase(); @@ -3609,6 +3660,5 @@ macrosmapping += "\r\n" + xwiki.getXWikiPreference("macros_mapping", "", context); return macrosmapping; } - } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiContext.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWikiContext.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiContext.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWikiContext.java 2006-08-02 16:41:45.000000000 +0300 @@ -26,13 +26,10 @@ import java.net.URL; import java.util.Hashtable; -import java.util.Map; -import java.util.HashMap; import org.apache.xmlrpc.XmlRpcServer; import com.xpn.xwiki.doc.XWikiDocument; -import com.xpn.xwiki.doc.XWikiDocumentArchive; import com.xpn.xwiki.user.api.XWikiUser; import com.xpn.xwiki.util.Util; import com.xpn.xwiki.web.XWikiEngineContext; @@ -40,7 +37,6 @@ import com.xpn.xwiki.web.XWikiRequest; import com.xpn.xwiki.web.XWikiResponse; import com.xpn.xwiki.web.XWikiURLFactory; -import com.xpn.xwiki.objects.classes.BaseClass; public class XWikiContext extends Hashtable { @@ -62,6 +58,7 @@ private boolean virtual; private XWikiUser user; private String language; + private String interfaceLanguage; private int mode; private URL url; private XWikiURLFactory URLFactory; @@ -70,12 +67,7 @@ private XWikiDocument wikiServer; private int cacheDuration = 0; - // Used to avoid recursive loading of documents if there are recursives usage of classes - private Map classCache = new HashMap(); - // Used to avoir reloading archives in the same request - private Map archiveCache = new HashMap(); - - public XWikiContext() { + public XWikiContext() { } public XWiki getWiki() { @@ -180,7 +172,7 @@ String username = getUser(); return username.substring(username.indexOf(":") + 1); } - + public XWikiUser getXWikiUser() { return user; } @@ -193,6 +185,14 @@ this.language = language; } + public String getInterfaceLanguage() { + return interfaceLanguage; + } + + public void setInterfaceLanguage(String interfaceLanguage) { + this.interfaceLanguage = interfaceLanguage; + } + public int getMode() { return mode; } @@ -272,25 +272,4 @@ public void setMainXWiki(String str) { put("mainxwiki", str); } - - // Used to avoid recursive loading of documents if there are recursives usage of classes - public void addBaseClass(BaseClass bclass) { - classCache.put(bclass.getName(), bclass); - } - - // Used to avoid recursive loading of documents if there are recursives usage of classes - public BaseClass getBaseClass(String name) { - return (BaseClass) classCache.get(name); - } - - // Used to avoid recursive loading of documents if there are recursives usage of classes - public void addDocumentArchive(String key, Object obj) { - classCache.put(key, obj); - } - - // Used to avoid recursive loading of documents if there are recursives usage of classes - public Object getDocumentArchive(String key) { - return classCache.get(key); - } - } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWikiException.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiException.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWikiException.java 2006-07-12 14:10:01.000000000 +0300 @@ -25,8 +25,7 @@ package com.xpn.xwiki; - -// import com.xpn.xwiki.store.XWikiBatcher; +import com.xpn.xwiki.store.XWikiBatcher; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.velocity.exception.MethodInvocationException; @@ -67,7 +66,6 @@ public static final int MODULE_XWIKI_DIFF = 13; public static final int MODULE_XWIKI_GROOVY = 14; public static final int MODULE_XWIKI_NOTIFICATION = 15; - public static final int MODULE_XWIKI_CACHE = 16; public static final int MODULE_PLUGIN_LASZLO = 21; @@ -198,8 +196,6 @@ public static final int ERROR_XWIKI_NOTIFICATION = 15001; - public static final int ERROR_CACHE_INITIALIZING = 16001; - public static final int ERROR_LASZLO_INVALID_XML = 21001; public static final int ERROR_LASZLO_INVALID_DOTDOT = 21002; @@ -304,7 +300,6 @@ buffer.append("\n"); buffer.append(getStackTraceAsString()); buffer.append("\n"); - /* List list = XWikiBatcher.getSQLStats().getRecentSqlList(); if (list.size() > 0) { buffer.append("Recent SQL:\n"); @@ -313,7 +308,6 @@ buffer.append("\n"); } } - */ return buffer.toString(); } @@ -321,14 +315,14 @@ super.printStackTrace(s); if (exception != null) { s.write("\n\nWrapped Exception:\n\n"); - if (exception.getCause()!=null) - exception.getCause().printStackTrace(s); - else if (exception instanceof org.hibernate.JDBCException) { + if (exception instanceof org.hibernate.JDBCException) { (((JDBCException) exception).getSQLException()).printStackTrace(s); } else if (exception instanceof MethodInvocationException) { (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s); } else if (exception instanceof ServletException) { (((ServletException) exception).getRootCause()).printStackTrace(s); + } else if (exception instanceof TransformerException) { + (((TransformerException) exception).getCause()).printStackTrace(s); } else { exception.printStackTrace(s); } @@ -339,14 +333,14 @@ super.printStackTrace(s); if (exception != null) { s.print("\n\nWrapped Exception:\n\n"); - if (exception.getCause()!=null) - exception.getCause().printStackTrace(s); - else if (exception instanceof org.hibernate.JDBCException) { + if (exception instanceof org.hibernate.JDBCException) { (((JDBCException) exception).getSQLException()).printStackTrace(s); } else if (exception instanceof MethodInvocationException) { (((MethodInvocationException) exception).getWrappedThrowable()).printStackTrace(s); } else if (exception instanceof ServletException) { (((ServletException) exception).getRootCause()).printStackTrace(s); + } else if (exception instanceof TransformerException) { + (((TransformerException) exception).getCause()).printStackTrace(s); } else { exception.printStackTrace(s); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiInterface.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWikiInterface.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiInterface.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/XWikiInterface.java 2006-08-02 16:35:52.000000000 +0300 @@ -1,25 +1,25 @@ -/* - * Copyright 2006, 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. - * - * @author vmassol - * @author sdumitriu - */ +/* + * Copyright 2006, 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. + * + * @author vmassol + * @author sdumitriu + */ package com.xpn.xwiki; @@ -142,7 +142,11 @@ String getUserPreference(String prefname, boolean useCookie, XWikiContext context); - String getLanguagePreference(XWikiContext context); + String getLanguagePreference(XWikiContext context); + + String getDocLanguagePreference(XWikiContext context); + + String getInterfaceLanguagePreference(XWikiContext context); long getXWikiPreferenceAsLong(String prefname, XWikiContext context); @@ -279,7 +283,7 @@ void setRightService(XWikiRightService rightService); - XWikiGroupService getGroupService(XWikiContext context) throws XWikiException; + XWikiGroupService getGroupService(); void setGroupService(XWikiGroupService groupService); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/api/Attachment.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Attachment.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Attachment.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Attachment.java 2006-07-29 17:26:36.000000000 +0300 @@ -26,8 +26,8 @@ import java.util.Date; import java.util.List; -import org.suigeneris.jrcs.rcs.Archive; -import org.suigeneris.jrcs.rcs.Version; +import org.apache.commons.jrcs.rcs.Archive; +import org.apache.commons.jrcs.rcs.Version; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Class.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java 2006-07-12 14:09:50.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Class.java 2006-07-20 23:00:31.000000000 +0300 @@ -25,6 +25,8 @@ package com.xpn.xwiki.api; +import java.util.Arrays; +import java.util.Comparator; import java.util.Iterator; import com.xpn.xwiki.XWikiContext; @@ -55,6 +57,7 @@ for (Iterator it = coll.iterator(); it.hasNext();i++) { properties[i] = new PropertyClass((com.xpn.xwiki.objects.classes.PropertyClass) it.next(), context); } + Arrays.sort(properties, new PropertyComparator()); return properties; } @@ -89,5 +92,14 @@ BaseObject obj = (BaseObject)getBaseClass().newObject(context); return obj.newObjectApi(obj, context); } +} +class PropertyComparator implements Comparator{ + public int compare(java.lang.Object o1, java.lang.Object o2) { + PropertyClass po1 = (PropertyClass)o1; + PropertyClass po2 = (PropertyClass)o2; + if(po1.getNumber() < po2.getNumber()) return -1; + if(po1.getNumber() > po2.getNumber()) return 1; + return 0; + } } \ No newline at end of file diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Context.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java 2006-07-12 14:09:50.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Context.java 2006-08-02 16:42:25.000000000 +0300 @@ -115,6 +115,14 @@ /** * + * @return the interface language preference of the current user + */ + public String getInterfaceLanguage() { + return context.getInterfaceLanguage(); + } + + /** + * * @return the XWiki object if you have the programming right */ public com.xpn.xwiki.XWiki getXWiki() { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/api/Document.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Document.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Document.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Document.java 2006-07-28 22:14:09.000000000 +0300 @@ -36,15 +36,15 @@ import java.util.Map; import java.util.Vector; -import org.suigeneris.jrcs.diff.DifferentiationFailedException; -import org.suigeneris.jrcs.rcs.Version; +import org.apache.commons.jrcs.diff.DifferentiationFailedException; +import org.apache.commons.jrcs.rcs.Archive; +import org.apache.commons.jrcs.rcs.Version; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.doc.XWikiAttachment; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.doc.XWikiLock; -import com.xpn.xwiki.doc.XWikiDocumentArchive; import com.xpn.xwiki.objects.BaseObject; import com.xpn.xwiki.objects.classes.BaseClass; import com.xpn.xwiki.stats.impl.DocumentStats; @@ -188,7 +188,7 @@ return doc.getRenderedContent(context); } - public String getRenderedContent(String text) throws XWikiException { + public String getRenderedContent(String text) { return doc.getRenderedContent(text, context); } @@ -196,12 +196,12 @@ return doc.getEscapedContent(context); } - public String getArchive() throws XWikiException { - return doc.getDocumentArchive(context).getArchive(); + public Archive getRCSArchive() { + return doc.getRCSArchive(); } - public XWikiDocumentArchive getDocumentArchive() throws XWikiException { - return doc.getDocumentArchive(context); + public String getArchive() throws XWikiException { + return doc.getArchive(); } public boolean isNew() { @@ -504,7 +504,7 @@ return doc.displayForm(className, context); } - public String displayRendered(com.xpn.xwiki.api.PropertyClass pclass, String prefix, Collection object) throws XWikiException { + public String displayRendered(com.xpn.xwiki.api.PropertyClass pclass, String prefix, Collection object) { if ((pclass==null)||(object==null)) return ""; return doc.displayRendered(pclass.getBasePropertyClass(), prefix, object.getCollection(), context); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/api/Object.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Object.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Object.java 2006-07-12 14:09:50.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/Object.java 2006-08-02 18:29:56.000000000 +0300 @@ -28,8 +28,6 @@ import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.objects.BaseObject; -import java.lang.*; - public class Object extends Collection { public Object(BaseObject obj, XWikiContext context) { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/api/User.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/User.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/api/User.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/User.java 2006-07-12 14:09:50.000000000 +0300 @@ -1,24 +1,24 @@ -/* - * Copyright 2006, 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. - * - * @author kaaloo - */ +/* + * Copyright 2006, 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. + * + * @author kaaloo + */ package com.xpn.xwiki.api; @@ -46,7 +46,7 @@ } public boolean isUserInGroup(String groupName) throws XWikiException { - XWikiGroupService groupService = context.getWiki().getGroupService(context); + XWikiGroupService groupService = context.getWiki().getGroupService(); Collection groups = groupService.listGroupsForUser(user.getUser(), context); return groups.contains(groupName); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/XWiki.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/api/XWiki.java 2006-08-02 19:39:29.000000000 +0300 @@ -28,27 +28,29 @@ package com.xpn.xwiki.api; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.commons.jrcs.diff.Chunk; + import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.render.groovy.XWikiGroovyRenderer; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.objects.meta.MetaClass; import com.xpn.xwiki.stats.api.XWikiStatsService; import com.xpn.xwiki.stats.impl.DocumentStats; import com.xpn.xwiki.web.Utils; import com.xpn.xwiki.web.XWikiMessageTool; -import org.suigeneris.jrcs.diff.Chunk; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.OutputStream; -import java.util.*; -import java.lang.*; -import java.lang.Object; - -import groovy.lang.GroovyClassLoader; public class XWiki extends Api { private com.xpn.xwiki.XWiki xwiki; @@ -394,6 +396,14 @@ return xwiki.getLanguagePreference(context); } + public String getDocLanguagePreference() { + return xwiki.getDocLanguagePreference(context); + } + + public String getInterfaceLanguagePreference() { + return xwiki.getInterfaceLanguagePreference(context); + } + public boolean isVirtual() { return xwiki.isVirtual(); } @@ -557,7 +567,7 @@ } } - public String renderText(String text, Document doc) throws XWikiException { + public String renderText(String text, Document doc) { return xwiki.getRenderingEngine().renderText(text, doc.getDoc(), context); } @@ -998,7 +1008,7 @@ public Object parseGroovyFromString(String script) throws XWikiException { if (checkProgrammingRights()) - return xwiki.parseGroovyFromString(script, context); + return (Object)xwiki.parseGroovyFromString(script, context); else return null; } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/cache/api/XWikiCache.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/api/XWikiCache.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/cache/api/XWikiCache.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/api/XWikiCache.java 2006-07-12 14:09:50.000000000 +0300 @@ -1,24 +1,24 @@ -/* - * Copyright 2006, 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. - * - * @author sdumitriu - */ +/* + * Copyright 2006, 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. + * + * @author sdumitriu + */ package com.xpn.xwiki.cache.api; @@ -29,7 +29,6 @@ void putInCache(String key, Object obj); Object getFromCache(String key) throws XWikiCacheNeedsRefreshException; Object getFromCache(String key, int refeshPeriod) throws XWikiCacheNeedsRefreshException; - int getNumberEntries(); void cancelUpdate(String key); void flushAll(); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/cache/api/XWikiCacheService.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/api/XWikiCacheService.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/cache/api/XWikiCacheService.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/api/XWikiCacheService.java 2006-07-12 14:09:50.000000000 +0300 @@ -22,9 +22,6 @@ package com.xpn.xwiki.cache.api; import com.xpn.xwiki.XWiki; -import com.xpn.xwiki.XWikiException; - -import java.util.Properties; public interface XWikiCacheService { @@ -32,46 +29,24 @@ * Initializes the service */ public void init(XWiki context); - + /* - * Returns a local only (never clustered) cache - */ - public XWikiCache newLocalCache() throws XWikiException; + * Returns a local only (never clustered) cache + */ + public XWikiCache newLocalCache(); /* * Returns a local only (never clustered) cache with given capacity */ - public XWikiCache newLocalCache(int capacity) throws XWikiException; + public XWikiCache newLocalCache(int capacity); /* * Returns a cache that could be configured to be clustered */ - public XWikiCache newCache(String cacheName) throws XWikiException; + public XWikiCache newCache(); /* * Returns a cache that could be configured to be clustered with the given capacity */ - public XWikiCache newCache(String cacheName, int capacity) throws XWikiException; - - - /* - * Returns a custom cache - */ - public XWikiCache newCache(String cacheName, Properties props) throws XWikiException; - - /* - * Returns a custom local cache - */ - public XWikiCache newLocalCache(Properties props) throws XWikiException; - - /* - * Returns a custom cache with capacity - */ - public XWikiCache newCache(String cacheName, Properties props, int capacity) throws XWikiException; - - /* - * Returns a custom local cache with capacity - */ - public XWikiCache newLocalCache(Properties props, int capacity) throws XWikiException; - + public XWikiCache newCache(int capacity); } Only in xwiki/trunk/src/main/java/com/xpn/xwiki/cache/impl: ClusterSharedNotification.java diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/cache/impl/OSCacheCache.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/impl/OSCacheCache.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/cache/impl/OSCacheCache.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/impl/OSCacheCache.java 2006-07-12 14:09:50.000000000 +0300 @@ -1,9 +1,7 @@ package com.xpn.xwiki.cache.impl; +import java.util.Date; import java.util.Properties; -import java.util.Map; -import java.util.Collection; -import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -11,12 +9,9 @@ import com.opensymphony.oscache.base.Cache; import com.opensymphony.oscache.base.EntryRefreshPolicy; import com.opensymphony.oscache.base.NeedsRefreshException; -import com.opensymphony.oscache.base.CacheEntry; import com.opensymphony.oscache.general.GeneralCacheAdministrator; import com.xpn.xwiki.cache.api.XWikiCache; import com.xpn.xwiki.cache.api.XWikiCacheNeedsRefreshException; -import com.xpn.xwiki.XWiki; -import com.xpn.xwiki.XWikiException; /** * Copyright 2006, XpertNet SARL, and individual contributors as indicated by @@ -49,54 +44,50 @@ { private static final Log log = LogFactory.getLog(OSCacheCache.class); - private GeneralCacheAdministrator cacheAdmin; + private GeneralCacheAdministrator cache; private String name; private int capacity; - public OSCacheCache(Properties props) throws XWikiException + public OSCacheCache(Properties props) { - try { - cacheAdmin = new GeneralCacheAdministrator(props); - } catch (Throwable e) { - throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Exception while initializing cache", e); - } + cache = new GeneralCacheAdministrator(props); } - public OSCacheCache(Properties props, int capacity) throws XWikiException + public OSCacheCache(Properties props, int capacity) { this(props); - cacheAdmin.setCacheCapacity(capacity); + cache.setCacheCapacity(capacity); this.capacity = capacity; } /** * Provide package-private access to the underlying m_cache */ - Cache getCacheAdmin() + Cache getCache() { - return cacheAdmin.getCache(); + return cache.getCache(); } public void setCapacity(int capacity) { - cacheAdmin.setCacheCapacity(capacity); + cache.setCacheCapacity(capacity); this.capacity = capacity; } public void flushEntry(String key) { - cacheAdmin.flushEntry(key); + cache.flushEntry(key); } public void putInCache(String key, Object obj) { - cacheAdmin.putInCache(key, obj); + cache.putInCache(key, obj); logCacheAdd(key, obj); } public void putInCache(String key, Object obj, EntryRefreshPolicy expiry) { - cacheAdmin.putInCache(key, obj, expiry); + cache.putInCache(key, obj, expiry); logCacheAdd(key, obj); } @@ -104,7 +95,7 @@ { try { - return cacheAdmin.getFromCache(key); + return cache.getFromCache(key); } catch (NeedsRefreshException e) { @@ -116,7 +107,7 @@ { try { - return cacheAdmin.getFromCache(key, refeshPeriod); + return cache.getFromCache(key, refeshPeriod); } catch (NeedsRefreshException e) { @@ -126,28 +117,12 @@ public void cancelUpdate(String key) { - cacheAdmin.cancelUpdate(key); + cache.cancelUpdate(key); } public void flushAll() { - cacheAdmin.flushAll(); - Cache cache = cacheAdmin.getCache(); - - // Make sure we clean-up and finalize cached objects - Map map = (Map) XWiki.getPrivateField(cache, "cacheMap"); - Iterator it = map.values().iterator(); - while (it.hasNext()) { - try { - CacheEntry centry = (CacheEntry)it.next(); - Object obj = centry.getContent(); - if (obj instanceof XWikiCachedObject) { - ((XWikiCachedObject)obj).finalize(); - } - } catch (Throwable throwable) { - } - } - XWiki.callPrivateMethod(cache, "clear"); + cache.flushAll(new Date()); } /** @@ -156,13 +131,7 @@ */ public int getNumberEntries() { - int ret = cacheAdmin.getCache().getSize(); - return ret; - } - - public int getSize() - { - return cacheAdmin.getCache().getSize(); + return cache.getCache().getNbEntries(); } public void setName(String name) diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/cache/impl/OSCacheService.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/impl/OSCacheService.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/cache/impl/OSCacheService.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/cache/impl/OSCacheService.java 2006-08-02 18:30:07.000000000 +0300 @@ -1,18 +1,21 @@ package com.xpn.xwiki.cache.impl; -import java.io.InputStream; import java.io.File; import java.io.FileInputStream; +import java.io.InputStream; import java.lang.ref.WeakReference; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.xpn.xwiki.XWiki; -import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.cache.api.XWikiCache; import com.xpn.xwiki.cache.api.XWikiCacheService; @@ -76,73 +79,33 @@ log.info("Initialized OSCacheService"); } - public XWikiCache newLocalCache() throws XWikiException + public XWikiCache newLocalCache() { return new OSCacheCache(localCacheProperties); } - public XWikiCache newLocalCache(int capacity) throws XWikiException + public XWikiCache newLocalCache(int capacity) { return new OSCacheCache(localCacheProperties, capacity); } - public XWikiCache newCache(String cacheName, Properties props) throws XWikiException + public XWikiCache newCache(Properties props) { - OSCacheCache cc = new OSCacheCache(mergeProperties(props, cacheProperties)); - cc.setName(cacheName); + OSCacheCache cc = new OSCacheCache(props); initCache(cc); return cc; } - public XWikiCache newLocalCache(Properties props) throws XWikiException + public XWikiCache newCache() { - OSCacheCache cc = new OSCacheCache(mergeProperties(props, localCacheProperties)); - initCache(cc); - return cc; - } - - public XWikiCache newCache(String cacheName, Properties props, int capacity) throws XWikiException { - OSCacheCache cc = new OSCacheCache(mergeProperties(props, cacheProperties), capacity); - cc.setName(cacheName); - initCache(cc); - return cc; - } - - public XWikiCache newLocalCache(Properties props, int capacity) throws XWikiException { - OSCacheCache cc = new OSCacheCache(mergeProperties(props, localCacheProperties), capacity); - initCache(cc); - return cc; - } - - private Properties mergeProperties(Properties props, Properties sourceProps) { - Properties targetProps = new Properties(); - - Enumeration en = sourceProps.keys(); - while (en.hasMoreElements()) { - Object key = en.nextElement(); - Object value = sourceProps.get(key); - targetProps.put(key, value); - } - en = props.keys(); - while (en.hasMoreElements()) { - Object key = en.nextElement(); - Object value = props.get(key); - targetProps.put(key, value); - } - return targetProps; - } - - - public XWikiCache newCache(String cacheName) throws XWikiException { OSCacheCache cc = new OSCacheCache(cacheProperties); - cc.setName(cacheName); initCache(cc); return cc; } - public XWikiCache newCache(String cacheName, int capacity) throws XWikiException { + public XWikiCache newCache(int capacity) + { OSCacheCache cc = new OSCacheCache(cacheProperties, capacity); - cc.setName(cacheName); initCache(cc); return cc; } Only in xwiki/trunk/src/main/java/com/xpn/xwiki/cache/impl: SharedJavaGroupsBroadcastingListener.java Only in xwiki/trunk/src/main/java/com/xpn/xwiki/cache/impl: XWikiCachedObject.java diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiAttachment.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/doc/XWikiAttachment.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiAttachment.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/doc/XWikiAttachment.java 2006-07-12 14:09:50.000000000 +0300 @@ -32,9 +32,9 @@ import java.io.StringReader; import org.apache.commons.codec.binary.Base64; -import org.suigeneris.jrcs.rcs.Archive; -import org.suigeneris.jrcs.rcs.Node; -import org.suigeneris.jrcs.rcs.Version; +import org.apache.commons.jrcs.rcs.Archive; +import org.apache.commons.jrcs.rcs.Node; +import org.apache.commons.jrcs.rcs.Version; import org.dom4j.Element; import org.dom4j.Document ; import org.dom4j.DocumentException; diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiAttachmentArchive.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/doc/XWikiAttachmentArchive.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiAttachmentArchive.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/doc/XWikiAttachmentArchive.java 2006-08-02 18:30:31.000000000 +0300 @@ -25,9 +25,8 @@ import java.io.ByteArrayInputStream; import java.util.Date; -import org.suigeneris.jrcs.rcs.Archive; -import org.suigeneris.jrcs.util.ToString; -import org.apache.commons.codec.binary.Base64; +import org.apache.commons.jrcs.rcs.Archive; +import org.apache.commons.jrcs.rcs.Lines; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; @@ -107,13 +106,13 @@ attachment.incrementVersion(); attachment.setDate(new Date()); String sdata = attachment.toStringXML(true, false, context); - Object[] lines = ToString.stringToArray(sdata); + Lines lines = new Lines(sdata); if (archive!=null) { - archive.addRevision(lines,""); + archive.addRevision(lines.toArray(),""); } else - archive = new Archive(lines,getAttachment().getFilename(),getAttachment().getVersion()); + archive = new Archive(lines.toArray(),getAttachment().getFilename(),getAttachment().getVersion()); } catch (Exception e) { Object[] args = { getAttachment().getFilename() }; diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java 2006-07-23 22:32:27.000000000 +0300 @@ -38,21 +38,22 @@ import com.xpn.xwiki.objects.classes.PropertyClass; import com.xpn.xwiki.render.XWikiVelocityRenderer; import com.xpn.xwiki.store.XWikiStoreInterface; -import com.xpn.xwiki.store.XWikiAttachmentStoreInterface; -import com.xpn.xwiki.store.XWikiVersioningStoreInterface; import com.xpn.xwiki.util.Util; import com.xpn.xwiki.web.EditForm; import com.xpn.xwiki.web.ObjectAddForm; import com.xpn.xwiki.web.Utils; -import org.suigeneris.jrcs.diff.Diff; -import org.suigeneris.jrcs.diff.DifferentiationFailedException; -import org.suigeneris.jrcs.diff.Revision; -import org.suigeneris.jrcs.rcs.Version; -import org.suigeneris.jrcs.util.ToString; +import org.apache.commons.jrcs.diff.Diff; +import org.apache.commons.jrcs.diff.DifferentiationFailedException; +import org.apache.commons.jrcs.diff.Revision; +import org.apache.commons.jrcs.rcs.Archive; +import org.apache.commons.jrcs.rcs.Lines; +import org.apache.commons.jrcs.rcs.Version; +import org.apache.commons.jrcs.util.ToString; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ecs.filter.CharacterFilter; +import org.apache.tools.ant.filters.StringInputStream; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.tools.VelocityFormatter; import org.dom4j.Document; @@ -72,7 +73,6 @@ import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import java.lang.ref.SoftReference; public class XWikiDocument { @@ -88,6 +88,7 @@ private String creator; private String author; private String contentAuthor; + private Archive archive; private Date contentUpdateDate; private Date updateDate; private Date creationDate; @@ -102,9 +103,9 @@ private String database; // Used to make sure the MetaData String is regenerated - private boolean isContentDirty = true; + private boolean isContentDirty = false; // Used to make sure the MetaData String is regenerated - private boolean isMetaDataDirty = true; + private boolean isMetaDataDirty = false; public static final int HAS_ATTACHMENTS = 1; public static final int HAS_OBJECTS = 2; @@ -129,25 +130,8 @@ private Object wikiNode; - // We are using a SoftReference which will allow the archive to be - // discarded by the Garbage collector as long as the context is closed (usually during the request) - private SoftReference archive; - private XWikiStoreInterface store; - public XWikiStoreInterface getStore(XWikiContext context) { - return context.getWiki().getStore(); - } - - public XWikiAttachmentStoreInterface getAttachmentStore(XWikiContext context) { - return context.getWiki().getAttachmentStore(); - } - - public XWikiVersioningStoreInterface getVersioningStore(XWikiContext context) { - return context.getWiki().getVersioningStore(); - } - - public XWikiStoreInterface getStore() { return store; } @@ -225,6 +209,7 @@ this.author = ""; this.language = ""; this.defaultLanguage = ""; + this.archive = null; this.attachmentList = new ArrayList(); } @@ -501,22 +486,22 @@ public String getAttachmentURL(String filename, String action, XWikiContext context) { URL url = context.getURLFactory().createAttachmentURL(filename, getWeb(), getName(), action, null, context); - return context.getURLFactory().getURL(url, context); + return context.getURLFactory().getURL(url, context).toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } public String getAttachmentURL(String filename, String action, String querystring, XWikiContext context) { URL url = context.getURLFactory().createAttachmentURL(filename, getWeb(), getName(), action, querystring, context); - return context.getURLFactory().getURL(url, context); + return context.getURLFactory().getURL(url, context).toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } public String getAttachmentRevisionURL(String filename, String revision, XWikiContext context) { URL url = context.getURLFactory().createAttachmentRevisionURL(filename, getWeb(), getName(), revision, null, context); - return context.getURLFactory().getURL(url, context); + return context.getURLFactory().getURL(url, context).toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } public String getAttachmentRevisionURL(String filename, String revision, String querystring, XWikiContext context) { URL url = context.getURLFactory().createAttachmentRevisionURL(filename, getWeb(), getName(), revision, querystring, context); - return context.getURLFactory().getURL(url, context); + return context.getURLFactory().getURL(url, context).toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } public String getURL(String action, boolean redirect, XWikiContext context) { @@ -525,9 +510,9 @@ if (url == null) return null; else - return url.toString(); + return url.toString().toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } else - return context.getURLFactory().getURL(url, context); + return context.getURLFactory().getURL(url, context).toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } public String getURL(String action, XWikiContext context) { @@ -543,13 +528,13 @@ public String getExternalURL(String action, XWikiContext context) { URL url = context.getURLFactory().createExternalURL(getWeb(), getName(), action, null, null, context); - return url.toString(); + return url.toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } public String getExternalURL(String action, String querystring, XWikiContext context) { URL url = context.getURLFactory().createExternalURL(getWeb(), getName(), action, querystring, null, context); - return url.toString(); + return url.toString().replaceAll("&", "&").replaceAll("&amp;", "&"); } @@ -560,49 +545,13 @@ return context.getURLFactory().getURL(url, context); } - public XWikiDocumentArchive getDocumentArchive(XWikiContext context) throws XWikiException { - loadArchive(context); - return getDocumentArchive(); - } - - public void loadArchive(XWikiContext context) throws XWikiException { - if (archive==null) { - XWikiDocumentArchive arch = getVersioningStore(context).getXWikiDocumentArchive(this, context); - // We are using a SoftReference which will allow the archive to be - // discarded by the Garbage collector as long as the context is closed (usually during the request) - archive = new SoftReference(arch); - } - } - - public XWikiDocumentArchive getDocumentArchive() { - // We are using a SoftReference which will allow the archive to be - // discarded by the Garbage collector as long as the context is closed (usually during the request) - if (archive==null) - return null; - else - return (XWikiDocumentArchive) archive.get(); - } - - public void setDocumentArchive(XWikiDocumentArchive arch) { - // We are using a SoftReference which will allow the archive to be - // discarded by the Garbage collector as long as the context is closed (usually during the request) - if (arch!=null) - this.archive = new SoftReference(arch); - } - - public void setDocumentArchive(String sarch) throws XWikiException { - XWikiDocumentArchive xda = new XWikiDocumentArchive(getId()); - xda.setArchive(sarch); - setDocumentArchive(xda); - } - public Version[] getRevisions(XWikiContext context) throws XWikiException { - return getVersioningStore(context).getXWikiDocVersions(this, context); + return getStore().getXWikiDocVersions(this, context); } public String[] getRecentRevisions(int nb, XWikiContext context) throws XWikiException { try { - Version[] revisions = getVersioningStore(context).getXWikiDocVersions(this, context); + Version[] revisions = getStore().getXWikiDocVersions(this, context); int length = nb; // 0 means all revisions @@ -622,6 +571,59 @@ } } + public Archive getRCSArchive() { + return archive; + } + + public void setRCSArchive(Archive archive) { + this.archive = archive; + } + + public String getArchive() throws XWikiException { + return getArchive(null); + } + + public String getArchive(XWikiContext context) throws XWikiException { + if ((content == null) || (content.equals(""))) + setContent("\n"); + if (archive == null) + updateArchive(toXML(context)); + if (archive == null) + return ""; + else { + StringBuffer buffer = new StringBuffer(); + archive.toString(buffer); + return buffer.toString(); + } + } + + public void setArchive(String text) throws XWikiException { + try { + StringInputStream is = new StringInputStream(text); + archive = new Archive(getFullName(), is); + } + catch (Exception e) { + Object[] args = {getFullName()}; + throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_ARCHIVEFORMAT, + "Exception while manipulating the archive for doc {0}", e, args); + } + } + + public void updateArchive(String text) throws XWikiException { + try { + Lines lines = new Lines(text); + if (archive != null) + archive.addRevision(lines.toArray(), ""); + else + archive = new Archive(lines.toArray(), getFullName(), getVersion()); + } + catch (Exception e) { + Object[] args = {getFullName()}; + throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_ARCHIVEFORMAT, + "Exception while manipulating the archive for doc {0}", e, args); + } + } + public boolean isMostRecent() { return mostRecent; } @@ -1203,8 +1205,8 @@ // This should not happen } + doc.setRCSArchive(getRCSArchive()); doc.setRCSVersion(getRCSVersion()); - doc.setDocumentArchive(getDocumentArchive()); doc.setAuthor(getAuthor()); doc.setContentAuthor(getContentAuthor()); doc.setContent(getContent()); @@ -1310,6 +1312,13 @@ if (!getTemplate().equals(doc.getTemplate())) return false; + try { + if (!getArchive().equals(doc.getArchive())) + return false; + } catch (XWikiException e) { + return false; + } + if (!getxWikiClass().equals(doc.getxWikiClass())) return false; @@ -1462,7 +1471,7 @@ el = new DOMElement("version"); el.addText(getVersion()); docel.add(el); - + el = new DOMElement("title"); el.addText(getTitle()); docel.add(el); @@ -1483,7 +1492,7 @@ if (bclass.getFieldList().size() > 0) { docel.add(bclass.toXML(null)); } - + // Add Objects Iterator it = getxWikiObjects().values().iterator(); while (it.hasNext()) { @@ -1525,7 +1534,7 @@ if (bWithVersions) { el = new DOMElement("versions"); try { - el.addText(getDocumentArchive(context).getArchive()); + el.addText(getArchive()); } catch (XWikiException e) { return null; } @@ -1625,9 +1634,10 @@ String archive = getElement(docel, "versions"); if (withArchive && archive != null && archive.length() > 0) { - setDocumentArchive(archive); + setArchive(archive); } + String sdate = getElement(docel, "date"); if (!sdate.equals("")) { Date date = new Date(Long.parseLong(sdate)); @@ -1663,10 +1673,6 @@ bobject.fromXML(objel); addObject(bobject.getClassName(), bobject); } - - // We have been reading from XML so the document does not need a new version when saved - setMetaDataDirty(false); - setContentDirty(false); } public void setAttachmentList(List list) { @@ -1727,7 +1733,7 @@ context.setDatabase(getDatabase()); try{ context.getWiki().getAttachmentStore().deleteXWikiAttachment(attachment, context, true); - }catch(java.lang.OutOfMemoryError e){ + }catch(java.lang.OutOfMemoryError e){ throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_JAVA_HEAP_SPACE, "Out Of Memory Exception"); @@ -1740,11 +1746,11 @@ } public List getBacklinks(XWikiContext context) throws XWikiException { - return getStore(context).loadBacklinks(getFullName(), context, true); + return getStore().loadBacklinks(getFullName(), context, true); } public List getLinks(XWikiContext context) throws XWikiException { - return getStore(context).loadLinks(getId(), context, true); + return getStore().loadLinks(getId(), context, true); } public void renameProperties(String className, Map fieldsToRename) { @@ -1877,7 +1883,7 @@ } } - public String displayRendered(PropertyClass pclass, String prefix, BaseCollection object, XWikiContext context) throws XWikiException { + public String displayRendered(PropertyClass pclass, String prefix, BaseCollection object, XWikiContext context) { String result = pclass.displayView(pclass.getName(), prefix, object, context); return getRenderedContent(result, context); } @@ -2136,7 +2142,7 @@ if (getDatabase() != null) context.setDatabase(getDatabase()); - tdoc = getStore(context).loadXWikiDoc(tdoc, context); + tdoc = context.getWiki().getStore().loadXWikiDoc(tdoc, context); if (tdoc.isNew()) tdoc = this; @@ -2345,11 +2351,11 @@ } public XWikiLock getLock(XWikiContext context) throws XWikiException { - XWikiLock theLock = getStore(context).loadLock(getId(), context, true); + XWikiLock theLock = getStore().loadLock(getId(), context, true); if (theLock != null) { int timeout = context.getWiki().getXWikiPreferenceAsInt("lock_Timeout", 30 * 60, context); if (theLock.getDate().getTime() + timeout * 1000 < new Date().getTime()) { - getStore(context).deleteLock(theLock, context, true); + getStore().deleteLock(theLock, context, true); theLock = null; } } @@ -2358,13 +2364,13 @@ public void setLock(String userName, XWikiContext context) throws XWikiException { XWikiLock lock = new XWikiLock(getId(), userName); - getStore(context).saveLock(lock, context, true); + getStore().saveLock(lock, context, true); } public void removeLock(XWikiContext context) throws XWikiException { - XWikiLock lock = getStore(context).loadLock(getId(), context, true); + XWikiLock lock = getStore().loadLock(getId(), context, true); if (lock != null) { - getStore(context).deleteLock(lock, context, true); + getStore().deleteLock(lock, context, true); } } @@ -2516,8 +2522,4 @@ return context.getUser().equals(getFullName()); } - public void resetArchive(XWikiContext context) throws XWikiException { - getVersioningStore(context).resetRCSArchive(this, true, context); - } - } Only in xwiki/trunk/src/main/java/com/xpn/xwiki/doc: XWikiDocumentArchive.java diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/notify/DocObjectChangedRule.java 2006-07-12 14:09:51.000000000 +0300 @@ -1,24 +1,24 @@ -/* - * Copyright 2006, 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. - * - * @author sdumitriu - */ +/* + * Copyright 2006, 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. + * + * @author sdumitriu + */ package com.xpn.xwiki.notify; @@ -45,8 +45,8 @@ } public boolean hasEqualsObjectsFromClass(XWikiDocument newdoc, XWikiDocument olddoc, String classname) { - Vector vobj1 = (newdoc==null) ? null : newdoc.getObjects(classname); - Vector vobj2 = (olddoc==null) ? null : olddoc.getObjects(classname); + Vector vobj1 = newdoc.getObjects(classname); + Vector vobj2 = olddoc.getObjects(classname); if ((vobj1==null)&&(vobj2==null)) return true; if ((vobj1==null)||(vobj2==null)) @@ -54,12 +54,10 @@ if (vobj1.size()!=vobj2.size()) return false; for (int i=0;i", ""); - xml = xml.replaceAll("", ""); - try { StringReader in = new StringReader(xml); domdoc = reader.read(in); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java 2006-07-12 14:09:51.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java 2006-07-20 18:01:46.000000000 +0300 @@ -23,6 +23,7 @@ package com.xpn.xwiki.objects.classes; +import org.apache.ecs.xhtml.input; import org.apache.ecs.xhtml.option; import org.apache.ecs.xhtml.select; @@ -63,7 +64,6 @@ setStringValue("displayType", type); } - public BaseProperty fromString(String value) { BaseProperty property = newProperty(); Number nvalue = null; @@ -91,8 +91,15 @@ } } - public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) { + if(getDisplayType().equals("checkbox")){ + displayCheckboxEdit(buffer, name, prefix, object, context); + } + else { + displaySelectEdit(buffer, name, prefix, object, context); + } + } + public void displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) { select select = new select(prefix + name, 1); String String0 = getDisplayValue(context, 0); String String1 = getDisplayValue(context, 1); @@ -103,40 +110,72 @@ options[2].addElement(String0); try { + IntegerProperty prop = (IntegerProperty) object.safeget(name); + if (prop!=null) { + Integer ivalue = (Integer)prop.getValue(); + if (ivalue!=null) { + int value = ivalue.intValue(); + if (value==1) + options[1].setSelected(true); + else if (value==0) + options[2].setSelected(true); + } else { + int value = getDefaultValue(); + if (value==1) + options[1].setSelected(true); + else if (value==0) + options[2].setSelected(true); + } + } + } catch (Exception e) { + // This should not happen + e.printStackTrace(); + } + select.addElement(options); + buffer.append(select.toString()); + } + + public void displayCheckboxEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) { + org.apache.ecs.xhtml.input check = new input(input.checkbox, prefix + name, 1); + org.apache.ecs.xhtml.input checkNo = new input(input.hidden, prefix + name, 0); + + try { IntegerProperty prop = (IntegerProperty) object.safeget(name); if (prop!=null) { Integer ivalue = (Integer)prop.getValue(); if (ivalue!=null) { int value = ivalue.intValue(); if (value==1) - options[1].setSelected(true); + check.setChecked(true); else if (value==0) - options[2].setSelected(true); - } else { + check.setChecked(false); + } + else { int value = getDefaultValue(); if (value==1) - options[1].setSelected(true); - else if (value==0) - options[2].setSelected(true); + check.setChecked(true); + else + check.setChecked(false); } }} catch (Exception e) { // This should not happen e.printStackTrace(); } - select.addElement(options); - buffer.append(select.toString()); + buffer.append(check.toString()); + buffer.append(checkNo.toString()); } - private String getDisplayValue(XWikiContext context, int value) { try { XWikiMessageTool msg = (XWikiMessageTool) context.get("msg"); String strname = getDisplayType() + "_" + value; String result = msg.get(strname); - if (result.equals(strname)) - return "" + value; - else - return result; + if (result.equals(strname)){ + return "" + value; + } + else{ + return result; + } } catch (Exception e) { return "" + value; } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java 2006-07-12 14:09:51.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java 2006-08-03 23:00:52.000000000 +0300 @@ -139,7 +139,8 @@ if (prop!=null) input.setValue(toFormString(prop)); input.setType("text"); - input.setName(prefix + name); + input.setName(prefix + name); + input.setID(prefix + name); input.setSize(getSize()); buffer.append(input.toString()); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java 2006-08-03 23:01:53.000000000 +0300 @@ -1,22 +1,24 @@ package com.xpn.xwiki.objects.classes; -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.objects.meta.PropertyMetaClass; -import com.xpn.xwiki.objects.StringProperty; -import com.xpn.xwiki.objects.BaseProperty; -import com.xpn.xwiki.objects.BaseCollection; -import org.apache.ecs.xhtml.select; -import org.apache.ecs.xhtml.option; -import org.apache.ecs.xhtml.input; -import org.apache.ecs.xhtml.button; -import org.apache.commons.lang.StringUtils; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.apache.ecs.xhtml.button; +import org.apache.ecs.xhtml.input; +import org.apache.ecs.xhtml.option; +import org.apache.ecs.xhtml.select; + +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.XWikiException; +import com.xpn.xwiki.objects.BaseCollection; +import com.xpn.xwiki.objects.BaseProperty; +import com.xpn.xwiki.objects.StringProperty; +import com.xpn.xwiki.objects.meta.PropertyMetaClass; + public class GroupsClass extends ListClass { + public static final long serialVersionUID = 20060802; public GroupsClass(PropertyMetaClass wclass) { super("groupslist", "Groups List", wclass); @@ -31,7 +33,7 @@ public List getList(XWikiContext context) { List list; try { - list = context.getWiki().getGroupService(context).listAllGroups(context); + list = context.getWiki().getGroupService().listAllGroups(context); } catch (XWikiException e) { // TODO add log exception list = new ArrayList(); @@ -80,7 +82,7 @@ if (value == null) return list; - String val = StringUtils.replace(value, "\\,", "%SEP%"); + value = StringUtils.replace(value, "\\,", "%SEP%"); String[] result = StringUtils.split(value, ", "); for (int i = 0; i < result.length; i++) list.add(StringUtils.replace(result[i], "%SEP%", ",")); @@ -149,6 +151,7 @@ input in = new input(); in.setType("hidden"); in.setName(prefix + name); + in.setID(prefix + name); buffer.append(in.toString()); } } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java 2006-07-12 14:09:51.000000000 +0300 @@ -2,7 +2,6 @@ import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.web.XWikiRequest; import com.xpn.xwiki.objects.BaseCollection; import com.xpn.xwiki.objects.BaseProperty; import com.xpn.xwiki.objects.StringProperty; @@ -37,9 +36,7 @@ } - XWikiRequest req = context.getRequest(); - if (("editrights".equals(req.get("xpage"))) - &&(!"1".equals(req.get("global")))) { + if (!"1".equals(context.getRequest().get("global"))) { list.remove("admin"); list.remove("programming"); list.remove("delete"); @@ -69,7 +66,7 @@ } public String getText(String value, XWikiContext context) { - return value; + return context.getWiki().getUserName(value, null, false, context); } public static List getListFromString(String value) { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java 2006-07-12 14:09:51.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java 2006-08-03 23:03:22.000000000 +0300 @@ -186,6 +186,7 @@ input.setType("hidden"); input.setName(prefix + name); + input.setID(prefix + name); buffer.append(input.toString()); } @@ -208,39 +209,79 @@ input.setType("text"); input.setSize(60); input.setName(prefix + name); + input.setID(prefix + name); buffer.append(input.toString()); + } else if (getDisplayType().equals("radio")) { + displayRadioEdit(buffer, name, prefix, object, context); + } + else { + displaySelectEdit(buffer, name, prefix, object, context); + } + } + + protected void displayRadioEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context){ + List list = getList(context); + List selectlist; + + BaseProperty prop = (BaseProperty)object.safeget(name); + if (prop==null) { + selectlist = new ArrayList(); + } else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) { + selectlist = (List) prop.getValue(); } else { - select select = new select(prefix + name, 1); - select.setMultiple(isMultiSelect()); - select.setSize(getSize()); - - List list = getList(context); - List selectlist; - - BaseProperty prop = (BaseProperty)object.safeget(name); - if (prop==null) { - selectlist = new ArrayList(); - } else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) { - selectlist = (List) prop.getValue(); - } else { - selectlist = new ArrayList(); - selectlist.add(prop.getValue()); - } + selectlist = new ArrayList(); + selectlist.add(prop.getValue()); + } - // Add options from Set - for (Iterator it=list.iterator();it.hasNext();) { - String value = it.next().toString(); - option option = new option(value, value); - option.addElement(value); - if (selectlist.contains(value)) - option.setSelected(true); - select.addElement(option); + // Add options from Set + for (Iterator it=list.iterator();it.hasNext();) { + String value = it.next().toString(); + input radio = new input(input.radio, prefix + name, value); + + if (selectlist.contains(value)) + radio.setChecked(true); + radio.addElement(value); + buffer.append(radio.toString()); + if(it.hasNext()){ + buffer.append("
"); } + } + } + + protected void displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context){ + select select = new select(prefix + name, 1); + select.setMultiple(isMultiSelect()); + select.setSize(getSize()); + select.setName(prefix + name); + select.setID(prefix + name); + + List list = getList(context); + List selectlist; + + BaseProperty prop = (BaseProperty)object.safeget(name); + if (prop==null) { + selectlist = new ArrayList(); + } else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) { + selectlist = (List) prop.getValue(); + } else { + selectlist = new ArrayList(); + selectlist.add(prop.getValue()); + } - buffer.append(select.toString()); + // Add options from Set + for (Iterator it=list.iterator();it.hasNext();) { + String value = it.next().toString(); + option option = new option(value, value); + option.addElement(value); + if (selectlist.contains(value)) + option.setSelected(true); + select.addElement(option); } + + buffer.append(select.toString()); } + public abstract List getList(XWikiContext context); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java 2006-07-12 14:09:51.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java 2006-08-03 22:56:10.000000000 +0300 @@ -106,7 +106,8 @@ BaseProperty prop = (BaseProperty) object.safeget(name); if (prop!=null) input.setValue(prop.toFormString()); - input.setType("text"); + input.setType("text"); + input.setID(prefix + name); input.setName(prefix + name); input.setSize(getSize()); buffer.append(input.toString()); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PasswordClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/PasswordClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PasswordClass.java 2006-07-12 14:09:51.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/PasswordClass.java 2006-08-03 23:03:42.000000000 +0300 @@ -67,7 +67,8 @@ if (prop!=null) input.setValue("********"); input.setType("password"); - input.setName(prefix + name); + input.setName(prefix + name); + input.setID(prefix + name); input.setSize(getSize()); buffer.append(input.toString()); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java 2006-07-12 14:09:51.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java 2006-08-03 22:57:09.000000000 +0300 @@ -117,6 +117,7 @@ input.setType("hidden"); input.setName(prefix + name); + input.setID(prefix + name); buffer.append(input.toString()); } @@ -127,6 +128,7 @@ input.setType("text"); input.setName(prefix + name); + input.setID(prefix + name); buffer.append(input.toString()); } @@ -142,6 +144,7 @@ input.setType("text"); input.setName(prefix + name); + input.setID(prefix + name); buffer.append(input.toString()); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java 2006-07-12 14:09:52.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java 2006-08-03 22:57:38.000000000 +0300 @@ -72,7 +72,8 @@ if (prop!=null) input.setValue(prop.toFormString()); input.setType("text"); - input.setName(prefix + name); + input.setName(prefix + name); + input.setID(prefix + name); input.setSize(getSize()); buffer.append(input.toString()); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java 2006-07-12 14:09:52.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java 2006-08-02 18:28:13.000000000 +0300 @@ -30,7 +30,6 @@ import com.xpn.xwiki.objects.BaseCollection; import com.xpn.xwiki.objects.BaseProperty; import com.xpn.xwiki.objects.LargeStringProperty; -import com.xpn.xwiki.objects.BaseObject; import com.xpn.xwiki.objects.meta.PropertyMetaClass; public class TextAreaClass extends StringClass { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/classes/UsersClass.java 2006-07-12 14:09:52.000000000 +0300 @@ -31,7 +31,7 @@ public List getList(XWikiContext context) { List list; try { - list = context.getWiki().getGroupService(context).listMemberForGroup(null, context); + list = context.getWiki().getGroupService().listMemberForGroup(null, context); } catch (XWikiException e) { // TODO add log exception list = new ArrayList(); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java 2006-07-12 14:09:52.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/meta/LevelsMetaClass.java 2006-08-02 17:46:01.000000000 +0300 @@ -1,10 +1,8 @@ package com.xpn.xwiki.objects.meta; -import com.xpn.xwiki.objects.classes.GroupsClass; -import com.xpn.xwiki.objects.classes.LevelsClass; -import com.xpn.xwiki.objects.classes.BooleanClass; -import com.xpn.xwiki.objects.BaseCollection; import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.objects.BaseCollection; +import com.xpn.xwiki.objects.classes.LevelsClass; public class LevelsMetaClass extends ListMetaClass { public LevelsMetaClass() { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java 2006-07-12 14:09:52.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/meta/MetaClass.java 2006-08-02 17:48:38.000000000 +0300 @@ -22,13 +22,12 @@ package com.xpn.xwiki.objects.meta; +import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.objects.BaseCollection; import com.xpn.xwiki.objects.BaseProperty; import com.xpn.xwiki.objects.PropertyInterface; import com.xpn.xwiki.objects.classes.BaseClass; import com.xpn.xwiki.objects.classes.PropertyClass; -import com.xpn.xwiki.objects.classes.UsersClass; -import com.xpn.xwiki.XWikiContext; public class MetaClass extends BaseClass { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java 2006-07-12 14:09:52.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/objects/meta/UsersMetaClass.java 2006-08-02 17:49:10.000000000 +0300 @@ -1,11 +1,9 @@ package com.xpn.xwiki.objects.meta; -import com.xpn.xwiki.objects.classes.StaticListClass; -import com.xpn.xwiki.objects.classes.StringClass; -import com.xpn.xwiki.objects.classes.UsersClass; -import com.xpn.xwiki.objects.classes.BooleanClass; -import com.xpn.xwiki.objects.BaseCollection; import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.objects.BaseCollection; +import com.xpn.xwiki.objects.classes.BooleanClass; +import com.xpn.xwiki.objects.classes.UsersClass; public class UsersMetaClass extends ListMetaClass { public UsersMetaClass() { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/XWikiDefaultPlugin.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/XWikiDefaultPlugin.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/XWikiDefaultPlugin.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/XWikiDefaultPlugin.java 2006-07-12 14:09:56.000000000 +0300 @@ -23,7 +23,6 @@ package com.xpn.xwiki.plugin; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.api.Api; import com.xpn.xwiki.doc.XWikiAttachment; diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/XWikiPluginInterface.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/XWikiPluginInterface.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/XWikiPluginInterface.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/XWikiPluginInterface.java 2006-07-12 14:09:56.000000000 +0300 @@ -1,29 +1,28 @@ -/* - * Copyright 2006, 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. - * - * @author moghrabix - */ +/* + * Copyright 2006, 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. + * + * @author moghrabix + */ package com.xpn.xwiki.plugin; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.api.Api; import com.xpn.xwiki.doc.XWikiAttachment; @@ -33,7 +32,7 @@ void setClassName(String name); void setName(String name); - void init(XWikiContext context) throws XWikiException; + void init(XWikiContext context); void virtualInit(XWikiContext context); /* diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/charts/actions/ChartWizardAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/charts/actions/ChartWizardAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/charts/actions/ChartWizardAction.java 2006-07-12 14:09:53.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/charts/actions/ChartWizardAction.java 2006-08-02 18:30:22.000000000 +0300 @@ -21,15 +21,14 @@ */ package com.xpn.xwiki.plugin.charts.actions; -import org.apache.velocity.VelocityContext; - -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.plugin.charts.params.DefaultChartParams2; -import com.xpn.xwiki.plugin.charts.params.HorizontalAlignmentChartParam; -import com.xpn.xwiki.plugin.charts.wizard.FontHelper; -import com.xpn.xwiki.plugin.charts.wizard.DatasourceDefaultsHelper; -import com.xpn.xwiki.web.XWikiAction; +import org.apache.velocity.VelocityContext; + +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.XWikiException; +import com.xpn.xwiki.plugin.charts.params.DefaultChartParams2; +import com.xpn.xwiki.plugin.charts.wizard.DatasourceDefaultsHelper; +import com.xpn.xwiki.plugin.charts.wizard.FontHelper; +import com.xpn.xwiki.web.XWikiAction; public class ChartWizardAction extends XWikiAction { public String render(XWikiContext context) throws XWikiException { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/charts/wizard/FontHelper.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/charts/wizard/FontHelper.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/charts/wizard/FontHelper.java 2006-07-12 14:09:54.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/charts/wizard/FontHelper.java 2006-08-02 18:30:38.000000000 +0300 @@ -21,10 +21,8 @@ */ package com.xpn.xwiki.plugin.charts.wizard; -import java.awt.Font; -import java.awt.GraphicsEnvironment; - -import org.jfree.chart.JFreeChart; +import java.awt.Font; +import java.awt.GraphicsEnvironment; public class FontHelper { public FontHelper(){ diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/feed/FeedPlugin.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/feed/FeedPlugin.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/feed/FeedPlugin.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/feed/FeedPlugin.java 2006-08-02 18:28:04.000000000 +0300 @@ -26,21 +26,32 @@ import java.io.IOException; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.sun.syndication.feed.synd.*; +import com.sun.syndication.feed.synd.SyndCategory; +import com.sun.syndication.feed.synd.SyndContent; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndFeedImpl; import com.sun.syndication.fetcher.FeedFetcher; import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.objects.BaseObject; -import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.api.Api; import com.xpn.xwiki.cache.api.XWikiCache; import com.xpn.xwiki.cache.api.XWikiCacheNeedsRefreshException; +import com.xpn.xwiki.doc.XWikiDocument; +import com.xpn.xwiki.objects.BaseObject; import com.xpn.xwiki.plugin.XWikiDefaultPlugin; import com.xpn.xwiki.plugin.XWikiPluginInterface; @@ -100,48 +111,19 @@ public void flushCache() { if (feedCache!=null) feedCache.flushAll(); - feedCache = null; } public void init(XWikiContext context) { super.init(context); - prepareCache(context); + feedCache = context.getWiki().getCacheService().newLocalCache(); refreshPeriod = (int) context.getWiki().ParamAsLong("xwiki.plugins.feed.cacherefresh", 3600); } - - public void initCache(XWikiContext context) throws XWikiException { - int iCapacity = 100; - try { - String capacity = context.getWiki().Param("xwiki.plugins.feed.cache.capacity"); - if (capacity != null) - iCapacity = Integer.parseInt(capacity); - } catch (Exception e) {} - - initCache(iCapacity, context); - } - - public void initCache(int iCapacity, XWikiContext context) throws XWikiException { - feedCache = context.getWiki().getCacheService().newLocalCache(iCapacity); - } - - protected void prepareCache(XWikiContext context) { - try { - if (feedCache==null) - initCache(context); - } catch (XWikiException e) { - } - } - public SyndFeed getFeeds(String sfeeds, XWikiContext context) throws IOException { - return getFeeds(sfeeds, false, true, context); + return getFeeds(sfeeds, true, context); } - public SyndFeed getFeeds(String sfeeds, boolean force, XWikiContext context) throws IOException { - return getFeeds(sfeeds, false, force, context); - } - - public SyndFeed getFeeds(String sfeeds, boolean ignoreInvalidFeeds, boolean force, XWikiContext context) throws IOException { + public SyndFeed getFeeds(String sfeeds, boolean ignoreInvalidFeeds, XWikiContext context) throws IOException { String[] feeds; if (sfeeds.indexOf("\n") != -1) feeds = sfeeds.split("\n"); @@ -167,7 +149,7 @@ outputFeed.setEntries(entries); for (int i = 0; i < feeds.length; i++) { - SyndFeed feed = getFeed(feeds[i], ignoreInvalidFeeds, force, context); + SyndFeed feed = getFeed(feeds[i], ignoreInvalidFeeds, context); if (feed != null) entries.addAll(feed.getEntries()); } @@ -187,15 +169,13 @@ public SyndFeed getFeed(String sfeed, boolean ignoreInvalidFeeds, boolean force, XWikiContext context) throws IOException { SyndFeed feed = null; - prepareCache(context); - if (!force) { - try { - feed = (SyndFeed) feedCache.getFromCache(sfeed, refreshPeriod); + if (!force) + try { + feed = (SyndFeed) feedCache.getFromCache(sfeed, refreshPeriod); - } catch (XWikiCacheNeedsRefreshException e) { - feedCache.cancelUpdate(sfeed); - } catch (Exception e) { - } + } catch (XWikiCacheNeedsRefreshException e) { + feedCache.cancelUpdate(sfeed); + } catch (Exception e) { } if (feed==null) diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/feed/FeedPluginApi.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/feed/FeedPluginApi.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/feed/FeedPluginApi.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/feed/FeedPluginApi.java 2006-07-12 14:09:55.000000000 +0300 @@ -1,25 +1,25 @@ -/* - * Copyright 2006, 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. - * - * @author ludovic - * @author sdumitriu - */ +/* + * Copyright 2006, 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. + * + * @author ludovic + * @author sdumitriu + */ package com.xpn.xwiki.plugin.feed; @@ -49,14 +49,6 @@ return plugin.getFeeds(sfeeds, context); } - public SyndFeed getFeeds(String sfeeds, boolean force) throws IOException { - return plugin.getFeeds(sfeeds, force, context); - } - - public SyndFeed getFeeds(String sfeeds, boolean ignoreInvalidFeeds, boolean force) throws IOException { - return plugin.getFeeds(sfeeds, ignoreInvalidFeeds, force, context); - } - public SyndFeed getFeed(String sfeed) throws IOException { return plugin.getFeed(sfeed, false, context); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/flickr/FlickrPlugin.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/flickr/FlickrPlugin.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/flickr/FlickrPlugin.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/flickr/FlickrPlugin.java 2006-07-12 14:09:55.000000000 +0300 @@ -1,24 +1,24 @@ -/* - * Copyright 2006, 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. - * - * @author sdumitriu - */ +/* + * Copyright 2006, 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. + * + * @author sdumitriu + */ package com.xpn.xwiki.plugin.flickr; @@ -27,7 +27,6 @@ import com.aetrion.flickr.RequestContext; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.api.Api; import com.xpn.xwiki.plugin.XWikiDefaultPlugin; import com.xpn.xwiki.plugin.XWikiPluginInterface; diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/image/ImagePlugin.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/image/ImagePlugin.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/image/ImagePlugin.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/image/ImagePlugin.java 2006-08-02 18:30:10.000000000 +0300 @@ -36,6 +36,9 @@ import javax.imageio.ImageIO; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.cache.api.XWikiCache; @@ -44,16 +47,19 @@ import com.xpn.xwiki.doc.XWikiAttachment; import com.xpn.xwiki.plugin.PluginException; import com.xpn.xwiki.plugin.XWikiDefaultPlugin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class ImagePlugin extends XWikiDefaultPlugin { private static final Log log = LogFactory.getLog(ImagePlugin.class); private static final int TYPE_JPG = 1; + private static final int TYPE_PNG = 2; + private static final int TYPE_BMP = 3; + private static String name = "image"; + private XWikiCache imageCache; + private int capacity = 50; public ImagePlugin(String name, String className, XWikiContext context) { @@ -73,10 +79,6 @@ public void init(XWikiContext context) { super.init(context); - initCache(context); - } - - public void initCache(XWikiContext context) { String capacityParam = ""; try { capacityParam = context.getWiki().Param("xwiki.plugin.image.cache.capacity"); @@ -95,17 +97,13 @@ props.put("cache.persistence.class", "com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener"); props.put("cache.path", "temp/imageCache"); - - try { - imageCache = context.getWiki().getCacheService().newLocalCache(props, capacity); - } catch (XWikiException e) { - } + + imageCache = new OSCacheCache(props, capacity); } public void flushCache() { if (imageCache != null) imageCache.flushAll(); - imageCache = null; } public XWikiAttachment downloadAttachment(XWikiAttachment attachment, XWikiContext context) { @@ -113,10 +111,6 @@ int height = 0; int width = 0; XWikiAttachment attachmentClone = null; - - if (imageCache==null) - initCache(context); - try { String sheight = context.getRequest().getParameter("height"); String swidth = context.getRequest().getParameter("width"); @@ -152,9 +146,8 @@ } } catch (Exception e) { attachmentClone = attachment; - } finally { - return attachmentClone; } + return attachmentClone; } public XWikiAttachment getImageByHeight(XWikiAttachment attachment, int thumbnailHeight, XWikiContext context) throws Exception { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/packaging/Package.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/packaging/Package.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/packaging/Package.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/packaging/Package.java 2006-07-12 14:09:56.000000000 +0300 @@ -56,6 +56,7 @@ import com.xpn.xwiki.doc.XWikiDocument; + public class Package { private static final Log log = LogFactory.getLog(Package.class); @@ -193,7 +194,7 @@ public boolean updateDoc(String docFullName, int action, XWikiContext context) throws XWikiException { XWikiDocument doc = new XWikiDocument(); doc.setFullName(docFullName, context); - return add(doc, action, context); + return add(doc, action, context); } public boolean add(String docFullName, int DefaultAction, XWikiContext context) throws XWikiException { @@ -448,7 +449,6 @@ // So we need to cancel the dirty status doc.getDoc().setContentDirty(false); doc.getDoc().setMetaDataDirty(false); - context.getWiki().saveDocument(doc.getDoc(), context); doc.getDoc().saveAllAttachments(context); } catch (XWikiException e) { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/query/QueryPlugin.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/query/QueryPlugin.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/query/QueryPlugin.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/plugin/query/QueryPlugin.java 2006-07-12 14:09:56.000000000 +0300 @@ -32,7 +32,6 @@ import org.apache.jackrabbit.core.query.QueryRootNode; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.api.Api; import com.xpn.xwiki.cache.api.XWikiCache; import com.xpn.xwiki.plugin.XWikiDefaultPlugin; @@ -44,11 +43,11 @@ private static final Log log = LogFactory.getLog(QueryPlugin.class); XWikiCache cache; XWikiContext context; - public QueryPlugin(String name, String className, XWikiContext context) throws XWikiException { - super(name, className, context); - this.context = context; - this.cache = this.context.getWiki().getCacheService().newCache("xwiki.plugin.query.cache", 100); - } + public QueryPlugin(String name, String className, XWikiContext context) { + super(name, className, context); + this.context = context; + this.cache = this.context.getWiki().getCacheService().newCache(); + } public String getName() { return "query"; } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiMacrosMappingRenderer.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiMacrosMappingRenderer.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiMacrosMappingRenderer.java 2006-07-12 14:09:56.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiMacrosMappingRenderer.java 2006-08-02 18:28:19.000000000 +0300 @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.io.IOException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -34,11 +33,10 @@ import com.xpn.xwiki.XWiki; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.notify.XWikiNotificationRule; -import com.xpn.xwiki.notify.XWikiDocChangeNotificationInterface; -import com.xpn.xwiki.notify.PropertyChangedRule; -import com.xpn.xwiki.notify.DocChangeRule; import com.xpn.xwiki.doc.XWikiDocument; +import com.xpn.xwiki.notify.DocChangeRule; +import com.xpn.xwiki.notify.XWikiDocChangeNotificationInterface; +import com.xpn.xwiki.notify.XWikiNotificationRule; public class XWikiMacrosMappingRenderer implements XWikiRenderer, XWikiDocChangeNotificationInterface { private static final Log log = LogFactory.getLog(XWikiMacrosMappingRenderer.class); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiRadeoxRenderEngine.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiRadeoxRenderEngine.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiRadeoxRenderEngine.java 2006-07-12 14:09:57.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiRadeoxRenderEngine.java 2006-08-08 21:28:37.000000000 +0300 @@ -280,10 +280,6 @@ if ((db==null)||(database.equals(db))) addLinkToContext(newdoc.getFullName(), context); - String editor = context.getWiki().getEditorPreference(context); - if ((!editor.equals("")&&(!editor.equals("text")))) - querystring += "&xpage=" + editor; - URL url = context.getURLFactory().createURL(newdoc.getWeb(), newdoc.getName(), "edit", querystring, null, context); String surl = context.getURLFactory().getURL(url, context); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiRenderer.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiRenderer.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiRenderer.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiRenderer.java 2006-07-12 14:09:57.000000000 +0300 @@ -1,29 +1,28 @@ -/* - * Copyright 2006, 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. - * - * @author ludovic - */ +/* + * Copyright 2006, 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. + * + * @author ludovic + */ package com.xpn.xwiki.render; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.doc.XWikiDocument; public interface XWikiRenderer { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiRenderingEngine.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiRenderingEngine.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/XWikiRenderingEngine.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/XWikiRenderingEngine.java 2006-07-12 14:09:57.000000000 +0300 @@ -1,273 +1,251 @@ -/* - * Copyright 2006, 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. - * - * @author ludovic - * @author sdumitriu - */ - -package com.xpn.xwiki.render; - -import java.util.*; - -import com.xpn.xwiki.XWiki; -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.web.XWikiRequest; -import com.xpn.xwiki.cache.api.XWikiCache; -import com.xpn.xwiki.cache.api.XWikiCacheNeedsRefreshException; -import com.xpn.xwiki.cache.api.XWikiCacheService; -import com.xpn.xwiki.doc.XWikiDocument; -import com.xpn.xwiki.monitor.api.MonitorPlugin; -import com.xpn.xwiki.render.groovy.XWikiGroovyRenderer; -import com.xpn.xwiki.util.Util; - -public class XWikiRenderingEngine { - - private List renderers = new ArrayList(); - private HashMap renderermap = new LinkedHashMap(); - private XWikiCache cache; - - public XWikiRenderingEngine(XWiki xwiki, XWikiContext context) throws XWikiException { - - if (xwiki.Param("xwiki.render.macromapping", "0").equals("1")) - addRenderer("mapping", new XWikiMacrosMappingRenderer(xwiki, context)); - // addRenderer(new XWikiJSPRenderer()); - if (xwiki.Param("xwiki.render.velocity", "1").equals("1")) - addRenderer("velocity", new XWikiVelocityRenderer()); - if (xwiki.Param("xwiki.render.groovy", "1").equals("1")) { - addRenderer("groovy", new XWikiGroovyRenderer()); - } - if (xwiki.Param("xwiki.render.plugin", "1").equals("1")) - addRenderer("plugin", new XWikiPluginRenderer()); - - // The first should not removePre - // The last one should removePre - if (xwiki.Param("xwiki.render.wiki", "1").equals("1")) - addRenderer("wiki", new XWikiRadeoxRenderer(false)); - - // if (xwiki.Param("xwiki.render.wiki2", "1").equals("1")) - // addRenderer("wiki2", new XWikiWikiParser2Renderer(false)); - - if (xwiki.Param("xwiki.render.wikiwiki", "0").equals("1")) { - addRenderer("xwiki", new XWikiWikiBaseRenderer(true, true)); - } else { - addRenderer("xwiki", new XWikiWikiBaseRenderer(false, true)); - } - - initCache(context); - } - - public void initCache(XWikiContext context) throws XWikiException { - int iCapacity = 100; - try { - String capacity = context.getWiki().Param("xwiki.render.cache.capacity"); - if (capacity != null) - iCapacity = Integer.parseInt(capacity); - } catch (Exception e) {} - initCache(iCapacity, context); - } - - public void initCache(int iCapacity, XWikiContext context) throws XWikiException { - XWikiCacheService cacheService = context.getWiki().getCacheService(); - cache = cacheService.newCache("xwiki.rendering.cache", iCapacity); - } - - public XWikiCache getCache() { - return cache; - } - - public void addRenderer(String name, XWikiRenderer renderer) { - renderers.add(renderer); - renderermap.put(name, renderer); - } - - public XWikiRenderer getRenderer(String name) { - return (XWikiRenderer) renderermap.get(name); - } - - public List getRendererList() { - return (List) ((ArrayList) renderers).clone(); - } - - public List getRendererNames() { - return new LinkedList(renderermap.keySet()); - } - - protected XWikiRenderer removeRenderer(String name) { - XWikiRenderer result = (XWikiRenderer) renderermap.remove(name); - if (result != null) { - renderers.remove(result); - } - return result; - } - - public String renderDocument(XWikiDocument doc, XWikiContext context) throws XWikiException { - return renderText(doc.getTranslatedContent(context), doc, context); - } - - public String renderDocument(XWikiDocument doc, XWikiDocument includingdoc, XWikiContext context) throws XWikiException { - return renderText(doc.getTranslatedContent(context), includingdoc, context); - } - - public String renderText(String text, XWikiDocument includingdoc, XWikiContext context) { - return renderText(text, includingdoc, includingdoc, context); - } - - public void addToCached(String key, XWikiContext context) { - List cached = (ArrayList) context.get("render_cached"); - if (cached==null) { - cached = new ArrayList(); - context.put("render_cached", cached); - } - cached.add(key); - } - - public void addToRefreshed(String key, XWikiContext context) { - List cached = (ArrayList) context.get("render_refreshed"); - if (cached==null) { - cached = new ArrayList(); - context.put("render_refreshed", cached); - } - cached.add(key); - } - - public String renderText(String text, XWikiDocument contentdoc, XWikiDocument includingdoc, XWikiContext context) { - String key = getKey(text, contentdoc, includingdoc, context); - - try { - if (cache==null) - initCache(context); - } catch (XWikiException e) {} - - synchronized (key) { - try { - XWikiRenderingCache cacheObject = null; - try { - cacheObject = (cache!=null) ? (XWikiRenderingCache) cache.getFromCache(key) : null; - } catch (XWikiCacheNeedsRefreshException e2) { - cache.cancelUpdate(key); - } - if (cacheObject!=null) { - XWikiRequest request = context.getRequest(); - boolean refresh = (request!=null) && ("1".equals(request.get("refresh"))); - if ((cacheObject.isValid()&&(!refresh))) { - addToCached(key, context); - return cacheObject.getContent(); - } else { - addToRefreshed(key, context); - } - } - } catch (Exception e) { - } - - MonitorPlugin monitor = Util.getMonitorPlugin(context); - try { - // Start monitoring timer - if (monitor!=null) - monitor.startTimer("rendering"); - - XWikiDocument doc = context.getDoc(); - XWikiDocument cdoc = context.getDoc(); - - // Let's call the beginRendering loop - context.getWiki().getPluginManager().beginRendering(context); - - String content = text; - - // Which is the current idoc and sdoc - XWikiDocument idoc = (XWikiDocument) context.get("idoc"); - XWikiDocument sdoc = (XWikiDocument) context.get("sdoc"); - // We put the including and security doc in the context - // It will be needed to verify programming rights - context.put("idoc", includingdoc); - context.put("sdoc", contentdoc); - - try { - - for (int i=0;i0) { - XWikiRenderingCache cacheObject = new XWikiRenderingCache(key, content, cacheDuration, new Date()); - cache.putInCache(key, (Object)cacheObject); - } - } catch (Exception e) {} - return content; - } - finally { - if (monitor!=null) - monitor.endTimer("rendering"); - } - } - } - - private String getKey(String text, XWikiDocument contentdoc, XWikiDocument includingdoc, XWikiContext context) { - return ((context==null) ? "xwiki" : context.getDatabase()) + "-" - + ((contentdoc==null) ? "" : contentdoc.getDatabase() + ":" + contentdoc.getFullName()) + "-" - + ((includingdoc==null) ? "" : includingdoc.getDatabase() + ":" + includingdoc.getFullName()) + "-" - + ((context.getRequest()==null) ? "" : context.getRequest().getQueryString()) - + "-" + text.hashCode(); - } - - public void flushCache() { - for (int i=0;i0) { + XWikiRenderingCache cacheObject = new XWikiRenderingCache(key, content, cacheDuration, new Date()); + cache.putInCache(key, (Object)cacheObject); + } + } catch (Exception e) {} + return content; + } + finally { + if (monitor!=null) + monitor.endTimer("rendering"); + } + } + } + + private String getKey(String text, XWikiDocument contentdoc, XWikiDocument includingdoc, XWikiContext context) { + return ((context==null) ? "xwiki" : context.getDatabase()) + "-" + + ((contentdoc==null) ? "" : contentdoc.getDatabase() + ":" + contentdoc.getFullName()) + "-" + + ((includingdoc==null) ? "" : includingdoc.getDatabase() + ":" + includingdoc.getFullName()) + "-" + + ((context.getRequest()==null) ? "" : context.getRequest().getQueryString()) + + "-" + text.hashCode(); + } + + public void flushCache() { + for (int i=0;i script and <%= %> expression syntax. It also lets you use normal groovy expressions in * the template text much like the new JSP EL functionality. The variable 'out' is bound to the writer that the template is being written to. * */ -public class GroovyTemplateEngine extends TemplateEngine { - -/* (non-Javadoc) -* @see groovy.util.TemplateEngine#createTemplate(java.io.Reader) -*/ -public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { - com.xpn.xwiki.render.groovy.GroovyTemplateEngine.SimpleTemplate template = new com.xpn.xwiki.render.groovy.GroovyTemplateEngine.SimpleTemplate(); - GroovyShell shell = new GroovyShell(); - String script = template.parse(reader); - template.script = shell.parse(script); - return template; -} - -private static class SimpleTemplate implements Template, XWikiCachedObject { - - private Script script; - private Binding binding; - private Map map; - - - public void finalize() throws Throwable - { - try { - if (script!=null) { - InvokerHelper.removeClass(script.getClass()); - removeClass(script.getClass()); - } - } finally { - super.finalize(); - } - } - - /** - * Set the binding for the template. Keys will be converted to Strings. - * - * @see groovy.text.Template#setBinding(java.util.Map) - */ - public void setBinding(final Map map) { - this.map = map; - binding = new Binding(map); - } - - /** - * Write the template document with the set binding applied to the writer. - * - * @see groovy.lang.Writable#writeTo(java.io.Writer) - */ - public Writer writeTo(Writer writer) throws IOException { - if (binding == null) binding = new Binding(); - Script scriptObject = InvokerHelper.createScript(script.getClass(), binding); - PrintWriter pw = new PrintWriter(writer); - scriptObject.setProperty("out", pw); - scriptObject.run(); - pw.flush(); - return writer; - } - - /** - * Convert the template and binding into a result String. - * - * @see java.lang.Object#toString() - */ - public String toString() { - try { - StringWriter sw = new StringWriter(); - writeTo(sw); - return sw.toString(); - } catch (Exception e) { - return e.toString(); - } - } - - /** - * Parse the text document looking for <% or <%= and then call out to the appropriate handler, otherwise copy the text directly - * into the script while escaping quotes. - * - * @param reader - * @return - * @throws IOException - */ - private String parse(Reader reader) throws IOException { - if (!reader.markSupported()) { - reader = new BufferedReader(reader); - } - StringWriter sw = new StringWriter(); - startScript(sw); - boolean start = false; - int c; - while((c = reader.read()) != -1) { - if (c == '<') { - c = reader.read(); - if (c != '%') { - sw.write('<'); - } else { - reader.mark(1); - c = reader.read(); - if (c == '=') { - groovyExpression(reader, sw); - } else { - reader.reset(); - groovySection(reader, sw); - } - continue; - } - } - if (c == '\"') { - sw.write('\\'); - } - if ((c!='\r')&&(c!='\n')) - sw.write(c); - else if (c=='\n') { - sw.write("\");out.println();out.print(\""); - } - } - endScript(sw); - String result = sw.toString(); - //System.out.println( "source text:\n" + result ); - return result; - } - - private void startScript(StringWriter sw) { - sw.write("/* Generated by GroovyTemplateEngine */ "); - sw.write("out.print(\""); - } - - private void endScript(StringWriter sw) { - sw.write("\");"); - } - - /** - * Closes the currently open write and writes out the following text as a GString expression until it reaches an end %>. - * - * @param reader - * @param sw - * @throws IOException - */ - private void groovyExpression(Reader reader, StringWriter sw) throws IOException { - sw.write("\");out.print(\"${"); - int c; - while((c = reader.read()) != -1) { - if (c == '%') { - c = reader.read(); - if (c != '>') { - sw.write('%'); - } else { - break; - } - } - sw.write(c); - } - sw.write("}\");out.print(\""); - } - - /** - * Closes the currently open write and writes the following text as normal Groovy script code until it reaches an end %>. - * - * @param reader - * @param sw - * @throws IOException - */ - private void groovySection(Reader reader, StringWriter sw) throws IOException { - sw.write("\");"); - int c; - while((c = reader.read()) != -1) { - if (c == '%') { - c = reader.read(); - if (c != '>') { - sw.write('%'); - } else { - break; - } - } - sw.write(c); - } - sw.write(";out.print(\""); - } - - public Writable make() { - return make(null); - } - - public Writable make(final Map map) { - return new Writable() { - /** - * Write the template document with the set binding applied to the writer. - * - * @see groovy.lang.Writable#writeTo(java.io.Writer) - */ - public Writer writeTo(Writer writer) throws IOException { - Binding binding; - if (map == null) binding = new Binding(); else binding = new Binding(map); - Script scriptObject = InvokerHelper.createScript(script.getClass(), binding); - PrintWriter pw = new PrintWriter(writer); - scriptObject.setProperty("out", pw); - scriptObject.run(); - pw.flush(); - return writer; - } - - /** - * Convert the template and binding into a result String. - * - * @see java.lang.Object#toString() - */ - public String toString() { - try { - StringWriter sw = new StringWriter(); - writeTo(sw); - return sw.toString(); - } catch (Exception e) { - return e.toString(); - } - } - }; - } -} - protected static void clearMetaClassRegistry(MetaClassRegistry mcr) { - Map map = (Map) com.xpn.xwiki.XWiki.getPrivateField(mcr, "metaClasses"); - map.clear(); - Map map2 = (Map) com.xpn.xwiki.XWiki.getPrivateField(mcr, "loaderMap"); - map2.clear(); - - Class[] classes; - Object[] objects; - - classes = new Class[1]; - classes[0] = DefaultGroovyMethods.class.getClass(); - objects = new Object[1]; - objects[0] = DefaultGroovyMethods.class; - com.xpn.xwiki.XWiki.callPrivateMethod(mcr, "lookup", classes, objects); - - classes = new Class[2]; - classes[0] = DefaultGroovyMethods.class.getClass(); - classes[1] = boolean.class; - objects = new Object[2]; - objects[0] = DefaultGroovyMethods.class; - objects[1] = Boolean.TRUE; - com.xpn.xwiki.XWiki.callPrivateMethod(mcr, "registerMethods", classes, objects); - - classes = new Class[1]; - classes[0] = DefaultGroovyStaticMethods.class.getClass(); - objects = new Object[1]; - objects[0] = DefaultGroovyStaticMethods.class; - com.xpn.xwiki.XWiki.callPrivateMethod(mcr, "lookup", classes, objects); - - classes = new Class[2]; - classes[0] = DefaultGroovyStaticMethods.class.getClass(); - classes[1] = boolean.class; - objects = new Object[2]; - objects[0] = DefaultGroovyStaticMethods.class; - objects[1] = Boolean.FALSE; - com.xpn.xwiki.XWiki.callPrivateMethod(mcr, "registerMethods", classes, objects); - - com.xpn.xwiki.XWiki.callPrivateMethod(mcr, "checkInitialised"); - } - - public static void flushCache() { - // Clear up groovy registry - MetaClassRegistry mcr = MetaClassRegistry.getIntance(0); - clearMetaClassRegistry(mcr); - mcr = MetaClassRegistry.getIntance(1); - clearMetaClassRegistry(mcr); - mcr = InvokerHelper.getInstance().getMetaRegistry(); - clearMetaClassRegistry(mcr); - Introspector.flushCaches(); - } - - public static void removeClass(Class clazz) { - // Clear up groovy registry - MetaClassRegistry mcr = MetaClassRegistry.getIntance(0); - mcr.removeMetaClass(clazz); - mcr = MetaClassRegistry.getIntance(1); - mcr.removeMetaClass(clazz); - mcr = InvokerHelper.getInstance().getMetaRegistry(); - mcr.removeMetaClass(clazz); - } + public class GroovyTemplateEngine extends TemplateEngine { -} + /* (non-Javadoc) + * @see groovy.util.TemplateEngine#createTemplate(java.io.Reader) + */ + public Template createTemplate(Reader reader) throws CompilationFailedException, ClassNotFoundException, IOException { + com.xpn.xwiki.render.groovy.GroovyTemplateEngine.SimpleTemplate template = new com.xpn.xwiki.render.groovy.GroovyTemplateEngine.SimpleTemplate(); + GroovyShell shell = new GroovyShell(); + String script = template.parse(reader); + template.script = shell.parse(script); + return template; + } + + private static class SimpleTemplate implements Template { + + private Script script; + private Binding binding; + private Map map; + + + public void finalize() + { + if (script!=null) + InvokerHelper.removeClass(script.getClass()); + } + + /** + * Set the binding for the template. Keys will be converted to Strings. + * + * @see groovy.text.Template#setBinding(java.util.Map) + */ + public void setBinding(final Map map) { + this.map = map; + binding = new Binding(map); + } + + /** + * Write the template document with the set binding applied to the writer. + * + * @see groovy.lang.Writable#writeTo(java.io.Writer) + */ + public Writer writeTo(Writer writer) throws IOException { + if (binding == null) binding = new Binding(); + Script scriptObject = InvokerHelper.createScript(script.getClass(), binding); + PrintWriter pw = new PrintWriter(writer); + scriptObject.setProperty("out", pw); + scriptObject.run(); + pw.flush(); + return writer; + } + + /** + * Convert the template and binding into a result String. + * + * @see java.lang.Object#toString() + */ + public String toString() { + try { + StringWriter sw = new StringWriter(); + writeTo(sw); + return sw.toString(); + } catch (Exception e) { + return e.toString(); + } + } + + /** + * Parse the text document looking for <% or <%= and then call out to the appropriate handler, otherwise copy the text directly + * into the script while escaping quotes. + * + * @param reader + * @return + * @throws IOException + */ + private String parse(Reader reader) throws IOException { + if (!reader.markSupported()) { + reader = new BufferedReader(reader); + } + StringWriter sw = new StringWriter(); + startScript(sw); + boolean start = false; + int c; + while((c = reader.read()) != -1) { + if (c == '<') { + c = reader.read(); + if (c != '%') { + sw.write('<'); + } else { + reader.mark(1); + c = reader.read(); + if (c == '=') { + groovyExpression(reader, sw); + } else { + reader.reset(); + groovySection(reader, sw); + } + continue; + } + } + if (c == '\"') { + sw.write('\\'); + } + if ((c!='\r')&&(c!='\n')) + sw.write(c); + else if (c=='\n') { + sw.write("\");out.println();out.print(\""); + } + } + endScript(sw); + String result = sw.toString(); + //System.out.println( "source text:\n" + result ); + return result; + } + + private void startScript(StringWriter sw) { + sw.write("/* Generated by GroovyTemplateEngine */ "); + sw.write("out.print(\""); + } + + private void endScript(StringWriter sw) { + sw.write("\");"); + } + + /** + * Closes the currently open write and writes out the following text as a GString expression until it reaches an end %>. + * + * @param reader + * @param sw + * @throws IOException + */ + private void groovyExpression(Reader reader, StringWriter sw) throws IOException { + sw.write("\");out.print(\"${"); + int c; + while((c = reader.read()) != -1) { + if (c == '%') { + c = reader.read(); + if (c != '>') { + sw.write('%'); + } else { + break; + } + } + sw.write(c); + } + sw.write("}\");out.print(\""); + } + + /** + * Closes the currently open write and writes the following text as normal Groovy script code until it reaches an end %>. + * + * @param reader + * @param sw + * @throws IOException + */ + private void groovySection(Reader reader, StringWriter sw) throws IOException { + sw.write("\");"); + int c; + while((c = reader.read()) != -1) { + if (c == '%') { + c = reader.read(); + if (c != '>') { + sw.write('%'); + } else { + break; + } + } + sw.write(c); + } + sw.write(";out.print(\""); + } + + public Writable make() { + return make(null); + } + + public Writable make(final Map map) { + return new Writable() { + /** + * Write the template document with the set binding applied to the writer. + * + * @see groovy.lang.Writable#writeTo(java.io.Writer) + */ + public Writer writeTo(Writer writer) throws IOException { + Binding binding; + if (map == null) binding = new Binding(); else binding = new Binding(map); + Script scriptObject = InvokerHelper.createScript(script.getClass(), binding); + PrintWriter pw = new PrintWriter(writer); + scriptObject.setProperty("out", pw); + scriptObject.run(); + pw.flush(); + return writer; + } + + /** + * Convert the template and binding into a result String. + * + * @see java.lang.Object#toString() + */ + public String toString() { + try { + StringWriter sw = new StringWriter(); + writeTo(sw); + return sw.toString(); + } catch (Exception e) { + return e.toString(); + } + } + }; + } + } + } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/groovy/XWikiGroovyRenderer.java 2006-07-12 14:09:57.000000000 +0300 @@ -46,7 +46,6 @@ import com.xpn.xwiki.api.XWiki; import com.xpn.xwiki.cache.api.XWikiCache; import com.xpn.xwiki.cache.api.XWikiCacheNeedsRefreshException; -import com.xpn.xwiki.cache.impl.XWikiCachedObject; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.render.XWikiRenderer; import com.xpn.xwiki.render.XWikiVirtualMacro; @@ -57,22 +56,15 @@ private XWikiCache cache; private XWikiCache classCache; - public XWikiGroovyRenderer() { } public void flushCache() { - if (cache!=null) { + if (cache!=null) cache.flushAll(); - } if (classCache!=null) classCache.flushAll(); - - GroovyTemplateEngine.flushCache(); - - cache = null; - classCache = null; } public Map prepareContext(XWikiContext context) { @@ -99,35 +91,17 @@ return gcontext; } - public void initCache(XWikiContext context) throws XWikiException { - int iCapacity = 100; - try { - String capacity = context.getWiki().Param("xwiki.render.groovy.cache.capacity"); - if (capacity != null) - iCapacity = Integer.parseInt(capacity); - } catch (Exception e) {} - - int iClassCapacity = 100; - try { - String capacity = context.getWiki().Param("xwiki.render.groovy.classcache.capacity"); - if (capacity != null) - iCapacity = Integer.parseInt(capacity); - } catch (Exception e) {} - - - initCache(iCapacity, iClassCapacity, context); - } - - public void initCache(int iCapacity, int iClassCapacity, XWikiContext context) throws XWikiException { - cache = context.getWiki().getCacheService().newLocalCache(iCapacity); - classCache = context.getWiki().getCacheService().newLocalCache(iClassCapacity); + public void initCache(XWikiContext context) { + cache = context.getWiki().getCacheService().newCache(100); + classCache = context.getWiki().getCacheService().newCache(100); } protected void prepareCache(XWikiContext context) { - try { - if ((cache==null)||(classCache==null)) - initCache(context); - } catch (Exception e) { + if (cache==null) { + cache = context.getWiki().getCacheService().newCache(100); + } + if (classCache==null) { + classCache = context.getWiki().getCacheService().newCache(100); } } @@ -135,7 +109,6 @@ GroovyTemplateEngine engine = new GroovyTemplateEngine(); Template template = null; boolean refresh = false; - try { XWikiRequest request = (XWikiRequest) gcontext.get("request"); refresh = "1".equals(request.get("refresh")); @@ -183,8 +156,6 @@ if (!context.getWiki().getRightService().hasProgrammingRights(contentdoc, context)) return content; - prepareCache(context); - Map gcontext = null; try { String name = contextdoc.getFullName(); @@ -292,12 +263,12 @@ gc = cgc.getGroovyClass(); } catch (XWikiCacheNeedsRefreshException e) { - classCache.cancelUpdate(script); GroovyClassLoader gcl = new GroovyClassLoader(); gc = gcl.parseClass(script); cgc = new CachedGroovyClass(gc); classCache.putInCache(script, cgc); } finally { + classCache.cancelUpdate(script); } return gc.newInstance(); } catch (Exception e) { @@ -307,7 +278,7 @@ } } - public class CachedGroovyClass implements XWikiCachedObject { + private class CachedGroovyClass { protected Class cl; public CachedGroovyClass(Class cl) { @@ -318,15 +289,9 @@ return cl; } - public void finalize() throws Throwable { - try { - if (cl!=null) { - InvokerHelper.removeClass(cl); - GroovyTemplateEngine.removeClass(cl); - } - } finally { - super.finalize(); - } + public void finalize() { + if (cl!=null) + InvokerHelper.removeClass(cl); } - } + } } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/macro/DisplayMacro.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/macro/DisplayMacro.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/macro/DisplayMacro.java 2006-07-12 14:09:57.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/macro/DisplayMacro.java 2006-08-02 17:46:35.000000000 +0300 @@ -17,23 +17,11 @@ * Created by * User: Ludovic Dubost - * Date: 25 août 2004 + * Date: 25 August 2004 * Time: 13:43:19 */ package com.xpn.xwiki.render.macro; -import java.io.IOException; -import java.io.Writer; - -import org.radeox.api.engine.RenderEngine; -import org.radeox.api.engine.context.RenderContext; -import org.radeox.macro.BaseLocaleMacro; -import org.radeox.macro.parameter.MacroParameter; - -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.doc.XWikiDocument; -import com.xpn.xwiki.objects.BaseObject; -import com.xpn.xwiki.render.XWikiRadeoxRenderEngine; public class DisplayMacro extends FieldMacro { public String getLocaleKey() { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java 2006-08-09 14:46:12.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java 2006-07-27 12:13:51.000000000 +0300 @@ -56,10 +56,10 @@ str.append(""); diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/render/macro/UseMacro.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/macro/UseMacro.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/render/macro/UseMacro.java 2006-07-12 14:09:57.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/render/macro/UseMacro.java 2006-08-02 17:49:04.000000000 +0300 @@ -17,7 +17,7 @@ * Created by * User: Ludovic Dubost - * Date: 25 août 2004 + * Date: 25 August 2004 * Time: 13:43:19 */ package com.xpn.xwiki.render.macro; @@ -25,16 +25,14 @@ import java.io.IOException; import java.io.Writer; +import org.apache.velocity.VelocityContext; import org.radeox.api.engine.RenderEngine; import org.radeox.api.engine.context.RenderContext; import org.radeox.macro.BaseLocaleMacro; import org.radeox.macro.parameter.MacroParameter; -import org.apache.velocity.VelocityContext; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.api.Document; -import com.xpn.xwiki.doc.XWikiDocument; -import com.xpn.xwiki.objects.BaseObject; import com.xpn.xwiki.render.XWikiRadeoxRenderEngine; public class UseMacro extends BaseLocaleMacro { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiBatcher.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiBatcher.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiBatcher.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiBatcher.java 2006-07-12 14:09:58.000000000 +0300 @@ -1,40 +1,36 @@ -/* - * Copyright 2006, 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. - * - * @author ludovic - */ +/* + * Copyright 2006, 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. + * + * @author ludovic + */ package com.xpn.xwiki.store; -/* import org.hibernate.jdbc.BatchingBatcher; import org.hibernate.jdbc.JDBCContext; -import org.hibernate.jdbc.ConnectionManager; import org.hibernate.HibernateException; import org.hibernate.ScrollMode; -import org.hibernate.Interceptor; import org.hibernate.dialect.Dialect; import java.sql.SQLException; import java.sql.ResultSet; import java.sql.PreparedStatement; import java.sql.CallableStatement; -*/ /** * Created by IntelliJ IDEA. @@ -43,7 +39,6 @@ * Time: 10:56:45 * To change this template use File | Settings | File Templates. */ -/* public class XWikiBatcher extends BatchingBatcher { private static ThreadLocal sqlStats = new ThreadLocal() { @@ -61,8 +56,8 @@ super.addToBatch(expectedRowCount); } - public XWikiBatcher(ConnectionManager cmgr, Interceptor interceptor) { - super(cmgr, interceptor); + public XWikiBatcher(JDBCContext jdbcContext) { + super(jdbcContext); } public void abortBatch(SQLException sqle) { @@ -80,9 +75,9 @@ getSQLStats().incrementPreparedSQLCounter(); } - public PreparedStatement prepareStatement(String sql, boolean getGeneratedKeys, String[] param) throws SQLException, HibernateException { + public PreparedStatement prepareStatement(String sql, boolean getGeneratedKeys) throws SQLException, HibernateException { addToPreparedSql(sql); - return super.prepareStatement(sql, getGeneratedKeys, param); + return super.prepareStatement(sql, getGeneratedKeys); } public PreparedStatement prepareSelectStatement(String sql) throws SQLException, HibernateException { @@ -126,4 +121,3 @@ getSQLStats().resetOnNextSQL(); } } -*/ \ No newline at end of file diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiBatcherFactory.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiBatcherFactory.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiBatcherFactory.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiBatcherFactory.java 2006-08-02 18:30:34.000000000 +0300 @@ -1,28 +1,29 @@ -/* - * Copyright 2006, 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. - * - * @author ludovic - */ +/* + * Copyright 2006, 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. + * + * @author ludovic + */ package com.xpn.xwiki.store; -import org.hibernate.jdbc.*; -import org.hibernate.Interceptor; +import org.hibernate.jdbc.Batcher; +import org.hibernate.jdbc.BatchingBatcherFactory; +import org.hibernate.jdbc.JDBCContext; /** * Created by IntelliJ IDEA. @@ -31,11 +32,8 @@ * Time: 12:02:10 * To change this template use File | Settings | File Templates. */ -/* public class XWikiBatcherFactory extends BatchingBatcherFactory { - - public Batcher createBatcher(ConnectionManager cmgr, Interceptor interceptor) { - return new XWikiBatcher( cmgr, interceptor ); + public Batcher createBatcher(JDBCContext jdbcContext) { + return new XWikiBatcher( jdbcContext ); } } -*/ \ No newline at end of file diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiCacheStore.java 2006-08-02 18:30:15.000000000 +0300 @@ -24,6 +24,12 @@ package com.xpn.xwiki.store; +import java.util.List; + +import org.apache.commons.jrcs.rcs.Version; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.cache.api.XWikiCache; @@ -32,11 +38,6 @@ import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.doc.XWikiLock; import com.xpn.xwiki.objects.classes.BaseClass; -import org.suigeneris.jrcs.rcs.Version; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.List; @@ -47,36 +48,32 @@ private XWikiStoreInterface store; private XWikiCache cache; private XWikiCache pageExistCache; + private XWikiCache classCache; + private XWikiCache prefsCache; private int cacheCapacity = 100; + private int prefsCacheCapacity = 1000; private int pageExistCacheCapacity = 10000; - public XWikiCacheStore(XWikiStoreInterface store, XWikiContext context) throws XWikiException { + public XWikiCacheStore(XWikiStoreInterface store, XWikiContext context) { setStore(store); - initCache(context); + initCache(cacheCapacity, pageExistCacheCapacity, getPrefsCacheCapacity(), context); } - public synchronized void initCache(XWikiContext context) throws XWikiException { - if ((cache==null)||(pageExistCache==null)) { - try { - String capacity = context.getWiki().Param("xwiki.store.cache.capacity"); - if (capacity != null) - cacheCapacity = Integer.parseInt(capacity); - } catch (Exception e) { - } - try { - String capacity = context.getWiki().Param("xwiki.store.cache.pageexistcapacity"); - if (capacity != null) - pageExistCacheCapacity = Integer.parseInt(capacity); - } catch (Exception e) { - } - initCache(cacheCapacity, pageExistCacheCapacity, context); - } + public void initCache(int capacity, int pageExistCacheCapacity, int prefsCacheCapacity, XWikiContext context) { + XWikiCacheService cacheService = context.getWiki().getCacheService(); + setCache(cacheService.newCache(capacity)); + setPageExistCache(cacheService.newCache(pageExistCacheCapacity)); + setPrefsCache(cacheService.newCache(prefsCacheCapacity)); } - public void initCache(int capacity, int pageExistCacheCapacity, XWikiContext context) throws XWikiException { - XWikiCacheService cacheService = context.getWiki().getCacheService(); - setCache(cacheService.newCache("xwiki.store.pagecache", capacity)); - setPageExistCache(cacheService.newCache("xwiki.store.pageexistcache",pageExistCacheCapacity)); + public void setCacheCapacity(int capacity) { + cacheCapacity = capacity; + getCache().setCapacity(capacity); + } + + public void setPageExistCacheCapacity(int capacity) { + pageExistCacheCapacity = capacity; + getPageExistCache().setCapacity(capacity); } public XWikiStoreInterface getStore() { @@ -96,9 +93,6 @@ synchronized(key) { store.saveXWikiDoc(doc, context, bTransaction); doc.setStore(store); - // Make sure cache is initialized - initCache(context); - // We need to flush so that caches // on the cluster are informed about the change getCache().flushEntry(key); @@ -109,14 +103,9 @@ } public void flushCache() { - if (cache!=null) { - cache.flushAll(); - cache = null; - } - if (pageExistCache!=null) { - pageExistCache.flushAll(); - pageExistCache = null; - } + getCache().flushAll(); + getPageExistCache().flushAll(); + getPrefsCache().flushAll(); } public String getKey(XWikiDocument doc, XWikiContext context) { @@ -139,9 +128,6 @@ if (log.isDebugEnabled()) log.debug("Cache: begin for doc " + key + " in cache"); - // Make sure cache is initialized - initCache(context); - synchronized (key) { try { if (log.isDebugEnabled()) @@ -176,20 +162,26 @@ return doc; } + public XWikiDocument loadXWikiDoc(XWikiDocument doc, String version, XWikiContext context) throws XWikiException { + XWikiDocument doc2 = store.loadXWikiDoc(doc, version, context); + doc2.setStore(store); + return doc2; + } + public void deleteXWikiDoc(XWikiDocument doc, XWikiContext context) throws XWikiException { String key = getKey(doc, context); synchronized(key) { store.deleteXWikiDoc(doc, context); - - // Make sure cache is initialized - initCache(context); - getCache().flushEntry(key); getPageExistCache().flushEntry(key); getPageExistCache().putInCache(key, new Boolean(false)); } } + public Version[] getXWikiDocVersions(XWikiDocument doc, XWikiContext context) throws XWikiException { + return store.getXWikiDocVersions(doc, context); + } + public List getClassList(XWikiContext context) throws XWikiException { return store.getClassList(context); } @@ -294,7 +286,6 @@ public boolean exists(XWikiDocument doc, XWikiContext context) throws XWikiException { String key = getKey(doc,context); - initCache(context); synchronized(key) { try { try { @@ -338,4 +329,21 @@ public void injectUpdatedCustomMappings(XWikiContext context) throws XWikiException { store.injectUpdatedCustomMappings(context); } + + public XWikiCache getPrefsCache() { + return prefsCache; + } + + public void setPrefsCache(XWikiCache prefsCache) { + this.prefsCache = prefsCache; + } + + public int getPrefsCacheCapacity() { + return prefsCacheCapacity; + } + + public void setPrefsCacheCapacity(int prefsCacheCapacity) { + this.prefsCacheCapacity = prefsCacheCapacity; + getPrefsCache().setCapacity(prefsCacheCapacity); + } } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiCacheStoreInterface.java 2006-07-12 14:09:58.000000000 +0300 @@ -23,11 +23,14 @@ package com.xpn.xwiki.store; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; public interface XWikiCacheStoreInterface extends XWikiStoreInterface { public XWikiStoreInterface getStore(); public void setStore(XWikiStoreInterface store); public void flushCache(); - public void initCache(int capacity, int pageExistCapacity, XWikiContext context) throws XWikiException; + public void setCacheCapacity(int capacity); + public void setPageExistCacheCapacity(int capacity); + public void setPrefsCacheCapacity(int capacity); + public void initCache(int capacity, int pageExistCapacity, + int prefsCacheCapacity, XWikiContext context); } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateAttachmentStore.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiHibernateAttachmentStore.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateAttachmentStore.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiHibernateAttachmentStore.java 2006-08-02 18:29:47.000000000 +0300 @@ -1,19 +1,18 @@ package com.xpn.xwiki.store; -import com.xpn.xwiki.doc.XWikiAttachment; -import com.xpn.xwiki.doc.XWikiAttachmentContent; -import com.xpn.xwiki.doc.XWikiAttachmentArchive; -import com.xpn.xwiki.doc.XWikiDocumentArchive; -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.XWiki; -import org.hibernate.Session; -import org.hibernate.Query; -import org.hibernate.SessionFactory; +import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hibernate.Query; +import org.hibernate.Session; -import java.util.List; +import com.xpn.xwiki.XWiki; +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.XWikiException; +import com.xpn.xwiki.doc.XWikiAttachment; +import com.xpn.xwiki.doc.XWikiAttachmentArchive; +import com.xpn.xwiki.doc.XWikiAttachmentContent; /** * Created by IntelliJ IDEA. @@ -63,33 +62,23 @@ } Session session = getSession(context); - String db = context.getDatabase(); - String attachdb = (attachment.getDoc()==null) ? null : attachment.getDoc().getDatabase(); - try { - if (attachdb!=null) - context.setDatabase(attachdb); - - Query query = session.createQuery("select attach.id from XWikiAttachmentContent as attach where attach.id = :id"); - query.setLong("id", content.getId()); - if (query.uniqueResult()==null) - session.save(content); - else - session.update(content); - - query = session.createQuery("select attach.id from XWikiAttachmentArchive as attach where attach.id = :id"); - query.setLong("id", archive.getId()); - if (query.uniqueResult()==null) - session.save(archive); - else - session.update(archive); - if (parentUpdate) - context.getWiki().getStore().saveXWikiDoc(attachment.getDoc(), context, true); - - } finally { - context.setDatabase(db); - } + Query query = session.createQuery("select attach.id from XWikiAttachmentContent as attach where attach.id = :id"); + query.setLong("id", content.getId()); + if (query.uniqueResult()==null) + session.save(content); + else + session.update(content); + + query = session.createQuery("select attach.id from XWikiAttachmentArchive as attach where attach.id = :id"); + query.setLong("id", archive.getId()); + if (query.uniqueResult()==null) + session.save(archive); + else + session.update(archive); + if (parentUpdate) + context.getWiki().getStore().saveXWikiDoc(attachment.getDoc(), context, true); if (bTransaction) { endTransaction(context, true); } @@ -115,17 +104,11 @@ } Session session = getSession(context); - String db = context.getDatabase(); - String attachdb = (attachment.getDoc()==null) ? null : attachment.getDoc().getDatabase(); - try { - if (attachdb!=null) - context.setDatabase(attachdb); - XWikiAttachmentContent content = new XWikiAttachmentContent(attachment); - attachment.setAttachment_content(content); - session.load(content, new Long(content.getId())); - } finally { - context.setDatabase(db); - } + + XWikiAttachmentContent content = new XWikiAttachmentContent(attachment); + attachment.setAttachment_content(content); + + session.load(content, new Long(content.getId())); if (bTransaction) endTransaction(context, false, false); @@ -151,19 +134,11 @@ Session session = getSession(context); - String db = context.getDatabase(); - String attachdb = (attachment.getDoc()==null) ? null : attachment.getDoc().getDatabase(); - try { - if (attachdb!=null) - context.setDatabase(attachdb); + XWikiAttachmentArchive archive = new XWikiAttachmentArchive(); + archive.setAttachment(attachment); + attachment.setAttachment_archive(archive); - XWikiAttachmentArchive archive = new XWikiAttachmentArchive(); - archive.setAttachment(attachment); - attachment.setAttachment_archive(archive); - session.load(archive, new Long(archive.getId())); - } finally { - context.setDatabase(db); - } + session.load(archive, new Long(archive.getId())); if (bTransaction) endTransaction(context, false, false); @@ -193,49 +168,38 @@ Session session = getSession(context); - - String db = context.getDatabase(); - String attachdb = (attachment.getDoc()==null) ? null : attachment.getDoc().getDatabase(); + // Delete the three attachement entries try { - if (attachdb!=null) - context.setDatabase(attachdb); - - // Delete the three attachement entries - try { - loadAttachmentContent(attachment, context, false); - } catch (Exception e) { - if (log.isWarnEnabled()) - log.warn("Error loading attachment content when deleting attachment " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); - } - try { - session.delete(attachment.getAttachment_content()); - } catch (Exception e) { - if (log.isWarnEnabled()) - log.warn("Error deleting attachment content " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); - } - try { - loadAttachmentContent(attachment, context, false); - } catch(XWikiException e){ - if (log.isWarnEnabled()) - log.warn("Error loading attachment archive when deleting attachment " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); - } - - try { - session.delete(attachment.getAttachment_archive()); - } catch (Exception e) { - if (log.isWarnEnabled()) - log.warn("Error deleting attachment archive " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); - } + loadAttachmentContent(attachment, context, false); + } catch (Exception e) { + if (log.isWarnEnabled()) + log.warn("Error loading attachment content when deleting attachment " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); + } + try { + session.delete(attachment.getAttachment_content()); + } catch (Exception e) { + if (log.isWarnEnabled()) + log.warn("Error deleting attachment content " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); + } + try { + loadAttachmentContent(attachment, context, false); + } catch(XWikiException e){ + if (log.isWarnEnabled()) + log.warn("Error loading attachment archive when deleting attachment " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); + } - try { - session.delete(attachment); - } catch (Exception e) { - if (log.isWarnEnabled()) - log.warn("Error deleting attachment meta data " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); - } + try { + session.delete(attachment.getAttachment_archive()); + } catch (Exception e) { + if (log.isWarnEnabled()) + log.warn("Error deleting attachment archive " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); + } - } finally { - context.setDatabase(db); + try { + session.delete(attachment); + } catch (Exception e) { + if (log.isWarnEnabled()) + log.warn("Error deleting attachment meta data " + attachment.getFilename() + " of doc " + attachment.getDoc().getFullName()); } try { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiHibernateBaseStore.java 2006-07-12 14:09:58.000000000 +0300 @@ -53,8 +53,8 @@ * @param context */ public XWikiHibernateBaseStore(XWiki xwiki, XWikiContext context) { - String path = xwiki.Param("xwiki.store.hibernate.path", "hibernate.cfg.xml"); - if ((path!=null)&&((new File(path).exists() || context.getEngineContext() == null))) { + String path = xwiki.Param("xwiki.store.hibernate.path"); + if (new File(path).exists() || context.getEngineContext() == null){ setPath (path); } else { try { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java 2006-08-09 14:35:15.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/store/XWikiHibernateStore.java 2006-08-02 18:39:18.000000000 +0300 @@ -29,39 +29,62 @@ package com.xpn.xwiki.store; +import java.io.Serializable; +import java.lang.reflect.Field; +import java.sql.Connection; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import org.apache.commons.jrcs.rcs.Archive; +import org.apache.commons.jrcs.rcs.Node; +import org.apache.commons.jrcs.rcs.Version; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.EntityMode; +import org.hibernate.FlushMode; +import org.hibernate.ObjectNotFoundException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Settings; +import org.hibernate.connection.ConnectionProvider; +import org.hibernate.impl.SessionFactoryImpl; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; + import com.xpn.xwiki.XWiki; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.stats.impl.XWikiStats; -import com.xpn.xwiki.render.XWikiRenderer; -import com.xpn.xwiki.doc.*; +import com.xpn.xwiki.doc.XWikiAttachment; +import com.xpn.xwiki.doc.XWikiDocument; +import com.xpn.xwiki.doc.XWikiLink; +import com.xpn.xwiki.doc.XWikiLock; import com.xpn.xwiki.monitor.api.MonitorPlugin; -import com.xpn.xwiki.objects.*; +import com.xpn.xwiki.objects.BaseCollection; +import com.xpn.xwiki.objects.BaseElement; +import com.xpn.xwiki.objects.BaseObject; +import com.xpn.xwiki.objects.BaseProperty; +import com.xpn.xwiki.objects.LargeStringProperty; +import com.xpn.xwiki.objects.ListProperty; +import com.xpn.xwiki.objects.PropertyInterface; +import com.xpn.xwiki.objects.StringProperty; import com.xpn.xwiki.objects.classes.BaseClass; import com.xpn.xwiki.objects.classes.PropertyClass; -import com.xpn.xwiki.objects.classes.TextAreaClass; import com.xpn.xwiki.objects.classes.StringClass; +import com.xpn.xwiki.objects.classes.TextAreaClass; +import com.xpn.xwiki.render.XWikiRenderer; +import com.xpn.xwiki.stats.impl.XWikiStats; import com.xpn.xwiki.util.Util; -import org.suigeneris.jrcs.rcs.Archive; -import org.suigeneris.jrcs.rcs.Node; -import org.suigeneris.jrcs.rcs.Version; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.*; -import org.hibernate.mapping.PersistentClass; -import org.hibernate.mapping.Property; -import org.hibernate.connection.ConnectionProvider; -import org.hibernate.cfg.Configuration; -import org.hibernate.cfg.Settings; -import org.hibernate.impl.SessionFactoryImpl; - -import java.io.Serializable; -import java.io.BufferedReader; -import java.sql.Connection; -import java.sql.Statement; -import java.util.*; -import java.lang.reflect.Field; public class XWikiHibernateStore extends XWikiHibernateBaseStore implements XWikiStoreInterface { @@ -235,20 +258,14 @@ doc.setContentAuthor(doc.getAuthor()); } doc.incrementVersion(); - context.getWiki().getVersioningStore().updateXWikiDocArchive(doc, doc.toXML(context), false, context); + doc.updateArchive(doc.toXML(context)); } else { - if (doc.getDocumentArchive()!=null) { - // Let's make sure we save the archive if we have one - // This is especially needed if we load a document from XML - context.getWiki().getVersioningStore().saveXWikiDocArchive(doc.getDocumentArchive(),false, context); - } else { - // Make sure the getArchive call has been made once - // with a valid context - try { - doc.getDocumentArchive(context); - } catch (XWikiException e) { - // this is a non critical error - } + // Make sure the getArchive call has been made once + // with a valid context + try { + doc.getArchive(context); + } catch (XWikiException e) { + // this is a non critical error } } @@ -324,7 +341,6 @@ public XWikiDocument loadXWikiDoc(XWikiDocument doc, XWikiContext context) throws XWikiException { //To change body of implemented methods use Options | File Templates. - BufferedReader fr = null; boolean bTransaction = true; MonitorPlugin monitor = Util.getMonitorPlugin(context); try { @@ -365,10 +381,6 @@ doc.setxWikiClass(bclass); } - // Store this XWikiClass in the context so that we can use it in case of recursive usage of classes - context.addBaseClass(bclass); - - if (doc.hasElement(XWikiDocument.HAS_OBJECTS)) { Query query; query = session.createQuery("from BaseObject as bobject where bobject.name = :name order by bobject.number"); @@ -461,6 +473,77 @@ } } + public XWikiDocument loadXWikiDoc(XWikiDocument basedoc,String version, XWikiContext context) throws XWikiException { + XWikiDocument doc = new XWikiDocument(basedoc.getWeb(), basedoc.getName()); + MonitorPlugin monitor = Util.getMonitorPlugin(context); + try { + // Start monitoring timer + if (monitor!=null) + monitor.startTimer("hibernate"); + doc.setStore(this); + Archive archive = basedoc.getRCSArchive(); + doc.setRCSArchive(archive); + + if (archive == null) { + doc.updateArchive(doc.toXML(context)); + archive = basedoc.getRCSArchive(); + } + + Version v = null; + try { + v = archive.getRevisionVersion(version); + } catch (Exception e) {} + + if (v==null) { + Object[] args = { doc.getFullName(), version.toString() }; + throw new XWikiException( XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_UNEXISTANT_VERSION, + "Version {1} does not exist while reading document {0}", null,args); + } + + if (!version.equals(v.toString())) { + doc.setVersion(version); + return doc; + } + Object[] text = (Object[]) archive.getRevision(version); + if (text[0].toString().startsWith("<")) { + StringBuffer content = new StringBuffer(); + for (int i=0;i 0) { return text + "-" + occurence; } else { Only in xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web: AdminAction.java diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/AttachAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/AttachAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/AttachAction.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/AttachAction.java 2006-07-29 14:36:30.000000000 +0300 @@ -26,7 +26,6 @@ public class AttachAction extends XWikiAction { public String render(XWikiContext context) throws XWikiException { - return "attach"; } } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/DeleteAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/DeleteAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/DeleteAction.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/DeleteAction.java 2006-08-02 18:32:54.000000000 +0300 @@ -57,10 +57,7 @@ } public String render(XWikiContext context) throws XWikiException { - XWiki xwiki = context.getWiki(); XWikiRequest request = context.getRequest(); - XWikiResponse response = context.getResponse(); - XWikiDocument doc = context.getDoc(); String confirm = request.getParameter("confirm"); if ((confirm!=null)&&(confirm.equals("1"))) { return "deleted"; diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/EditAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/EditAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/EditAction.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/EditAction.java 2006-07-29 15:21:34.000000000 +0300 @@ -83,7 +83,7 @@ } else { // If the translated doc object is the same as the doc object // this means the translated doc did not exists so we need to create it - if ((tdoc==doc)&&context.getWiki().isMultiLingual(context)) { + if ((tdoc==doc)) { tdoc = new XWikiDocument(doc.getWeb(), doc.getName()); tdoc.setLanguage(languagetoedit); tdoc.setContent(doc.getContent()); @@ -99,7 +99,15 @@ tdoc2.setContent(content); context.put("tdoc", tdoc2); vcontext.put("tdoc", new Document(tdoc2, context)); - tdoc2.readFromTemplate(peform, context); + try{ + tdoc2.readFromTemplate(peform, context); + } + catch (XWikiException e) { + if (e.getCode() == XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY) { + context.put("exception", e); + return "docalreadyexists"; + } + } /* Setup a lock */ try { Only in xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web: JSAction.java diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/PDFAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/PDFAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/PDFAction.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/PDFAction.java 2006-08-02 17:49:15.000000000 +0300 @@ -22,13 +22,12 @@ */ package com.xpn.xwiki.web; -import java.io.IOException; - -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.doc.XWikiDocument; -import com.xpn.xwiki.pdf.impl.PdfExportImpl; -import com.xpn.xwiki.pdf.impl.PdfURLFactory; +import java.io.IOException; + +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.XWikiException; +import com.xpn.xwiki.doc.XWikiDocument; +import com.xpn.xwiki.pdf.impl.PdfExportImpl; public class PDFAction extends XWikiAction { public String render(XWikiContext context) throws XWikiException { Only in xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web: RedirectAction.java Only in xwiki/trunk/src/main/java/com/xpn/xwiki/web: ResetVersionsAction.java diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/RollbackAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/RollbackAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/RollbackAction.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/RollbackAction.java 2006-07-25 14:21:05.000000000 +0300 @@ -29,15 +29,17 @@ public class RollbackAction extends XWikiAction { public boolean action(XWikiContext context) throws XWikiException { XWiki xwiki = context.getWiki(); - XWikiRequest request = context.getRequest(); XWikiResponse response = context.getResponse(); XWikiDocument doc = context.getDoc(); RollbackForm form = (RollbackForm) context.getForm(); - + + String confirm = form.getConfirm(); String rev = form.getRev(); String language = form.getLanguage(); - XWikiDocument tdoc; - + XWikiDocument tdoc; + if((confirm == null) || (!confirm.equals("1"))){ + return true; + } if ((language==null)||(language.equals(""))||(language.equals("default"))||(language.equals(doc.getDefaultLanguage()))) { // Need to save parent and defaultLanguage if they have changed tdoc = doc; @@ -62,5 +64,12 @@ String redirect = Utils.getRedirect("view", context); sendRedirect(response, redirect); return false; - } + } + + public String render(XWikiContext context) throws XWikiException { + handleRevision(context); + XWikiDocument doc = (XWikiDocument) context.get("doc"); + String defaultTemplate = doc.getDefaultTemplate(); + return "rollback"; + } } diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/RollbackForm.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/RollbackForm.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/RollbackForm.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/RollbackForm.java 2006-07-25 13:43:29.000000000 +0300 @@ -23,12 +23,14 @@ public class RollbackForm extends XWikiForm { private String rev; - private String language; + private String language; + private String confirm; public void readRequest() { XWikiRequest request = getRequest(); setRev(request.getParameter("rev")); - setLanguage(request.getParameter("language")); + setLanguage(request.getParameter("language")); + setConfirm(request.getParameter("confirm")); } public String getRev() { @@ -45,5 +47,13 @@ public void setLanguage(String language) { this.language = language; - } + } + + public String getConfirm() { + return confirm; + } + + public void setConfirm(String confirm) { + this.confirm = confirm; + } } \ No newline at end of file diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/SaveAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/SaveAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/SaveAction.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/SaveAction.java 2006-07-29 15:09:33.000000000 +0300 @@ -1,98 +1,95 @@ -/* - * Copyright 2006, 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. - * - * @author ludovic - * @author namphunghai - * @author sdumitriu - */ -package com.xpn.xwiki.web; - -import com.xpn.xwiki.XWiki; -import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.doc.XWikiDocument; -import com.xpn.xwiki.doc.XWikiLock; - -import java.util.Date; - -public class SaveAction extends XWikiAction { - public boolean action(XWikiContext context) throws XWikiException { - XWiki xwiki = context.getWiki(); - XWikiRequest request = context.getRequest(); - XWikiResponse response = context.getResponse(); - XWikiDocument doc = context.getDoc(); - XWikiForm form = context.getForm(); - - synchronized (doc) { - String language = ((EditForm)form).getLanguage(); - String defaultLanguage = ((EditForm)form).getDefaultLanguage(); - XWikiDocument tdoc; - - if ((language==null)||(language.equals(""))||(language.equals("default"))||(language.equals(doc.getDefaultLanguage()))) { - // Need to save parent and defaultLanguage if they have changed - tdoc = doc; - } else { - tdoc = doc.getTranslatedDocument(language, context); - if ((tdoc == doc)&&xwiki.isMultiLingual(context)) { - tdoc = new XWikiDocument(doc.getWeb(), doc.getName()); - tdoc.setLanguage(language); - tdoc.setStore(doc.getStore()); - } - tdoc.setTranslation(1); - } - - XWikiDocument olddoc = (XWikiDocument) tdoc.clone(); - try { - tdoc.readFromTemplate(((EditForm)form).getTemplate(), context); - } catch (XWikiException e) { - if (e.getCode() == XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY) { - context.put("exception", e); - return true; - } - } - - - tdoc.readFromForm((EditForm)form, context); - - // TODO: handle Author - String username = context.getUser(); - tdoc.setAuthor(username); - if (tdoc.isNew()) - tdoc.setCreator(username); - - xwiki.saveDocument(tdoc, olddoc, context); - XWikiLock lock = tdoc.getLock(context); - if (lock != null ) - tdoc.removeLock(context); - } - - // forward to view - String redirect = Utils.getRedirect("view", context); - sendRedirect(response, redirect); - return false; - } - - public String render(XWikiContext context) throws XWikiException { - XWikiException e = (XWikiException) context.get("exception"); - if ((e!=null)&&(e.getCode() == XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY)) { - return "docalreadyexists"; - } else - return "exception"; - } -} +/* + * Copyright 2006, 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. + * + * @author ludovic + * @author namphunghai + * @author sdumitriu + */ +package com.xpn.xwiki.web; + +import com.xpn.xwiki.XWiki; +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.XWikiException; +import com.xpn.xwiki.doc.XWikiDocument; +import com.xpn.xwiki.doc.XWikiLock; + +public class SaveAction extends XWikiAction { + public boolean action(XWikiContext context) throws XWikiException { + XWiki xwiki = context.getWiki(); + XWikiRequest request = context.getRequest(); + XWikiResponse response = context.getResponse(); + XWikiDocument doc = context.getDoc(); + XWikiForm form = context.getForm(); + + synchronized (doc) { + String language = ((EditForm)form).getLanguage(); + XWikiDocument tdoc; + + if ((language==null)||(language.equals(""))||(language.equals("default"))||(language.equals(doc.getDefaultLanguage()))) { + // Need to save parent and defaultLanguage if they have changed + tdoc = doc; + } else { + tdoc = doc.getTranslatedDocument(language, context); + if (tdoc == doc) { + tdoc = new XWikiDocument(doc.getWeb(), doc.getName()); + tdoc.setLanguage(language); + tdoc.setStore(doc.getStore()); + } + tdoc.setTranslation(1); + } + + XWikiDocument olddoc = (XWikiDocument) tdoc.clone(); + try { + tdoc.readFromTemplate(((EditForm)form).getTemplate(), context); + } catch (XWikiException e) { + if (e.getCode() == XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY) { + context.put("exception", e); + return true; + } + } + + + tdoc.readFromForm((EditForm)form, context); + + // TODO: handle Author + String username = context.getUser(); + tdoc.setAuthor(username); + if (tdoc.isNew()) + tdoc.setCreator(username); + + xwiki.saveDocument(tdoc, olddoc, context); + XWikiLock lock = tdoc.getLock(context); + if (lock != null ) + tdoc.removeLock(context); + } + + // forward to view + String redirect = Utils.getRedirect("view", context); + sendRedirect(response, redirect); + return false; + } + + public String render(XWikiContext context) throws XWikiException { + XWikiException e = (XWikiException) context.get("exception"); + if ((e!=null)&&(e.getCode() == XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY)) { + return "docalreadyexists"; + } else + return "exception"; + } +} diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/SkinAction.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/SkinAction.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/SkinAction.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/SkinAction.java 2006-08-08 15:16:20.000000000 +0300 @@ -70,13 +70,17 @@ } if ((content!=null)&&(!content.equals(""))) { - // Choose the right content type - response.setContentType(xwiki.getEngineContext().getMimeType(filename.toLowerCase())); + // Choose the right content type + String mimetype = xwiki.getEngineContext().getMimeType(filename.toLowerCase()); + if(mimetype.equals("text/css")){ + content = context.getWiki().parseContent(content, context); + } + response.setContentType(mimetype); response.setDateHeader("Last-Modified", doc.getDate().getTime()); // Sending the content of the attachment response.setContentLength(content.length()); - try { - response.getWriter().write(content); + try { + response.getWriter().write(content); return true; } catch (IOException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_APP, @@ -88,8 +92,12 @@ XWikiAttachment attachment = doc.getAttachment(filename); if (attachment!=null) { // Sending the content of the attachment - byte[] data = attachment.getContent(context); - response.setContentType(xwiki.getEngineContext().getMimeType(filename.toLowerCase())); + byte[] data = attachment.getContent(context); + String mimetype = xwiki.getEngineContext().getMimeType(filename.toLowerCase()); + if(mimetype.equals("text/css")){ + data = context.getWiki().parseContent(new String(data), context).getBytes(); + } + response.setContentType(mimetype); response.setDateHeader("Last-Modified", attachment.getDate().getTime()); response.setContentLength(data.length); try { @@ -119,15 +127,14 @@ response.setContentType("application/octet-stream"); // Sending the content of the file - InputStream is = context.getWiki().getResourceAsStream(path); - if (is==null) - return false; - - int nRead = 0; - byte[] data = new byte[65535]; - while ((nRead = is.read(data)) !=-1) { - response.getOutputStream().write(data,0,nRead); + byte[] data = context.getWiki().getResourceContentAsBytes(path); + if (data == null || data.length == 0) + return false; + + if(mimetype.equals("text/css")){ + data = context.getWiki().parseContent(new String(data), context).getBytes(); } + response.getOutputStream().write(data); return true; } catch (IOException e) { if (skin.equals(xwiki.getDefaultBaseSkin(context))) diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/Utils.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/Utils.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/Utils.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/Utils.java 2006-07-23 22:29:45.000000000 +0300 @@ -108,7 +108,10 @@ if (context.getResponse() instanceof XWikiServletResponse) { // Set the content length to the numnber of bytes, not the // string length, so as to handle multi-byte encodings - response.setContentLength(content.getBytes().length); + try{ + response.setContentLength(content.getBytes("UTF-8").length); + } + catch(UnsupportedEncodingException ex){response.setContentLength(content.getBytes().length);} } try { diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java 2006-07-12 14:10:00.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java 2006-08-02 17:49:19.000000000 +0300 @@ -28,18 +28,15 @@ import java.net.MalformedURLException; import java.net.URL; -import java.io.IOException; -import java.util.List; -import com.xpn.xwiki.XWikiContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.xpn.xwiki.XWiki; +import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiException; -import com.xpn.xwiki.plugin.XWikiPluginManager; import com.xpn.xwiki.doc.XWikiAttachment; import com.xpn.xwiki.doc.XWikiDocument; -import org.apache.velocity.VelocityContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class XWikiServletURLFactory extends XWikiDefaultURLFactory { protected URL serverURL; diff -u -r --exclude=.svn xwiki/trunk/src/main/java/com/xpn/xwiki/xmlrpc/ConfluenceRpcHandler.java xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/xmlrpc/ConfluenceRpcHandler.java --- xwiki/trunk/src/main/java/com/xpn/xwiki/xmlrpc/ConfluenceRpcHandler.java 2006-08-09 14:35:16.000000000 +0300 +++ xwiki-sandbox/interface/src/main/java/com/xpn/xwiki/xmlrpc/ConfluenceRpcHandler.java 2006-07-12 14:10:01.000000000 +0300 @@ -1,24 +1,24 @@ -/* - * Copyright 2006, 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. - * - * @author sdumitriu - */ +/* + * Copyright 2006, 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. + * + * @author sdumitriu + */ package com.xpn.xwiki.xmlrpc; @@ -28,7 +28,7 @@ import java.util.List; import java.util.Vector; -import org.suigeneris.jrcs.rcs.Version; +import org.apache.commons.jrcs.rcs.Version; import org.apache.velocity.VelocityContext; import com.xpn.xwiki.XWiki;