use of org.pentaho.platform.api.engine.ObjectFactoryException in project pentaho-platform by pentaho.
the class PentahoConnectionFactory method getConnection.
/**
* @param datasourceType
* @param properties
* can be null
* @param session
* can be null
* @param logger
* @return
*/
public static IPentahoConnection getConnection(final String datasourceType, Properties properties, final IPentahoSession session, final ILogger logger) {
/*
* TODO - This is where the "connection factory" action occurs. Based on if the datasourceType, location,
* username, or password have changed then we create a new one.
*/
String key = CONNECTION_PREFIX + datasourceType;
IPentahoConnection connection = null;
try {
connection = PentahoSystem.getObjectFactory().get(IPentahoConnection.class, key, session);
if (connection instanceof IPentahoLoggingConnection) {
((IPentahoLoggingConnection) connection).setLogger(logger);
}
connection.setProperties(properties);
} catch (ObjectFactoryException e) {
Logger.error(PentahoSystem.class.getName(), Messages.getInstance().getErrorString("PentahoConnectionFactory.ERROR_0001_COULD_NOT_CREATE_CONNECTION", key), // $NON-NLS-1$
e);
}
return connection;
}
use of org.pentaho.platform.api.engine.ObjectFactoryException in project pentaho-platform by pentaho.
the class PentahoDataSourceResolver method lookup.
public DataSource lookup(String dataSourceName) throws Exception {
javax.sql.DataSource datasource = null;
String unboundDsName = null;
IDBDatasourceService datasourceSvc = null;
try {
datasourceSvc = PentahoSystem.getObjectFactory().get(IDBDatasourceService.class, PentahoSessionHolder.getSession());
unboundDsName = datasourceSvc.getDSUnboundName(dataSourceName);
datasource = datasourceSvc.getDataSource(unboundDsName);
} catch (ObjectFactoryException e) {
// $NON-NLS-1$
logger.error(Messages.getInstance().getErrorString("PentahoXmlaServlet.ERROR_0002_UNABLE_TO_INSTANTIATE"), e);
throw e;
} catch (DBDatasourceServiceException e) {
/* We tried to find the datasource using unbound name.
** Now as a fall back we will attempt to find this datasource as it is.
** For example jboss/datasource/Hibernate. The unbound name ends up to be Hibernate
** We will first look for Hibernate and if we fail then look for jboss/datasource/Hibernate */
logger.warn(Messages.getInstance().getString("PentahoXmlaServlet.WARN_0001_UNABLE_TO_FIND_UNBOUND_NAME", dataSourceName, unboundDsName), // $NON-NLS-1$
e);
try {
datasource = datasourceSvc.getDataSource(dataSourceName);
} catch (DBDatasourceServiceException dbse) {
logger.error(Messages.getInstance().getErrorString("PentahoXmlaServlet.ERROR_0002_UNABLE_TO_INSTANTIATE"), // $NON-NLS-1$
e);
throw dbse;
}
}
return datasource;
}
use of org.pentaho.platform.api.engine.ObjectFactoryException in project pentaho-platform by pentaho.
the class XactionUtil method executeInternal.
@SuppressWarnings("rawtypes")
protected static IRuntimeContext executeInternal(RepositoryFile file, IParameterProvider requestParams, HttpServletRequest httpServletRequest, IOutputHandler outputHandler, Map<String, IParameterProvider> parameterProviders, IPentahoSession userSession, boolean forcePrompt, List messages) throws Exception {
String processId = XactionUtil.class.getName();
// $NON-NLS-1$
String instanceId = httpServletRequest.getParameter("instance-id");
// $NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory("");
ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, userSession);
ISystemSettings systemSettings = PentahoSystem.getSystemSettings();
if (solutionEngine == null) {
throw new ObjectFactoryException("No Solution Engine");
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
boolean instanceEnds = "true".equalsIgnoreCase(requestParams.getStringParameter("instanceends", "true"));
// $NON-NLS-1$ //$NON-NLS-2$
String parameterXsl = systemSettings.getSystemSetting("default-parameter-xsl", "DefaultParameterForm.xsl");
solutionEngine.setLoggingLevel(2);
solutionEngine.init(userSession);
solutionEngine.setForcePrompt(forcePrompt);
if (parameterXsl != null) {
solutionEngine.setParameterXsl(parameterXsl);
}
return solutionEngine.execute(file.getPath(), processId, false, instanceEnds, instanceId, false, parameterProviders, outputHandler, null, urlFactory, messages);
}
use of org.pentaho.platform.api.engine.ObjectFactoryException in project pentaho-platform by pentaho.
the class PentahoEntryCollector method getAcesIncludingMagicAces.
/**
* Extracts ACEs including magic aces. Magic ACEs are added for (1) the owner, (2) as a result of magic ACE
* definitions, and (3) as a result of ancestor ACL contributions.
* <p/>
* <p> Modifications to these ACLs are not persisted. </p>
*/
@SuppressWarnings("unchecked")
protected List<PentahoEntry> getAcesIncludingMagicAces(final String path, final String owner, final ACLTemplate ancestorAcl, final ACLTemplate acl) throws RepositoryException {
if (PentahoSessionHolder.getSession() == null || PentahoSessionHolder.getSession().getId() == null || PentahoSessionHolder.getSession().getId().trim().equals("")) {
// $NON-NLS-1$
if (log.isDebugEnabled()) {
// $NON-NLS-1$
log.debug("no PentahoSession so no magic ACEs");
}
return Collections.emptyList();
}
if (owner != null) {
addOwnerAce(owner, acl);
}
boolean match = false;
IRoleAuthorizationPolicyRoleBindingDao roleBindingDao = null;
try {
roleBindingDao = PentahoSystem.getObjectFactory().get(IRoleAuthorizationPolicyRoleBindingDao.class, "roleAuthorizationPolicyRoleBindingDaoTarget", PentahoSessionHolder.getSession());
} catch (ObjectFactoryException e) {
e.printStackTrace();
}
ITenant tenant = JcrTenantUtils.getTenant();
for (final MagicAceDefinition def : getMagicAceDefinitions()) {
match = false;
String substitutedPath = MessageFormat.format(def.path, tenant.getRootFolderAbsolutePath());
if (isAllowed(roleBindingDao, def.logicalRole)) {
if (def.applyToTarget) {
match = path.equals(substitutedPath);
}
if (!match && def.applyToChildren) {
match = path.startsWith(substitutedPath + "/");
// check to see if we should exclude the match due to the exclude list
if (match && def.exceptChildren != null) {
for (String childPath : def.exceptChildren) {
String substitutedChildPath = MessageFormat.format(childPath, tenant.getRootFolderAbsolutePath());
if (path.startsWith(substitutedChildPath + "/")) {
match = false;
break;
}
}
}
}
if (!match && def.applyToAncestors) {
match = substitutedPath.startsWith(path + "/");
}
}
if (match) {
Principal principal = new MagicPrincipal(JcrTenantUtils.getTenantedUser(PentahoSessionHolder.getSession().getName()));
// unfortunately, we need the ACLTemplate because it alone can create ACEs that can be cast successfully
// later;
// changed never persisted
acl.addAccessControlEntry(principal, def.privileges);
}
}
@SuppressWarnings("rawtypes") List acEntries = new ArrayList();
// leaf ACEs go first so ACL metadata ACE stays first
acEntries.addAll(buildPentahoEntries(acl));
acEntries.addAll(getRelevantAncestorAces(ancestorAcl));
return acEntries;
}
use of org.pentaho.platform.api.engine.ObjectFactoryException in project pentaho-platform by pentaho.
the class EmbeddedQuartzSystemListener method startup.
public boolean startup(final IPentahoSession session) {
boolean result = true;
Properties quartzProps = null;
if (quartzPropertiesFile != null) {
quartzProps = PentahoSystem.getSystemSettings().getSystemSettingsProperties(quartzPropertiesFile);
} else if (quartzProperties != null) {
quartzProps = quartzProperties;
}
try {
if (quartzProps == null) {
quartzProps = findPropertiesInClasspath();
}
if (quartzProps == null) {
result = false;
} else {
// $NON-NLS-1$
String dsName = quartzProps.getProperty("org.quartz.dataSource.myDS.jndiURL");
if (dsName != null) {
IDBDatasourceService datasourceService = getQuartzDatasourceService(session);
String boundDsName = datasourceService.getDSBoundName(dsName);
if (boundDsName != null) {
// $NON-NLS-1$
quartzProps.setProperty("org.quartz.dataSource.myDS.jndiURL", boundDsName);
}
DataSource ds = datasourceService.getDataSource(dsName);
result = verifyQuartzIsConfigured(ds);
}
// $NON-NLS-1$
QuartzScheduler scheduler = (QuartzScheduler) PentahoSystem.get(IScheduler.class, "IScheduler2", null);
if (logger.isDebugEnabled()) {
// $NON-NLS-1$
logger.debug("Quartz configured with properties");
// $NON-NLS-1$
quartzProps.store(System.out, "debugging");
}
scheduler.setQuartzSchedulerFactory(new org.quartz.impl.StdSchedulerFactory(quartzProps));
if (logger.isDebugEnabled()) {
logger.debug(scheduler.getQuartzScheduler().getSchedulerName());
}
scheduler.start();
}
} catch (IOException ex) {
result = false;
logger.error(Messages.getInstance().getErrorString("EmbeddedQuartzSystemListener.ERROR_0004_LOAD_PROPERTIES_FROM_CLASSPATH"), // $NON-NLS-1$
ex);
} catch (ObjectFactoryException objface) {
logger.error(Messages.getInstance().getErrorString("EmbeddedQuartzSystemListener.ERROR_0005_UNABLE_TO_INSTANTIATE_OBJECT", EmbeddedQuartzSystemListener.class.getName()), // $NON-NLS-1$
objface);
result = false;
} catch (DBDatasourceServiceException dse) {
logger.error(Messages.getInstance().getErrorString("EmbeddedQuartzSystemListener.ERROR_0006_UNABLE_TO_GET_DATASOURCE", EmbeddedQuartzSystemListener.class.getName()), // $NON-NLS-1$
dse);
result = false;
} catch (SQLException sqle) {
// $NON-NLS-1$
logger.error("EmbeddedQuartzSystemListener.ERROR_0007_SQLERROR", sqle);
result = false;
} catch (SchedulerException e) {
logger.error(Messages.getInstance().getErrorString("EmbeddedQuartzSystemListener.ERROR_0001_Scheduler_Not_Initialized", EmbeddedQuartzSystemListener.class.getName()), // $NON-NLS-1$
e);
result = false;
} catch (org.pentaho.platform.api.scheduler2.SchedulerException e) {
logger.error(Messages.getInstance().getErrorString("EmbeddedQuartzSystemListener.ERROR_0001_Scheduler_Not_Initialized", EmbeddedQuartzSystemListener.class.getName()), // $NON-NLS-1$
e);
result = false;
}
return result;
}
Aggregations