Changeset 25069


Ignore:
Timestamp:
02/10/12 15:33:02 (9 years ago)
Author:
sjm84
Message:

Added a function to clear all the documents

File:
1 edited

Legend:

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

    r24993 r25069  
    3131
    3232import org.greenstone.util.GlobalProperties;
     33import org.greenstone.gsdl3.util.GSParams;
    3334import org.greenstone.gsdl3.util.GSXML;
    3435import org.greenstone.gsdl3.util.GSPath;
     
    6263    protected static final String DELETE_ITEMS_SERVICE = "DeleteDocuments";
    6364    protected static final String DELETE_ITEM_SERVICE = "DeleteDocument";
     65    protected static final String CLEAR_ITEMS_SERVICE = "ClearDocuments";
    6466    //added
    6567    protected static final String MERGE_ITEM_SERVICE = "MergeDocument";
     
    141143        deleteone_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEM_SERVICE);
    142144        this.short_service_info.appendChild(deleteone_service);
     145       
     146        // set up short_service_info_ - for now just has name and type
     147        Element deleteall_service = this.doc.createElement(GSXML.SERVICE_ELEM);
     148        deleteall_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
     149        deleteall_service.setAttribute(GSXML.NAME_ATT, CLEAR_ITEMS_SERVICE);
     150        this.short_service_info.appendChild(deleteall_service);
    143151
    144152        // set up short_service_info_ - for now just has name and type
     
    187195            return del_service;
    188196        }
     197       
     198        if (service_id.equals(CLEAR_ITEMS_SERVICE))
     199        {
     200
     201            Element clear_service = this.doc.createElement(GSXML.SERVICE_ELEM);
     202            clear_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
     203            clear_service.setAttribute(GSXML.NAME_ATT, CLEAR_ITEMS_SERVICE);
     204            return clear_service;
     205        }
    189206
    190207        if (service_id.equals(DELETE_ITEM_SERVICE))
     
    235252            item = item.substring(pos + 1);
    236253        }
     254        System.err.println("COLLECTION ADD IS " + collection);
    237255        //logger.error("COLLECTION = " + collection + " *** ITEM = " + item);
    238256        if (docsMap.containsKey(collection))
     
    401419        return item;
    402420    }
     421   
     422    protected Element processClearDocuments(Element request)
     423    {
     424        Hashtable docsMap = updateDocMap(request);
     425       
     426        Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
     427       
     428        // Get the parameters of the request
     429        Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     430       
     431        if (param_list == null)
     432        {
     433            logger.error("DocumentBasket Error: DeleteDocument request had no paramList.");
     434            return result; // Return the empty result
     435        }
     436
     437        HashMap params = GSXML.extractParams(param_list, false);
     438        String collection = (String) params.get(GSParams.COLLECTION);
     439
     440        System.err.println("COLLECTION = " + collection);
     441        if (collection == null)
     442            return result;
     443       
     444        docsMap.put(collection, new Hashtable());
     445       
     446        return result;
     447    }
    403448
    404449    protected Element processDeleteDocuments(Element request)
     
    480525        HashMap params = GSXML.extractParams(param_list, false);
    481526
    482         String param = (String) params.get("item");
    483 
    484         if (param == null)
     527        String item = (String) params.get("item");
     528
     529        if (item == null)
    485530            return result;
    486 
    487         String item = param;
    488531
    489532        String collection = "";
Note: See TracChangeset for help on using the changeset viewer.