Search in sources :

Example 16 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project pentaho-platform by pentaho.

the class SolutionEngineInteractivityService method setupRequestHandler.

protected void setupRequestHandler(final HttpServletRequest request, final HttpServletRequestHandler requestHandler, final IParameterProvider requestParameters, final IPentahoSession userSession) {
    this.setupRequestHandler(request, requestHandler);
    // first take a secondary action
    // $NON-NLS-1$
    String actionName = requestParameters.getStringParameter("action2", null);
    if (actionName == null) {
        // now look for a primary action
        // $NON-NLS-1$
        actionName = requestParameters.getStringParameter("action", null);
    }
    ISystemSettings systemSettings = PentahoSystem.getSystemSettings();
    String defaultParameterXsl = systemSettings.getSystemSetting("default-parameter-xsl", "DefaultParameterForm.xsl");
    // $NON-NLS-1$ //$NON-NLS-2$
    requestHandler.setParameterXsl(defaultParameterXsl);
}
Also used : ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings)

Example 17 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings 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);
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings)

Example 18 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project pentaho-platform by pentaho.

the class HttpSessionPentahoSessionIntegrationFilterTest method testSessionCookieSettingsEnabled.

@Test
public void testSessionCookieSettingsEnabled() throws ObjectFactoryException {
    final ISystemSettings systemSettings = PentahoSystem.getSystemSettings();
    try {
        final ISystemSettings mockSettings = Mockito.mock(ISystemSettings.class);
        Mockito.when(mockSettings.getSystemSetting("session-expired-dialog", "true")).thenReturn("true");
        PentahoSystem.setSystemSettingsService(mockSettings);
        final AuthenticationProvider mockObj = Mockito.mock(AuthenticationProvider.class);
        PentahoSystem.registerObject(mockObj, AuthenticationProvider.class);
        new HttpSessionPentahoSessionIntegrationFilter().setSessionExpirationCookies(httpSession, pentahoSession, servletResponse);
        Mockito.verify(servletResponse, Mockito.times(2)).addCookie(Mockito.any());
    } finally {
        PentahoSystem.setSystemSettingsService(systemSettings);
    }
}
Also used : AuthenticationProvider(org.springframework.security.authentication.AuthenticationProvider) ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) Test(org.junit.Test)

Example 19 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project pentaho-platform by pentaho.

the class HttpSessionPentahoSessionIntegrationFilterTest method testSessionCookieSsoEnabled.

@Test
public void testSessionCookieSsoEnabled() throws ObjectFactoryException {
    final ISystemSettings systemSettings = PentahoSystem.getSystemSettings();
    try {
        final ISystemSettings mockSettings = Mockito.mock(ISystemSettings.class);
        Mockito.when(mockSettings.getSystemSetting("session-expired-dialog", "true")).thenReturn("true");
        PentahoSystem.setSystemSettingsService(mockSettings);
        final CasAuthenticationProvider mockObj = Mockito.mock(CasAuthenticationProvider.class);
        PentahoSystem.registerObject(mockObj, AuthenticationProvider.class);
        HttpSessionPentahoSessionIntegrationFilter hspsif = new HttpSessionPentahoSessionIntegrationFilter();
        hspsif.setSsoEnabled(true);
        hspsif.setSessionExpirationCookies(httpSession, pentahoSession, servletResponse);
        Mockito.verify(servletResponse, Mockito.never()).addCookie(Mockito.any());
    } finally {
        PentahoSystem.setSystemSettingsService(systemSettings);
    }
}
Also used : ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) Test(org.junit.Test)

Example 20 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project pentaho-platform by pentaho.

the class PentahoSystemTest method initXMLFactories.

private void initXMLFactories(boolean factoriesInPentahoXML) throws Exception {
    // mock pentaho.xml
    final ISystemSettings settingsService = mock(ISystemSettings.class);
    if (factoriesInPentahoXML) {
        final Node testNode = mock(Node.class);
        final Node testNodeName = mock(Node.class);
        when(testNodeName.getText()).thenReturn(testSystemPropertyName);
        when(testNode.selectSingleNode(eq("@name"))).thenReturn(testNodeName);
        final Node testNodeImplementation = mock(Node.class);
        when(testNodeImplementation.getText()).thenReturn(testXMLValue);
        when(testNode.selectSingleNode(eq("@implementation"))).thenReturn(testNodeImplementation);
        when(settingsService.getSystemSettings(eq("xml-factories/factory-impl"))).thenReturn(new LinkedList() {

            {
                add(testNode);
            }
        });
    } else {
        when(settingsService.getSystemSettings(eq("xml-factories/factory-impl"))).thenReturn(new LinkedList());
    }
    when(settingsService.getSystemSetting(anyString(), anyString())).thenReturn("");
    PentahoSystem.setSystemSettingsService(settingsService);
    // mock java-system-properties.properties
    final IPentahoObjectFactory objectFactory = mock(IPentahoObjectFactory.class);
    final ISystemConfig systemConfig = mock(ISystemConfig.class);
    final IConfiguration configuration = mock(IConfiguration.class);
    when(configuration.getProperties()).thenReturn(new Properties() {

        {
            setProperty(testSystemPropertyName, testPropertyValue);
        }
    });
    when(systemConfig.getConfiguration(eq(PentahoSystem.JAVA_SYSTEM_PROPERTIES))).thenReturn(configuration);
    when(objectFactory.objectDefined(eq(ISystemConfig.class))).thenReturn(true);
    final IPentahoObjectReference pentahoObjectReference = mock(IPentahoObjectReference.class);
    when(pentahoObjectReference.getObject()).thenReturn(systemConfig);
    when(objectFactory.getObjectReferences(eq(ISystemConfig.class), any(IPentahoSession.class), any(Map.class))).thenReturn(new LinkedList() {

        {
            add(pentahoObjectReference);
        }
    });
    PentahoSystem.registerObjectFactory(objectFactory);
    PentahoSystem.init();
}
Also used : IPentahoObjectReference(org.pentaho.platform.api.engine.IPentahoObjectReference) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Node(org.dom4j.Node) ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) IConfiguration(org.pentaho.platform.api.engine.IConfiguration) Properties(java.util.Properties) Map(java.util.Map) LinkedList(java.util.LinkedList)

Aggregations

ISystemSettings (org.pentaho.platform.api.engine.ISystemSettings)21 Test (org.junit.Test)13 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 Before (org.junit.Before)3 File (java.io.File)2 Matchers.anyString (org.mockito.Matchers.anyString)2 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)2 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)2 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)2 DatasourceDTO (org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceDTO)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Node (org.dom4j.Node)1 Expectations (org.jmock.Expectations)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 IActionCompleteListener (org.pentaho.platform.api.engine.IActionCompleteListener)1