Hi Lilianne,
This looks fine, you can submit it again via a JIRA tasks this way we
can track it more easily to add it to the code.
Ludovic
Lilianne E. Blaze a écrit :
Hello,
I'd like to propose a small "improvement" to XWiki.getAuthService and
XWiki.getRightService, with these it would be easier to find out
problems with custom implementations of these services.
Also, it's a good example of what I had in mind earlier in my
"Comments and log statements?" post.
Greetings, Lilianne E. Blaze
Index: com/xpn/xwiki/XWiki.java
===================================================================
--- com/xpn/xwiki/XWiki.java (revision 580)
+++ com/xpn/xwiki/XWiki.java (working copy)
@@ -68,6 +68,7 @@
import com.xpn.xwiki.user.api.XWikiGroupService;
import com.xpn.xwiki.user.api.XWikiRightService;
import com.xpn.xwiki.user.api.XWikiUser;
+import com.xpn.xwiki.user.impl.LDAP.LDAPAuthServiceImpl;
import com.xpn.xwiki.user.impl.exo.ExoAuthServiceImpl;
import com.xpn.xwiki.user.impl.exo.ExoGroupServiceImpl;
import com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl;
@@ -2474,22 +2499,51 @@
public XWikiAuthService getAuthService() {
if (authService==null) {
- String authClass;
- if (isExo())
- authClass =
Param("xwiki.authentication.authclass","com.xpn.xwiki.user.impl.exo.ExoAuthServiceImpl");
- else if (isLDAP())
- authClass =
Param("xwiki.authentication.authclass","com.xpn.xwiki.user.impl.LDAP.LDAPAuthServiceImpl");
+ + log.info("Initializing AuthService...");
+ + String authClass =
Param("xwiki.authentication.authclass");
+ if( authClass != null )
+ {
+ if( log.isDebugEnabled() ) log.debug("Using custom
AuthClass "+authClass+".");
+ }
else
- authClass =
Param("xwiki.authentication.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+".");
+ + }
try {
+
authService = (XWikiAuthService)
Class.forName(authClass).newInstance();
+ + log.debug("Initialized AuthService
using Relfection.");
+
} catch (Exception e) {
- e.printStackTrace();
+ + log.warn("Failed to initialize
AuthService "+authClass+" using Reflection, trying default
implementations using 'new'.");
+ + // e.printStackTrace(); - not needed?
-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( log.isDebugEnabled() )
log.debug("Initialized AuthService
"+authService.getClass().getName()+" using 'new'.");
+ }
}
return authService;
@@ -2497,12 +2551,36 @@
public XWikiRightService getRightService() {
if (rightService==null) {
- String rightsClass =
Param("xwiki.authentication.rightsclass","com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl");
+ + 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+".");
+ }
+ + try {
+ rightService = (XWikiRightService)
Class.forName(rightsClass).newInstance();
+ log.debug("Initialized RightService using Reflection.");
+ } catch (Exception e) {
- e.printStackTrace();
+ + log.warn("Failed to initialize
RightService "+rightsClass+" using Reflection, trying default
implementation using 'new'.");
+ + //e.printStackTrace(); - not needed?
-LBlaze
+ rightService = new
XWikiRightServiceImpl();
+ + if( log.isDebugEnabled() )
log.debug("Initialized RightService
"+authService.getClass().getName()+" using 'new'.");
+
}
}
return rightService;
------------------------------------------------------------------------
--
You receive this message as a subscriber of the xwiki-dev(a)objectweb.org mailing list.
To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page:
http://www.objectweb.org/wws