/** * Set the parameters to the supplied value. The supplied parameters value may suppliment or * replace the existing parameters value. * * @param parameters the supplied parameters * @param merge if TRUE the supplied parameters are merged with existing parameters otherwise the * supplied parameters replace any existing parameters * @exception IllegalStateException if the component type backing the model does not implement the * parameteriazable interface * @exception NullPointerException if the supplied parameters are null */ public void setParameters(Parameters parameters, boolean merge) throws IllegalStateException { if (!isParameterizable()) { final String error = REZ.getString( "deployment.parameters.irrational", getDeploymentClass().getName(), this.toString()); throw new IllegalStateException(error); } if (parameters == null) { throw new NullPointerException("parameters"); } if (merge) { Properties props = Parameters.toProperties(m_parameters); Properties suppliment = Parameters.toProperties(parameters); Enumeration list = suppliment.propertyNames(); while (list.hasMoreElements()) { String name = (String) list.nextElement(); String value = suppliment.getProperty(name); if (value == null) { props.remove(name); } else { props.setProperty(name, value); } } m_parameters = Parameters.fromProperties(props); } else { m_parameters = parameters; } }
@Override public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) { if (log.isDebugEnabled()) log.debug("begin setup"); try { super.setup(resolver, objectModel, src, par); ContextManager cm = (ContextManager) this.manager.lookup(ContextManager.ROLE); try { if (cm.hasSessionContext()) { cm.deleteContext("authentication"); } } catch (Exception exe) { } userid = par.getParameter("username", null); password = par.getParameter("password", null); try { String jaasRealmTmp = par.getParameter("jaasRealm", null); if (jaasRealmTmp != null && !jaasRealmTmp.equalsIgnoreCase("")) { jaasRealm = jaasRealmTmp; } } catch (Exception se) { } try { String toUpper = par.getParameter("toUpperCase", null); if (toUpper != null && !toUpper.equalsIgnoreCase("true")) { userid = userid.toUpperCase(); } } catch (Exception se) { } if (log.isDebugEnabled()) log.debug("trying to login as " + userid + " on the webpage"); } catch (Exception ex) { new ProcessingException(ex.getMessage()); } if (log.isDebugEnabled()) log.debug("end setup"); }
@Override public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, parameters); authorized = true; try { String stepID = parameters.getParameter("step_id"); String beanID = parameters.getParameter("bean_id"); int workspaceID = Integer.valueOf(parameters.getParameter("workspace_item_id").substring(1)); WorkspaceService wi = WorkspaceService.find(context, workspaceID); SubmissionProcess process = SubmissionProcessFactory.getSubmissionProcess(context, wi.getCollection()); SubmissionStep step = process.getStep(context, Integer.parseInt(stepID)); xmluiActionUI = (AbstractXMLUIAction) SubmissionProcessXMLUIFactory.getActionInterface(beanID); // authorized = step.getActionConfig(beanID).getProcessingAction().isAuthorized(context, // ObjectModelHelper.getRequest(objectModel), wi); if (xmluiActionUI != null) xmluiActionUI.setup(resolver, objectModel, src, parameters); // else // throw new ProcessingException("SubmissionStep class is null! We do not have // a valid AbstractStep in " + this.transformerClassName + ". "); } catch (Exception e) { log.error( LogManager.getHeader(context, "error while setting up SubmissionTransformer", ""), e); e.printStackTrace(); throw new ProcessingException("Something went wrong while setting up the workflow"); } // TODO: throw exception ! }
/** * Return the parameters to be applied to the component. * * @return the assigned parameters */ public Parameters getParameters() { Parameters params = new Parameters(); if (null != m_parameters) { params.merge(m_parameters); } params.makeReadOnly(); return params; }
/** * Create a Parameters object. The first value of each parameter is added to the Parameters * object. * * @return An Parameters object - if no parameters are defined this is an empty object. */ public static Parameters getFirstParameters(SourceParameters params) { Parameters result = new Parameters(); Iterator iter = params.getParameterNames(); String parName; while (iter.hasNext()) { parName = (String) iter.next(); result.setParameter(parName, params.getParameter(parName)); } return result; }
public Map act( Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters par) throws Exception { if (this.getLogger().isDebugEnabled()) { this.getLogger() .debug( "BEGIN act resolver=" + resolver + ", objectModel=" + objectModel + ", source=" + source + ", par=" + par); } int mode; final String modeString = par.getParameter("mode", "if-not-authenticated"); if (modeString.equals("if-not-authenticated")) { mode = AuthenticationConstants.LOGOUT_MODE_IF_NOT_AUTHENTICATED; } else if (modeString.equalsIgnoreCase("if-unused")) { mode = AuthenticationConstants.LOGOUT_MODE_IF_UNUSED; } else if (modeString.equalsIgnoreCase("immediately")) { mode = AuthenticationConstants.LOGOUT_MODE_IMMEDIATELY; } else { throw new ProcessingException("Unknown mode " + modeString); } // logout AuthenticationManager authManager = null; try { authManager = (AuthenticationManager) this.manager.lookup(AuthenticationManager.ROLE); RequestState state = authManager.getState(); final String handlerName = par.getParameter("handler", (state == null ? null : state.getHandlerName())); if (null == handlerName) { throw new ProcessingException("LogoutAction requires at least the handler parameter."); } authManager.logout(handlerName, mode); } finally { this.manager.release(authManager); } if (this.getLogger().isDebugEnabled()) { this.getLogger().debug("END act map={}"); } return EMPTY_MAP; }
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, parameters); this.exception = parameters.getParameter("exception", super.source); this.code = Integer.parseInt(parameters.getParameter("code", "0")); // Throw exception in the setup phase? if (parameters.getParameterAsBoolean("setup", false)) { ExceptionAction.exception(this.exception, this.code); } }
/** * Set the <code>SourceResolver</code>, the <code>Map</code> with the object model, the source and * sitemap <code>Parameters</code> used to process the request. */ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws SAXException, ProcessingException, IOException { if (src == null && defaultSrc != null) { if (getLogger().isDebugEnabled()) { getLogger().debug("src is null, using default source " + defaultSrc); } src = defaultSrc; } if (src == null) { throw new ProcessingException("Stylesheet URI can't be null"); } this.par = par; this.objectModel = objectModel; this.resolver = resolver; try { this.inputSource = resolver.resolveURI(src); } catch (SourceException se) { throw SourceUtil.handle("Unable to resolve " + src, se); } _useParameters = par.getParameterAsBoolean("use-request-parameters", this.useParameters); _useCookies = par.getParameterAsBoolean("use-cookies", this.useCookies); _useSessionInfo = par.getParameterAsBoolean("use-session-info", this.useSessionInfo); final boolean _checkIncludes = par.getParameterAsBoolean("check-includes", this.checkIncludes); if (getLogger().isDebugEnabled()) { getLogger().debug("Using stylesheet: '" + this.inputSource.getURI() + "' in " + this); getLogger().debug("Use parameters is " + this._useParameters); getLogger().debug("Use cookies is " + this._useCookies); getLogger().debug("Use session info is " + this._useSessionInfo); getLogger().debug("Check for included stylesheets is " + _checkIncludes); } // Get a Transformer Handler if we check for includes // If we don't check the handler is get during setConsumer() try { if (_checkIncludes) { XSLTProcessor.TransformerHandlerAndValidity handlerAndValidity = this.xsltProcessor.getTransformerHandlerAndValidity(this.inputSource, null); this.transformerHandler = handlerAndValidity.getTransfomerHandler(); this.transformerValidity = handlerAndValidity.getTransfomerValidity(); } else { this.transformerValidity = this.inputSource.getValidity(); } } catch (XSLTProcessorException se) { throw new ProcessingException( "Unable to get transformer handler for " + this.inputSource.getURI(), se); } }
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { this.objectModel = objectModel; try { this.key = par.getParameter("key"); } catch (ParameterException e) { throw new CascadingRuntimeException("Could not find parameter key", e); } }
public Object getSelectorContext(Map objectModel, Parameters parameters) { String name = parameters.getParameter("parameter-name", this.defaultName); if (name == null) { getLogger().warn("No parameter name given -- failing."); return null; } return ObjectModelHelper.getRequest(objectModel).getParameter(name); }
/** * Append parameters to the uri. Each parameter is appended to the uri with "parameter=value", the * parameters are separated by "&". */ public static String appendParameters(String uri, Parameters parameters) { if (parameters != null) { StringBuffer buffer = new StringBuffer(uri); String[] keys = parameters.getNames(); String current; char separator = (uri.indexOf("?") == -1 ? '?' : '&'); if (keys != null) { for (int i = 0; i < keys.length; i++) { current = keys[i]; buffer .append(separator) .append(current) .append('=') .append(SourceUtil.encode(parameters.getParameter(current, null))); separator = '&'; } } return buffer.toString(); } return uri; }
/** * Set the SourceResolver, objectModel Map, the source and sitemap Parameters used to process the * request. * * @param resolver Source resolver * @param objectmodel Object model * @param src Source * @param parameters Parameters * @throws IOException * @throws ProcessingException * @throws SAXException */ public void setup(SourceResolver resolver, Map objectmodel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectmodel, src, parameters); try { this.encoding = parameters.getParameter("encoding", null); this.inputSource = resolver.resolveURI(src); String nXmlCh = parameters.getParameter("nonXmlChars", String.valueOf(initNonXmlChars)); if (nXmlCh.length() != initNonXmlChars.length) throw new ProcessingException( "Error during resolving of '" + src + "'.", new SourceException( "length of attribute string 'nonXmlChars' is " + nXmlCh.length() + " where it should be " + initNonXmlChars.length + "!")); this.nonXmlChars = nXmlCh.toCharArray(); } catch (SourceException se) { throw new ProcessingException("Error during resolving of '" + src + "'.", se); } }
/** Setup this component, passing the tag names to be tidied. */ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); String tagsParam = par.getParameter("tags", ""); if (getLogger().isDebugEnabled()) { getLogger().debug("tags: " + tagsParam); } this.tags = new HashMap(); StringTokenizer tokenizer = new StringTokenizer(tagsParam, ","); while (tokenizer.hasMoreElements()) { String tok = tokenizer.nextToken().trim(); this.tags.put(tok, tok); } }
public void parameterize(Parameters params) throws ParameterException { this.m_namespace = params.getParameter("namespace", DEFAULT_PROPERTY_NS); this.m_propertyname = params.getParameter("name", DEFAULT_PROPERTY_NAME); this.m_extension = params.getParameter("extension", ".xml"); this.m_xpath = params.getParameter("xpath", "/*"); }
/** * Provide component with parameters. * * @param parameters the parameters * @throws ParameterException if parameters are invalid */ public void parameterize(Parameters parameters) throws ParameterException { this.localizable = parameters.getParameterAsBoolean("localizable", false); }
public Event createEvent(Parameters params) throws ParameterException { final String name = params.getParameter(EVENT_NAME_PARAM); final String value = params.getParameter(EVENT_VALUE_PARAM); return new NameValueEvent(name, value); }
/** Get the parameters for the logicsheet */ protected Map getLogicSheetParameters() { if (this.logicSheetParameters != null) { return this.logicSheetParameters; } HashMap map = null; if (par != null) { String[] params = par.getNames(); if (params != null) { for (int i = 0; i < params.length; i++) { String name = params[i]; if (isValidXSLTParameterName(name)) { String value = par.getParameter(name, null); if (value != null) { if (map == null) { map = new HashMap(params.length); } map.put(name, value); } } } } } if (this._useParameters) { Request request = ObjectModelHelper.getRequest(objectModel); Enumeration parameters = request.getParameterNames(); if (parameters != null) { while (parameters.hasMoreElements()) { String name = (String) parameters.nextElement(); if (isValidXSLTParameterName(name)) { String value = request.getParameter(name); if (map == null) { map = new HashMap(); } map.put(name, value); } } } } if (this._useSessionInfo) { final Request request = ObjectModelHelper.getRequest(objectModel); if (map == null) { map = new HashMap(6); } final Session session = request.getSession(false); if (session != null) { map.put("session-available", "true"); map.put("session-is-new", BooleanUtils.toStringTrueFalse(session.isNew())); map.put( "session-id-from-cookie", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromCookie())); map.put( "session-id-from-url", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromURL())); map.put( "session-valid", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdValid())); map.put("session-id", session.getId()); } else { map.put("session-available", "false"); } } if (this._useCookies) { Request request = ObjectModelHelper.getRequest(objectModel); Cookie cookies[] = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { String name = cookies[i].getName(); if (isValidXSLTParameterName(name)) { String value = cookies[i].getValue(); if (map == null) { map = new HashMap(cookies.length); } map.put(name, value); } } } } this.logicSheetParameters = map; return this.logicSheetParameters; }
/** * Creation of a new deployment model. * * @param context the deployment context */ public DefaultComponentModel(ComponentContext context, SecurityModel security) throws ModelException { super(context, security); m_context = context; m_activation = getDefaultActivationPolicy(); setCollectionPolicy(m_context.getComponentProfile().getCollectionPolicy()); ClassLoader classLoader = m_context.getClassLoader(); if (isConfigurable()) { final Configuration defaults = m_context.getType().getConfiguration(); final Configuration explicit = m_context.getComponentProfile().getConfiguration(); final Configuration consolidated = consolidateConfigurations(explicit, defaults); if (consolidated != null) { m_config = consolidated; } else { m_config = EMPTY_CONFIGURATION; } } if (isParameterizable()) { Parameters staticDefaults = m_context.getType().getParameters(); final Parameters parameters = m_context.getComponentProfile().getParameters(); if (parameters != null) { if (null == staticDefaults) { m_parameters = parameters; } else { m_parameters = new Parameters(); m_parameters.merge(staticDefaults); m_parameters.merge(parameters); } } else { if (null == staticDefaults) { m_parameters = Parameters.EMPTY_PARAMETERS; } else { m_parameters = staticDefaults; } } } final ContextDescriptor contextDescriptor = m_context.getType().getContext(); final ContextDirective contextDirective = m_context.getComponentProfile().getContext(); final Logger log = getLogger().getChildLogger("context"); m_contextModel = new DefaultContextModel(log, contextDescriptor, contextDirective, context); // // create the dependency models for subsequent assembly // management // DependencyDescriptor[] dependencies = m_context.getType().getDependencies(); m_dependencies = new DefaultDependencyModel[dependencies.length]; for (int i = 0; i < dependencies.length; i++) { DependencyDescriptor descriptor = dependencies[i]; DependencyDirective directive = context.getComponentProfile().getDependencyDirective(descriptor.getKey()); m_dependencies[i] = new DefaultDependencyModel( context.getLogger().getChildLogger("deps"), context.getPartitionName(), context.getProfile().getName(), descriptor, directive); } // // create the stage models for subsequent assembly // management // StageDescriptor[] stages = m_context.getType().getStages(); m_stages = new DefaultStageModel[stages.length]; for (int i = 0; i < stages.length; i++) { StageDescriptor descriptor = stages[i]; StageDirective directive = context.getComponentProfile().getStageDirective(descriptor.getKey()); m_stages[i] = new DefaultStageModel( context.getLogger().getChildLogger("stages"), context.getPartitionName(), descriptor, directive); } }