Changeset 24888


Ignore:
Timestamp:
12/13/11 10:00:19 (9 years ago)
Author:
sjm84
Message:

Some further changes to help Greenstone 3 use Perl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r24855 r24888  
    167167    protected Element processActivateCollection(Element request)
    168168    {
    169         Element response = runCommand(request, GS2PerlConstructor.ACTIVATE);
    170169        // this activates the collection on disk. but now we need to tell
    171170        // the MR about it. but we have to wait until the process is finished.
    172         Element status = (Element) GSXML.getChildByTagName(response, GSXML.STATUS_ELEM);
    173171        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    174172        HashMap params = GSXML.extractParams(param_list, false);
    175173        String coll_name = (String) params.get(COL_PARAM);
    176174        String lang = request.getAttribute(GSXML.LANG_ATT);
     175
     176        systemRequest("delete", coll_name, null, lang);
     177
     178        Element response = runCommand(request, GS2PerlConstructor.ACTIVATE);
     179        Element status = (Element) GSXML.getChildByTagName(response, GSXML.STATUS_ELEM);
     180
     181        String request_type = request.getAttribute(GSXML.TYPE_ATT);
     182        if (request_type.equals(GSXML.REQUEST_TYPE_STATUS))
     183        {
     184            return response;
     185        }
     186
    177187        // check for finished
    178188        int status_code = Integer.parseInt(status.getAttribute(GSXML.STATUS_ERROR_CODE_ATT));
     
    320330    protected void systemRequest(String action_name, String coll_name, Element status, String lang)
    321331    {
    322 
    323332        // send the request to the MR
    324333        Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     
    348357        String[] args = { coll_name };
    349358
    350         if (response == null)
    351         {
    352             t = this.doc.createTextNode(getTextString(action_name + ".configure_error", lang, args));
    353             status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
     359        if (status != null)
     360        {
     361            if (response == null)
     362            {
     363                t = this.doc.createTextNode(getTextString(action_name + ".configure_error", lang, args));
     364                status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
     365                status.appendChild(t);
     366                return;
     367            }
     368
     369            // if we got here, we have succeeded!
     370            t = this.doc.createTextNode(getTextString(action_name + ".success", lang, args));
     371            status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.SUCCESS));
    354372            status.appendChild(t);
    355             return;
    356         }
    357 
    358         // if we got here, we have succeeded!
    359         t = this.doc.createTextNode(getTextString(action_name + ".success", lang, args));
    360         status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.SUCCESS));
    361         status.appendChild(t);
     373        }
    362374    }
    363375
     
    421433    protected Element runCommand(Element request, int type)
    422434    {
    423 
    424435        // the response to send back
    425436        String name = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT));
     
    430441
    431442        String lang = request.getAttribute(GSXML.LANG_ATT);
     443        String uid = request.getAttribute(GSXML.USER_ID_ATT);
    432444        String request_type = request.getAttribute(GSXML.TYPE_ATT);
    433445
     
    479491            coll_name = (String) params.get(COL_PARAM);
    480492        }
    481         logger.error("Coll name = " + coll_name);
     493        logger.info("Coll name = " + coll_name);
    482494        // makes a paramList of the relevant params
    483495        Element other_params = extractOtherParams(params, type);
    484496
    485497        //create the constructor to do the work
    486 
    487498        GS2PerlConstructor constructor = new GS2PerlConstructor("perl_build");
    488499        if (!constructor.configure())
     
    494505        }
    495506
     507        GS2PerlListener listener = new GS2PerlListener();
    496508        constructor.setSiteHome(this.site_home);
    497509        constructor.setCollectionName(coll_name);
    498510        constructor.setActionType(type);
    499511        constructor.setProcessParams(other_params);
    500         // the listener
    501         GS2PerlListener listener = new GS2PerlListener();
     512
    502513        constructor.addListener(listener);
    503514        constructor.start();
     
    511522        status.appendChild(t);
    512523        return response;
    513 
    514524    }
    515525
Note: See TracChangeset for help on using the changeset viewer.