Source Code Cross Referenced for RuntimeContext.java in  » Report » pentaho-report » org » pentaho » core » runtime » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » pentaho report » org.pentaho.core.runtime 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2006 Pentaho Corporation.  All rights reserved. 
0003:         * This software was developed by Pentaho Corporation and is provided under the terms 
0004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use 
0005:         * this file except in compliance with the license. If you need a copy of the license, 
0006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho 
0007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
0008:         *
0009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS" 
0010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
0011:         * the license for the specific language governing your rights and limitations.
0012:         */
0013:        /*
0014:         * Created on Jun 17, 2005
0015:         *
0016:         * TODO To change the template for this generated file go to
0017:         * Window - Preferences - Java - Code Style - Code Templates
0018:         */
0019:        package org.pentaho.core.runtime;
0020:
0021:        import java.io.ByteArrayInputStream;
0022:        import java.io.File;
0023:        import java.io.FileNotFoundException;
0024:        import java.io.IOException;
0025:        import java.io.InputStream;
0026:        import java.io.InputStreamReader;
0027:        import java.io.OutputStream;
0028:        import java.io.Reader;
0029:        import java.math.BigDecimal;
0030:        import java.util.ArrayList;
0031:        import java.util.Collections;
0032:        import java.util.Date;
0033:        import java.util.HashMap;
0034:        import java.util.Iterator;
0035:        import java.util.List;
0036:        import java.util.Map;
0037:        import java.util.Set;
0038:        import java.util.regex.Matcher;
0039:        import java.util.regex.Pattern;
0040:
0041:        import javax.activation.DataSource;
0042:
0043:        import org.apache.commons.logging.Log;
0044:        import org.apache.commons.logging.LogFactory;
0045:        import org.dom4j.Document;
0046:        import org.dom4j.Element;
0047:        import org.dom4j.Node;
0048:        import org.pentaho.actionsequence.dom.actions.ActionFactory;
0049:        import org.pentaho.commons.connection.IPentahoResultSet;
0050:        import org.pentaho.core.audit.AuditHelper;
0051:        import org.pentaho.core.audit.MessageTypes;
0052:        import org.pentaho.core.component.IComponent;
0053:        import org.pentaho.core.output.IContentOutputHandler;
0054:        import org.pentaho.core.repository.IContentItem;
0055:        import org.pentaho.core.repository.IContentLocation;
0056:        import org.pentaho.core.repository.IContentRepository;
0057:        import org.pentaho.core.repository.IRuntimeElement;
0058:        import org.pentaho.core.repository.IRuntimeRepository;
0059:        import org.pentaho.core.repository.content.ContentRepositoryOutputHandler;
0060:        import org.pentaho.core.session.IPentahoSession;
0061:        import org.pentaho.core.solution.ActionParameterSource;
0062:        import org.pentaho.core.solution.ActionSequenceParameterMgr;
0063:        import org.pentaho.core.solution.ConditionalExecution;
0064:        import org.pentaho.core.solution.HttpRequestParameterProvider;
0065:        import org.pentaho.core.solution.HttpSessionParameterProvider;
0066:        import org.pentaho.core.solution.IActionCompleteListener;
0067:        import org.pentaho.core.solution.IActionDefinition;
0068:        import org.pentaho.core.solution.IActionResource;
0069:        import org.pentaho.core.solution.IActionSequence;
0070:        import org.pentaho.core.solution.IOutputHandler;
0071:        import org.pentaho.core.solution.IParameterProvider;
0072:        import org.pentaho.core.solution.ISolutionEngine;
0073:        import org.pentaho.core.system.PentahoMessenger;
0074:        import org.pentaho.core.system.PentahoSystem;
0075:        import org.pentaho.core.ui.IPentahoUrlFactory;
0076:        import org.pentaho.core.util.IParameterResolver;
0077:        import org.pentaho.core.util.TemplateUtil;
0078:        import org.pentaho.core.util.XForm;
0079:        import org.pentaho.core.util.XmlHelper;
0080:        import org.pentaho.messages.Messages;
0081:        import org.pentaho.messages.util.LocaleHelper;
0082:        import org.pentaho.util.logging.Logger;
0083:
0084:        import com.pentaho.repository.subscribe.ISubscriptionRepository;
0085:
0086:        /**
0087:         * @author James Dixon
0088:         * 
0089:         * TODO To change the template for this generated type comment go to Window -
0090:         * Preferences - Java - Code Style - Code Templates
0091:         */
0092:        public class RuntimeContext extends PentahoMessenger implements 
0093:                IRuntimeContext {
0094:
0095:            /**
0096:             * 
0097:             */
0098:            private static final long serialVersionUID = -1179016850860938879L;
0099:
0100:            private IRuntimeElement runtimeData;
0101:
0102:            // private int loggingLevel = UNKNOWN;
0103:            private static String LOG_NAME = "RUNTIME"; //$NON-NLS-1$
0104:
0105:            protected static String PARAMETER_FORM = "actionparam"; //$NON-NLS-1$
0106:
0107:            private String logId;
0108:
0109:            private IPentahoSession session;
0110:
0111:            protected ISolutionEngine solutionEngine;
0112:
0113:            private int errorLevel = RUNTIME_CONTEXT_RESOLVE_OK;
0114:
0115:            protected StringBuffer xformHeader;
0116:
0117:            protected StringBuffer xformBody;
0118:
0119:            protected Map xformFields;
0120:
0121:            private static final String DEFAULT_PARAMETER_XSL = "DefaultParameterForm.xsl"; //$NON-NLS-1$
0122:
0123:            protected String parameterXsl = DEFAULT_PARAMETER_XSL;
0124:
0125:            protected String parameterTemplate = null;
0126:
0127:            protected String parameterTarget;
0128:
0129:            private String instanceId;
0130:
0131:            private String processId;
0132:
0133:            private String handle;
0134:
0135:            private String solutionName;
0136:
0137:            protected IPentahoUrlFactory urlFactory;
0138:
0139:            protected Map parameterProviders;
0140:
0141:            protected static Map componentClassMap;
0142:
0143:            protected IActionSequence actionSequence;
0144:
0145:            public static final boolean debug = PentahoSystem.debug;
0146:
0147:            private boolean audit = true;
0148:
0149:            private int status;
0150:
0151:            protected IOutputHandler outputHandler;
0152:
0153:            protected ParameterManager paramManager;
0154:
0155:            private String currentComponent;
0156:
0157:            private IActionDefinition currentActionDef;
0158:
0159:            private int promptStatus = PROMPT_NO;
0160:
0161:            private int contentSequenceNumber; // = 0
0162:
0163:            // Normally shouldn't need to synchronize. But, a bug in
0164:            // pattern compilation results in the need to synchronize
0165:            // a small block of code. If/when this problem is fixed, we
0166:            // can remove this synchronization lock.
0167:            private static final byte[] PATTERN_COMPILE_LOCK = new byte[0];
0168:
0169:            private static final Log logger = LogFactory
0170:                    .getLog(RuntimeContext.class);
0171:
0172:            static {
0173:                getComponentClassMap();
0174:            }
0175:
0176:            public Log getLogger() {
0177:                return logger;
0178:            }
0179:
0180:            /*
0181:             * public RuntimeContext( IApplicationContext applicationContext, String
0182:             * solutionName ) { this( null, solutionName, applicationContext, null,
0183:             * null, null, null ); }
0184:             */
0185:            public RuntimeContext(String instanceId,
0186:                    ISolutionEngine solutionEngine, String solutionName,
0187:                    IRuntimeElement runtimeData, IPentahoSession session,
0188:                    IOutputHandler outputHandler, String processId,
0189:                    IPentahoUrlFactory urlFactory, Map parameterProviders,
0190:                    List messages) {
0191:                this .instanceId = instanceId;
0192:                this .solutionEngine = solutionEngine;
0193:                this .session = session;
0194:                this .outputHandler = outputHandler;
0195:                this .processId = processId;
0196:                this .solutionName = solutionName;
0197:                this .urlFactory = urlFactory;
0198:                this .parameterProviders = parameterProviders;
0199:                setMessages(messages);
0200:                xformHeader = new StringBuffer();
0201:                xformBody = new StringBuffer();
0202:                xformFields = new HashMap();
0203:                // TODO - Throw invalid parameter error if these babies are null
0204:
0205:                this .currentComponent = ""; //$NON-NLS-1$
0206:                this .currentActionDef = null;
0207:
0208:                status = RUNTIME_STATUS_NOT_STARTED;
0209:
0210:                this .runtimeData = runtimeData;
0211:                if (runtimeData != null) {
0212:                    this .instanceId = runtimeData.getInstanceId();
0213:                }
0214:
0215:                handle = "context-" + this .hashCode() + "-" + new Date().getTime(); //$NON-NLS-1$ //$NON-NLS-2$
0216:
0217:                logId = ((instanceId != null) ? instanceId : solutionName)
0218:                        + ":" + LOG_NAME + ":" + handle + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0219:
0220:                paramManager = new ParameterManager();
0221:
0222:                // Set the default XSL for parameter forms
0223:                parameterXsl = DEFAULT_PARAMETER_XSL;
0224:
0225:            }
0226:
0227:            private IRuntimeElement createChild(boolean persisted) {
0228:                try {
0229:                    IRuntimeRepository runtimeRepository = PentahoSystem
0230:                            .getRuntimeRepository(session);
0231:                    //            IRuntimeRepository runtimeRepository = RuntimeRepository.getInstance(session);
0232:                    runtimeRepository.setLoggingLevel(loggingLevel);
0233:                    IRuntimeElement childRuntimeData = runtimeRepository
0234:                            .newRuntimeElement(instanceId,
0235:                                    "instance", !persisted); //$NON-NLS-1$
0236:                    String childInstanceId = childRuntimeData.getInstanceId();
0237:                    // audit the creation of this against the parent instance
0238:                    AuditHelper.audit(instanceId, session.getName(),
0239:                            getActionName(), getObjectName(), processId,
0240:                            MessageTypes.INSTANCE_START, childInstanceId,
0241:                            "", null, this ); //$NON-NLS-1$
0242:                    return childRuntimeData;
0243:                } catch (Exception e) {
0244:                    error(
0245:                            Messages
0246:                                    .getString("RuntimeContext.ERROR_0027_COULD_NOT_CREATE_CHILD"), e); //$NON-NLS-1$
0247:                    return null;
0248:                }
0249:            }
0250:
0251:            public String createNewInstance(boolean persisted) {
0252:                try {
0253:                    IRuntimeElement childRuntimeData = createChild(persisted);
0254:                    String childInstanceId = childRuntimeData.getInstanceId();
0255:                    return childInstanceId;
0256:                } catch (Exception e) {
0257:                    error(
0258:                            Messages
0259:                                    .getString("RuntimeContext.ERROR_0027_COULD_NOT_CREATE_CHILD"), e); //$NON-NLS-1$
0260:                    return null;
0261:                }
0262:            }
0263:
0264:            public String createNewInstance(boolean persisted, Map parameters) {
0265:                return createNewInstance(persisted, parameters, false);
0266:            }
0267:
0268:            public String createNewInstance(boolean persisted, Map parameters,
0269:                    boolean forceImmediateWrite) {
0270:                try {
0271:                    IRuntimeElement childRuntimeData = createChild(persisted);
0272:                    if (parameters != null) {
0273:                        Iterator parameterIterator = parameters.keySet()
0274:                                .iterator();
0275:                        while (parameterIterator.hasNext()) {
0276:                            String parameterName = (String) parameterIterator
0277:                                    .next();
0278:                            Object parameterValue = parameters
0279:                                    .get(parameterName);
0280:                            if (parameterValue instanceof  String) {
0281:                                childRuntimeData.setStringProperty(
0282:                                        parameterName, (String) parameterValue);
0283:                            } else if (parameterValue instanceof  BigDecimal) {
0284:                                childRuntimeData.setBigDecimalProperty(
0285:                                        parameterName,
0286:                                        (BigDecimal) parameterValue);
0287:                            } else if (parameterValue instanceof  Date) {
0288:                                childRuntimeData.setDateProperty(parameterName,
0289:                                        (Date) parameterValue);
0290:                            } else if (parameterValue instanceof  List) {
0291:                                childRuntimeData.setListProperty(parameterName,
0292:                                        (List) parameterValue);
0293:                            } else if (parameterValue instanceof  Long) {
0294:                                childRuntimeData.setLongProperty(parameterName,
0295:                                        (Long) parameterValue);
0296:                            }
0297:                        }
0298:                    }
0299:                    String childInstanceId = childRuntimeData.getInstanceId();
0300:                    if (forceImmediateWrite) {
0301:                        childRuntimeData.forceSave();
0302:                    }
0303:                    return childInstanceId;
0304:                } catch (Exception e) {
0305:                    error(
0306:                            Messages
0307:                                    .getString("RuntimeContext.ERROR_0027_COULD_NOT_CREATE_CHILD"), e); //$NON-NLS-1$
0308:                    return null;
0309:                }
0310:
0311:            }
0312:
0313:            public int getStatus() {
0314:                return status;
0315:            }
0316:
0317:            public void promptNow() {
0318:                promptStatus = PROMPT_NOW;
0319:            }
0320:
0321:            /** Sets the prompt flag but continue processing Actions */
0322:            public void promptNeeded() {
0323:                if (promptStatus < PROMPT_WAITING) { // Don't mask a Prompt_Now
0324:                    promptStatus = PROMPT_WAITING;
0325:                }
0326:            }
0327:
0328:            /**
0329:             * Tells if a component is waiting for a prompt
0330:             * 
0331:             * @return true if a prompt is pending
0332:             */
0333:            public boolean isPromptPending() {
0334:                return (promptStatus != PROMPT_NO);
0335:            }
0336:
0337:            public IPentahoUrlFactory getUrlFactory() {
0338:                return urlFactory;
0339:            }
0340:
0341:            public boolean feedbackAllowed() {
0342:                return outputHandler != null && outputHandler.allowFeedback();
0343:            }
0344:
0345:            public IContentItem getFeedbackContentItem() {
0346:                return outputHandler.getFeedbackContentItem();
0347:            }
0348:
0349:            private int getContentSequenceNumber() {
0350:                return contentSequenceNumber++;
0351:            }
0352:
0353:            public IContentItem getOutputItem(String outputName,
0354:                    String mimeType, String extension) {
0355:
0356:                // TODO support content output versions in the action definition
0357:
0358:                IActionParameter outputParameter = getOutputParameter(outputName);
0359:                if (outputParameter == null) {
0360:                    error(Messages
0361:                            .getErrorString(
0362:                                    "RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", outputName, actionSequence.getSequenceName())); //$NON-NLS-1$
0363:                    throw new InvalidParameterException();
0364:                }
0365:
0366:                // If there is an output mapping, use that name to store the content
0367:                // under.
0368:                //        String contentName = outputName;
0369:                //        if (currentActionDef != null) {
0370:                //            contentName = currentActionDef.getMappedOutputName(outputName);
0371:                //            contentName = (contentName != null) ? contentName : outputName;
0372:                //        }
0373:
0374:                // contentrepo : {solution}/{path}/{action}.{extension}
0375:                int seqNum = getContentSequenceNumber();
0376:                String contentName = "contentrepo:" + getSolutionName() + "/" + getSolutionPath() + "/" + getActionName() + ((seqNum > 0) ? Integer.toString(seqNum) : "") + extension; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
0377:
0378:                if (!IActionParameter.TYPE_CONTENT.equals(outputParameter
0379:                        .getType())) {
0380:                    error(Messages
0381:                            .getErrorString(
0382:                                    "RuntimeContext.ERROR_0023_INVALID_OUTPUT_STREAM", outputName)); //$NON-NLS-1$
0383:                    return null;
0384:                }
0385:
0386:                try {
0387:                    IContentOutputHandler output = PentahoSystem
0388:                            .getOutputDestinationFromContentRef(contentName,
0389:                                    session);
0390:                    if (output != null) {
0391:                        // TODO get this info
0392:                        output.setActionName(getActionName());
0393:                        output.setInstanceId(instanceId);
0394:                        output.setMimeType(mimeType);
0395:                        output.setSession(session);
0396:                        output.setSolutionName(solutionName);
0397:                        output.setSolutionPath(getSolutionPath());
0398:                        IContentItem contentItem = output
0399:                                .getFileOutputContentItem();
0400:                        setOutputValue(outputName, contentItem);
0401:                        return contentItem;
0402:                    }
0403:                } catch (Exception e) {
0404:
0405:                }
0406:
0407:                return null;
0408:
0409:            }
0410:
0411:            public IContentItem getOutputContentItem(String mimeType) {
0412:                // TODO check the sequence definition to see where this should come from
0413:                return outputHandler.getOutputContentItem(
0414:                        IOutputHandler.RESPONSE, IOutputHandler.CONTENT,
0415:                        actionSequence.getTitle(), null, solutionName,
0416:                        instanceId, mimeType);
0417:            }
0418:
0419:            public IContentItem getOutputContentItem(String outputName,
0420:                    String mimeType) {
0421:
0422:                IActionParameter parameter = (IActionParameter) actionSequence
0423:                        .getOutputDefinitions().get(outputName);
0424:                if (parameter == null) {
0425:                    error(Messages
0426:                            .getErrorString(
0427:                                    "RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", outputName, actionSequence.getSequenceName())); //$NON-NLS-1$
0428:                    throw new InvalidParameterException();
0429:                }
0430:
0431:                List destinationsList = parameter.getVariables();
0432:                Iterator destinationsIterator = destinationsList.iterator();
0433:                // we can only handle one destination at the moment
0434:                if (destinationsIterator.hasNext()) {
0435:                    ActionParameterSource destination = (ActionParameterSource) destinationsIterator
0436:                            .next();
0437:                    String objectName = destination.getSourceName();
0438:                    String contentName = destination.getValue();
0439:                    contentName = TemplateUtil.applyTemplate(contentName, this );
0440:                    return outputHandler.getOutputContentItem(objectName,
0441:                            contentName, actionSequence.getTitle(), null,
0442:                            solutionName, instanceId, mimeType);
0443:                }
0444:                return null;
0445:            }
0446:
0447:            public String getHandle() {
0448:                return handle;
0449:            }
0450:
0451:            public IPentahoSession getSession() {
0452:                return session;
0453:            }
0454:
0455:            public String getSolutionName() {
0456:                return (solutionName);
0457:            }
0458:
0459:            public String getSolutionPath() {
0460:                return ((actionSequence != null) ? actionSequence
0461:                        .getSolutionPath() : null);
0462:            }
0463:
0464:            public String getCurrentComponentName() {
0465:                if ("".equals(currentComponent)) { //$NON-NLS-1$
0466:                    return this .getClass().getName();
0467:                }
0468:                return currentComponent;
0469:            }
0470:
0471:            public String getInstanceId() {
0472:                return instanceId;
0473:            }
0474:
0475:            public int getErrorLevel() {
0476:                return errorLevel;
0477:            }
0478:
0479:            public void setActionSequence(IActionSequence sequence) {
0480:                this .actionSequence = sequence;
0481:                paramManager = new ParameterManager(sequence);
0482:            }
0483:
0484:            public int validateSequence(String sequenceName) {
0485:                paramManager.resetParameters();
0486:
0487:                logId = ((instanceId != null) ? instanceId : solutionName)
0488:                        + ":" + LOG_NAME + ":" + handle + ":" + sequenceName + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
0489:                if (audit) {
0490:                    audit(MessageTypes.ACTION_SEQUENCE_START,
0491:                            MessageTypes.START, "", 0); //$NON-NLS-1$
0492:                }
0493:
0494:                if (status != RUNTIME_STATUS_NOT_STARTED) {
0495:                    error(Messages
0496:                            .getErrorString("RuntimeContext.ERROR_0001_RUNTIME_RUNNING")); //$NON-NLS-1$
0497:                    return (status);
0498:                }
0499:
0500:                errorLevel = RUNTIME_CONTEXT_VALIDATE_OK;
0501:
0502:                // validate action header
0503:                errorLevel = validateHeader(sequenceName);
0504:                if (errorLevel != RUNTIME_CONTEXT_VALIDATE_OK) {
0505:                    error(Messages
0506:                            .getErrorString(
0507:                                    "RuntimeContext.ERROR_0002_ACTION_NOT_VALIDATED", sequenceName)); //$NON-NLS-1$
0508:                    status = RUNTIME_CONTEXT_VALIDATE_FAIL;
0509:                    return errorLevel;
0510:                }
0511:
0512:                // TODO deep validation of sequence and action inputs and outputs
0513:
0514:                // validate resources
0515:                errorLevel = validateResources();
0516:                if (errorLevel != RUNTIME_CONTEXT_VALIDATE_OK) {
0517:                    error(Messages
0518:                            .getErrorString(
0519:                                    "RuntimeContext.ERROR_0005_ACTION_RESOURCES_NOT_VALID", sequenceName)); //$NON-NLS-1$
0520:                    status = RUNTIME_CONTEXT_VALIDATE_FAIL;
0521:                    return errorLevel;
0522:                }
0523:
0524:                // validate component
0525:                errorLevel = validateComponents();
0526:                if (errorLevel != RUNTIME_CONTEXT_VALIDATE_OK) {
0527:                    error(Messages
0528:                            .getErrorString(
0529:                                    "RuntimeContext.ERROR_0006_ACTION_COMPONENT_NOT_VALID", sequenceName)); //$NON-NLS-1$
0530:                    status = RUNTIME_CONTEXT_VALIDATE_FAIL;
0531:                    return errorLevel;
0532:                }
0533:
0534:                status = RUNTIME_CONTEXT_VALIDATE_OK;
0535:
0536:                return RUNTIME_CONTEXT_VALIDATE_OK;
0537:            }
0538:
0539:            private int validateHeader(String sequenceName) {
0540:
0541:                /*        if (!actionSequence.getSequenceName().equals(sequenceName)) {
0542:                 error(Messages.getErrorString("RuntimeContext.ERROR_0007_NAMES_DO_NOT_MATCH", actionSequence.getSequenceName(), sequenceName)); //$NON-NLS-1$ 
0543:                 return RUNTIME_CONTEXT_VALIDATE_FAIL;
0544:                 }*/
0545:
0546:                // setup auditing and logging etc
0547:                errorLevel = initFromActionSequenceDefinition();
0548:                if (errorLevel != RUNTIME_CONTEXT_RESOLVE_OK) {
0549:                    error(Messages
0550:                            .getErrorString(
0551:                                    "RuntimeContext.ERROR_0008_ACTION_INITIALIZATION_FAILED", sequenceName)); //$NON-NLS-1$
0552:                    return errorLevel;
0553:                }
0554:
0555:                return RUNTIME_CONTEXT_VALIDATE_OK;
0556:            }
0557:
0558:            private int validateResources() {
0559:
0560:                // allResources = actionSequence.getResourceDefinitions();
0561:                return RUNTIME_CONTEXT_VALIDATE_OK;
0562:            }
0563:
0564:            private int validateComponents() {
0565:                return (validateComponents(actionSequence));
0566:            }
0567:
0568:            private int validateComponents(IActionSequence sequence) {
0569:
0570:                List defList = sequence.getActionDefinitionsAndSequences();
0571:
0572:                Object listItem;
0573:                for (Iterator it = defList.iterator(); it.hasNext();) {
0574:                    listItem = it.next();
0575:
0576:                    if (listItem instanceof  IActionSequence) {
0577:                        int rtn = validateComponents((IActionSequence) listItem);
0578:                        if (rtn != RUNTIME_CONTEXT_VALIDATE_OK) {
0579:                            return (rtn);
0580:                        }
0581:                    } else if (listItem instanceof  IActionDefinition) {
0582:                        IActionDefinition actionDef = (IActionDefinition) listItem;
0583:
0584:                        if (debug)
0585:                            debug(Messages
0586:                                    .getString(
0587:                                            "RuntimeContext.DEBUG_VALIDATING_COMPONENT", actionDef.getComponentName())); //$NON-NLS-1$
0588:
0589:                        IComponent component = resolveComponent(actionDef,
0590:                                instanceId, processId, session);
0591:                        if (component != null) {
0592:                            component.setLoggingLevel(loggingLevel);
0593:
0594:                            // allow the ActionDefinition to cache the component
0595:                            actionDef.setComponent(component);
0596:                            paramManager.setCurrentParameters(actionDef);
0597:                            // int stat = component.validate( instanceId,
0598:                            // actionSequence.getSequenceName(), processId,
0599:                            // actionDef.getComponentSection(), this, session, this,
0600:                            // loggingLevel );
0601:                            int stat = component.validate();
0602:                            if (stat != RUNTIME_CONTEXT_VALIDATE_OK) {
0603:                                return (stat);
0604:                            }
0605:                            paramManager.addOutputParameters(actionDef);
0606:                        } else {
0607:                            return RUNTIME_CONTEXT_VALIDATE_FAIL;
0608:                        }
0609:                        setCurrentComponent(""); //$NON-NLS-1$
0610:                        setCurrentActionDef(null);
0611:                    }
0612:                }
0613:                return (RUNTIME_CONTEXT_VALIDATE_OK);
0614:            }
0615:
0616:            protected static Map getComponentClassMap() {
0617:                if (componentClassMap == null) {
0618:                    componentClassMap = Collections
0619:                            .synchronizedMap(createComponentClassMap());
0620:                }
0621:                return componentClassMap;
0622:            }
0623:
0624:            public static Map createComponentClassMap() {
0625:                HashMap ccm = new HashMap();
0626:                // map the short names
0627:                ccm
0628:                        .put(
0629:                                "ContentOutputComponent", "org.pentaho.plugin.core.ContentOutputComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0630:                ccm
0631:                        .put(
0632:                                "ContentRepositoryCleaner", "org.pentaho.plugin.core.ContentRepositoryCleaner"); //$NON-NLS-1$ //$NON-NLS-2$
0633:                ccm
0634:                        .put(
0635:                                "HelloWorldComponent", "org.pentaho.plugin.core.HelloWorldComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0636:                ccm
0637:                        .put(
0638:                                "ResultSetCompareComponent", "org.pentaho.plugin.core.ResultSetCompareComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0639:                ccm
0640:                        .put(
0641:                                "ResultSetExportComponent", "org.pentaho.plugin.core.ResultSetExportComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0642:                ccm
0643:                        .put(
0644:                                "ResultSetFlattenerComponent", "org.pentaho.plugin.core.ResultSetFlattenerComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0645:                ccm
0646:                        .put(
0647:                                "SecureFilterComponent", "org.pentaho.plugin.core.SecureFilterComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0648:                ccm
0649:                        .put(
0650:                                "SubActionComponent", "org.pentaho.plugin.core.SubActionComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0651:                ccm
0652:                        .put(
0653:                                "TemplateComponent", "org.pentaho.plugin.core.TemplateComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0654:                ccm
0655:                        .put(
0656:                                "BIRTReportComponent", "org.pentaho.plugin.eclipsebirt.BIRTReportComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0657:                ccm
0658:                        .put(
0659:                                "EmailComponent", "org.pentaho.plugin.email.EmailComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0660:                ccm
0661:                        .put(
0662:                                "JasperReportsComponent", "org.pentaho.plugin.jasperreports.JasperReportsComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0663:                ccm
0664:                        .put(
0665:                                "JavascriptRule", "org.pentaho.plugin.javascript.JavascriptRule"); //$NON-NLS-1$ //$NON-NLS-2$
0666:                ccm
0667:                        .put(
0668:                                "ChartComponent", "org.pentaho.plugin.jfreechart.ChartComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0669:                ccm
0670:                        .put(
0671:                                "JFreeReportComponent", "org.pentaho.plugin.jfreereport.JFreeReportComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0672:                ccm
0673:                        .put(
0674:                                "JFreeReportGeneratorComponent", "org.pentaho.plugin.jfreereport.JFreeReportGeneratorComponent");//$NON-NLS-1$ //$NON-NLS-2$
0675:                ccm
0676:                        .put(
0677:                                "ReportWizardSpecComponent", "org.pentaho.plugin.jfreereport.ReportWizardSpecComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0678:                ccm
0679:                        .put(
0680:                                "KettleComponent", "org.pentaho.plugin.kettle.KettleComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0681:                ccm
0682:                        .put(
0683:                                "MDXDataComponent", "org.pentaho.plugin.mdx.MDXDataComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0684:                ccm
0685:                        .put(
0686:                                "MDXLookupRule", "org.pentaho.plugin.mdx.MDXLookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0687:                ccm
0688:                        .put(
0689:                                "XMLALookupRule", "org.pentaho.plugin.xmla.XMLALookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0690:                ccm
0691:                        .put(
0692:                                "HQLLookupRule", "org.pentaho.plugin.hql.HQLLookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0693:                ccm
0694:                        .put(
0695:                                "ReceiptAuditComponent", "org.pentaho.plugin.misc.ReceiptAuditComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0696:                ccm
0697:                        .put(
0698:                                "TestComponent", "org.pentaho.plugin.misc.TestComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0699:                ccm
0700:                        .put(
0701:                                "UtilityComponent", "org.pentaho.plugin.misc.UtilityComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0702:                ccm
0703:                        .put(
0704:                                "MondrianModelComponent", "org.pentaho.plugin.olap.MondrianModelComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0705:                ccm
0706:                        .put(
0707:                                "PivotViewComponent", "org.pentaho.plugin.olap.PivotViewComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0708:                ccm
0709:                        .put(
0710:                                "PrintComponent", "org.pentaho.plugin.print.PrintComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0711:                ccm
0712:                        .put(
0713:                                "JobSchedulerComponent", "org.pentaho.plugin.quartz.JobSchedulerComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0714:                ccm
0715:                        .put(
0716:                                "SchedulerAdminComponent", "org.pentaho.plugin.quartz.SchedulerAdminComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0717:                ccm
0718:                        .put(
0719:                                "SharkWorkflowComponent", "org.pentaho.plugin.shark.SharkWorkflowComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0720:                ccm
0721:                        .put(
0722:                                "SQLDataComponent", "org.pentaho.plugin.sql.SQLDataComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0723:                ccm
0724:                        .put(
0725:                                "SQLLookupRule", "org.pentaho.plugin.sql.SQLLookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0726:                ccm.put("SQLExecute", "org.pentaho.plugin.sql.SQLExecute"); //$NON-NLS-1$ //$NON-NLS-2$
0727:                ccm
0728:                        .put(
0729:                                "SubscriptionBurstComponent", "org.pentaho.plugin.SubscriptionBurstComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0730:                ccm
0731:                        .put(
0732:                                "XQueryLookupRule", "org.pentaho.plugin.xquery.XQueryLookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0733:                ccm
0734:                        .put(
0735:                                "ResultSetCrosstabComponent", "org.pentaho.plugin.core.ResultSetCrosstabComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0736:                ccm
0737:                        .put(
0738:                                "MQLRelationalDataComponent", "org.pentaho.plugin.mql.MQLRelationalDataComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0739:
0740:                // map the old names
0741:                ccm
0742:                        .put(
0743:                                "org.pentaho.component.ContentOutputComponent", "!org.pentaho.plugin.core.ContentOutputComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0744:                ccm
0745:                        .put(
0746:                                "org.pentaho.component.ContentRepositoryCleaner", "!org.pentaho.plugin.core.ContentRepositoryCleaner"); //$NON-NLS-1$ //$NON-NLS-2$
0747:                ccm
0748:                        .put(
0749:                                "org.pentaho.component.HelloWorldComponent", "!org.pentaho.plugin.core.HelloWorldComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0750:                ccm
0751:                        .put(
0752:                                "org.pentaho.component.ResultSetCompareComponent", "!org.pentaho.plugin.core.ResultSetCompareComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0753:                ccm
0754:                        .put(
0755:                                "org.pentaho.component.ResultSetExportComponent", "!org.pentaho.plugin.core.ResultSetExportComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0756:                ccm
0757:                        .put(
0758:                                "org.pentaho.component.ResultSetFlattenerComponent", "!org.pentaho.plugin.core.ResultSetFlattenerComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0759:                ccm
0760:                        .put(
0761:                                "org.pentaho.component.SecureFilterComponent", "!org.pentaho.plugin.core.SecureFilterComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0762:                ccm
0763:                        .put(
0764:                                "org.pentaho.component.SubActionComponent", "!org.pentaho.plugin.core.SubActionComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0765:                ccm
0766:                        .put(
0767:                                "org.pentaho.component.TemplateComponent", "!org.pentaho.plugin.core.TemplateComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0768:                ccm
0769:                        .put(
0770:                                "org.pentaho.birt.BIRTReportComponent", "!org.pentaho.plugin.eclipsebirt.BIRTReportComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0771:                ccm
0772:                        .put(
0773:                                "org.pentaho.component.EmailComponent", "!org.pentaho.plugin.email.EmailComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0774:                ccm
0775:                        .put(
0776:                                "org.pentaho.jasper.JasperReportsComponent", "!org.pentaho.plugin.jasperreports.JasperReportsComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0777:                ccm
0778:                        .put(
0779:                                "org.pentaho.component.JavascriptRule", "!org.pentaho.plugin.javascript.JavascriptRule"); //$NON-NLS-1$ //$NON-NLS-2$
0780:                ccm
0781:                        .put(
0782:                                "org.pentaho.component.ChartComponent", "!org.pentaho.plugin.jfreechart.ChartComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0783:                ccm
0784:                        .put(
0785:                                "org.pentaho.jfree.JFreeReportComponent", "!org.pentaho.plugin.jfreereport.JFreeReportComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0786:                ccm
0787:                        .put(
0788:                                "org.pentaho.kettle.KettleComponent", "!org.pentaho.plugin.kettle.KettleComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0789:                ccm
0790:                        .put(
0791:                                "org.pentaho.component.MDXDataComponent", "!org.pentaho.plugin.mdx.MDXDataComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0792:                ccm
0793:                        .put(
0794:                                "org.pentaho.component.MDXLookupRule", "!org.pentaho.plugin.mdx.MDXLookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0795:                ccm
0796:                        .put(
0797:                                "org.pentaho.component.ReceiptAuditComponent", "!org.pentaho.plugin.misc.ReceiptAuditComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0798:                ccm
0799:                        .put(
0800:                                "org.pentaho.component.TestComponent", "!org.pentaho.plugin.misc.TestComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0801:                ccm
0802:                        .put(
0803:                                "org.pentaho.component.UtilityComponent", "!org.pentaho.plugin.misc.UtilityComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0804:                ccm
0805:                        .put(
0806:                                "org.pentaho.component.MondrianModelComponent", "!org.pentaho.plugin.olap.MondrianModelComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0807:                ccm
0808:                        .put(
0809:                                "org.pentaho.component.PivotViewComponent", "!org.pentaho.plugin.olap.PivotViewComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0810:                ccm
0811:                        .put(
0812:                                "org.pentaho.component.PrintComponent", "!org.pentaho.plugin.print.PrintComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0813:                ccm
0814:                        .put(
0815:                                "org.pentaho.component.JobSchedulerComponent", "!org.pentaho.plugin.quartz.JobSchedulerComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0816:                ccm
0817:                        .put(
0818:                                "org.pentaho.component.SchedulerAdminComponent", "!org.pentaho.plugin.quartz.SchedulerAdminComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0819:                ccm
0820:                        .put(
0821:                                "org.pentaho.component.SharkWorkflowComponent", "!org.pentaho.plugin.shark.SharkWorkflowComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0822:                ccm
0823:                        .put(
0824:                                "org.pentaho.component.SQLDataComponent", "!org.pentaho.plugin.sql.SQLDataComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0825:                ccm
0826:                        .put(
0827:                                "org.pentaho.component.SQLLookupRule", "!org.pentaho.plugin.sql.SQLLookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0828:                ccm
0829:                        .put(
0830:                                "org.pentaho.component.XQueryLookupRule", "!org.pentaho.plugin.xquery.XQueryLookupRule"); //$NON-NLS-1$ //$NON-NLS-2$
0831:                ccm
0832:                        .put(
0833:                                "com.pentaho.component.JFreeReportGeneratorComponent", "!org.pentaho.plugin.jfreereport.JFreeReportGeneratorComponent"); //$NON-NLS-1$ //$NON-NLS-2$
0834:
0835:                return ccm;
0836:            }
0837:
0838:            protected void setCurrentComponent(String componentClassName) {
0839:                currentComponent = componentClassName;
0840:            }
0841:
0842:            protected void setCurrentActionDef(
0843:                    IActionDefinition actionDefinition) {
0844:                currentActionDef = actionDefinition;
0845:            }
0846:
0847:            protected static String getComponentClassName(String rawClassName,
0848:                    IRuntimeContext runtime) {
0849:                String mappedClassName = (String) getComponentClassMap().get(
0850:                        rawClassName);
0851:                if (mappedClassName != null) {
0852:                    if (mappedClassName.indexOf('!') == 0) {
0853:                        // this is deprecated, log a warning
0854:                        mappedClassName = mappedClassName.substring(1);
0855:                        runtime
0856:                                .warn(Messages
0857:                                        .getString(
0858:                                                "RuntimeContext.WARN_DEPRECATED_COMPONENT_CLASS", rawClassName, mappedClassName)); //$NON-NLS-1$
0859:                        runtime.audit(MessageTypes.DEPRECATION_WARNING,
0860:                                rawClassName, mappedClassName, 0);
0861:                    }
0862:                    return mappedClassName;
0863:                }
0864:                return rawClassName;
0865:
0866:            }
0867:
0868:            protected IComponent resolveComponent(
0869:                    IActionDefinition actionDefinition,
0870:                    String currentInstanceId, String currentProcessId,
0871:                    IPentahoSession currentSession) {
0872:
0873:                // try to create an instance of the component class specified in the
0874:                // action document
0875:                String componentClassName = actionDefinition.getComponentName()
0876:                        .trim();
0877:
0878:                String mappedClassName = (String) getComponentClassMap().get(
0879:                        componentClassName);
0880:                if (mappedClassName != null) {
0881:                    if (mappedClassName.indexOf('!') == 0) {
0882:                        // this is deprecated, log a warning
0883:                        mappedClassName = mappedClassName.substring(1);
0884:                        warn(Messages
0885:                                .getString(
0886:                                        "RuntimeContext.WARN_DEPRECATED_COMPONENT_CLASS", componentClassName, mappedClassName)); //$NON-NLS-1$
0887:                        audit(MessageTypes.DEPRECATION_WARNING,
0888:                                componentClassName, mappedClassName, 0);
0889:                    }
0890:                    componentClassName = mappedClassName;
0891:                }
0892:
0893:                Node componentDefinition = actionDefinition
0894:                        .getComponentSection();
0895:                setCurrentComponent(componentClassName);
0896:                setCurrentActionDef(actionDefinition);
0897:                try {
0898:
0899:                    /*
0900:                     * String instanceId, String actionName, String processId, Node
0901:                     * componentDefinition, IRuntimeContext runtimeContext,
0902:                     * IPentahoSession sessionContext, int loggingLevel
0903:                     */
0904:
0905:                    IComponent component = null;
0906:                    Class componentClass;
0907:                    /*
0908:                     Class[] paramClasses = new Class[] { String.class, String.class, String.class, Node.class, IRuntimeContext.class, IPentahoSession.class, int.class, List.class };
0909:                     Integer logLevel = new Integer(getLoggingLevel());
0910:                     Object[] paramArgs = new Object[] { instanceId, getActionName(), processId, componentDefinition, this, session, logLevel, getMessages() };
0911:                     Constructor componentConstructor;
0912:                     componentClass = Class.forName(componentClassName);
0913:                     componentConstructor = componentClass.getConstructor(paramClasses);
0914:                     component = (IComponent) componentConstructor.newInstance(paramArgs);
0915:                     */
0916:
0917:                    componentClass = Class.forName(componentClassName);
0918:                    component = (IComponent) componentClass.newInstance();
0919:                    component.setInstanceId(currentInstanceId);
0920:                    component.setActionName(getActionName());
0921:                    component.setProcessId(currentProcessId);
0922:
0923:                    // This next conditional is used to allow components to use the new action sequence dom commons project. The ActionFactory
0924:                    // should return an object that wraps the action definition element to be processed by the component. The component can
0925:                    // then use the wrappers API to access the action definition rather than make explicit references to the dom nodes.
0926:                    if (component instanceof  org.pentaho.core.util.IParameterResolver) {
0927:                        component
0928:                                .setActionDefinition(ActionFactory
0929:                                        .getActionDefinition(
0930:                                                (Element) actionDefinition
0931:                                                        .getNode(),
0932:                                                new ActionSequenceParameterMgr(
0933:                                                        this ,
0934:                                                        currentSession,
0935:                                                        (org.pentaho.core.util.IParameterResolver) component)));
0936:                    } else {
0937:                        component.setActionDefinition(ActionFactory
0938:                                .getActionDefinition((Element) actionDefinition
0939:                                        .getNode(),
0940:                                        new ActionSequenceParameterMgr(this ,
0941:                                                currentSession)));
0942:                    }
0943:
0944:                    component.setComponentDefinition(componentDefinition);
0945:                    component.setRuntimeContext(this );
0946:                    component.setSession(currentSession);
0947:                    component.setLoggingLevel(getLoggingLevel());
0948:                    component.setMessages(getMessages());
0949:                    return component;
0950:                } catch (Exception e) {
0951:                    error(
0952:                            Messages
0953:                                    .getErrorString(
0954:                                            "RuntimeContext.ERROR_0009_COULD_NOT_CREATE_COMPONENT", componentClassName), e); //$NON-NLS-1$
0955:                }
0956:
0957:                // we were not successful
0958:                return null;
0959:            }
0960:
0961:            public int executeSequence(IActionCompleteListener listener,
0962:                    boolean async) {
0963:                paramManager.resetParameters();
0964:
0965:                long start = new Date().getTime();
0966:                if (status != RUNTIME_CONTEXT_VALIDATE_OK) {
0967:                    audit(
0968:                            MessageTypes.ACTION_SEQUENCE_FAILED,
0969:                            MessageTypes.VALIDATION,
0970:                            Messages
0971:                                    .getErrorString("RuntimeContext.ERROR_0010_RUNTIME_DID_NOT_VALIDATE"), 0); //$NON-NLS-1$
0972:                    error(Messages
0973:                            .getErrorString("RuntimeContext.ERROR_0010_RUNTIME_DID_NOT_VALIDATE")); //$NON-NLS-1$
0974:                    return (status);
0975:                }
0976:                status = RUNTIME_STATUS_RUNNING;
0977:
0978:                // create an IActionDef object
0979:                List actionDefinitions = actionSequence
0980:                        .getActionDefinitionsAndSequences();
0981:
0982:                if (actionDefinitions == null) {
0983:                    audit(
0984:                            MessageTypes.ACTION_SEQUENCE_FAILED,
0985:                            MessageTypes.VALIDATION,
0986:                            Messages
0987:                                    .getErrorString("RuntimeContext.ERROR_0011_NO_VALID_ACTIONS"), 0); //$NON-NLS-1$
0988:                    error(Messages
0989:                            .getErrorString("RuntimeContext.ERROR_0011_NO_VALID_ACTIONS")); //$NON-NLS-1$
0990:                    return RUNTIME_CONTEXT_VALIDATE_FAIL;
0991:                }
0992:
0993:                setLoggingLevel(loggingLevel);
0994:
0995:                if (debug)
0996:                    debug(Messages
0997:                            .getString("RuntimeContext.DEBUG_EXECUTING_ACTIONS")); //$NON-NLS-1$
0998:
0999:                paramManager.setCurrentParameters(null);
1000:                errorLevel = resolveParameters();
1001:                if (errorLevel != RUNTIME_CONTEXT_RESOLVE_OK) {
1002:                    audit(
1003:                            MessageTypes.ACTION_SEQUENCE_FAILED,
1004:                            MessageTypes.VALIDATION,
1005:                            Messages
1006:                                    .getErrorString("RuntimeContext.ERROR_0013_BAD_PARAMETERS"), 0); //$NON-NLS-1$
1007:                    error(Messages
1008:                            .getErrorString("RuntimeContext.ERROR_0013_BAD_PARAMETERS")); //$NON-NLS-1$
1009:                    return errorLevel;
1010:                }
1011:
1012:                int rtnStat = executeSequence(actionSequence, listener, async);
1013:
1014:                if (this .feedbackAllowed()
1015:                        && (promptStatus != PROMPT_NO
1016:                                || (xformBody.length() > 0) || (parameterTemplate != null))) {
1017:                    try {
1018:                        sendFeedbackForm();
1019:                    } catch (Exception e) {
1020:                        // TODO log an error
1021:                        error(
1022:                                Messages
1023:                                        .getString("RuntimeContext.ERROR_0030_SEND_FEEDBACKFORM"), e); //$NON-NLS-1$
1024:                        try {
1025:                            outputHandler.getFeedbackContentItem().setMimeType(
1026:                                    "text/html"); //$NON-NLS-1$ 
1027:                            IContentItem contentItem = outputHandler
1028:                                    .getFeedbackContentItem();
1029:                            OutputStream os = contentItem
1030:                                    .getOutputStream(getActionName());
1031:                            if (os != null) {
1032:                                os
1033:                                        .write(Messages
1034:                                                .getString(
1035:                                                        "RuntimeContext.USER_BAD_PARAMETER_PAGE").getBytes(LocaleHelper.getSystemEncoding())); //$NON-NLS-1$
1036:                            }
1037:                            contentItem.closeOutputStream();
1038:                        } catch (Throwable t) {
1039:                            return RUNTIME_STATUS_FAILURE;
1040:                        }
1041:                    }
1042:                }
1043:
1044:                paramManager.setCurrentParameters(null);
1045:
1046:                long end = new Date().getTime();
1047:                if ((rtnStat == RUNTIME_STATUS_SUCCESS) && audit) {
1048:                    audit(MessageTypes.ACTION_SEQUENCE_END, MessageTypes.END,
1049:                            "", (int) (end - start)); //$NON-NLS-1$
1050:                } else {
1051:                    audit(MessageTypes.ACTION_SEQUENCE_FAILED,
1052:                            MessageTypes.EXECUTION, "", (int) (end - start)); //$NON-NLS-1$
1053:                }
1054:
1055:                status = rtnStat;
1056:
1057:                if ((rtnStat == RUNTIME_STATUS_SUCCESS) && !isPromptPending()) {
1058:                    Map returnParamMap = paramManager.getReturnParameters();
1059:
1060:                    for (Iterator it = returnParamMap.entrySet().iterator(); it
1061:                            .hasNext();) {
1062:                        Map.Entry mapEntry = (Map.Entry) it.next();
1063:
1064:                        String paramName = (String) mapEntry.getKey();
1065:                        ParameterManager.ReturnParameter returnParam = (ParameterManager.ReturnParameter) mapEntry
1066:                                .getValue();
1067:
1068:                        if (returnParam == null) {
1069:                            error(Messages
1070:                                    .getErrorString(
1071:                                            "RuntimeContext.ERROR_0029_SAVE_PARAM_NOT_FOUND", paramName)); //$NON-NLS-1$
1072:                        } else {
1073:                            if (HttpSessionParameterProvider.SCOPE_SESSION
1074:                                    .equals(returnParam.destinationName)) {
1075:                                session.setAttribute(
1076:                                        returnParam.destinationParameter,
1077:                                        returnParam.value);
1078:                                if (debug)
1079:                                    debug(paramName
1080:                                            + " - session - " + returnParam.destinationParameter); //$NON-NLS-1$
1081:                            } else if ("response".equals(returnParam.destinationName)) { //$NON-NLS-1$
1082:                                if (outputHandler != null) {
1083:                                    outputHandler.setOutput(
1084:                                            returnParam.destinationParameter,
1085:                                            returnParam.value);
1086:                                } else {
1087:                                    info(Messages
1088:                                            .getString("RuntimeContext.INFO_NO_OUTPUT_HANDLER")); //$NON-NLS-1$
1089:                                }
1090:                                if (debug) {
1091:                                    debug(paramName
1092:                                            + " - response - " + returnParam.destinationParameter); //$NON-NLS-1$
1093:                                }
1094:                            } else if (PentahoSystem.SCOPE_GLOBAL
1095:                                    .equals(returnParam.destinationName)) {
1096:                                PentahoSystem.putInGlobalAttributesMap(
1097:                                        returnParam.destinationParameter,
1098:                                        returnParam.value);
1099:                                if (debug) {
1100:                                    debug(paramName
1101:                                            + " - global - " + returnParam.destinationParameter); //$NON-NLS-1$
1102:                                }
1103:                            } else { // Unrecognized scope
1104:                                warn(Messages
1105:                                        .getString(
1106:                                                "RuntimeContext.WARN_UNRECOGNIZED_SCOPE", returnParam.destinationName, returnParam.destinationParameter)); //$NON-NLS-1$
1107:                            }
1108:                        }
1109:                    }
1110:                }
1111:
1112:                // return the status for the action
1113:                return (rtnStat);
1114:            }
1115:
1116:            public void setPromptStatus(int status) {
1117:                promptStatus = status;
1118:            }
1119:
1120:            protected int executeSequence(IActionSequence sequence,
1121:                    IActionCompleteListener listener, boolean async) {
1122:                String loopParamName = sequence.getLoopParameter();
1123:                Object loopList;
1124:                IActionParameter loopParm = null;
1125:
1126:                if (loopParamName == null) {
1127:                    loopList = new ArrayList();
1128:                    ((ArrayList) loopList).add(new Integer(0));
1129:                } else {
1130:                    loopParm = getLoopParameter(loopParamName);
1131:                    loopList = loopParm.getValue();
1132:                }
1133:
1134:                if (loopList instanceof  List) {
1135:                    int result = executeLoop(loopParm, (List) loopList,
1136:                            sequence, listener, async);
1137:                    if (loopParm != null) {
1138:                        addInputParameter(loopParm.getName(), loopParm); // replace the loop param in case the last loop muggled it
1139:                    }
1140:
1141:                    if (result != RUNTIME_STATUS_SUCCESS) {
1142:                        return result;
1143:                    }
1144:                } else if (loopList instanceof  IPentahoResultSet) {
1145:                    int result = executeLoop(loopParm,
1146:                            (IPentahoResultSet) loopList, sequence, listener,
1147:                            async);
1148:                    if (result != RUNTIME_STATUS_SUCCESS) {
1149:                        return result;
1150:                    }
1151:                }
1152:
1153:                return (RUNTIME_STATUS_SUCCESS);
1154:            }
1155:
1156:            private int executeLoop(IActionParameter loopParm,
1157:                    IPentahoResultSet loopSet, IActionSequence sequence,
1158:                    IActionCompleteListener listener, boolean async) {
1159:
1160:                // execute the actions
1161:                int loopCount = 0;
1162:
1163:                // TODO handle results sets directly instead of using Properties maps
1164:
1165:                Object row[] = loopSet.next();
1166:                Object headerSet[][] = loopSet.getMetaData().getColumnHeaders();
1167:                // TODO handle OLAP result sets
1168:                Object headers[] = headerSet[0];
1169:                while (row != null) {
1170:
1171:                    if (debug)
1172:                        debug(Messages
1173:                                .getString(
1174:                                        "RuntimeContext.DEBUG_EXECUTING_ACTION", Integer.toString(loopCount++))); //$NON-NLS-1$
1175:
1176:                    if (loopParm != null) {
1177:                        IActionParameter ap;
1178:                        for (int columnNo = 0; columnNo < headers.length; columnNo++) {
1179:                            String name = headers[columnNo].toString();
1180:                            Object value = row[columnNo];
1181:                            String type = null;
1182:                            if (value instanceof  String) {
1183:                                type = IActionParameter.TYPE_STRING;
1184:                            } else if (value instanceof  Date) {
1185:                                type = IActionParameter.TYPE_DATE;
1186:                            } else if (value instanceof  Long
1187:                                    || value instanceof  Integer) {
1188:                                type = IActionParameter.TYPE_INTEGER;
1189:                            } else if (value instanceof  BigDecimal) {
1190:                                type = IActionParameter.TYPE_DECIMAL;
1191:                            } else if (value instanceof  String[]) {
1192:                                type = IActionParameter.TYPE_STRING;
1193:                            } else if (value == null) {
1194:                                warn(Messages
1195:                                        .getString(
1196:                                                "RuntimeContext.WARN_VARIABLE_IN_LOOP_IS_NULL", name)); //$NON-NLS-1$
1197:                            } else {
1198:                                type = IActionParameter.TYPE_OBJECT;
1199:                                warn(Messages
1200:                                        .getString(
1201:                                                "RuntimeContext.WARN_VARIABLE_IN_LOOP_NOT_RECOGNIZED", name, value.getClass().toString())); //$NON-NLS-1$
1202:                            }
1203:                            // TODO make sure any previous loop values are removed
1204:                            if (type != null) {
1205:                                ap = new ActionParameter(name, type, value,
1206:                                        null, null);
1207:                                addInputParameter(name, ap);
1208:                            }
1209:                        }
1210:                    }
1211:                    int rtn = performActions(sequence, listener, async);
1212:                    if (rtn != RUNTIME_STATUS_SUCCESS) {
1213:                        return rtn;
1214:                    }
1215:                    row = loopSet.next();
1216:                }
1217:
1218:                return RUNTIME_STATUS_SUCCESS;
1219:            }
1220:
1221:            private int executeLoop(IActionParameter loopParm, List loopList,
1222:                    IActionSequence sequence, IActionCompleteListener listener,
1223:                    boolean async) {
1224:
1225:                // execute the actions
1226:                int loopCount = 0;
1227:                for (Iterator it = loopList.iterator(); it.hasNext();) {
1228:
1229:                    if (debug)
1230:                        debug(Messages
1231:                                .getString(
1232:                                        "RuntimeContext.DEBUG_EXECUTING_ACTION", Integer.toString(loopCount++))); //$NON-NLS-1$
1233:
1234:                    Object loopVar = it.next();
1235:                    if (loopParm != null) {
1236:                        IActionParameter ap;
1237:                        if (loopVar instanceof  Map) {
1238:                            ap = new ActionParameter(loopParm.getName(),
1239:                                    "property-map", loopVar, null, null); //$NON-NLS-1$
1240:                        } else {
1241:                            ap = new ActionParameter(loopParm.getName(),
1242:                                    "string", loopVar, null, null); //$NON-NLS-1$
1243:                        }
1244:
1245:                        addInputParameter(loopParm.getName(), ap);
1246:                    }
1247:
1248:                    int rtn = performActions(sequence, listener, async);
1249:                    if ((rtn != RUNTIME_STATUS_SUCCESS)
1250:                            || (promptStatus == PROMPT_NOW)) {
1251:                        return rtn;
1252:                    }
1253:                }
1254:                return RUNTIME_STATUS_SUCCESS;
1255:            }
1256:
1257:            private int performActions(IActionSequence sequence,
1258:                    IActionCompleteListener listener, boolean async) {
1259:                ConditionalExecution conditional = sequence
1260:                        .getConditionalExecution();
1261:                if (conditional != null) {
1262:                    boolean shouldExecute = false;
1263:                    try {
1264:                        shouldExecute = conditional.shouldExecute(paramManager
1265:                                .getAllParameters(), logger);
1266:                    } catch (Exception ex) {
1267:                        error(
1268:                                Messages
1269:                                        .getErrorString("RuntimeContext.ERROR_0032_CONDITIONAL_EXECUTION_FAILED"), ex); //$NON-NLS-1$
1270:                        // return the runtime so the messages are available
1271:                        currentComponent = ""; //$NON-NLS-1$
1272:                        return RUNTIME_STATUS_FAILURE;
1273:                    }
1274:                    if (!shouldExecute) {
1275:                        //audit(MessageTypes.ACTION_SEQUENCE_EXECUTE_CONDITIONAL, MessageTypes.NOT_EXECUTED, "", 0); //$NON-NLS-1$ //$NON-NLS-2$
1276:                        if (debug)
1277:                            this 
1278:                                    .debug(Messages
1279:                                            .getString("RuntimeContext.INFO_ACTION_NOT_EXECUTED")); //$NON-NLS-1$
1280:                        return RUNTIME_STATUS_SUCCESS;
1281:                    }
1282:                }
1283:
1284:                List defList = sequence.getActionDefinitionsAndSequences();
1285:
1286:                Object listItem;
1287:                for (Iterator actIt = defList.iterator(); actIt.hasNext();) {
1288:                    listItem = actIt.next();
1289:
1290:                    if (listItem instanceof  IActionSequence) {
1291:                        int rtn = executeSequence((IActionSequence) listItem,
1292:                                listener, async);
1293:                        if (rtn != RUNTIME_STATUS_SUCCESS) {
1294:                            return (rtn);
1295:                        }
1296:                    } else if (listItem instanceof  IActionDefinition) {
1297:                        IActionDefinition actionDef = (IActionDefinition) listItem;
1298:                        currentComponent = actionDef.getComponentName();
1299:                        currentActionDef = actionDef;
1300:                        paramManager.setCurrentParameters(actionDef);
1301:
1302:                        int executeResult = executeAction(actionDef,
1303:                                parameterProviders, listener, async);
1304:                        if (executeResult != IRuntimeContext.RUNTIME_STATUS_SUCCESS) {
1305:                            error(Messages
1306:                                    .getErrorString(
1307:                                            "RuntimeContext.ERROR_0012_EXECUTION_FAILED", currentComponent)); //$NON-NLS-1$
1308:                            // return the runtime so the messages are available
1309:                            currentComponent = ""; //$NON-NLS-1$
1310:                            return RUNTIME_STATUS_FAILURE;
1311:                        }
1312:                        paramManager.addOutputParameters(actionDef);
1313:                    }
1314:                    if (promptStatus == PROMPT_NOW) {
1315:                        // promptStatus = PROMPT_NO; // turn it off - just in case  DM - Turning off was causing problems
1316:                        return (RUNTIME_STATUS_SUCCESS);
1317:                    }
1318:                    currentComponent = ""; //$NON-NLS-1$
1319:                    currentActionDef = null;
1320:                }
1321:                return RUNTIME_STATUS_SUCCESS;
1322:            }
1323:
1324:            private int executeAction(IActionDefinition actionDefinition,
1325:                    Map pParameterProviders, IActionCompleteListener listener,
1326:                    boolean async) {
1327:
1328:                this .parameterProviders = pParameterProviders;
1329:                // TODO get audit setting from action definition
1330:
1331:                long start = new Date().getTime();
1332:                if (audit) {
1333:                    audit(MessageTypes.COMPONENT_EXECUTE_START,
1334:                            MessageTypes.START, "", 0); //$NON-NLS-1$
1335:                }
1336:
1337:                errorLevel = RUNTIME_CONTEXT_RESOLVE_OK;
1338:
1339:                // resolve the parameters
1340:                errorLevel = resolveParameters();
1341:                if (errorLevel != RUNTIME_CONTEXT_RESOLVE_OK) {
1342:                    error(Messages
1343:                            .getErrorString("RuntimeContext.ERROR_0013_BAD_PARAMETERS")); //$NON-NLS-1$
1344:                    audit(
1345:                            MessageTypes.COMPONENT_EXECUTE_FAILED,
1346:                            MessageTypes.VALIDATION,
1347:                            Messages
1348:                                    .getErrorString("RuntimeContext.ERROR_0013_BAD_PARAMETERS"), 0); //$NON-NLS-1$
1349:                    if (listener != null) {
1350:                        listener.actionComplete(this );
1351:                    }
1352:                    return errorLevel;
1353:                }
1354:
1355:                if (debug)
1356:                    debug(Messages
1357:                            .getString("RuntimeContext.DEBUG_PRE-EXECUTE_AUDIT")); //$NON-NLS-1$
1358:                List auditPre = actionDefinition.getPreExecuteAuditList();
1359:                audit(auditPre);
1360:
1361:                // resolve the output parameters
1362:                errorLevel = resolveOutputHandler();
1363:                if (errorLevel != RUNTIME_CONTEXT_RESOLVE_OK) {
1364:                    audit(
1365:                            MessageTypes.COMPONENT_EXECUTE_FAILED,
1366:                            MessageTypes.VALIDATION,
1367:                            Messages
1368:                                    .getErrorString("RuntimeContext.ERROR_0014_NO_OUTPUT_HANDLER"), 0); //$NON-NLS-1$
1369:                    if (listener != null) {
1370:                        listener.actionComplete(this );
1371:                    }
1372:                    return errorLevel;
1373:                }
1374:
1375:                // resolve the resources
1376:                // Param Manager resolves them at create time
1377:
1378:                if (async) {
1379:                    // TODO handle threading
1380:                    // create the thread if necessary
1381:                }
1382:
1383:                // initialize the component
1384:                IComponent component = actionDefinition.getComponent();
1385:
1386:                if (debug)
1387:                    debug(Messages
1388:                            .getString(
1389:                                    "RuntimeContext.DEBUG_SETTING_LOGGING", Logger.getLogLevelName(loggingLevel))); //$NON-NLS-1$
1390:                component.setLoggingLevel(loggingLevel);
1391:                if (debug)
1392:                    debug(Messages
1393:                            .getString("RuntimeContext.DEBUG_INITIALIZING_COMPONENT")); //$NON-NLS-1$
1394:                errorLevel = component.init() ? RUNTIME_STATUS_INITIALIZE_OK
1395:                        : RUNTIME_STATUS_INITIALIZE_FAIL;
1396:                if (errorLevel != RUNTIME_STATUS_INITIALIZE_OK) {
1397:                    audit(
1398:                            MessageTypes.COMPONENT_EXECUTE_FAILED,
1399:                            MessageTypes.VALIDATION,
1400:                            Messages
1401:                                    .getErrorString("RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED"), 0); //$NON-NLS-1$
1402:                    error(Messages
1403:                            .getErrorString("RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED")); //$NON-NLS-1$
1404:                    if (listener != null) {
1405:                        listener.actionComplete(this );
1406:                    }
1407:                    return errorLevel;
1408:                }
1409:
1410:                // run the component
1411:                errorLevel = executeComponent(actionDefinition);
1412:                if (errorLevel != RUNTIME_STATUS_SUCCESS) {
1413:                    if (listener != null) {
1414:                        listener.actionComplete(this );
1415:                    }
1416:                    return errorLevel;
1417:                }
1418:
1419:                if (debug)
1420:                    debug(Messages
1421:                            .getString("RuntimeContext.DEBUG_POST-EXECUTE_AUDIT")); //$NON-NLS-1$
1422:                List auditPost = actionDefinition.getPostExecuteAuditList();
1423:                audit(auditPost);
1424:                if (audit) {
1425:                    long end = new Date().getTime();
1426:                    audit(MessageTypes.COMPONENT_EXECUTE_END, MessageTypes.END,
1427:                            "", (int) (end - start)); //$NON-NLS-1$
1428:                }
1429:
1430:                if (listener != null) {
1431:                    listener.actionComplete(this );
1432:                }
1433:                return errorLevel;
1434:            }
1435:
1436:            protected int executeComponent(IActionDefinition actionDefinition) {
1437:                if (debug)
1438:                    debug(Messages
1439:                            .getString("RuntimeContext.DEBUG_STARTING_COMPONENT_EXECUTE")); //$NON-NLS-1$
1440:                int executeStatus = RUNTIME_STATUS_FAILURE;
1441:                try {
1442:                    executeStatus = actionDefinition.getComponent().execute();
1443:                    actionDefinition.getComponent().done();
1444:                } catch (Exception e) {
1445:                    audit(MessageTypes.COMPONENT_EXECUTE_FAILED,
1446:                            MessageTypes.FAILED, e.getLocalizedMessage(), 0);
1447:                    error(
1448:                            Messages
1449:                                    .getErrorString("RuntimeContext.ERROR_0017_COMPONENT_EXECUTE_FAILED"), e); //$NON-NLS-1$
1450:                }
1451:                if (debug)
1452:                    debug(Messages
1453:                            .getString("RuntimeContext.DEBUG_FINISHED_COMPONENT_EXECUTE")); //$NON-NLS-1$
1454:                return executeStatus;
1455:            }
1456:
1457:            private int initFromActionSequenceDefinition() {
1458:
1459:                // TODO get audit setting from action sequence
1460:
1461:                int actionLogLevel = actionSequence.getLoggingLevel();
1462:                int instanceLogLevel = runtimeData.getLoggingLevel();
1463:                int actionSequenceLoggingLevel = (instanceLogLevel != UNKNOWN) ? instanceLogLevel
1464:                        : ((actionLogLevel != UNKNOWN) ? actionLogLevel
1465:                                : solutionEngine.getLoggingLevel());
1466:
1467:                setLoggingLevel(actionSequenceLoggingLevel);
1468:
1469:                return RUNTIME_CONTEXT_RESOLVE_OK;
1470:            }
1471:
1472:            private int resolveParameters() {
1473:
1474:                Set inputNames = getInputNames();
1475:                Iterator inputNamesIterator = inputNames.iterator();
1476:                IActionParameter actionParameter;
1477:                List variables;
1478:                Iterator variablesIterator;
1479:                ActionParameterSource variable;
1480:                String sourceName;
1481:                String sourceValue;
1482:                Object variableValue = null;
1483:                IParameterProvider parameterProvider;
1484:                while (inputNamesIterator.hasNext()) {
1485:                    variableValue = null;
1486:
1487:                    String inputName = (String) inputNamesIterator.next();
1488:                    actionParameter = paramManager.getCurrentInput(inputName);
1489:                    if (actionParameter == null) {
1490:                        error(Messages
1491:                                .getErrorString(
1492:                                        "RuntimeContext.ERROR_0031_INPUT_NOT_FOUND", inputName)); //$NON-NLS-1$
1493:                        return RUNTIME_CONTEXT_RESOLVE_FAIL;
1494:                    }
1495:
1496:                    variables = actionParameter.getVariables();
1497:                    variablesIterator = variables.iterator();
1498:                    while (variablesIterator.hasNext()) {
1499:                        variable = (ActionParameterSource) variablesIterator
1500:                                .next();
1501:                        sourceName = variable.getSourceName();
1502:                        sourceValue = variable.getValue();
1503:                        variableValue = null;
1504:                        // TODO support accessing the ancestors of the current instance,
1505:                        // e.g. runtme.parent
1506:                        if ("runtime".equals(sourceName)) { //$NON-NLS-1$
1507:                            // first check the standard variables
1508:                            variableValue = getStringParameter(sourceValue,
1509:                                    null);
1510:                            if (variableValue == null) {
1511:                                // now check the runtime data
1512:                                variableValue = runtimeData.getStringProperty(
1513:                                        sourceValue, null);
1514:                            }
1515:                            if (variableValue != null) {
1516:                                break;
1517:                            }
1518:                        } else {
1519:                            parameterProvider = (IParameterProvider) parameterProviders
1520:                                    .get(sourceName);
1521:                            if (parameterProvider == null) {
1522:                                warn(Messages
1523:                                        .getString(
1524:                                                "RuntimeContext.WARN_REQUESTED_PARAMETER_SOURCE_NOT_AVAILABLE", sourceName, inputName)); //$NON-NLS-1$
1525:                            } else {
1526:                                variableValue = parameterProvider
1527:                                        .getParameter(sourceValue);
1528:                                // variableValue = parameterProvider.getStringParameter(
1529:                                // sourceValue, null );
1530:                                if (variableValue != null) {
1531:                                    break;
1532:                                }
1533:                            }
1534:                        }
1535:                    } //while
1536:
1537:                    if (variableValue == null) {
1538:
1539:                        if (actionParameter.getValue() != null) {
1540:                            if (actionParameter.hasDefaultValue()) {
1541:                                trace(Messages
1542:                                        .getString(
1543:                                                "RuntimeContext.TRACE_USING_DEFAULT_PARAMETER_VALUE", inputName)); //$NON-NLS-1$
1544:                            } else {
1545:                                trace(Messages
1546:                                        .getString("RuntimeContext.TRACE_INFO_USING_CURRENT_PARAMETER_VALUE" + inputName)); //$NON-NLS-1$
1547:                            }
1548:                        } else if ("content".equals(actionParameter.getType())) { //$NON-NLS-1$
1549:                            // store a dummy value in the map
1550:                            variableValue = ""; //$NON-NLS-1$
1551:                        } else {
1552:                            error(Messages
1553:                                    .getErrorString(
1554:                                            "RuntimeContext.ERROR_0018_PARAMETER_NOT_FULFILLED", inputName)); //$NON-NLS-1$
1555:                            return RUNTIME_CONTEXT_RESOLVE_FAIL;
1556:                        }
1557:                    } else {
1558:                        actionParameter.setValue(variableValue);
1559:                    }
1560:                } // while
1561:
1562:                return RUNTIME_CONTEXT_RESOLVE_OK;
1563:            }
1564:
1565:            public void dispose() {
1566:                paramManager.dispose();
1567:            }
1568:
1569:            private int resolveOutputHandler() {
1570:
1571:                // TODO
1572:                return RUNTIME_CONTEXT_RESOLVE_OK;
1573:            }
1574:
1575:            // IParameterProvider methods
1576:            public String getStringParameter(String name, String defaultValue) {
1577:                if ("instance-id".equals(name)) { //$NON-NLS-1$
1578:                    return instanceId;
1579:                } else if ("solution-id".equals(name)) { //$NON-NLS-1$
1580:                    return solutionName;
1581:                }
1582:                return defaultValue;
1583:                // return runtimeData.getStringProperty( name, defaultValue );
1584:            }
1585:
1586:            // IRuntimeContext input and output methods
1587:
1588:            public Object getInputParameterValue(String name) {
1589:                IActionParameter actionParameter = paramManager
1590:                        .getCurrentInput(name);
1591:                if (actionParameter == null) {
1592:                    // TODO need to know from the action definition if this is ok or not
1593:                    error(Messages
1594:                            .getErrorString(
1595:                                    "RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", name, actionSequence.getSequenceName())); //$NON-NLS-1$
1596:                    throw new InvalidParameterException();
1597:                }
1598:                return actionParameter.getValue();
1599:            }
1600:
1601:            public String getInputParameterStringValue(String name) {
1602:                IActionParameter actionParameter = paramManager
1603:                        .getCurrentInput(name);
1604:                if (actionParameter == null) {
1605:                    // TODO need to know from the action definition if this is ok or not
1606:                    error(Messages
1607:                            .getErrorString(
1608:                                    "RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", name, actionSequence.getSequenceName())); //$NON-NLS-1$
1609:                    throw new InvalidParameterException();
1610:                }
1611:                return actionParameter.getStringValue();
1612:            }
1613:
1614:            // TODO Add to Param Manager - Need spcial case to grab loop param only from sequence inputs
1615:            private IActionParameter getLoopParameter(String name) {
1616:                IActionParameter actionParameter = paramManager
1617:                        .getLoopParameter(name);
1618:                if (actionParameter == null) {
1619:                    // TODO need to know from the action definition if this is ok or not
1620:                    error(Messages
1621:                            .getErrorString(
1622:                                    "RuntimeContext.ERROR_0020_INVALID_LOOP_PARAMETER", name, actionSequence.getSequenceName())); //$NON-NLS-1$
1623:                    throw new InvalidParameterException();
1624:                }
1625:                return actionParameter;
1626:            }
1627:
1628:            public IActionParameter getInputParameter(String name) {
1629:                IActionParameter actionParameter = paramManager
1630:                        .getCurrentInput(name);
1631:                if (actionParameter == null) {
1632:                    // TODO need to know from the action definition if this is ok or not
1633:                    error(Messages
1634:                            .getErrorString(
1635:                                    "RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", name, actionSequence.getSequenceName())); //$NON-NLS-1$
1636:                    throw new InvalidParameterException();
1637:                }
1638:                return actionParameter;
1639:            }
1640:
1641:            public IActionParameter getOutputParameter(String name) {
1642:                IActionParameter actionParameter = paramManager
1643:                        .getCurrentOutput(name);
1644:                if (actionParameter == null) {
1645:                    // TODO need to know from the action definition if this is ok or not
1646:                    error(Messages
1647:                            .getErrorString(
1648:                                    "RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", name, actionSequence.getSequenceName())); //$NON-NLS-1$
1649:                    throw new InvalidParameterException();
1650:                }
1651:                return actionParameter;
1652:            }
1653:
1654:            public IActionResource getResourceDefintion(String name) {
1655:                IActionResource actionResource = paramManager
1656:                        .getCurrentResource(name);
1657:
1658:                if (actionResource == null) {
1659:                    // TODO need to know from the action definition if this is ok or not
1660:                    error(Messages
1661:                            .getErrorString(
1662:                                    "RuntimeContext.ERROR_0022_INVALID_RESOURCE_REQUEST", name, actionSequence.getSequenceName())); //$NON-NLS-1$
1663:                    throw new InvalidParameterException();
1664:                }
1665:                return actionResource;
1666:            }
1667:
1668:            public Set getInputNames() {
1669:                return paramManager.getCurrentInputNames();
1670:            }
1671:
1672:            public void addTempParameter(String name, IActionParameter param) {
1673:                paramManager.addToCurrentInputs(name, param);
1674:            }
1675:
1676:            public IContentItem getOutputItem_old(String outputName,
1677:                    String mimeType, String extension) {
1678:
1679:                // TODO support content output versions in the action definition
1680:
1681:                IActionParameter outputParameter = getOutputParameter(outputName);
1682:                if (outputParameter == null) {
1683:                    error(Messages
1684:                            .getErrorString(
1685:                                    "RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", outputName, actionSequence.getSequenceName())); //$NON-NLS-1$
1686:                    throw new InvalidParameterException();
1687:                }
1688:
1689:                // If there is an output mapping, use that name to store the content
1690:                // under.
1691:                String contentName = outputName;
1692:                if (currentActionDef != null) {
1693:                    contentName = currentActionDef
1694:                            .getMappedOutputName(outputName);
1695:                    contentName = (contentName != null) ? contentName
1696:                            : outputName;
1697:                }
1698:
1699:                if (!IActionParameter.TYPE_CONTENT.equals(outputParameter
1700:                        .getType())) {
1701:                    error(Messages
1702:                            .getErrorString(
1703:                                    "RuntimeContext.ERROR_0023_INVALID_OUTPUT_STREAM", outputName)); //$NON-NLS-1$
1704:                    return null;
1705:                }
1706:
1707:                if (this .outputHandler instanceof  ContentRepositoryOutputHandler) {
1708:                    // Handling for outputting to the content repository already provided
1709:                    // by the ContentRepositoryOutputHander. If it's the current output
1710:                    // handler, use it.
1711:                    IContentItem outputItem = this .outputHandler
1712:                            .getOutputContentItem(null, contentName,
1713:                                    actionSequence.getTitle(), null,
1714:                                    solutionName, instanceId, mimeType);
1715:                    outputItem.setMimeType(mimeType);
1716:                    try {
1717:                        setOutputValue(outputName, outputItem);
1718:                        return outputItem;
1719:                    } catch (Exception e) {
1720:
1721:                    }
1722:                    return null;
1723:                }
1724:
1725:                // get an output stream to hand to the caller
1726:                IContentRepository contentRepository = PentahoSystem
1727:                        .getContentRepository(session);
1728:                if (contentRepository == null) {
1729:                    error(Messages
1730:                            .getErrorString("RuntimeContext.ERROR_0024_NO_CONTENT_REPOSITORY")); //$NON-NLS-1$
1731:                    return null;
1732:                }
1733:                String extensionFolder = extension;
1734:                if (extensionFolder.startsWith(".")) { //$NON-NLS-1$
1735:                    extensionFolder = extensionFolder.substring(1);
1736:                }
1737:                String outputFolder = actionSequence.getSequenceName()
1738:                        .substring(
1739:                                0,
1740:                                actionSequence.getSequenceName().lastIndexOf(
1741:                                        '.'));
1742:                String contentPath = getSolutionName()
1743:                        + "/" + getSolutionPath() + "/" + outputFolder + "/" + contentName + "/" + extensionFolder; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
1744:                // Find the location if it's already there.
1745:                IContentLocation contentLocation = null;
1746:                try {
1747:                    contentLocation = contentRepository
1748:                            .getContentLocationByPath(contentPath);
1749:                } catch (Exception ex) {
1750:                    // ignored
1751:                }
1752:                if (contentLocation == null) {
1753:                    contentLocation = contentRepository.newContentLocation(
1754:                            contentPath, contentName, contentName,
1755:                            getSolutionName(), true);
1756:                }
1757:                if (contentLocation == null) {
1758:                    error(Messages
1759:                            .getErrorString("RuntimeContext.ERROR_0025_INVALID_CONTENT_LOCATION")); //$NON-NLS-1$
1760:                    return null;
1761:                }
1762:                // TODO support content expiration
1763:
1764:                // TODO make the write mode based on the output definition
1765:
1766:                // Get the content item from the location - if it's there.
1767:                IContentItem contentItem = null;
1768:                try {
1769:                    contentItem = contentLocation
1770:                            .getContentItemByName(instanceId);
1771:                } catch (Exception ex) {
1772:                    // Ignored
1773:                }
1774:                if (contentItem == null) { // DM - Need to keep versions so each report
1775:                    // in a burst gets saved
1776:                    contentItem = contentLocation.newContentItem(instanceId,
1777:                            contentName, extension, mimeType, null,
1778:                            IContentItem.WRITEMODE_KEEPVERSIONS);
1779:                }
1780:
1781:                try {
1782:                    setOutputValue(outputName, contentItem);
1783:                    return contentItem;
1784:                } catch (Exception e) {
1785:
1786:                }
1787:                return null;
1788:
1789:            }
1790:
1791:            public void setOutputValue(String name, Object output) {
1792:                IActionParameter actionParameter = paramManager
1793:                        .getCurrentOutput(name);
1794:                if (actionParameter == null) {
1795:                    // TODO need to know from the action definition if this is ok or not
1796:                    error(Messages
1797:                            .getErrorString(
1798:                                    "RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", name, actionSequence.getSequenceName())); //$NON-NLS-1$
1799:                    throw new InvalidParameterException();
1800:                }
1801:                actionParameter.setValue(output);
1802:
1803:                if (output instanceof  String) {
1804:                    runtimeData.setStringProperty(name, (String) output);
1805:                } else if (output instanceof  Date) {
1806:                    runtimeData.setDateProperty(name, (Date) output);
1807:                } else if (output instanceof  Long) {
1808:                    runtimeData.setLongProperty(name, (Long) output);
1809:                } else if (output instanceof  List) {
1810:                    runtimeData.setListProperty(name, (List) output);
1811:                } else if (output instanceof  Map) {
1812:                    runtimeData.setMapProperty(name, (Map) output);
1813:                } else if (output instanceof  IContentItem) {
1814:                    runtimeData.setStringProperty(name, ((IContentItem) output)
1815:                            .getPath());
1816:                }
1817:
1818:            }
1819:
1820:            public DataSource getDataSource(String parameterName) {
1821:
1822:                // TODO Temp workaround for content repos bug
1823:                IActionParameter actionParameter = paramManager
1824:                        .getCurrentInput(parameterName);
1825:                if (actionParameter == null) {
1826:                    error(Messages
1827:                            .getErrorString(
1828:                                    "RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", parameterName, actionSequence.getSequenceName())); //$NON-NLS-1$
1829:                    throw new InvalidParameterException();
1830:                }
1831:
1832:                Object locObj = actionParameter.getValue();
1833:                if (locObj instanceof  IContentItem) { // At this point we have an IContentItem so why do anything else?
1834:                    return ((IContentItem) locObj).getDataSource();
1835:                }
1836:
1837:                String location = locObj.toString();
1838:
1839:                // get an output stream to hand to the caller
1840:                IContentRepository contentRepository = PentahoSystem
1841:                        .getContentRepository(session);
1842:                if (contentRepository == null) {
1843:                    error(Messages
1844:                            .getErrorString("RuntimeContext.ERROR_0024_NO_CONTENT_REPOSITORY")); //$NON-NLS-1$
1845:                    return null;
1846:                }
1847:
1848:                IContentItem contentItem = contentRepository
1849:                        .getContentItemByPath(location);
1850:                if (contentItem == null) {
1851:                    return null;
1852:                }
1853:
1854:                return contentItem.getDataSource();
1855:            }
1856:
1857:            public String getContentUrl(IContentItem contentItem) {
1858:                if (contentItem == null) {
1859:                    return (null);
1860:                }
1861:                String url = PentahoSystem.getApplicationContext().getBaseUrl();
1862:                return (url + "GetContent?id=" + contentItem.getId()); //$NON-NLS-1$
1863:            }
1864:
1865:            public InputStream getInputStream(String parameterName) {
1866:
1867:                IActionParameter inputParameter = getInputParameter(parameterName);
1868:
1869:                if (inputParameter == null) {
1870:                    error(Messages
1871:                            .getErrorString(
1872:                                    "RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", parameterName, actionSequence.getSequenceName())); //$NON-NLS-1$
1873:                    throw new InvalidParameterException();
1874:                }
1875:                Object value = inputParameter.getValue();
1876:                if (value instanceof  IContentItem) {
1877:                    IContentItem contentItem = (IContentItem) value;
1878:                    return contentItem.getInputStream();
1879:                } else {
1880:                    return null;
1881:                }
1882:
1883:                /*
1884:                 * // get an output stream to hand to the caller IContentRepository
1885:                 * contentRepository = PentahoSystem.getContentRepository( session );
1886:                 * if( contentRepository == null ) { error(
1887:                 * Messages.getErrorString("RuntimeContext.ERROR_0024_NO_CONTENT_REPOSITORY") );
1888:                 * //$NON-NLS-1$ return null; } String outputFolder =
1889:                 * actionSequence.getSequenceName().substring( 0,
1890:                 * actionSequence.getSequenceName().lastIndexOf('.') ); String location =
1891:                 * getSolutionName()+"/"+getSolutionPath()+"/"+outputFolder+"/"+parameterName+"/"+instanceId;
1892:                 * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ IContentItem
1893:                 * contentItem = contentRepository.getContentItemByPath( location );
1894:                 * 
1895:                 * if( contentItem == null ) { return null; }
1896:                 * 
1897:                 * return contentItem.getInputStream();
1898:                 */
1899:            }
1900:
1901:            public Set getOutputNames() {
1902:                return paramManager.getCurrentOutputNames();
1903:            }
1904:
1905:            public Set getResourceNames() {
1906:                return paramManager.getCurrentResourceNames();
1907:            }
1908:
1909:            public InputStream getResourceInputStream(
1910:                    IActionResource actionResource)
1911:                    throws FileNotFoundException {
1912:                if (isEmbeddedResource(actionResource)) {
1913:                    return (new ByteArrayInputStream(getEmbeddedResource(
1914:                            actionResource).getBytes()));
1915:                }
1916:                return PentahoSystem.getSolutionRepository(session)
1917:                        .getResourceInputStream(actionResource, true);
1918:            }
1919:
1920:            public Reader getResourceReader(IActionResource actionResource)
1921:                    throws IOException {
1922:                if (isEmbeddedResource(actionResource)) {
1923:                    String s = actionResource.getAddress();
1924:                    if (s == null) {
1925:                        s = ""; //$NON-NLS-1$
1926:                    }
1927:                    return (new InputStreamReader(new ByteArrayInputStream(
1928:                            getEmbeddedResource(actionResource).getBytes())));
1929:                }
1930:                return PentahoSystem.getSolutionRepository(session)
1931:                        .getResourceReader(actionResource);
1932:            }
1933:
1934:            public String getResourceAsString(IActionResource actionResource)
1935:                    throws IOException {
1936:                if (isEmbeddedResource(actionResource)) {
1937:                    return (getEmbeddedResource(actionResource));
1938:                }
1939:                return PentahoSystem.getSolutionRepository(session)
1940:                        .getResourceAsString(actionResource);
1941:            }
1942:
1943:            public Document getResourceAsDocument(IActionResource actionResource)
1944:                    throws IOException {
1945:                if (isEmbeddedResource(actionResource)) {
1946:                    return (XmlHelper
1947:                            .getDocFromString(getEmbeddedResource(actionResource)));
1948:                }
1949:                return PentahoSystem.getSolutionRepository(session)
1950:                        .getResourceAsDocument(actionResource);
1951:            }
1952:
1953:            public DataSource getResourceDataSource(
1954:                    IActionResource actionResource)
1955:                    throws FileNotFoundException {
1956:                //TODO Provide a datasource wrapper for string and xml
1957:                return PentahoSystem.getSolutionRepository(session)
1958:                        .getResourceDataSource(actionResource);
1959:            }
1960:
1961:            private boolean isEmbeddedResource(IActionResource actionResource) {
1962:                int type = actionResource.getSourceType();
1963:                return ((type == IActionResource.STRING) || (type == IActionResource.XML));
1964:            }
1965:
1966:            private String getEmbeddedResource(IActionResource actionResource) {
1967:                String s = actionResource.getAddress();
1968:                return ((s == null) ? "" : s); //$NON-NLS-1$
1969:            }
1970:
1971:            // IAuditable methods
1972:
1973:            public String getId() {
1974:                return handle;
1975:            }
1976:
1977:            public String getProcessId() {
1978:                return processId;
1979:            }
1980:
1981:            public String getActionName() {
1982:                return ((actionSequence != null) ? actionSequence
1983:                        .getSequenceName() : Messages
1984:                        .getString("RuntimeContext.DEBUG_NO_ACTION")); //$NON-NLS-1$
1985:            }
1986:
1987:            public String getActionTitle() {
1988:                return ((actionSequence != null) ? actionSequence.getTitle()
1989:                        : Messages.getString("RuntimeContext.DEBUG_NO_ACTION")); //$NON-NLS-1$
1990:            }
1991:
1992:            // Audit methods
1993:
1994:            public void audit(List auditList) {
1995:
1996:                if (auditList == null || auditList.size() == 0) {
1997:                    return;
1998:                }
1999:
2000:                // TODO pass in a list of parameter objects instead of parameter names
2001:                Iterator it = auditList.iterator();
2002:                while (it.hasNext()) {
2003:                    Element auditNode = (Element) it.next();
2004:                    String name = auditNode.getText();
2005:                    String value = getStringParameter(name, ""); //$NON-NLS-1$
2006:                    AuditHelper.audit(this , session,
2007:                            MessageTypes.INSTANCE_ATTRIBUTE, name, value, null,
2008:                            this );
2009:                }
2010:
2011:            }
2012:
2013:            public void audit(String messageType, String message, String value,
2014:                    long duration) {
2015:                if (!audit) {
2016:                    return;
2017:                }
2018:
2019:                if (debug)
2020:                    debug(Messages
2021:                            .getString(
2022:                                    "RuntimeContext.DEBUG_AUDIT", instanceId, getCurrentComponentName(), messageType)); //$NON-NLS-1$
2023:                AuditHelper.audit(this , session, messageType, message, value,
2024:                        new BigDecimal(((double) duration / 1000)), this );
2025:            }
2026:
2027:            public void addInputParameter(String name, IActionParameter param) {
2028:                paramManager.addToAllInputs(name, param);
2029:            }
2030:
2031:            public String applyInputsToFormat(String format) {
2032:                return TemplateUtil.applyTemplate(format, this );
2033:            }
2034:
2035:            public String applyInputsToFormat(String format,
2036:                    IParameterResolver resolver) {
2037:                return TemplateUtil.applyTemplate(format, this , resolver);
2038:            }
2039:
2040:            // Feebdack form handling
2041:
2042:            public void sendFeedbackForm() throws IOException {
2043:                try {
2044:                    if (!feedbackAllowed()) {
2045:                        return;
2046:                    }
2047:                    // add the standard parameters that we need
2048:                    createFeedbackParameter(
2049:                            "solution", "solution", "", getSolutionName(), false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2050:                    createFeedbackParameter(
2051:                            "action", "action", "", getActionName(), false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2052:                    createFeedbackParameter(
2053:                            "path", "path", "", getSolutionPath(), false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2054:                    // ProSolutionEngine proSolutionEngine = (ProSolutionEngine) solutionEngine;
2055:                    IParameterProvider parameterProvider = (IParameterProvider) parameterProviders
2056:                            .get("PRO_EDIT_SUBSCRIPTION"); //$NON-NLS-1$
2057:                    String editId = null;
2058:                    if (parameterProvider == null) { // Then we are not editing subscriptions
2059:                        parameterProvider = (IParameterProvider) parameterProviders
2060:                                .get(HttpRequestParameterProvider.SCOPE_REQUEST);
2061:                    } else {
2062:                        editId = parameterProvider.getStringParameter(
2063:                                "subscribe-id", null); //$NON-NLS-1$
2064:                    }
2065:                    Iterator parameterNameIterator = parameterProvider
2066:                            .getParameterNames();
2067:                    while (parameterNameIterator.hasNext()) {
2068:                        String name = (String) parameterNameIterator.next();
2069:                        if (!"solution".equals(name) && !"action".equals(name) && !"path".equals(name) && (xformFields.get(name) == null)) {//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$                   
2070:                            // TODO we need to check to see if this has been handled as
2071:                            // a control before adding a hidden field
2072:                            Object value = parameterProvider.getParameter(name);
2073:                            if (value != null) {
2074:                                createFeedbackParameter(name, name,
2075:                                        "", value, false); //$NON-NLS-1$
2076:                            }
2077:                        }
2078:                    }
2079:                    if (parameterXsl == null) {
2080:                        // Generate XForm for the parameters needed, transform into
2081:                        // HTML, and float it down the feedback stream
2082:                        xformBody.append("<tr><td>"); //$NON-NLS-1$
2083:                        XForm
2084:                                .createXFormSubmit(
2085:                                        PARAMETER_FORM,
2086:                                        xformBody,
2087:                                        Messages
2088:                                                .getString("RuntimeContext.USER_PARAMETER_FORM_SUBMIT")); //$NON-NLS-1$
2089:                        xformBody.append("</td></tr></table></body>"); //$NON-NLS-1$
2090:                        String html = XForm.completeXForm(
2091:                                XForm.OUTPUT_HTML_PAGE, PARAMETER_FORM,
2092:                                xformHeader, xformBody, getSession());
2093:                        if (debug)
2094:                            debug(Messages
2095:                                    .getString(
2096:                                            "RuntimeContext.DEBUG_PARAMETER_HTML", html)); //$NON-NLS-1$
2097:                        outputHandler.getFeedbackContentItem().setMimeType(
2098:                                "text/html"); //$NON-NLS-1$ 
2099:                        OutputStream os = outputHandler
2100:                                .getFeedbackContentItem().getOutputStream(
2101:                                        getActionName());
2102:                        os.write(html.getBytes());
2103:                    } else if (parameterTemplate != null) {
2104:                        String html = XForm.completeXForm(
2105:                                XForm.OUTPUT_HTML_PAGE, PARAMETER_FORM,
2106:                                xformHeader,
2107:                                new StringBuffer(parameterTemplate),
2108:                                getSession());
2109:                        if (debug)
2110:                            debug(Messages
2111:                                    .getString(
2112:                                            "RuntimeContext.DEBUG_PARAMETER_HTML", html)); //$NON-NLS-1$
2113:                        IContentItem contentItem = outputHandler
2114:                                .getFeedbackContentItem();
2115:                        contentItem.setMimeType("text/html"); //$NON-NLS-1$ 
2116:                        OutputStream os = contentItem
2117:                                .getOutputStream(getActionName());
2118:                        os.write(html
2119:                                .getBytes(LocaleHelper.getSystemEncoding()));
2120:                        contentItem.closeOutputStream();
2121:                    } else if (parameterXsl.endsWith(".xsl")) { //$NON-NLS-1$
2122:                        String id = actionSequence.getSequenceName();
2123:                        int pos = id.indexOf('.');
2124:                        if (pos > -1) {
2125:                            id = id.substring(0, pos);
2126:                        }
2127:                        // make sure the id can form a valid javascript variable or
2128:                        // function name
2129:                        id = id.replace('-', '_');
2130:                        id = id.replace(' ', '_');
2131:                        String actionUrl = urlFactory.getActionUrlBuilder()
2132:                                .getUrl();
2133:                        String displayUrl = urlFactory.getDisplayUrlBuilder()
2134:                                .getUrl();
2135:                        // String target = (parameterTarget == null) ? "" : parameterTarget; //$NON-NLS-1$
2136:                        XForm.completeXFormHeader(PARAMETER_FORM, xformHeader);
2137:                        Document document = XmlHelper
2138:                                .getDocFromString("<?xml version=\"1.0\" encoding=\"" + LocaleHelper.getSystemEncoding() + "\" ?><filters xmlns:xf=\"http://www.w3.org/2002/xforms\">" + //$NON-NLS-1$ //$NON-NLS-2$
2139:                                        xformHeader
2140:                                        + "<id><![CDATA[" + //$NON-NLS-1$
2141:                                        id
2142:                                        + "]]></id><title><![CDATA[" + //$NON-NLS-1$
2143:                                        Messages
2144:                                                .getEncodedString(actionSequence
2145:                                                        .getTitle())
2146:                                        + "]]></title><description><![CDATA[" + //$NON-NLS-1$
2147:                                        Messages
2148:                                                .getEncodedString(actionSequence
2149:                                                        .getDescription())
2150:                                        + "]]></description><icon><![CDATA[" + //$NON-NLS-1$
2151:                                        actionSequence.getIcon()
2152:                                        + "]]></icon><help><![CDATA[" + //$NON-NLS-1$
2153:                                        Messages
2154:                                                .getEncodedString(actionSequence
2155:                                                        .getHelp())
2156:                                        + "]]></help>" + //$NON-NLS-1$
2157:                                        "<action><![CDATA["
2158:                                        + actionUrl
2159:                                        + "]]></action>" + //$NON-NLS-1$ //$NON-NLS-2$
2160:                                        "<display><![CDATA["
2161:                                        + displayUrl
2162:                                        + "]]></display>" + //$NON-NLS-1$ //$NON-NLS-2$
2163:                                        ((parameterTarget != null) ? "<target>" + parameterTarget + "</target>" : "") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2164:                                        xformBody.toString() + "</filters>"); //$NON-NLS-1$ 
2165:                        // add any subscription information here
2166:                        Element root = document.getRootElement();
2167:                        Element subscriptionsNode = root
2168:                                .addElement("subscriptions"); //$NON-NLS-1$
2169:                        Element schedulesNode = root.addElement("schedules"); //$NON-NLS-1$
2170:
2171:                        /*
2172:                         * FIX FOR BISERVER-238 Ezequiel Cuellar:
2173:                         * Add "doSubscribe" attribute to the "subscriptions" element.
2174:                         * The "doSubscribe" attribute will define what logic should be performed
2175:                         * by the DefaultParameterForm.xsl 
2176:                         * */
2177:                        boolean isSubscription = (parameterProvider
2178:                                .getStringParameter("subscribepage", "no").equalsIgnoreCase("yes")) || (editId != null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2179:                        subscriptionsNode
2180:                                .addAttribute(
2181:                                        "doSubscribe", isSubscription ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2182:
2183:                        if (getSession().getName() == null) {
2184:                            subscriptionsNode.addAttribute(
2185:                                    "valid-session", "false"); //$NON-NLS-1$ //$NON-NLS-2$
2186:                        } else {
2187:                            subscriptionsNode.addAttribute(
2188:                                    "valid-session", "true"); //$NON-NLS-1$//$NON-NLS-2$
2189:                            String contentId = getSolutionName()
2190:                                    + "/" + getSolutionPath() + "/" + getActionName(); //$NON-NLS-1$//$NON-NLS-2$
2191:                            ISubscriptionRepository subscriptionRepository = PentahoSystem
2192:                                    .getSubscriptionRepository(getSession());
2193:                            if (subscriptionRepository != null) {
2194:                                try {
2195:                                    subscriptionRepository
2196:                                            .addSubscriptionsToDocument(
2197:                                                    getSession().getName(),
2198:                                                    contentId,
2199:                                                    subscriptionsNode, editId,
2200:                                                    getSession());
2201:                                    subscriptionRepository
2202:                                            .addSchedulesToDocument(
2203:                                                    getSession().getName(),
2204:                                                    contentId, schedulesNode,
2205:                                                    editId);
2206:                                } catch (Throwable t) {
2207:                                    error(
2208:                                            Messages
2209:                                                    .getErrorString("PRO_SUBSCRIPTREP.ERROR_0005_GENERAL_ERROR"), t); //$NON-NLS-1$
2210:                                }
2211:                            }
2212:                            // TODO...
2213:                        }
2214:                        Map parameters = new HashMap();
2215:                        parameters
2216:                                .put(
2217:                                        "baseUrl", PentahoSystem.getApplicationContext().getBaseUrl()); //$NON-NLS-1$
2218:                        parameters
2219:                                .put(
2220:                                        "actionUrl", this .getUrlFactory().getActionUrlBuilder().getUrl()); //$NON-NLS-1$
2221:                        parameters
2222:                                .put(
2223:                                        "displayUrl", this .getUrlFactory().getDisplayUrlBuilder().getUrl()); //$NON-NLS-1$
2224:                        // Uncomment this line for troubleshooting the XSL.
2225:                        // System .out.println( document.asXML() );
2226:                        StringBuffer content = XmlHelper.transformXml(
2227:                                parameterXsl, getSolutionName()
2228:                                        + File.separator + getSolutionPath(),
2229:                                document, parameters, getSession());
2230:
2231:                        IContentItem contentItem = outputHandler
2232:                                .getFeedbackContentItem();
2233:                        contentItem.setMimeType("text/html"); //$NON-NLS-1$ 
2234:                        OutputStream os = contentItem
2235:                                .getOutputStream(getActionName());
2236:                        os.write(content.toString().getBytes(
2237:                                LocaleHelper.getSystemEncoding()));
2238:                        contentItem.closeOutputStream();
2239:                    }
2240:                } catch (Exception e) {
2241:                    throw new IOException(
2242:                            Messages
2243:                                    .getErrorString("RuntimeContext.ERROR_0030_SEND_FEEDBACKFORM") + e.getLocalizedMessage()); //$NON-NLS-1$
2244:                }
2245:            }
2246:
2247:            private void addXFormHeader() {
2248:
2249:                XForm.createXFormHeader(PARAMETER_FORM, xformHeader);
2250:
2251:                IActionResource resource = paramManager
2252:                        .getCurrentResource(parameterXsl);
2253:
2254:                if (!parameterXsl.endsWith(".xsl") && (resource != null)) { //$NON-NLS-1$
2255:                    // load the parameter page template
2256:                    try {
2257:                        parameterTemplate = getResourceAsString(resource);
2258:                    } catch (Exception e) {
2259:                        // TODO log this
2260:                    }
2261:                }
2262:
2263:            }
2264:
2265:            /**
2266:             * @deprecated
2267:             * Unused
2268:             */
2269:            public void createFeedbackParameter(IActionParameter actionParam) {
2270:                if (actionParam.hasSelections()) {
2271:                    // TODO support display styles
2272:                    // TODO support help hints
2273:                    createFeedbackParameter(
2274:                            actionParam.getName(),
2275:                            actionParam.getSelectionDisplayName(),
2276:                            "", actionParam.getStringValue(), actionParam.getSelectionValues(), actionParam.getSelectionNameMap(), null); //$NON-NLS-1$
2277:                }
2278:            }
2279:
2280:            public void createFeedbackParameter(SelectionMapper selMap,
2281:                    String fieldName, Object defaultValues) {
2282:                createFeedbackParameter(selMap, fieldName, defaultValues, false);
2283:            }
2284:
2285:            public void createFeedbackParameter(SelectionMapper selMap,
2286:                    String fieldName, Object defaultValues, boolean optional) {
2287:                if (selMap != null) {
2288:                    // TODO support help hints
2289:                    createFeedbackParameter(
2290:                            fieldName,
2291:                            selMap.getSelectionDisplayName(),
2292:                            "", defaultValues, selMap.getSelectionValues(), selMap.getSelectionNameMap(), selMap.getDisplayStyle(), optional); //$NON-NLS-1$
2293:                }
2294:            }
2295:
2296:            public void createFeedbackParameter(String fieldName,
2297:                    String displayName, String hint, Object defaultValues,
2298:                    List values, Map dispNames, String displayStyle) {
2299:                createFeedbackParameter(fieldName, displayName, hint,
2300:                        defaultValues, values, dispNames, displayStyle, false);
2301:            }
2302:
2303:            public void createFeedbackParameter(String fieldName,
2304:                    String displayName, String hint, Object defaultValues,
2305:                    List values, Map dispNames, String displayStyle,
2306:                    boolean optional) {
2307:
2308:                // If there is a "PRO_EDIT_SUBSCRIPTION" param provider, then we must be editing a subscription so use its values
2309:                IParameterProvider parameterProvider = (IParameterProvider) parameterProviders
2310:                        .get("PRO_EDIT_SUBSCRIPTION"); //$NON-NLS-1$
2311:                if (parameterProvider != null) {
2312:                    defaultValues = parameterProvider.getParameter(paramManager
2313:                            .getActualRequestParameterName(fieldName));
2314:                }
2315:
2316:                if (values == null) {
2317:                    return;
2318:                }
2319:                if ((xformHeader == null) || (xformHeader.length() == 0)) {
2320:                    // this is the first parameter, need to create the header...
2321:                    addXFormHeader();
2322:                }
2323:
2324:                // See if the parameter is defined in the template. If so, then
2325:                // don't add it to the XForm.
2326:                if (checkForFieldInTemplate(fieldName)) {
2327:                    return;
2328:                }
2329:
2330:                int type = (values.size() < 6) ? XForm.TYPE_RADIO
2331:                        : XForm.TYPE_SELECT;
2332:                if (displayStyle != null) {
2333:                    if ("text-box".equals(displayStyle)) { //$NON-NLS-1$
2334:                        type = XForm.TYPE_TEXT;
2335:                    } else if ("radio".equals(displayStyle)) { //$NON-NLS-1$
2336:                        type = XForm.TYPE_RADIO;
2337:                    } else if ("select".equals(displayStyle)) { //$NON-NLS-1$
2338:                        type = XForm.TYPE_SELECT;
2339:                    } else if ("list".equals(displayStyle)) { //$NON-NLS-1$
2340:                        type = XForm.TYPE_LIST;
2341:                    } else if ("list-multi".equals(displayStyle)) { //$NON-NLS-1$
2342:                        type = XForm.TYPE_LIST_MULTI;
2343:                    } else if ("check-multi".equals(displayStyle)) { //$NON-NLS-1$
2344:                        type = XForm.TYPE_CHECK_MULTI;
2345:                    } else if ("check-multi-scroll".equals(displayStyle)) { //$NON-NLS-1$
2346:                        type = XForm.TYPE_CHECK_MULTI_SCROLL;
2347:                    } else if ("check-multi-scroll-2-column".equals(displayStyle)) { //$NON-NLS-1$
2348:                        type = XForm.TYPE_CHECK_MULTI_SCROLL_2_COLUMN;
2349:                    } else if ("check-multi-scroll-3-column".equals(displayStyle)) { //$NON-NLS-1$
2350:                        type = XForm.TYPE_CHECK_MULTI_SCROLL_3_COLUMN;
2351:                    } else if ("check-multi-scroll-4-column".equals(displayStyle)) { //$NON-NLS-1$
2352:                        type = XForm.TYPE_CHECK_MULTI_SCROLL_4_COLUMN;
2353:                    }
2354:
2355:                }
2356:                fieldName = paramManager
2357:                        .getActualRequestParameterName(fieldName);
2358:                if (hint == null) {
2359:                    hint = ""; //$NON-NLS-1$
2360:                }
2361:                if (parameterXsl == null) {
2362:                    // create some xform to represent this parameter...
2363:                    xformBody
2364:                            .append(Messages
2365:                                    .getString(
2366:                                            "RuntimeContext.CODE_XFORM_CONTROL_LABEL_START", displayName)); //$NON-NLS-1$
2367:                    XForm.createXFormControl(type, fieldName, defaultValues,
2368:                            values, dispNames, PARAMETER_FORM, xformHeader,
2369:                            xformBody);
2370:                    xformBody
2371:                            .append(Messages
2372:                                    .getString("RuntimeContext.CODE_XFORM_CONTROL_LABEL_END")); //$NON-NLS-1$
2373:                } else if (parameterTemplate != null) {
2374:                    StringBuffer body = new StringBuffer();
2375:                    XForm.createXFormControl(type, fieldName, defaultValues,
2376:                            values, dispNames, PARAMETER_FORM, xformHeader,
2377:                            body);
2378:                    parameterTemplate = parameterTemplate.replaceAll(
2379:                            "\\{" + fieldName + "\\}", body.toString()); //$NON-NLS-1$ //$NON-NLS-2$
2380:                } else if (parameterXsl.endsWith(".xsl")) { //$NON-NLS-1$
2381:                    StringBuffer body = new StringBuffer();
2382:                    XForm.createXFormControl(type, fieldName, defaultValues,
2383:                            values, dispNames, PARAMETER_FORM, xformHeader,
2384:                            body);
2385:                    xformBody.append("<filter"); //$NON-NLS-1$
2386:                    if (optional) {
2387:                        xformBody.append(" optional=\"true\""); //$NON-NLS-1$
2388:                    }
2389:                    xformBody
2390:                            .append("><id><![CDATA[" + fieldName + "]]></id>") //$NON-NLS-1$ //$NON-NLS-2$
2391:                            .append(
2392:                                    "<title><![CDATA[" + displayName + "]]></title>") //$NON-NLS-1$ //$NON-NLS-2$
2393:                            .append(
2394:                                    "<help><![CDATA[" + hint + "]]></help><control>") //$NON-NLS-1$ //$NON-NLS-2$
2395:                            .append(body).append("</control></filter>"); //$NON-NLS-1$
2396:                }
2397:
2398:                xformFields.put(fieldName, fieldName);
2399:
2400:            }
2401:
2402:            public boolean checkForFieldInTemplate(String fieldName) {
2403:                //
2404:                // This pattern looks for:
2405:                //
2406:                // id="fieldname"
2407:                // iD="fieldname"
2408:                // Id="fieldname"
2409:                // ID="fieldname"
2410:                // id='fieldname'
2411:                // iD='fieldname'
2412:                // Id='fieldname'
2413:                // ID='fieldname'
2414:                //
2415:                // TODO: This is actually optimistic searching as it's not looking for the
2416:                // string within the form portion of the template. IMO, to be more robust,
2417:                // this needs to at least look for something only within a form and only
2418:                // within a control on a form.
2419:                if ((parameterTemplate == null)
2420:                        || (parameterTemplate.length() == 0)) {
2421:                    return false;
2422:                }
2423:                String regex = "[iI][dD]=[\'\"]" + fieldName + "[\'\"]"; //$NON-NLS-1$ //$NON-NLS-2$
2424:                Pattern pattern = null;
2425:                // Normally shouldn't need to synchronize. But, a Java bug in
2426:                // pattern compilation on multi-processor machines results in the 
2427:                // need to synchronize a small block of code. If/when this problem 
2428:                // is fixed, we can remove this synchronization lock.
2429:                // See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6238699
2430:                synchronized (PATTERN_COMPILE_LOCK) {
2431:                    pattern = Pattern.compile(regex);
2432:                }
2433:                Matcher matcher = pattern.matcher(parameterTemplate);
2434:                if (matcher.find()) {
2435:                    return true;
2436:                }
2437:                return false;
2438:            }
2439:
2440:            public void createFeedbackParameter(String fieldName,
2441:                    String displayName, String hint, Object defaultValue,
2442:                    boolean visible) {
2443:                createFeedbackParameter(fieldName, displayName, hint,
2444:                        defaultValue, visible, false);
2445:            }
2446:
2447:            public void createFeedbackParameter(String fieldName,
2448:                    String displayName, String hint, Object defaultValue,
2449:                    boolean visible, boolean optional) {
2450:
2451:                // If there is a "PRO_EDIT_SUBSCRIPTION" param provider, then we must be editing a subscription so use its values
2452:                IParameterProvider parameterProvider = (IParameterProvider) parameterProviders
2453:                        .get("PRO_EDIT_SUBSCRIPTION"); //$NON-NLS-1$
2454:                if (parameterProvider != null) {
2455:                    Object newValue = parameterProvider
2456:                            .getParameter(paramManager
2457:                                    .getActualRequestParameterName(fieldName));
2458:                    defaultValue = newValue == null ? defaultValue : newValue;
2459:                }
2460:
2461:                if ((xformHeader == null) || (xformHeader.length() == 0)) {
2462:                    // this is the first parameter, need to create the header...
2463:                    addXFormHeader();
2464:                }
2465:                if (parameterTemplate != null) {
2466:                    // see if the parameter is defined in the HTML template
2467:                    if (checkForFieldInTemplate(fieldName)) {
2468:                        return;
2469:                    }
2470:                }
2471:                if (hint == null) {
2472:                    hint = ""; //$NON-NLS-1$
2473:                }
2474:                fieldName = paramManager
2475:                        .getActualRequestParameterName(fieldName);
2476:                if (parameterXsl == null) {
2477:                    // create some xform to represent this parameter...
2478:
2479:                    if (visible) {
2480:                        xformBody
2481:                                .append(Messages
2482:                                        .getString(
2483:                                                "RuntimeContext.CODE_XFORM_CONTROL_LABEL_START", displayName)); //$NON-NLS-1$
2484:                        // xformBody.append( "<tr><td class=\"portlet-font\">").append(
2485:                        // displayName ).append("</td><td class=\"portlet-font\">"
2486:                        // );//$NON-NLS-1$ //$NON-NLS-2$
2487:                    }
2488:                    XForm.createXFormControl(fieldName, defaultValue,
2489:                            PARAMETER_FORM, xformHeader, xformBody, visible);
2490:                    if (visible) {
2491:                        xformBody
2492:                                .append(Messages
2493:                                        .getString("RuntimeContext.CODE_XFORM_CONTROL_LABEL_END")); //$NON-NLS-1$
2494:                        // xformBody.append( "</td></tr>" ); //$NON-NLS-1$
2495:                    }
2496:                } else if (parameterTemplate != null) {
2497:                    StringBuffer body = new StringBuffer();
2498:                    if (visible) {
2499:                        XForm.createXFormControl(fieldName, defaultValue,
2500:                                PARAMETER_FORM, xformHeader, body, visible);
2501:                    } else {
2502:                        try {
2503:                            if (defaultValue instanceof  Object[]) {
2504:                                setObjectArrayParameters(fieldName,
2505:                                        (Object[]) defaultValue);
2506:                            }
2507:                            String value = defaultValue.toString().replaceAll(
2508:                                    "&", "&amp;"); //$NON-NLS-1$//$NON-NLS-2$
2509:                            value = value.replaceAll("\"", "''"); //$NON-NLS-1$ //$NON-NLS-2$
2510:                            body
2511:                                    .append("<input type=\"hidden\" name=\"" + fieldName + "\" value=\"" + value + "\"></input>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2512:                        } catch (Exception e) {
2513:                            body
2514:                                    .append("<input type=\"hidden\" name=\"" + fieldName + "\" value=\"" + defaultValue + "\"></input>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2515:                        }
2516:                    }
2517:                    parameterTemplate = parameterTemplate.replaceAll(
2518:                            "\\{" + fieldName + "\\}", body.toString()); //$NON-NLS-1$ //$NON-NLS-2$
2519:                } else {
2520:                    if (visible) {
2521:                        StringBuffer body = new StringBuffer();
2522:                        XForm.createXFormControl(fieldName, defaultValue,
2523:                                PARAMETER_FORM, xformHeader, body, visible);
2524:                        xformBody.append("<filter"); //$NON-NLS-1$
2525:                        if (optional) {
2526:                            xformBody.append(" optional=\"true\""); //$NON-NLS-1$
2527:                        }
2528:                        xformBody
2529:                                .append(
2530:                                        "><id><![CDATA[" + fieldName + "]]></id>") //$NON-NLS-1$ //$NON-NLS-2$
2531:                                .append(
2532:                                        "<title><![CDATA[" + displayName + "]]></title>") //$NON-NLS-1$ //$NON-NLS-2$
2533:                                .append(
2534:                                        "<help><![CDATA[" + hint + "]]></help><control>") //$NON-NLS-1$ //$NON-NLS-2$
2535:                                .append(body).append("</control></filter>"); //$NON-NLS-1$
2536:
2537:                    } else {
2538:                        try {
2539:                            if (defaultValue instanceof  Object[]) {
2540:                                setObjectArrayParameters(fieldName,
2541:                                        (Object[]) defaultValue);
2542:                            } else {
2543:                                // String value = URLEncoder.encode(defaultValue, "UTF-8" );
2544:                                // //$NON-NLS-1$
2545:                                String value = defaultValue.toString()
2546:                                        .replaceAll("&", "&amp;"); //$NON-NLS-1$//$NON-NLS-2$
2547:                                value = value.replaceAll("\"", "''"); //$NON-NLS-1$ //$NON-NLS-2$
2548:                                xformBody
2549:                                        .append("<input type=\"hidden\" name=\"" + fieldName + "\" value=\"" + value + "\"></input>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2550:                            }
2551:                        } catch (Exception e) {
2552:                            xformBody
2553:                                    .append("<input type=\"hidden\" name=\"" + fieldName + "\" value=\"" + defaultValue + "\"></input>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2554:                        }
2555:                    }
2556:                }
2557:                xformFields.put(fieldName, fieldName);
2558:            }
2559:
2560:            private void setObjectArrayParameters(String fieldName,
2561:                    Object[] values) {
2562:                for (int i = 0; i < values.length; i++) {
2563:                    String value = values[i].toString()
2564:                            .replaceAll("&", "&amp;"); //$NON-NLS-1$//$NON-NLS-2$
2565:                    value = value.replaceAll("\"", "''"); //$NON-NLS-1$ //$NON-NLS-2$
2566:                    xformBody
2567:                            .append("<input type=\"hidden\" name=\"" + fieldName + "\" value=\"" + value + "\"></input>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
2568:                }
2569:            }
2570:
2571:            public void setParameterXsl(String xsl) {
2572:                this .parameterXsl = xsl;
2573:            }
2574:
2575:            public void setParameterTarget(String target) {
2576:                this .parameterTarget = target;
2577:            }
2578:
2579:            public String getLogId() {
2580:                return logId;
2581:            }
2582:
2583:            /**
2584:             * Forces the immediate write of runtime data to underlying persistence
2585:             * mechanism. In the case of using Hibernate for the runtime data
2586:             * persistence, this works out to a call to HibernateUtil.flush().
2587:             */
2588:            public void forceSaveRuntimeData() {
2589:                if (runtimeData != null) {
2590:                    runtimeData.forceSave();
2591:                }
2592:            }
2593:
2594:            /**
2595:             * Gets the output type preferred by the handler. Values are defined in
2596:             * org.pentaho.core.solution.IOutputHander and are OUTPUT_TYPE_PARAMETERS,
2597:             * OUTPUT_TYPE_CONTENT, or OUTPUT_TYPE_DEFAULT
2598:             * 
2599:             * @return Output type
2600:             */
2601:            public int getOutputPreference() {
2602:                return outputHandler.getOutputPreference();
2603:            }
2604:
2605:            public void setOutputHandler(IOutputHandler outputHandler) {
2606:                this .outputHandler = outputHandler;
2607:            }
2608:
2609:            public IActionSequence getActionSequence() {
2610:                return actionSequence;
2611:            }
2612:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.