01: /*
02: * Copyright 2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.plugin.quartz;
14:
15: import org.pentaho.core.repository.IContentItem;
16: import org.pentaho.core.repository.content.ContentRepositoryOutputHandler;
17: import org.pentaho.core.session.IPentahoSession;
18: import org.pentaho.core.solution.IOutputHandler;
19: import org.pentaho.core.solution.IParameterProvider;
20:
21: import org.pentaho.core.system.PentahoSystem;
22: import com.pentaho.security.UserDetailsRoleListService;
23:
24: public class SecurityAwareBackgroundExecutionHelper extends
25: org.pentaho.plugin.quartz.QuartzBackgroundExecutionHelper {
26:
27: public IPentahoSession getEffectiveUserSession(String userName) {
28: UserDetailsRoleListService userDetailsRoleListService = PentahoSystem
29: .getUserDetailsRoleListService();
30: if (userDetailsRoleListService != null) {
31: return userDetailsRoleListService
32: .getEffectiveUserSession(userName);
33: } else {
34: return super .getEffectiveUserSession(userName);
35: }
36: }
37:
38: public IOutputHandler getContentOutputHandler(String location,
39: String fileName, String solutionName,
40: IPentahoSession userSession,
41: IParameterProvider parameterProvider) {
42: // todo MB - try to detect background execution of a subscription in a better way
43: String subsName = parameterProvider.getStringParameter(
44: "subscribe-name", null); //$NON-NLS-1$
45: ContentRepositoryOutputHandler outputHandler = (ContentRepositoryOutputHandler) super
46: .getContentOutputHandler(location, fileName,
47: solutionName, userSession, parameterProvider);
48: if (subsName != null) {
49: // Any subscription-specific changes to outputHandler goes here...
50: outputHandler
51: .setWriteMode(IContentItem.WRITEMODE_KEEPVERSIONS);
52: }
53: return outputHandler;
54: }
55:
56: }
|