Skip to content

Commit

Permalink
IN PROGRESS - issue SPAGOBI-1656: Improved error handling in method c…
Browse files Browse the repository at this point in the history
…reateISecurityServiceSupplier

git-svn-id: svn://svn.forge.objectweb.org/svnroot/spagobi/V_4.x/Server/trunk@22385 99afaf0d-6903-0410-885a-c66a8bbb5f81
  • Loading branch information
gioia committed Mar 24, 2014
1 parent 24175df commit d55be4a
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 17 deletions.
44 changes: 27 additions & 17 deletions SpagoBIDAO/src/it/eng/spagobi/commons/utilities/UserUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import it.eng.spagobi.commons.dao.DAOFactory;
import it.eng.spagobi.commons.dao.IRoleDAO;
import it.eng.spagobi.commons.metadata.SbiTenant;
import it.eng.spagobi.dao.exception.DAORuntimeException;
import it.eng.spagobi.services.common.SsoServiceFactory;
import it.eng.spagobi.services.common.SsoServiceInterface;
import it.eng.spagobi.services.security.bo.SpagoBIUserProfile;
Expand Down Expand Up @@ -675,29 +676,38 @@ private static void checkTenant(SpagoBIUserProfile profile) {

/*
* Method copied from SecurityServiceSupplierFactory for DAO refactoring
*
* is this method in the right place?
*/

public static ISecurityServiceSupplier createISecurityServiceSupplier(){
logger.debug("IN");
SingletonConfig configSingleton = SingletonConfig.getInstance();
String engUserProfileFactorySB = configSingleton.getConfigValue("SPAGOBI.SECURITY.USER-PROFILE-FACTORY-CLASS.className");
if (engUserProfileFactorySB==null){
logger.warn("SPAGOBI.SECURITY.USER-PROFILE-FACTORY-CLASS ... NOT FOUND");
}
String engUserProfileFactoryClass = engUserProfileFactorySB;
engUserProfileFactoryClass = engUserProfileFactoryClass.trim();

ISecurityServiceSupplier securityServiceSupplier = null;
String engUserProfileFactoryClass = null;

try {
return (ISecurityServiceSupplier)Class.forName(engUserProfileFactoryClass).newInstance();
} catch (InstantiationException e) {
logger.warn("InstantiationException",e);
} catch (IllegalAccessException e) {
logger.warn("IllegalAccessException",e);
} catch (ClassNotFoundException e) {
logger.warn("ClassNotFoundException",e);
}finally{
logger.debug("OUT");
SingletonConfig configSingleton = SingletonConfig.getInstance();
engUserProfileFactoryClass = configSingleton.getConfigValue("SPAGOBI.SECURITY.USER-PROFILE-FACTORY-CLASS.className");
if (engUserProfileFactoryClass != null) {
engUserProfileFactoryClass = engUserProfileFactoryClass.trim();
try {
securityServiceSupplier = (ISecurityServiceSupplier)Class.forName(engUserProfileFactoryClass).newInstance();
} catch (Throwable t) {
throw new DAORuntimeException("Impossible to instatiate supplier class [" + engUserProfileFactoryClass+ "]", t);
}
} else{
throw new DAORuntimeException("Impossible read from configuartion the property [SPAGOBI.SECURITY.USER-PROFILE-FACTORY-CLASS] that contains the name of the class used as securityServiceSupplier");
}
} catch(Throwable t) {
if(t instanceof DAORuntimeException) throw (DAORuntimeException)t;
else throw new DAORuntimeException("Impossible to instatiate supplier class [" + engUserProfileFactoryClass+ "]", t);
}
return null;




return securityServiceSupplier;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* SpagoBI, the Open Source Business Intelligence suite
* Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice.
* If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package it.eng.spagobi.dao.exception;

import java.io.PrintWriter;
import java.io.StringWriter;

public class DAORuntimeException extends RuntimeException {

/**
* Keep compiler happy
*/
private static final long serialVersionUID = 1L;

/*
* User oriented description of the exception. It is usually prompted to the user.
* Instead the message passed to the constructor is developer oriented and it should be just logged.
*/
private String description;


/**
* Builds a <code>SpagoBIRuntimeException</code>.
*
* @param message Text of the exception
*/
public DAORuntimeException(String message) {
super(message);
}

/**
* Builds a <code>SpagoBIRuntimeException</code>.
*
* @param message Text of the exception
* @param ex previous Throwable object
*/
public DAORuntimeException(String message, Throwable ex) {
super(message, ex);
}

/**
* Builds a <code>SpagoBIRuntimeException</code>.
*
* @param ex previous Throwable object
*/
public DAORuntimeException(Throwable ex) {
super(ex);
}

public String getRootCause() {
String rootCause;
Throwable rootException;

rootException = this;
while(rootException.getCause() != null) {
rootException = rootException.getCause();
}

rootCause = rootException.getMessage()!=null
? rootException.getClass().getName() + ": " + rootException.getMessage()
: rootException.getClass().getName();

return rootCause;
}

public String getStackTraceDump() {
StringWriter buffer = new StringWriter();
this.printStackTrace(new PrintWriter(buffer));
return buffer.toString();
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}
}

0 comments on commit d55be4a

Please sign in to comment.