/* (non-Javadoc)
@see org.apereo.portal.url.processing.IRequestParameterProcessor#processParameters(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
966431
@Override
    public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
        final IPortalRequestInfo portalRequestInfo =
                this.urlSyntaxProvider.getPortalRequestInfo(request);

        final IPortletWindowId targetedPortletWindowId =
                portalRequestInfo.getTargetedPortletWindowId();

        for (final IPortletRequestInfo portletRequestInfo :
                portalRequestInfo.getPortletRequestInfoMap().values()) {
            final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
            final IPortletWindow portletWindow =
                    this.portletWindowRegistry.getPortletWindow(request, targetedPortletWindowId);

            final UrlType urlType = portalRequestInfo.getUrlType();
            switch (urlType) {
                case RENDER:
                    {
                        final Map<String, List<String>> portletParameters =
                                portletRequestInfo.getPortletParameters();
                        portletWindow.setRenderParameters(
                                ParameterMap.convertListMap(portletParameters));

                        // fall through, render uses state/mode info
                    }
                case ACTION:
                    {
                        final WindowState windowState = portletRequestInfo.getWindowState();
                        if (windowState != null) {
                            portletWindow.setWindowState(windowState);
                        }

                        final PortletMode portletMode = portletRequestInfo.getPortletMode();
                        if (portletMode != null) {
                            portletWindow.setPortletMode(portletMode);
                        }

                        break;
                    }

                default:
                    // Do nothing
            }

            // Override the window state of the targeted portlet window based on the url state
            if (portletWindowId.equals(targetedPortletWindowId)) {
                final UrlState urlState = portalRequestInfo.getUrlState();
                switch (urlState) {
                    case MAX:
                        {
                            portletWindow.setWindowState(WindowState.MAXIMIZED);
                            break;
                        }
                    case DETACHED:
                        {
                            portletWindow.setWindowState(IPortletRenderer.DETACHED);
                            break;
                        }
                    case EXCLUSIVE:
                        {
                            portletWindow.setWindowState(IPortletRenderer.EXCLUSIVE);
                            break;
                        }
                    default:
                        // Do nothing
                }
            }

            this.portletWindowRegistry.storePortletWindow(request, portletWindow);
        }

        return true;
    }
148311
@Override
  public void processResponse(CloseableHttpResponse response) throws IOException, UnexpectedResponseException {
    if (response.getStatusLine().getStatusCode() >= 400) {
      if (response.getEntity() != null) {
        throw new RuntimeException("Failed. " + EntityUtils.toString(response.getEntity())
                                 + " , response: " + ToStringBuilder.reflectionToString(response, ToStringStyle.SHORT_PREFIX_STYLE));
      }
      throw new RuntimeException("Failed. Response: " + ToStringBuilder.reflectionToString(response, ToStringStyle.SHORT_PREFIX_STYLE));
    }
  }
1249747
private void process() {
    Entity entity = entityClass.getAnnotation(Entity.class);
    ProjectedEntity projectedEntity = entityClass.getAnnotation(ProjectedEntity.class);
    if (entity != null) {
      initEntityMetadata(entity);
    } else if (projectedEntity != null) {
      initEntityMetadata(projectedEntity);
    } else {
      String message = String.format("Class %s must either have %s or %s annotation",
          entityClass.getName(), Entity.class.getName(), ProjectedEntity.class.getName());
      throw new EntityManagerException(message);
    }

    processPropertyOverrides();

    processFields();
    // If we did not find valid Identifier...
    if (entityMetadata.getIdentifierMetadata() == null) {
      throw new EntityManagerException(
          String.format("Class %s requires a field with annotation of %s", entityClass.getName(),
              Identifier.class.getName()));
    }
    entityMetadata.setEntityListenersMetadata(EntityListenersIntrospector.introspect(entityClass));
    entityMetadata.ensureUniqueProperties();
    entityMetadata.cleanup();
  }
103318
private Object processParam(TemplateParam<?, ?, ?> param, Map<String, Object> params, Template<?> template) {
		Object value = fetchParamValue(param, params, param.getFetcher());
		value = convertParamValue(value, param.getType(), param.getConverter());
		validateParamValue(value, param.getValidator());
		return value;
	}
1109273
private void processParameters() throws BadElementException, IOException {
        type = IMGTEMPLATE;
        originalType = ORIGINAL_WMF;
        InputStream is = null;
        try {
            String errorID;
            if (rawData == null){
                is = url.openStream();
                errorID = url.toString();
            }
            else{
                is = new java.io.ByteArrayInputStream(rawData);
                errorID = "Byte array";
            }
            InputMeta in = new InputMeta(is);
            if (in.readInt() != 0x9AC6CDD7)	{
                throw new BadElementException(errorID + " is not a valid placeable windows metafile.");
            }
            in.readWord();
            int left = in.readShort();
            int top = in.readShort();
            int right = in.readShort();
            int bottom = in.readShort();
            int inch = in.readWord();
            dpiX = 72;
            dpiY = 72;
            scaledHeight = (float)(bottom - top) / inch * 72f;
            setTop(scaledHeight);
            scaledWidth = (float)(right - left) / inch * 72f;
            setRight(scaledWidth);
        }
        finally {
            if (is != null) {
                is.close();
            }
            plainWidth = getWidth();
            plainHeight = getHeight();
        }
    }
340642
@NotNull
  @SuppressWarnings({ "null", "unused" })
  Link processRequest(@NotNull LinkRequest linkRequest) {

    // detect link type - first accepting wins
    LinkType linkType = null;
    List<Class<? extends LinkType>> linkTypes = linkHandlerConfig.getLinkTypes();
    if (linkTypes == null || linkTypes.isEmpty()) {
      throw new RuntimeException("No link types defined.");
    }
    for (Class<? extends LinkType> candidateLinkTypeClass : linkTypes) {
      LinkType candidateLinkType = AdaptTo.notNull(adaptable, candidateLinkTypeClass);
      if (candidateLinkType.accepts(linkRequest)) {
        linkType = candidateLinkType;
        break;
      }
    }
    Link link = new Link(linkType, linkRequest);

    // preprocess link before resolving
    List<Class<? extends LinkProcessor>> linkPreProcessors = linkHandlerConfig.getPreProcessors();
    if (linkPreProcessors != null) {
      for (Class<? extends LinkProcessor> processorClass : linkPreProcessors) {
        LinkProcessor processor = AdaptTo.notNull(adaptable, processorClass);
        link = processor.process(link);
        if (link == null) {
          throw new RuntimeException("LinkPreProcessor '" + processor + "' returned null, page '" + (currentPage != null ? currentPage.getPath() : "-") + "'.");
        }
      }
    }

    // resolve link
    if (linkType != null) {
      link = linkType.resolveLink(link);
      if (link == null) {
        throw new RuntimeException("LinkType '" + linkType + "' returned null, page '" + (currentPage != null ? currentPage.getPath() : "-") + "'.");
      }
    }

    // generate markup (if markup builder is available) - first accepting wins
    List<Class<? extends LinkMarkupBuilder>> linkMarkupBuilders = linkHandlerConfig.getMarkupBuilders();
    if (linkMarkupBuilders != null) {
      for (Class<? extends LinkMarkupBuilder> linkMarkupBuilderClass : linkMarkupBuilders) {
        LinkMarkupBuilder linkMarkupBuilder = AdaptTo.notNull(adaptable, linkMarkupBuilderClass);
        if (linkMarkupBuilder.accepts(link)) {
          link.setAnchor(linkMarkupBuilder.build(link));
          break;
        }
      }
    }

    // postprocess link after resolving
    List<Class<? extends LinkProcessor>> linkPostProcessors = linkHandlerConfig.getPostProcessors();
    if (linkPostProcessors != null) {
      for (Class<? extends LinkProcessor> processorClass : linkPostProcessors) {
        LinkProcessor processor = AdaptTo.notNull(adaptable, processorClass);
        link = processor.process(link);
        if (link == null) {
          throw new RuntimeException("LinkPostProcessor '" + processor + "' returned null, page '" + (currentPage != null ? currentPage.getPath() : "-") + "'.");
        }
      }
    }

    return link;
  }
326487
protected void processRequest(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        //get user's credentials from the request
        String uname = request.getParameter("j_username");
        String pass = request.getParameter("j_password");

        try {
            //validate given user using container's login mechanism
            request.login(uname, pass);

            ServletContext context = getServletConfig().getServletContext();
            
            //put user's credentials in the servlet context
            context.setAttribute("uname", uname);
            context.setAttribute("password", pass);
            
            //forward request to the initial page
            response.sendRedirect(request.getContextPath() + "/Console.html");
        } catch (ServletException e) {
            //login failed to forward user to the login form
            response.sendRedirect(request.getContextPath() + "/loginform.html");
        }
    }
667039
public void processParameters(final List<Object> parameters, final boolean isFetchAll, final DatabaseType databaseType) {
        fill(parameters);
        rewrite(parameters, isFetchAll, databaseType);
    }
948558
private void initParameters(ProcessingParameters pParams) {
        processingConfig = pParams;
        String ignoreErrors = processingConfig.get(ConfigKey.IGNORE_ERRORS);
        if (ignoreErrors != null && ignoreErrors.matches("^(true|yes|on|1)$")) {
            valueFaultHandler = ValueFaultHandler.IGNORING_VALUE_FAULT_HANDLER;
        } else {
            valueFaultHandler = ValueFaultHandler.THROWING_VALUE_FAULT_HANDLER;
        }
    }
284564
protected void process( HttpServletRequest request, HttpServletResponse response )
        throws IOException, ServletException
    {
        //
        // First wrap the request with an object that contains request-scoped values that our runtime uses.  This
        // is faster than sticking everything into attributes on the request (then basically reading from a HashMap).
        //
        PageFlowRequestWrapper requestWrapper = PageFlowRequestWrapper.wrapRequest( request );
        request = requestWrapper;
        
        ServletContext servletContext = getServletContext();
        String modulePath = PageFlowUtils.getModulePathForRelativeURI( InternalUtils.getDecodedServletPath( request ) );
        ModuleConfig registeredApp;
        
        //
        // Get the registered Struts module for the request.
        //
        registeredApp = getModuleConfig( modulePath, request, response );
        
        //
        // If we've dynamically registered a module, then we need to override the base process() behavior to select the
        // module.  Note that we don't want to synchronize the call to process().
        //
        if ( registeredApp != null )
        {
            //
            // Try to select the appropriate Struts module and delegate to its RequestProcessor.
            //
            ModuleConfig moduleConfig = InternalUtils.selectModule( modulePath, request, servletContext );
            
            // If this module came from an abstract page flow controller class, send an error.
            ControllerConfig cc = moduleConfig.getControllerConfig();
            if (cc instanceof PageFlowControllerConfig && ((PageFlowControllerConfig) cc).isAbstract()) {
                InternalUtils.sendDevTimeError( "PageFlow_AbstractPageFlow", null, HttpServletResponse.SC_NOT_FOUND, 
                                                request, response, servletContext,
                                                new Object[]{ modulePath } );
                return;
            }
                    
            RequestProcessor requestProcessor = getRequestProcessor( moduleConfig );
            requestProcessor.process( request, response );
        }
        else
        {
            //
            // Here, we're checking to see if this was a module that was registered externally by Struts (not by this
            // servlet).  This is the same as the base process() behavior, but it checks for a missing
            // module-configuration.
            //
            ModuleConfig moduleConfig = null;
            
            if ( InternalUtils.getModuleConfig( RequestUtils.getModuleName( request, servletContext ), servletContext ) != null )
            {
                String modulePrefix = RequestUtils.getModuleName( request, servletContext );
                moduleConfig = InternalUtils.selectModule( modulePrefix, request, servletContext );
            }
            
            String servletPath = InternalUtils.getDecodedServletPath( request );
            RequestProcessor rp = moduleConfig != null ? getRequestProcessor( moduleConfig ) : null;
            
            if ( rp != null && moduleCanHandlePath( moduleConfig, rp, servletPath ) )
            {
                rp.process( request, response );
            }
            else
            {
                //
                // Initialize the ServletContext in the request.  Often, we need access to the ServletContext when we only
                // have a ServletRequest.
                //
                InternalUtils.setServletContext( request, getServletContext() );
                
                if ( processUnhandledAction( request, response, servletPath ) ) return;
                
                String originalServletPath = requestWrapper.getOriginalServletPath();
                if ( originalServletPath != null )
                {
                    servletPath = originalServletPath;
                    modulePath = PageFlowUtils.getModulePathForRelativeURI( originalServletPath );
                }
                
                if ( _log.isErrorEnabled() )
                {
                    InternalStringBuilder msg = new InternalStringBuilder( "No module configuration registered for " );
                    msg.append( servletPath ).append( " (module path " ).append( modulePath ).append( ")." );
                    _log.error( msg.toString() );
                }

                //
                // If we're not in production mode, send a diagnostic on the response; otherwise, simply send a 404.
                //
                if ( modulePath.length() == 0 ) modulePath = "/";
                InternalUtils.sendDevTimeError( "PageFlow_NoModuleConf", null, HttpServletResponse.SC_NOT_FOUND, 
                                                request, response, servletContext,
                                                new Object[]{ servletPath, modulePath } );
            }
        }
    }
793701
private String processParameter(final Parameter p) {
        try {
            String encoding = nsService.lookup(p);
            if (encoding == null) {
                return encode(WILDCARD_ENCODING);
            }

            final ValueEncoding ve = getValueEncoding(encoding);
            if (ve == null) {
                return encode(encoding);
            }
            return encode(ve.getDisplayValue());
        } catch (NamespaceSyntaxWarning e) {
            return encode(WILDCARD_ENCODING);
        } catch (IndexingFailure idxf) {
            return encode(WILDCARD_ENCODING);
        }
    }
1337076
public static void processTreeRequest(String treeId, TreeElement treeRoot, HttpServletRequest request, HttpServletResponse response)
    {
        assert(treeId != null) : "parameter treeId must not be null.";
        assert(treeRoot != null) : "parameter treeRoot must not be null.";
        assert(request != null) : "paramater request must not be null.";

        // check the root node to see if it is a TreeRootElement.  if it is, then we
        // use it to change the selected node.  Otherwise we will do a recursive search
        // of the tree to select the node.
        String selectNode = request.getParameter(TreeElement.SELECTED_NODE);
        if (selectNode != null) {
            if (treeRoot instanceof ITreeRootElement) {
                ITreeRootElement root = (ITreeRootElement) treeRoot;
                root.changeSelected(selectNode, request);
            }
            else {
                setSelected(treeRoot, selectNode, request);
            }
        }

        // handle auto expand.
        String expandNode = null;

        // our we auto expanding this node?
        expandNode = request.getParameter(TreeElement.EXPAND_NODE);

        // if we are auto expanding flip the expand of this node if it was expanded
        if (expandNode != null) {
            TreeElement n = treeRoot.findNode(expandNode);
            if (n != null) {
                n.onExpand(request, response);
                n.setExpanded(!n.isExpanded());
            }
        }
    }
184352
public static void fetchAttributes(RequestAdapter requestAdapter, ProcessResult processResult) {
        if (processResult != null) {
            for (ContentResult contentResult : processResult) {
                for (ActionResult actionResult : contentResult) {
                    Object actionResultValue = actionResult.getResultValue();
                    if (actionResultValue instanceof ProcessResult) {
                        fetchAttributes(requestAdapter, (ProcessResult)actionResultValue);
                    } else {
                        String actionId = actionResult.getActionId();
                        if (actionId != null) {
                            requestAdapter.setAttribute(actionId, actionResultValue);
                        }
                    }
                }
            }
        }
    }
213080
private void processCustomDimensionParameters(@SuppressWarnings("rawtypes") GoogleAnalyticsRequest request, List<NameValuePair> postParms) {
    Map<String, String> customDimParms = new HashMap<String, String>();
    for (String defaultCustomDimKey : defaultRequest.customDimentions().keySet()) {
      customDimParms.put(defaultCustomDimKey, defaultRequest.customDimentions().get(defaultCustomDimKey));
    }

    @SuppressWarnings("unchecked")
    Map<String, String> requestCustomDims = request.customDimentions();
    for (String requestCustomDimKey : requestCustomDims.keySet()) {
      customDimParms.put(requestCustomDimKey, requestCustomDims.get(requestCustomDimKey));
    }

    for (String key : customDimParms.keySet()) {
      postParms.add(new BasicNameValuePair(key, customDimParms.get(key)));
    }
  }
365339
@Override
  public final void process(final Map<String, Object> pAddParam,
    final IRequestData pRequestData) throws Exception {
    for (ILstnCatalogChanged lstn : this.listeners) {
      lstn.onCatalogChanged();
    }
  }
1363570
@Override
  public final void handle(final Map<String, Object> pReqVars,
    final IRequestData pRequestData) throws Exception {
    String processorName = pRequestData.getParameter("nmPrc");
    if (processorName == null) {
      //WHandlerAndJsp requires handle NULL request:
      return;
    }
    IProcessor proc = this.processorsFactory.lazyGet(pReqVars, processorName);
    proc.process(pReqVars, pRequestData);
  }
239132
public void doProcess(HttpServletRequest req, HttpServletResponse res) 
        throws ServletException, IOException
    {
        Utility.getLogger().info("doProcess called in xmlws servlet");
        XMLMessageTransport xmlMessageTransport = null;
        ServletTask servletTask = null;
        BaseMessage msgReplyInternal = null;
        try {
            Map<String,Object> properties = m_initProperties;
        	String strDomain = BaseHttpTask.getParam(req, DBParams.DOMAIN);
        	if (strDomain != null)
        	{
		        properties = new HashMap<String,Object>();
		        if (m_initProperties != null)
		        	properties.putAll(m_initProperties);
				properties.put(DBParams.DOMAIN, strDomain);
        	}
            servletTask = new ServletTask(this, BasicServlet.SERVLET_TYPE.XML);
            servletTask.setProperties(properties);
            Environment env = null;
            if (servletTask.getApplication() != null)
                env = ((BaseApplication)servletTask.getApplication()).getEnvironment();
            if (env == null)
                env = Environment.getEnvironment(null);
            App app = env.getMessageApplication(true, properties);
            servletTask.setApplication(app);

            xmlMessageTransport = new XMLMessageTransport(servletTask);
            InputStream inStream = req.getInputStream();	// .getReader();
            Reader in = new InputStreamReader(inStream);
            String message = Utility.transferURLStream(null, null, in, null);
            try   {
                message = URLDecoder.decode(message, DBConstants.URL_ENCODING);
            } catch (java.io.UnsupportedEncodingException ex) {
                ex.printStackTrace();
            }
            //xMap<String,Object> properties = PropertiesField.stringToProperties(message);
            if (message.startsWith("xml="))	// Always
                message = message.substring(4);
            Map<String, Object> propMessage = null;
            if (message.length() == 0)
            {
            	Enumeration<?> names = req.getParameterNames();
            	while (names.hasMoreElements())
            	{
            		String key = names.nextElement().toString();
            		if ("xml".equalsIgnoreCase(key))
            			message = (String)req.getParameter(key);
            		else
            		{
            			if (propMessage == null)
            				propMessage = new HashMap<String, Object>();
            			propMessage.put(key, req.getParameter(key));	// RESTful params
            		}
            	}
            }

            BaseMessage messageIn = new TreeMessage(null, null);
            new XmlTrxMessageIn(messageIn, message);
            if (propMessage != null)
            {
            	for (String key : propMessage.keySet())
            	{
            		messageIn.put(key, propMessage.get(key));
            	}
            }

            msgReplyInternal = xmlMessageTransport.processIncomingMessage(messageIn, null);
            Utility.getLogger().info("msgReplyInternal: " + msgReplyInternal);

            int iErrorCode = xmlMessageTransport.convertToExternal(msgReplyInternal, null);
            Utility.getLogger().info("externalMessageReply: " + msgReplyInternal);

            if (iErrorCode == DBConstants.NORMAL_RETURN)
            {
            	if (msgReplyInternal.getExternalMessage() != null)
            	{	// Always
	                String strReply = msgReplyInternal.getExternalMessage().toString();
    	            res.getWriter().print(strReply);
        	        String strTrxID = (String)msgReplyInternal.getMessageHeader().get(TrxMessageHeader.LOG_TRX_ID);
            	    xmlMessageTransport.logMessage(strTrxID, msgReplyInternal, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.SENTOK, null, null);    // Sent (no reply required)
            	}
            }
        } catch (Throwable ex)  {
            ex.printStackTrace();
            String strError = "Error in processing or replying to a message";
            Utility.getLogger().warning(strError);
            if ((msgReplyInternal != null) && (xmlMessageTransport != null))
            {
                String strTrxID = (String)msgReplyInternal.getMessageHeader().get(TrxMessageHeader.LOG_TRX_ID);
                xmlMessageTransport.logMessage(strTrxID, msgReplyInternal, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.ERROR, strError, null);
            }
            return; // Error
        } finally   {
            if (xmlMessageTransport != null)
            {
                xmlMessageTransport.free();
                xmlMessageTransport = null;
            }
            if (servletTask != null)
                servletTask.free();
        }
    }