Changeset 30617 for main/trunk


Ignore:
Timestamp:
2016-07-22T19:41:17+12:00 (8 years ago)
Author:
ak19
Message:

Bugfix to oversight: web document editor didn't reindex on removing metadata, only on setting it. This is because there wasn't corresponding Service on Java side to handle removing metadata. Now the Java code has a ModifyMetdata service and this is connected to both the set- and remove-metadata functions in the javascript. For now, the javascript metadataserver calls have been made synchronous by setting the async ajax-jquery property to false. Need to test whether the code still works asynchronous as before.

Location:
main/trunk/greenstone3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java

    r30516 r30617  
    3535    public static final int BUILD = 2;
    3636    public static final int ACTIVATE = 3;
    37     public static final int SET_METADATA_SERVER = 4;
     37    public static final int MODIFY_METADATA_SERVER = 4;
    3838
    3939    /**
     
    122122            activateCollection();
    123123            break;
    124         case SET_METADATA_SERVER:
    125             setMetadataForCollection();
     124        case MODIFY_METADATA_SERVER:
     125            modifyMetadataForCollection();
    126126            break;
    127127        default:
     
    285285        command.add("-collectdir");
    286286        command.add(GSFile.collectDir(this.site_home));
    287 //      command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly
     287//      command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly. Shouldn't be added for incremental building
    288288        command.add("-skipactivation"); // gsdl3/util/GS2Construct does the activation and reactivation
    289289        command.addAll(extractParameters(this.process_params));
     
    302302
    303303
    304     protected void setMetadataForCollection()
    305     {
    306         sendMessage(new ConstructionEvent(this, GSStatus.INFO, "Collection metadata: setMetadata for collection."));
     304    protected void modifyMetadataForCollection()
     305    {
     306        sendMessage(new ConstructionEvent(this, GSStatus.INFO, "Collection metadata: modifyMetadata (set or remove meta) for collection."));
    307307
    308308        Vector<String> command = new Vector<String>();
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentMaker.java

    r30516 r30617  
    487487        if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ))
    488488        {
    489             logger.error("Could not open collection archives database. Somebody already using this database!");
     489            logger.error("Could not open collection archives database. Database doesn't exist or else somebody's already using it?");
     490            return;
    490491        }
    491492        String old_value = coll_db.getValue(oid);
     
    496497        {
    497498            logger.error("Could not open collection archives database. Somebody already using this database!");
     499            return;
    498500        }
    499501        coll_db.setValue(oid, new_value);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r30616 r30617  
    6767    private static final String DELETE_SERVICE = "DeleteCollection";
    6868    private static final String RELOAD_SERVICE = "ReloadCollection";
    69     private static final String SET_METADATA_SERVICE = "SetMetadata";
     69    private static final String MODIFY_METADATA_SERVICE = "ModifyMetadata"; // set or remove metadata
     70
    7071
    7172    // params used
     
    128129                param_list.appendChild(param);
    129130            }
    130             else if (service.equals(ACTIVATE_SERVICE) || service.equals(IMPORT_SERVICE) || service.equals(BUILD_SERVICE) || service.equals(RELOAD_SERVICE) || service.equals(DELETE_SERVICE) || service.equals(SET_METADATA_SERVICE))
     131            else if (service.equals(ACTIVATE_SERVICE) || service.equals(IMPORT_SERVICE) || service.equals(BUILD_SERVICE) || service.equals(RELOAD_SERVICE) || service.equals(DELETE_SERVICE) || service.equals(MODIFY_METADATA_SERVICE))
    131132            {
    132133
     
    185186    {
    186187        // check permissions
    187         if (!userHasCollectionEditPermissions(request)) {
     188        if (!userHasCollectionEditPermissions(request)) {
    188189            Document result_doc = XMLConverter.newDOM();
    189190            Element result = GSXML.createBasicResponse(result_doc, "processBuildAndActivateCollection");
    190191            GSXML.addError(result, "This user does not have the required permissions to perform this action.");
    191192            return result;
    192         }
    193 
     193        }
     194
     195           
    194196        waitUntilReady(request);
    195197        Element buildResponse = processBuildCollection(request);
     
    305307    }
    306308
    307     protected Element processSetMetadata(Element request)
     309    protected Element processModifyMetadata(Element request)
    308310    {
    309311        if (!userHasCollectionEditPermissions(request)) {
    310312        Document result_doc = XMLConverter.newDOM();
    311         Element result = GSXML.createBasicResponse(result_doc, "processSetMetadata");
     313        Element result = GSXML.createBasicResponse(result_doc, "processModifyMetadata");
    312314        GSXML.addError(result, "This user does not have the required permissions to perform this action.");
    313315        return result;
    314316        }
    315317
    316         return runCommand(request, GS2PerlConstructor.SET_METADATA_SERVER);
     318        return runCommand(request, GS2PerlConstructor.MODIFY_METADATA_SERVER);
    317319    }
    318320
     
    619621        e = this.desc_doc.createElement(GSXML.SERVICE_ELEM);
    620622        e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
    621         e.setAttribute(GSXML.NAME_ATT, SET_METADATA_SERVICE);
     623        e.setAttribute(GSXML.NAME_ATT, MODIFY_METADATA_SERVICE);
    622624        this.short_service_info.appendChild(e);
    623625
     
    708710            constructor.setManifestFile(this.site_home + File.separator + "collect" + File.separator + params.get(COL_PARAM) + File.separator + "manifests" + File.separator + "tempManifest.xml");
    709711        }
    710         else if (type == GS2PerlConstructor.SET_METADATA_SERVER) {
     712        else if (type == GS2PerlConstructor.MODIFY_METADATA_SERVER) {
    711713            StringBuffer querystring = new StringBuffer();
    712714           
     
    977979        if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ))
    978980        {
    979             logger.error("Could not open collection archives database. Database doesn't exist or else somebody is already using it?");
     981            logger.error("Could not open collection archives database. Database doesn't exist or else somebody's already using it?");
    980982            return;
    981983        }
     
    988990        {
    989991            logger.error("Could not open collection archives database. Somebody already using this database!");
     992            return;
    990993        }
    991994        coll_db.setValue(oid, new_value);
  • main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js

    r30014 r30617  
    424424function callMetadataServer(callingFunction, url, responseFunction)
    425425{
    426     // rewrite URLs to call GS2Construct's SetMetadata service instead.
     426    // If doing set- or remove- (not get-) metadata, then rewrite URLs to call GS2Construct's ModfiyMetadata service instead (which will ensure this only works when authenticated).
    427427    // From:
    428428    // <gs3server>/cgi-bin/metadata-server.pl?a=set-archives-metadata&c=smallcol&site=localsite&d=HASH01454f31011f6b6b26eaf8d7&metaname=Title&metavalue=Moo&prevmetavalue=Blabla&metamode=override
    429429    // To:
    430     // <gs3server>/library?a=g&rt=r&ro=1&s=SetMetadata&s1.a=set-archives-metadata&s1.collection=smallcol&s1.site=localsite&s1.d=HASH01454f31011f6b6b26eaf8d7&s1.metaname=Title&s1.metavalue=Moo&s1.prevmetavalue=Blabla&s1.metamode=override
    431 
    432     // if we're doing a set- metdata operation, then we'll be changing the URL to make sure we go through GS3's authentication
    433     if(url.indexOf("set-") != -1) {
     430    // <gs3server>/library?a=g&rt=r&ro=1&s=ModifyMetadata&s1.a=set-archives-metadata&s1.collection=smallcol&s1.site=localsite&s1.d=HASH01454f31011f6b6b26eaf8d7&s1.metaname=Title&s1.metavalue=Moo&s1.prevmetavalue=Blabla&s1.metamode=override
     431
     432    // if we're doing a set- or remove- metadata operations, then we'll be changing the URL to make sure we go through GS3's authentication
     433    if(url.indexOf("set-") != -1 || url.indexOf("remove-") != -1) {
     434   
    434435    url = url.replace("&c=",  "&collection="); // c is a special param name for GS2Construct
    435436    url = url.replace(/(&|\?)([^=]*=)/g, "$1"+"s1.$2"); // prefix param names with "s1."
    436     url = url.replace("cgi-bin/metadata-server.pl?",  gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=SetMetadata&");
    437 
     437    url = url.replace("cgi-bin/metadata-server.pl?",  gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=ModifyMetadata&");
    438438    console.log("@@@@@ URL is " + url);
    439439    } // otherwise, such as for get- metadata operation, we proceed as before, which will not require authentication
    440 
    441     $.ajax(url)
     440   
     441    $.ajax(url, {async: false})
    442442    .success(function(response)
    443443    {
Note: See TracChangeset for help on using the changeset viewer.