Changeset 30540

Show
Ignore:
Timestamp:
16.05.2016 14:24:50 (4 years ago)
Author:
litvinovg
Message:

Added collection groups. Config file in web/sites/localsite/groupConfig.xml
PageAction? now send request to CollectionGroups? service to retrieve information about collections and groups.

Location:
main/trunk/greenstone3
Files:
2 added
7 modified

Legend:

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

    r28964 r30540  
    2626 
    2727    public Node process(Node message_node) 
     28     
    2829    { 
    2930        Element message = GSXML.nodeToElement(message_node); 
     
    9293      Document doc = XMLConverter.newDOM(); 
    9394         
     95 
    9496        UserContext userContext = new UserContext(request); 
    9597        // first, get the message router info 
    9698        Element info_message = doc.createElement(GSXML.MESSAGE_ELEM); 
    97         Element coll_list_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext); 
    98         info_message.appendChild(coll_list_request); 
     99        Element info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext); 
     100        //Create param list 
     101        Element param_list_element = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     102        info_request.appendChild(param_list_element); 
     103        //Describe params without collectionlist. Collectionlist provided by CollectionGroup service 
     104        GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.CLUSTER_ELEM + GSXML.LIST_MODIFIER); 
     105        GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
     106        GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.SITE_ELEM + GSXML.LIST_MODIFIER); 
     107        GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 
     108        info_message.appendChild(info_request); 
     109        //Send request to message router 
    99110        Element info_response_message = (Element) this.mr.process(info_message); 
     111        //Check if it is not null 
    100112        if (info_response_message == null) 
    101113        { 
     
    103115            return null; 
    104116        } 
     117        //Check if it is not null 
    105118        Element info_response = (Element) GSXML.getChildByTagName(info_response_message, GSXML.RESPONSE_ELEM); 
    106119        if (info_response == null) 
     
    108121            logger.error("couldn't query the message router!"); 
    109122            return null; 
     123        } 
     124         
     125        Element resp_service_list = (Element) GSXML.getChildByTagName(info_response, GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
     126         
     127        if (resp_service_list == null) { 
     128            logger.error("No services available. Couldn't query the message router!"); 
     129            return null; 
     130        } 
     131        Element groupInfoService = GSXML.getNamedElement(resp_service_list, GSXML.SERVICE_ELEM, GSXML.TYPE_ATT, 
     132                GSXML.SERVICE_TYPE_GROUPINFO); 
     133        if (groupInfoService != null) { 
     134            // Prepare request for CollectionGroup service to get current 
     135            // collections and groups list 
     136            Element group_info_message = doc.createElement(GSXML.MESSAGE_ELEM); 
     137            Element group_info_request = GSXML.createBasicRequest(doc, GSXML.TO_ATT, 
     138                    groupInfoService.getAttribute(GSXML.NAME_ATT), userContext); 
     139            group_info_message.appendChild(group_info_request); 
     140            //Append group request if exists 
     141            Element paramList = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     142            if (paramList != null) { 
     143                group_info_request.appendChild(doc.importNode(paramList, true)); 
     144            } 
     145            Element group_info_response_message = (Element) this.mr.process(group_info_message); 
     146            Element group_info_response = (Element) GSXML.getChildByTagName(group_info_response_message, 
     147                    GSXML.RESPONSE_ELEM); 
     148            Element collection_list = (Element) GSXML.getChildByTagName(group_info_response, 
     149                    GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 
     150            // Add Collection List from CollectionGroup Service to response 
     151            // from message router 
     152            info_response = (Element) doc.importNode(info_response, true); 
     153            if (collection_list != null) { 
     154                info_response.appendChild(doc.importNode(collection_list, true)); 
     155            } 
     156            Element group_list = (Element) GSXML.getChildByTagName(group_info_response, 
     157                    GSXML.GROUP_ELEM + GSXML.LIST_MODIFIER); 
     158            if (group_list != null) { 
     159                info_response.appendChild(doc.importNode(group_list, true)); 
     160            } 
     161            // Send message to groupInfoType Services 
     162        } else { 
     163            // If no service with type SERVICE_TYPE_GROUPINFO could be provided 
     164            // request message router for all available collections 
     165            GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, 
     166                    GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 
     167            info_response_message = (Element) this.mr.process(info_message); 
     168 
     169            if (info_response_message == null) { 
     170                logger.error(" couldn't query the message router!"); 
     171                return null; 
     172            } 
     173            info_response = (Element) GSXML.getChildByTagName(info_response_message, GSXML.RESPONSE_ELEM); 
     174            if (info_response == null) { 
     175                logger.error("couldn't query the message router!"); 
     176                return null; 
     177            } 
    110178        } 
    111179 
     
    113181        // elements but for now, we'll just get it all 
    114182        Element collection_list = (Element) GSXML.getChildByTagName(info_response, GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 
    115         logger.debug(GSXML.xmlNodeToString(collection_list)); 
     183        //logger.debug(GSXML.xmlNodeToString(collection_list)); 
    116184        if (collection_list != null) 
    117185        { 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSFile.java

    r30516 r30540  
    5454 
    5555    } 
     56     
     57    /** site config file path */ 
     58    static public String groupConfigFile(String site_home) 
     59    { 
     60        return site_home + File.separatorChar + "groupConfig.xml"; 
     61 
     62    } 
     63     
     64    /** site images file path */ 
     65    static public String imagesFilePath(String site_home) 
     66    { 
     67        return site_home + File.separatorChar + "images"; 
     68 
     69    } 
    5670 
    5771    /** interface config file path */ 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r30049 r30540  
    233233    public static final String SERVICE_TYPE_RETRIEVE = "retrieve"; 
    234234    public static final String SERVICE_TYPE_BROWSE = "browse"; 
     235    public static final String SERVICE_TYPE_GROUPINFO = "groupinfo"; 
    235236    public static final String SERVICE_TYPE_APPLET = "applet"; 
    236237    public static final String SERVICE_TYPE_PROCESS = "process"; 
     
    306307    public static final String UTIL_NAMESPACE = "xalan://org.greenstone.gsdl3.util.XSLTUtil"; 
    307308 
     309    //Groups configuration 
     310    public static final String HIERARCHY_ELEM = "hierarchy"; 
     311    public static final String GROUP_DESC_ELEM = "groupDescriptions"; 
     312    public static final String TITLE_ELEM = "title"; 
     313    public static final String DESCRIPTION_ELEM = "description"; 
     314    public static final String SHORT_DESCRIPTION_ELEM = "shortDescription"; 
     315    public static final String BACKGROUND_IMAGE_ELEM = "backgroundImage"; 
     316    public static final String POSITION_ATT = "position"; 
     317     
    308318    /** 
    309319     * takes a list of elements, and returns an array of strings of the values 
  • main/trunk/greenstone3/web/interfaces/default/style/core.css

    r30382 r30540  
    286286} 
    287287 
     288#groupLinks a img{ 
     289        display: block; 
     290        float: left; 
     291        border: 1px solid #888; 
     292        margin: 0 20px 20px 0; 
     293        font-size: 150%; 
     294        color: #444; 
     295        text-decoration: none; 
     296        height:60px; 
     297} 
     298 
     299.groupLink { 
     300    display: block; 
     301    float: left; 
     302    border: 1px solid #888; 
     303    margin: 0 20px 20px 0; 
     304    font-size: 150%; 
     305    color: #444; 
     306    text-decoration: none; 
     307    min-width: 200px; 
     308    text-align:center; 
     309} 
    288310.collectionLink { 
    289311    display: block; 
     
    302324} 
    303325 
     326.groupLinkText { 
     327        padding: 15px 15px 10px; 
     328} 
     329 
    304330/* some text should not be rendered as it is just there for search engines */ 
    305331#collectionLinks a b { 
    306332    display: none; 
     333} 
     334 
     335#groupLinks a b { 
     336        display: none; 
    307337} 
    308338 
  • main/trunk/greenstone3/web/interfaces/default/transform/gslib.xsl

    r30478 r30540  
    199199      </input> 
    200200    </form> 
     201  </xsl:template> 
     202   
     203  <xsl:template name="groupLinkWithImage"> 
     204    <xsl:variable name="desc"><xsl:value-of select="description"/></xsl:variable> 
     205    <xsl:variable name="group_href"><xsl:value-of select="$library_name"/>?a=p&amp;sa=home&amp;group=<xsl:value-of select="/page/pageRequest/paramList/param[@name='group']/@value"/>/<xsl:value-of select="@name"/></xsl:variable> 
     206    <xsl:choose> 
     207      <xsl:when test="backgroundImage"> 
     208        <a href="{$group_href}" title="{$desc}"> 
     209          <img class="groupLinkImage"> 
     210            <xsl:attribute name="alt"><xsl:value-of select="displayItem[@name='name']"/></xsl:attribute> 
     211            <xsl:attribute name="src">sites/<xsl:value-of select="$site_name"/>/images/<xsl:value-of select="backgroundImage"/></xsl:attribute> 
     212          </img> 
     213        </a> 
     214      </xsl:when> 
     215      <xsl:otherwise> 
     216        <a href="{$group_href}" title="{$desc}"> 
     217          <div class="groupLink ui-corner-all"> 
     218            <div class="groupLinkText ui-widget-content ui-corner-top"> 
     219                <xsl:value-of select="title"/> 
     220            </div> 
     221            <div style="height:15px;" class="ui-state-default ui-corner-bottom"><xsl:text> </xsl:text></div> 
     222          </div> 
     223        </a> 
     224      </xsl:otherwise> 
     225    </xsl:choose> 
    201226  </xsl:template> 
    202227   
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/home.xsl

    r30478 r30540  
    1515 
    1616    <!-- set page breadcrumbs --> 
    17     <xsl:template name="breadcrumbs"></xsl:template> 
     17    <xsl:template name="breadcrumbs"> 
     18        <xsl:if test="/page/pageRequest/paramList/param[@name='group']"> 
     19            <gslib:siteLink/> 
     20        </xsl:if> 
     21    </xsl:template> 
    1822 
    1923    <!-- the page content --> 
     
    2630        <h2><gslib:selectACollectionTextBar/></h2> 
    2731 
    28         <xsl:call-template name="collectionLinks"/> 
    29  
     32        <xsl:for-each select="collectionList/collection|groupList/group"> 
     33                    <xsl:sort select="@position"/> 
     34            <xsl:if test="name() = 'collection'"> 
     35                                <gslib:collectionLinkWithImage/> 
     36            </xsl:if> 
     37            <xsl:if test="name() = 'group'"> 
     38                                <gslib:groupLinkWithImage/> 
     39            </xsl:if>            
     40                </xsl:for-each> 
     41     
    3042            <div style="clear: both; padding-top: 4px; padding-bottom: 4px;"><hr/></div> 
    3143 
     
    4355    </xsl:template> 
    4456 
     57    <xsl:template name="groupLinks"> 
     58        <div id="groupLinks"> 
     59            <!-- <xsl:if test="count(groupList/group) = 0"> 
     60                <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home.no_collections')"/> 
     61                <br/> 
     62            </xsl:if> 
     63            --> 
     64            <xsl:for-each select="groupList/group"> 
     65                <gslib:groupLinkWithImage/> 
     66            </xsl:for-each> 
     67            <br class="clear"/> 
     68        </div> 
     69    </xsl:template> 
     70     
    4571    <xsl:template name="collectionLinks"> 
    4672        <div id="collectionLinks"> 
  • main/trunk/greenstone3/web/sites/localsite/siteConfig.xml

    r28260 r30540  
    1212         
    1313        <serviceRack name="ArchiveIO"/> 
     14        <serviceRack name="CollectionGroups"/> 
    1415        <serviceRack name="DocumentMaker"/> 
    1516        <serviceRack name="DocXMLUtil"/>