Changeset 25260


Ignore:
Timestamp:
2012-03-23T14:21:37+13:00 (12 years ago)
Author:
sjm84
Message:

Making sure the remoteAddress is passed into any services called by the General action. This is used in the Authentication service.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java

    r25128 r25260  
    2626    public Node process(Node message_node)
    2727    {
    28 
    2928        Element message = this.converter.nodeToElement(message_node);
    3029
     
    4847            String optionName = (String) params.get("configChangeName");
    4948            String optionValue = (String) params.get("configChangeValue");
    50            
     49
    5150            changeConfig(optionName, optionValue);
    5251        }
     
    8483        {
    8584            //do the request
    86 
    8785            Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    8886            Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
     
    104102                mr_query_request.appendChild(param_list);
    105103            }
     104
     105            Element userInformation = (Element) GSXML.getChildByTagName(request, GSXML.USER_INFORMATION_ELEM);
     106            if (userInformation != null)
     107            {
     108                mr_query_request.appendChild(this.doc.importNode(userInformation, true));
     109            }
     110            mr_query_request.setAttribute("remoteAddress", request.getAttribute("remoteAddress"));
    106111
    107112            Element mr_query_response = (Element) this.mr.process(mr_query_message);
     
    144149        return result;
    145150    }
    146    
    147     protected void changeConfig (String optionName, String optionValue)
     151
     152    protected void changeConfig(String optionName, String optionValue)
    148153    {
    149         if(this.config_params.get(optionName) != null)
     154        if (this.config_params.get(optionName) != null)
    150155        {
    151156            this.config_params.put(optionName, optionValue);
    152            
    153             File interfaceConfigFile = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), (String)this.config_params.get("interface_name"))));
    154            
     157
     158            File interfaceConfigFile = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), (String) this.config_params.get("interface_name"))));
     159
    155160            Document interfaceXML = null;
    156161            try
     
    163168
    164169                NodeList optionList = optionListElem.getElementsByTagName("option");
    165                
    166                 for(int i = 0; i < optionList.getLength(); i++)
     170
     171                for (int i = 0; i < optionList.getLength(); i++)
    167172                {
    168                     Element currentOption = (Element)optionList.item(i);
    169                     if(currentOption.getAttribute(GSXML.NAME_ATT) != null && currentOption.getAttribute(GSXML.NAME_ATT).equals(optionName))
     173                    Element currentOption = (Element) optionList.item(i);
     174                    if (currentOption.getAttribute(GSXML.NAME_ATT) != null && currentOption.getAttribute(GSXML.NAME_ATT).equals(optionName))
    170175                    {
    171176                        currentOption.setAttribute(GSXML.VALUE_ATT, optionValue);
    172177                    }
    173178                }
    174                
     179
    175180                DOMSource source = new DOMSource(interfaceXML);
    176181                Result xmlresult = new StreamResult(interfaceConfigFile);
     
    179184                transformer.transform(source, xmlresult);
    180185            }
    181             catch(Exception ex)
     186            catch (Exception ex)
    182187            {
    183188                ex.printStackTrace();
Note: See TracChangeset for help on using the changeset viewer.