Changeset 21163 in main


Ignore:
Timestamp:
07/28/20 18:47:02 (6 days ago)
Author:
GarthBraithwaite_STG
Message:

java, view - Saved QD via ajax. Moved QDs into the QD detail modelmap which side was to remove queryDefinitionMiscDetailsModelMap and java MM and did away with QUERY_DEFINITIONS_NAME. Added blank.jsp so that ajax requests can properly report success/fail via return HTTP200 status. Reordered modelmap list controller so that more specific model maps are processed first. Added list of pathPrefixesToRemove to QueryDefinitionsFromHTTPRequest and QueryModuleFromHTTPRequest to allow for name from the specific path segments and not rely on the end segment. This allows for different paths including secure and sub dirs.

Location:
trunk
Files:
1 added
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/ibisph-view/src/main/webapp/WEB-INF/config/spring/common.xml

    r20981 r21163  
    608608        </bean>
    609609        -->
    610 
    611610</beans>
  • trunk/ibisph-view/src/main/webapp/WEB-INF/config/spring/query-definition.xml

    r21145 r21163  
    9595        </bean>
    9696
    97         <bean id="queryDefinitionMiscDetailsModelMap" class="org.ibisph.querydefinition.modelmap.MiscQueryDefinitionDetailsFromHTTPRequest">
    98                 <description>
    99                         Adds a session QM title and sticky QD title to the model map so that
    100                         the UI can make decisions and display approp actions. 
    101                 </description>
    102                 <property name="queryModuleSessionName"           value="#{queryModuleSessionName.string}"/>
    103                 <property name="queryModuleModelMapKey"           value="#{commonXMLModelMapKey.string}"/>
    104                 <property name="sessionQueryModuleTitleMapKey"    value="SessionQueryModuleTitle"/>
    105 <!--
    106                 <property name="stickyQueryDefinitionSessionName" value="#{queryStickyDefinitionDefinitionSessionName.string}"/>
    107                 <property name="stickyQueryDefinitionModelMapKey" value="StickyQueryDefinition"/>
    108 -->
    109         </bean>
    110 
    11197
    11298        <!--  C O N T R O L L E R S  -->
     
    139125                        <list>
    140126                                <ref bean="queryDefinitionsFromHTTPRequestModelMap"/>
    141                                 <ref bean="queryDefinitionMiscDetailsModelMap"/>
    142127                        </list>
    143128                </property>
     
    312297                                                                        <bean class="org.ibisph.web.HTTPRequestParameterNameToXMLElementName"><constructor-arg value="privateFlag"/><constructor-arg value="PRIVATE_FLAG"/></bean>
    313298                                                                        <bean class="org.ibisph.web.HTTPRequestParameterNameToXMLElementName"><constructor-arg value="requestPath"/><constructor-arg value="REQUEST_PATH_PREFIX"/></bean>
    314                                                                         <bean class="org.ibisph.web.HTTPRequestParameterNameToXMLElementName"><constructor-arg value="configurationPath"/><constructor-arg value="CONFIGURATION_PATH"/></bean>
     299                                                                        <bean class="org.ibisph.web.HTTPRequestParameterNameToXMLElementName"><constructor-arg value="modifiedDate"/><constructor-arg value="MODIFIED_DATE"/></bean>
    315300                                                                </list>
    316301                                                        </property>
     
    325310                        </list>
    326311                </property>
     312                <property name="view" value="/WEB-INF/jsp/blank.jsp"/>
    327313        </bean>
    328314
     
    334320                <property name="modelMapList">
    335321                        <list>
    336                                 <bean id="queryDefinitionDeleteQueryDefinitionFromHTTPRequestModelMap"
    337                                         class="org.ibisph.querydefinition.modelmap.DeleteQueryDefinitionFromHTTPRequest"
     322                                <bean class="org.ibisph.querydefinition.modelmap.DeleteQueryDefinitionFromHTTPRequest"
    338323                                        parent="queryDefinitionModelMapProperties"
    339324                                >
     
    346331                                        <property name="modelMapKey" value="#{commonXMLModelMapKey.string}"/>
    347332                                </bean>
    348                                 <ref bean="queryDefinitionMiscDetailsModelMap"/>
    349333                        </list>
    350334                </property>
     
    363347                <property name="XSLTPathAndFilename" value="html/query/definition/detail/DetailPage.xslt"/>
    364348        </bean>
    365 
    366349</beans>
  • trunk/ibisph-view/src/main/webapp/WEB-INF/config/spring/secure.xml

    r20915 r21163  
    203203                                <ref bean="queryDefinitionFromHTTPRequestModelMap"/>
    204204                                <ref bean="secureQueryDefinitionQueryModuleFromQueryDefinitionModelMap"/>
    205                                 <ref bean="queryDefinitionMiscDetailsModelMap"/>
    206205                        </list>
    207206                </property>
  • trunk/ibisph-view/src/main/webapp/xsd/query_definitions.xsd

    r9852 r21163  
    3939                                -->
    4040                                <xsd:element name="REQUEST_PATH_PREFIX" type="xsd:string" minOccurs="0" maxOccurs="1"/>
    41 
    42                                 <!-- element added by java service when the def is retrieved so
    43                                         that the UI can access to determine if the QD is there's or not.
    44                                 -->
    45                                 <xsd:element ref="QUERY_DEFINITIONS_NAME" minOccurs="0" maxOccurs="1"/>
    4641                        </xsd:all>
    4742                        <xsd:attribute name="name" type="xsd:string" use="optional"/>
  • trunk/ibisph-view/src/main/webapp/xslt/html/query/definition/HelpContent.xslt

    r21145 r21163  
    120120<xsl:param name="HelpContent.viewOverviewContent">
    121121                You are viewing the details of one of
    122                 <xsl:value-of select="$QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME"/>'s
     122                <xsl:value-of select="$QueryDefinition.queryDefinitions/NAME"/>'s
    123123                saved query defintion.  Please see the
    124124                <a href="{$HelpContent.savedQueryHelpRequestPath}">Saved Query Help</a>
     
    150150                        <li>
    151151                                Apply the query definition's criteria to the current query dataset
    152 (<xsl:value-of select="SessionQueryModuleTitle"/>) and return
    153                                 to the query builder page for further refinement and then to
    154                                 submit the query to view the results.
     152                                and return to the query builder page for further refinement and
     153                                then to submit the query to view the results.
    155154                        </li>
    156155                </ul>
  • trunk/ibisph-view/src/main/webapp/xslt/html/query/definition/QueryDefinition.xslt

    r21145 r21163  
    1717
    1818        <xsl:param name="QueryDefinitions"
    19                 ibis:doc="Main model for the index page requests.  Put in this param and
    20                         the code below to handle ever injected."
     19                ibis:doc="Main model XML for the index page requests (ie param not used
     20                        for this).  This param and the code below to handle if ever injected."
    2121        />
    2222        <xsl:param name="QueryDefinition.queryDefinitions"
     
    4040        <xsl:param name="QueryDefinition.isMyQueryDefinitions" select="
    4141                        boolean($ibis.userProfile) and
    42                         ($QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME = $ibis.userProfile/ID)
     42                        ($QueryDefinition.queryDefinitions/NAME = $ibis.userProfile/ID)
    4343                "
    4444        />
     
    8383                                </xsl:call-template>
    8484                        </div>
    85                         <button type="button" onclick="saveModuleDefinition();">Save</button>
     85                        <button type="button" onclick="saveDefinition();">Save</button>
    8686                        <button type="button" onclick="queryDefinitionEditIdentityDialog.close()" title="Closes the edit without saving.">Cancel</button>
    8787                </div>
     
    9898                <xsl:param name="configuration" select="$queryModule/CONFIGURATIONS/CONFIGURATION[NAME = $request/CONFIGURATION_NAME]"/>
    9999                <form name="form" id="identityForm" method="post" action="{$QueryDefinition.baseRequestPath}save" autocomplete="on">
    100                         <input type="hidden" id="configurationPath" name="configurationPath" value="{$request/CONFIGURATION_PATH}"/>
    101100                        <input type="hidden" id="requestBasePath"   name="requestBasePath"
    102101                                value="{if( string-length($QueryDefinition.queryDefinition/REQUEST_PATH_PREFIX) != 0)
     
    126125                                                        value="{concat(replace($request/CONFIGURATION_PATH, '/', '_'), '_', $queryModule/REQUEST/SERIAL_NUMBER)}"
    127126                                                />
    128                                                 <input id="newQueryDefinitionFlag" name="newQueryDefinitionFlag" type="hidden" value="x"/>
    129127                                                </xsl:if>
    130128                                                <xsl:if test="not($QueryDefinition.isBlankQueryDefinition)">
    131 <!-- this isn't needed.  If existing then the MODIFIED_DATE is populated new is blank.
    132129                                                <input id="name" name="name" type="hidden" value="{$QueryDefinition.queryDefinition/NAME}"/>
    133 -->
    134130                                                <xsl:value-of select="$QueryDefinition.queryDefinition/NAME"/>
    135131                                                </xsl:if>
     
    183179                                        </th>
    184180                                        <td  class="Title" title="Enter the main title for this query definition.">
    185                                                 <input type="checkbox"  name="privateFlag" id="privateFlag" value="private">
     181                                                <input type="checkbox"  name="privateFlag" id="privateFlag" value="x">
    186182                                                        <xsl:if test="$QueryDefinition.queryDefinition/PRIVATE_FLAG">
    187183                                                                <xsl:attribute name="checked" select="'checked'"/>
     
    206202                                                        else $QueryDefinition.queryDefinition/MODIFIED_DATE
    207203                                                "/>
     204                                                <input id="modifiedDate" name="modifiedDate" type="hidden" value="{$QueryDefinition.queryDefinition/MODIFIED_DATE}"/>
    208205                                        </td>
    209206                                </tr>
     
    221218                <script type="text/javascript">
    222219                        // <![CDATA[
    223                         var queryDefinitionEditIdentityDialog;
     220                        var queryDefinitionEditIdentityDialog = null;
    224221                        $(document).ready(function()
    225222                        {
     
    232229                                                ,modal: true
    233230                                        }).data("kendoWindow");
     231
     232                                $(function()
     233                                {
     234                                        $("#identityForm").submit(function(event)
     235                                        {
     236                                                event.preventDefault(); // Prevent the form from submitting via the browser
     237                                                var form = $(this);
     238                                                $.ajax
     239                                                ({
     240                                                        type: form.attr("method")
     241                                                        ,url: form.attr("action")
     242                                                        ,data: form.serialize()
     243                                                        ,success: function(data) { alert("Successfully Saved."); }
     244                                                        ,error: function(data)
     245                                                        {
     246                                                                alert("Save Failed!");
     247                                                                console.log("Query Definition Save Failed.  Data: ");
     248                                                                console.log(data);
     249                                                                console.log(data.responseText);
     250                                                        }
     251                                                });
     252
     253                                        });
     254                                });
     255
    234256                        }); //~~~~~~~~~~~~~~~~~~~~ End of Ready Function ~~~~~~~~~~~~~~~~~~~
    235 
    236257                        function showIdentityDialog()
    237258                        {
    238259                                queryDefinitionEditIdentityDialog.center().open();
    239                                 document.form.name.focus();
     260                                document.getElementById("name").focus();
    240261                        } //~~~~~~~~~~~~~~~~~~~~ End of Function ~~~~~~~~~~~~~~~~~~~
    241262
     
    261282                                        return(false);
    262283                                }
    263                                 document.form.submit();
     284                                $("#identityForm").trigger("submit");
     285                                queryDefinitionEditIdentityDialog.close();
     286                                location.reload();
    264287                        }
    265 /*
    266 https://stackoverflow.com/questions/1960240/jquery-ajax-submit-form
    267 see hijax - 3rd down
    268 
    269 $("button").click(function(){
    270   $.post("demo_test_post.asp",
    271   {
    272     name: "Donald Duck",
    273     city: "Duckburg"
    274   },
    275   function(data, status){
    276     alert("Data: " + data + "\nStatus: " + status);
    277   });
    278 });
    279 
    280 $("#theForm").ajaxForm({url: 'server.php', type: 'post'})
    281 or
    282 $("#theForm").ajaxSubmit({url: 'server.php', type: 'post'})
    283 
    284                 $.ajax({
    285            type: "POST",
    286            url: url,
    287            data: form.serialize(), // serializes the form's elements.
    288            success: function(data)
    289            {
    290                alert(data); // show response from the php script.
    291            }
    292          });
    293                  
    294                  
    295                         $.ajax({
    296                                 url: "<xsl:value-of select="ibis:getRequestURL($sourceContentURL)"/>"
    297                                 ,type: "GET"
    298                                 ,success: function(data)
    299                                 {
    300                                 alert(successfully saved);
    301                                         $("<xsl:value-of select="$destContentJQuerySelector"/>").html( $(data).find("<xsl:value-of select="$sourceContentJQuerySelector"/>").html() );
    302                                 }
    303                                 ,error: function (data) {
    304                 console.log('An error occurred.');
    305                 console.log(data);
    306             },
    307                         });
    308 */
    309288                        // ]]>
    310289                </script>
  • trunk/ibisph-view/src/main/webapp/xslt/html/query/definition/detail/Page.xslt

    r21145 r21163  
    3030                        </xsl:when>
    3131                        <xsl:otherwise>
    32                                 Viewing <xsl:value-of select="$QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME"/>'s
     32                                Viewing <xsl:value-of select="$QueryDefinition.queryDefinitions/NAME"/>'s
    3333                                "<xsl:value-of select="$QueryDefinition.queryDefinition/TITLE"/>"
    3434                                Saved Query Definition Details
     
    5959
    6060        <xsl:param name="Page.viewSavedQueryOverviewContent">
    61                 Viewing <xsl:value-of select="$QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME"/>'s
     61                Viewing <xsl:value-of select="$QueryDefinition.queryDefinitions/NAME"/>'s
    6262                "<xsl:value-of select="$QueryDefinition.queryDefinition/TITLE"/>"
    6363                Saved Query Definition Details.  This page allows you to see the the
     
    103103                <xsl:param name="configuration" select="$queryModule/CONFIGURATIONS/CONFIGURATION[NAME = $request/CONFIGURATION_NAME]"/>
    104104
    105                 <xsl:variable name="definitionURLSuffix" select="concat($QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
     105                <xsl:variable name="definitionURLSuffix" select="concat($QueryDefinition.queryDefinitions/NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
    106106
    107107                <xsl:call-template name="Page.contentOptions">
     
    137137                                                </th>
    138138                                                <td  class="Title" title="Creating user's ID">
    139                                                         <xsl:value-of select="$QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME"/>
     139                                                        <xsl:value-of select="$QueryDefinition.queryDefinitions/NAME"/>
    140140                                                </td>
    141141                                        </tr>
     
    292292                                        </tr>
    293293                                </table>
    294 
    295294                        </xsl:with-param>
    296295                </xsl:call-template>
     
    330329                                                        <xsl:with-param name="helpPopupContent"  select="$HelpContent.listLink"/>
    331330                                                        <xsl:with-param name="urlDescription"    select="'copy this value for a basic definitions list link.'"/>
    332                                                         <xsl:with-param name="urlRequestCommand" select="concat('list/', $QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME, '.html')"/>
     331                                                        <xsl:with-param name="urlRequestCommand" select="concat('list/', $QueryDefinition.queryDefinitions/NAME, '.html')"/>
    333332                                                </xsl:call-template>
    334333                                                <xsl:call-template name="Page.shareTableRow">
     
    338337                                                        <xsl:with-param name="helpPopupContent"  select="$HelpContent.indexLink"/>
    339338                                                        <xsl:with-param name="urlDescription"    select="'copy this value for a basic definitions list link.'"/>
    340                                                         <xsl:with-param name="urlRequestCommand" select="concat('index/', $QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME, '.html')"/>
     339                                                        <xsl:with-param name="urlRequestCommand" select="concat('index/', $QueryDefinition.queryDefinitions/NAME, '.html')"/>
    341340                                                </xsl:call-template>
    342341
     
    347346                                                        <xsl:with-param name="helpPopupContent"  select="$HelpContent.builderLink"/>
    348347                                                        <xsl:with-param name="urlDescription"    select="'copy this value for a query builder request link.'"/>
    349                                                         <xsl:with-param name="urlRequestCommand" select="concat('builder/', $QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
     348                                                        <xsl:with-param name="urlRequestCommand" select="concat('builder/', $QueryDefinition.queryDefinitions/NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
    350349                                                </xsl:call-template>
    351350                                                <xsl:call-template name="Page.shareTableRow">
     
    355354                                                        <xsl:with-param name="helpPopupContent"  select="$HelpContent.resultLink"/>
    356355                                                        <xsl:with-param name="urlDescription"    select="'copy this value for a query builder request link.'"/>
    357                                                         <xsl:with-param name="urlRequestCommand" select="concat('result/', $QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
     356                                                        <xsl:with-param name="urlRequestCommand" select="concat('result/', $QueryDefinition.queryDefinitions/NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
    358357                                                </xsl:call-template>
    359358                                                <xsl:call-template name="Page.shareTableRow">
     
    363362                                                        <xsl:with-param name="helpPopupContent"  select="$HelpContent.detailLink"/>
    364363                                                        <xsl:with-param name="urlDescription"    select="'copy this value for a query builder request link.'"/>
    365                                                         <xsl:with-param name="urlRequestCommand" select="concat('detail/', $QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
     364                                                        <xsl:with-param name="urlRequestCommand" select="concat('detail/', $QueryDefinition.queryDefinitions/NAME, '/', $QueryDefinition.queryDefinition/NAME, '.html')"/>
    366365                                                </xsl:call-template>
    367366                                        </tbody>
     
    408407
    409408                                <button id="indexButton" type="button" accesskey="I" font-icon="&#xe614;" 
    410                                         onclick="location.href='{$baseRequestPath}index/{$QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME}.html'"
     409                                        onclick="location.href='{$baseRequestPath}index/{$QueryDefinition.queryDefinitions/NAME}.html'"
    411410                                        title="Display list of query definitions"
    412411                                >
    413                                         <xsl:value-of select="if($QueryDefinition.isMyQueryDefinitions) then 'My' else $QueryDefinition.queryDefinition/QUERY_DEFINITIONS_NAME"/>
     412                                        <xsl:value-of select="if($QueryDefinition.isMyQueryDefinitions) then 'My' else $QueryDefinition.queryDefinitions/NAME"/>
    414413                                        Saved Query Definitions Index
    415414<!--
  • trunk/ibisph-view/src/main/webapp/xslt/html/query/definition/index/Page.xslt

    r21106 r21163  
    135135                </style>
    136136
    137                 <xsl:variable name="queryDefinitionCount" select="count($QueryDefinition.queryDefinitions/QUERY_DEFINITION)"/>
     137                <xsl:variable name="queryDefinitions" select="$QueryDefinition.queryDefinitions/QUERY_DEFINITION[not(PRIVATE_FLAG) or $QueryDefinition.isMyQueryDefinitions]"/>
     138                <xsl:variable name="queryDefinitionCount" select="count($queryDefinitions)"/>
    138139                <xsl:if test="0 = $queryDefinitionCount">
    139140                        <xsl:copy-of select="$HelpContent.noSavedDefinitionsMessageContent"/>
     
    211212                                <tbody>
    212213                                        <!-- loop for all definitions -->
    213                                         <xsl:for-each select="$QueryDefinition.queryDefinitions/QUERY_DEFINITION[not(PRIVATE_FLAG) or $QueryDefinition.isMyQueryDefinitions]">
     214                                        <xsl:for-each select="$queryDefinitions">
    214215                                                <xsl:sort select="TITLE"/>
    215216
  • trunk/ibisph-view/src/main/webapp/xslt/html/query/module/builder/Builder.xslt

    r20990 r21163  
    149149                        </xsl:otherwise>
    150150                </xsl:choose>
    151 
     151<!--
    152152<xsl:call-template name="StickyQueryDefinitionToggle.inputAndScript"/>
    153 
     153-->
    154154        </xsl:template>
    155155
  • trunk/ibisph/src/main/java/org/ibisph/querydefinition/modelmap/AbstractQueryDefinitionModelMap.java

    r4116 r21163  
    1313  protected QueryDefinitionXML queryDefinitionService = null;
    1414  protected CurrentUser        currentUserService     = null;
    15 
    1615
    1716  public void setQueryDefinitionService(QueryDefinitionXML queryDefinitionService) {
  • trunk/ibisph/src/main/java/org/ibisph/querydefinition/modelmap/QueryDefinitionFromHTTPRequest.java

    r9048 r21163  
    11package org.ibisph.querydefinition.modelmap;
     2
     3import java.util.HashMap;
     4import java.util.Map;
    25
    36import javax.servlet.http.HttpServletRequest;
    47
    58import org.dom4j.Node;
    6 import org.ibisph.modelmap.GetModelMapFromHTTPRequest;
    79import org.ibisph.util.IOPath;
    8 import org.ibisph.util.StrLib;
    910
    1011/**
    1112 * Loads either current user's query definition or a specified user's query
    1213 * definition based on request URL (and the forceUseCurrentUserIfEquals list). 
    13  * The query defs and definition are loaded via the injected service.  Typical
    14  * URLs are of the form:
    15  * /query/definition/[result, builder, apply, detail/[Defs name]/Def name].html
     14 * The query defs comes from super with both QDs and QD being loaded via the
     15 * injected QD service.  Typical URLs are of the form:
     16 * /query/definition/[result, builder, detail/[Defs name]/Def name].html
    1617 *
    1718 * @author Garth Braithwaite, STG
     
    1920public class QueryDefinitionFromHTTPRequest
    2021  extends QueryDefinitionsFromHTTPRequest
    21   implements GetModelMapFromHTTPRequest
    2222{
     23  String queryDefinitionsModelMapKey = "QueryDefinitions";
     24
     25
     26  public void setQueryDefinitionsModelMapKey(String queryDefinitionsModelMapKey) {
     27    this.queryDefinitionsModelMapKey = queryDefinitionsModelMapKey;
     28  } //-------------------------- End of Method ------------------------------
    2329
    2430  /**
    25    * Returns a query def XML doc via the HTTP request and query defs service. 
    26    * First check if the request is MyDefinitions ("force current user") type
    27    * request.  If so then get the current user's id and use for the query defs.
    28    * If not then use the request's 2nd to last segment for the query defs name.
    29    * The last segment is the def name. 
     31   * Puts both the QDs and QD XML docs into the model map.  The last segment or
     32   * request filename (sans extension) should be the QD name.  The QDs are put
     33   * into the map because the detail page needs to know if the def is theirs or
     34   * different user's so it can allow edits.
    3035   * @param request HttpServletRequest that the configuration path is retrieved from.
    3136   * @return the fully loaded query definition xml document object.
    3237   */
    33   protected Object getModel(HttpServletRequest request) throws Exception {
    34     String[] pathSegment = IOPath.getPathSegments(IOPath.getFilePathAndNameWithoutExtension(request.getRequestURI()));
    35     String queryDefinitionName  = pathSegment[pathSegment.length-1];
    36     String queryDefinitionsName = pathSegment[pathSegment.length-2];
    37     if((null != this.forceUseCurrentUserIfEquals)
    38       && this.forceUseCurrentUserIfEquals.contains(queryDefinitionsName)
    39     ) {
    40       queryDefinitionsName = this.currentUserService.getUserDetailsUsername(request);
    41       if(!StrLib.isSomething(queryDefinitionsName)) return(null);
    42     }
    43     Node queryDefinition = this.queryDefinitionService.getQueryDefinition(queryDefinitionsName, queryDefinitionName);
    44     return(queryDefinition);
     38
     39  public Map<String, Object> getModelMap(HttpServletRequest request) throws Exception {
     40    Map<String, Object> modelMap = new HashMap<String, Object>();
     41
     42    // use all the code of the QDs modelmap to determine the path and load the
     43    // QDs.  QDs are needed for the UI to know if the QDs are the logged user's
     44    // QDs or some other user's QDs.  The QDs are needed to be loaded anyway to
     45    // retrieve the desired QD so might as well put into the modelmap for the UI.
     46    // This also allows for future UI enhancements and validations.
     47    Node queryDefinitions = (Node)super.getModel(request);
     48    modelMap.put(this.queryDefinitionsModelMapKey, queryDefinitions);
     49
     50    // for detail requests the QD name is always the last segment.  Get it and
     51    // put into the map.
     52    String queryDefinitionName = IOPath.getFilenameWithoutExtension(request.getRequestURI());
     53    Node queryDefinition = this.queryDefinitionService.getQueryDefinition(queryDefinitions, queryDefinitionName);
     54    modelMap.put(this.modelMapKey, queryDefinition);
     55   
     56    return(modelMap);
    4557  } //-------------------------- End of Method ------------------------------
    4658
  • trunk/ibisph/src/main/java/org/ibisph/querydefinition/modelmap/QueryDefinitionsFromHTTPRequest.java

    r9126 r21163  
    1313
    1414/**
    15  * Loads either current user's query definitions or a specified user's query
    16  * definitions based on request URL (and the forceUseCurrentUserIfEquals list). 
    17  * The query defs are loaded via the injected service and the defs name.  This
    18  * model map is used by all the list type query def controllers.
     15 * Loads either the current logged in user's query definitions or another user's
     16 * query definitions based on request URL (the forceUseCurrentUserIfEquals list
     17 * is used to identify the "My" definitions). 
     18 * The query defs are loaded via the injected service and the defs name from the
     19 * request URL.  This model map is used by all the list and detail query def
     20 * controllers.
    1921 *
    2022 * @author Garth Braithwaite, STG
     
    2426  implements GetModelMapFromHTTPRequest
    2527{
     28  protected String[] pathPrefixesToRemove = new String[] {
     29    "query/definition/list",   "query/definition/index",
     30    "query/definition/detail", "query/definition/result",
     31    "query/definition/builder","query/definition/contentblocks"
     32  };
    2633  protected List<String> forceUseCurrentUserIfEquals;
     34
     35
     36  /**
     37   * Sets the Query Def Path prefixes to search for and remove all path info up
     38   * to and including that value to retrieve the actual path.
     39   * @param pathPrefixesToRemove array of strings to be looped through.
     40   */
     41  public void setPathPrefixesToRemove(String[] pathPrefixesToRemove) {this.pathPrefixesToRemove = pathPrefixesToRemove;}
    2742
    2843  /**
     
    4358  /**
    4459   * Returns a query defs XML doc via the HTTP request and query defs service. 
    45    * First check if the request is MyDefinitions ("force current user") type
    46    * request.  If so then get the current user's id and use for the query defs.
    47    * If not then use the request's last segment for the query defs name to be
    48    * opened and returned. 
     60   * First remove the path prefixes.  For list and index type requests the defs
     61   * name is the last request segment.  For detail requests (which inherit and
     62   * use this code) the defs is the 2nd to last segment.  This code at one point
     63   * simply used the request's filename w/o extension.  However, the newer approach
     64   * allows for secure saved query paths and the use for the detail type requests.
     65   * Next need to check if the request is MyDefinitions ("force current user") type
     66   * request.  If so then get the current user's id and use for the query defs
     67   * name. 
    4968   * @param request HttpServletRequest that the configuration path is retrieved from.
    5069   * @return query definitions xml document object.
    5170   */
    5271  protected Object getModel(HttpServletRequest request) throws Exception {
    53     String queryDefinitionsName = IOPath.getFilenameWithoutExtension(request.getRequestURI());
     72    // get rid of path prefixes to gain access to the actual defs name.
     73    String requestPath = IOPath.getFilePathAndNameWithoutExtension(request.getRequestURI());
     74    String pathSuffix = null;
     75    for(String pathPrefixToRemove : this.pathPrefixesToRemove) {
     76      int i = requestPath.indexOf(pathPrefixToRemove);
     77      if(i > -1) {
     78        pathSuffix = requestPath.substring(i + pathPrefixToRemove.length() + 1);
     79        break;
     80      }
     81    }
     82
     83    // check if the requested defs name is a special MyDefinitions type request.
     84    // if so then use the current, logged in user's ID as the defs name.
     85    String[] pathSegments = IOPath.getPathSegments(pathSuffix);
     86    String queryDefinitionsName = pathSegments[0];
    5487    if((null != this.forceUseCurrentUserIfEquals)
    5588      && this.forceUseCurrentUserIfEquals.contains(queryDefinitionsName)
     
    6295    if(!StrLib.isSomething(queryDefinitionsName)) return(null);
    6396
     97    // use the service to load the query defs XML doc.
    6498    Node queryDefinitions = null;
    6599    try {
  • trunk/ibisph/src/main/java/org/ibisph/querydefinition/modelmap/SaveQueryDefinitionFromHTTPRequest.java

    r21145 r21163  
    44
    55import org.dom4j.Node;
     6import org.ibisph.modelmap.GetModelMapFromHTTPRequest;
    67import org.ibisph.querydefinition.service.QueryModuleXMLToQueryDefinitionXML;
    78import org.ibisph.util.StrLib;
     
    1415 * @author Garth Braithwaite, STG
    1516 */
    16 public class SaveQueryDefinitionFromHTTPRequest extends AbstractQueryDefinitionModelMap {
     17public class SaveQueryDefinitionFromHTTPRequest
     18  extends AbstractQueryDefinitionModelMap
     19  implements GetModelMapFromHTTPRequest
     20{
    1721  protected HTTPRequestParametersToContainerElementService httpRequestParametersToContainerElementService;
    18  
     22
    1923  protected String queryModuleSessionName = null;
    2024  protected QueryModuleXMLToQueryDefinitionXML queryModuleXMLToQueryDefinitionXMLService;
    21  
     25
     26  protected String modelMapKey = "XML";
    2227
    2328  /**
     
    6166    Node queryDefinition;
    6267    String userDetailsUsername = this.currentUserService.getUserDetailsUsername(request);
    63     Node queryDefinitions = this.queryDefinitionService.getQueryDefinitions(userDetailsUsername);
    6468
    6569    Node requestQueryDefinitionNode = this.httpRequestParametersToContainerElementService.load(request);
     
    7377        );
    7478      }
    75       XMLLib.replaceNode(queryDefinition, "TITLE", XMLLib.getNode(queryDefinition, "TITLE"));
    76       XMLLib.replaceNode(queryDefinition, "DESCRIPTION", XMLLib.getNode(queryDefinition, "DESCRIPTION"));
    77       XMLLib.replaceNode(queryDefinition, "PRIVATE_FLAG", XMLLib.getNode(queryDefinition, "PRIVATE_FLAG"));
     79      XMLLib.replaceNode(queryDefinition, "TITLE",        XMLLib.getNode(requestQueryDefinitionNode, "TITLE"));
     80      XMLLib.replaceNode(queryDefinition, "DESCRIPTION",  XMLLib.getNode(requestQueryDefinitionNode, "DESCRIPTION"));
     81      XMLLib.replaceNode(queryDefinition, "PRIVATE_FLAG", XMLLib.getNode(requestQueryDefinitionNode, "PRIVATE_FLAG"));
    7882    }
    7983
     
    8690
    8791    // save the definition in the definitions XML file (updates the modified date).
    88     queryDefinitions = this.queryDefinitionService.saveQueryDefinition(userDetailsUsername, queryDefinition);
     92    this.queryDefinitionService.saveQueryDefinition(userDetailsUsername, queryDefinition);
    8993
    9094    return(queryDefinition);
  • trunk/ibisph/src/main/java/org/ibisph/querydefinition/service/QueryDefinitionXML.java

    r21145 r21163  
    9898      );
    9999    }
    100 
    101     // add the USER_ID to the QD so that XSLT can access etc.
    102     XMLLib.addNode(queryDefinition, XMLLib.newNode("QUERY_DEFINITIONS_NAME", queryDefinitionsName));
    103 
    104100    return(queryDefinition);
    105101  } //-------------------------- End of Method ------------------------------
  • trunk/ibisph/src/main/java/org/ibisph/querydefinition/service/QueryModuleXMLToQueryDefinitionXML.java

    r21145 r21163  
    4949    XMLLib.setText(queryDefinition, "PRIVATE_FLAG",           queryDefinitionPrivateFlag);
    5050    XMLLib.setText(queryDefinition, "REQUEST_PATH_PREFIX",    queryDefinitionRequestPathPrefix);
    51     XMLLib.setText(queryDefinition, "QUERY_DEFINITIONS_NAME", queryDefinitionsName);
    5251
    5352    XMLLib.setText(queryDefinition, "MODIFIED_DATE",      (new Date()).toString());
  • trunk/ibisph/src/main/java/org/ibisph/querymodule/modelmap/QueryModuleFromHTTPRequest.java

    r21106 r21163  
    2828  protected String reloadRequestParameterName     = "Reload";  // request param name used to start new query.
    2929  protected String configurationPathParameterName = null;      // request param name for the qm configuration path.
    30   protected String[] configurationPathRequestPathPrefixes =
     30  protected String[] pathPrefixesToRemove =
    3131      new String[] { "query/builder", "query/submit", "query/result", "query/configuration"};
    3232
     
    8282   * remove all path info up to and including that value to retrieve the actual
    8383   * config path.
    84    * @param configurationPathPrefixToRemove array of strings to be looped through.
     84   * @param pathPrefixesToRemove array of strings to be looped through.
    8585   */
    86   public void setConfigurationPathRequestPathPrefixes(String[] configurationPathRequestPathPrefixes) {this.configurationPathRequestPathPrefixes = configurationPathRequestPathPrefixes;}
     86  public void setPathPrefixesToRemove(String[] pathPrefixesToRemove) {this.pathPrefixesToRemove = pathPrefixesToRemove;}
    8787
    8888
     
    131131    if(!StrLib.isSomething(configurationPath)) {
    132132      String requestPath = IOPath.getFilePathAndNameWithoutExtension(request.getRequestURI());
    133       for (String pathPrefix : configurationPathRequestPathPrefixes) {
    134         int i = requestPath.indexOf(pathPrefix);
     133      for (String pathPrefixToRemove : this.pathPrefixesToRemove) {
     134        int i = requestPath.indexOf(pathPrefixToRemove);
    135135        if(i > -1) {
    136           configurationPath = requestPath.substring(i + pathPrefix.length() + 1);
     136          configurationPath = requestPath.substring(i + pathPrefixToRemove.length() + 1);
    137137          break;
    138138        }
  • trunk/ibisph/src/main/java/org/ibisph/web/springmvc/ModelMapListProcessingController.java

    r9203 r21163  
    110110      Map<String, Object> newModelMap = null;
    111111
    112       if(modelMapService instanceof GetModelMap)
    113         newModelMap = ((GetModelMap)modelMapService).getModelMap();
     112      if(modelMapService instanceof GetModelMapFromModelMapAndHTTPRequest)
     113        newModelMap = ((GetModelMapFromModelMapAndHTTPRequest)modelMapService).getModelMap(modelMap, request);
    114114      else if(modelMapService instanceof GetModelMapFromHTTPRequest)
    115115        newModelMap = ((GetModelMapFromHTTPRequest)modelMapService).getModelMap(request);
    116116      else if(modelMapService instanceof GetModelMapFromModelMap)
    117117        newModelMap = ((GetModelMapFromModelMap)modelMapService).getModelMap(modelMap);
    118       else if(modelMapService instanceof GetModelMapFromModelMapAndHTTPRequest)
    119         newModelMap = ((GetModelMapFromModelMapAndHTTPRequest)modelMapService).getModelMap(modelMap, request);
     118      else if(modelMapService instanceof GetModelMap)
     119        newModelMap = ((GetModelMap)modelMapService).getModelMap();
    120120
    121121      else {
    122         if(modelMapService instanceof ProcessModelMap)
     122        if(modelMapService instanceof ProcessModelMapFromHTTPRequest)
     123          ((ProcessModelMapFromHTTPRequest)modelMapService).processModelMap(modelMap, request);
     124        else if(modelMapService instanceof ProcessModelMap)
    123125          ((ProcessModelMap)modelMapService).processModelMap(modelMap);
    124         else if(modelMapService instanceof ProcessModelMapFromHTTPRequest)
    125           ((ProcessModelMapFromHTTPRequest)modelMapService).processModelMap(modelMap, request);
    126126      }
    127127
Note: See TracChangeset for help on using the changeset viewer.