Changeset 30516


Ignore:
Timestamp:
2016-05-09T16:11:32+12:00 (8 years ago)
Author:
Georgiy Litvinov
Message:

Moved to incremental rebuild in webeditor

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
5 edited

Legend:

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

    r29947 r30516  
    203203        command.add(perlPath + "perl");
    204204        command.add("-S");
    205         command.add(GlobalProperties.getGS2Build() + File.separator + "bin" + File.separator + "script" + File.separator + "buildcol.pl");
     205        command.add(GlobalProperties.getGS2Build() + File.separator + "bin" + File.separator + "script" + File.separator + "incremental-buildcol.pl");
     206        command.add("-incremental");
     207        command.add("-builddir");
     208        command.add(GSFile.collectDir(this.site_home) + File.separator + this.collection_name + File.separator +"index");
    206209        command.add("-site");
    207210        command.add(this.site_name);
    208211        command.add("-collectdir");
    209212        command.add(GSFile.collectDir(this.site_home));
    210         command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly
     213//      command.add("-removeold"); // saves some seconds processing time when this flag's added in explicitly
    211214        command.addAll(extractParameters(this.process_params));
    212215        command.add(this.collection_name);
     
    228231        // first check that we have a building directory
    229232        // (don't want to bother running activate.pl otherwise)
    230         File build_dir = new File(GSFile.collectionBuildDir(this.site_home, this.collection_name));
     233        File build_dir = new File(GSFile.collectionIndexDir(this.site_home, this.collection_name));
    231234        if (!build_dir.exists())
    232235        {
     
    275278        command.add("-S");
    276279        command.add(GlobalProperties.getGS2Build() + File.separator + "bin" + File.separator + "script" + File.separator + "activate.pl");
     280        command.add("-incremental");
     281        command.add("-builddir");
     282        command.add(GSFile.collectDir(this.site_home) + File.separator + this.collection_name + File.separator +"index");
    277283        command.add("-site");
    278284        command.add(this.site_name);
    279285        command.add("-collectdir");
    280286        command.add(GSFile.collectDir(this.site_home));
    281         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
    282288        command.add("-skipactivation"); // gsdl3/util/GS2Construct does the activation and reactivation
    283289        command.addAll(extractParameters(this.process_params));
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentMaker.java

    r28966 r30516  
    3636import org.apache.log4j.*;
    3737
     38import org.greenstone.gsdl3.util.UserContext;
     39import org.greenstone.gsdl3.util.SimpleCollectionDatabase;
     40
     41
    3842import org.greenstone.gsdl3.util.GSDocumentModel;
     43import org.greenstone.gsdl3.util.GSFile;
    3944import org.greenstone.gsdl3.util.GSPath;
    4045import org.greenstone.gsdl3.util.GSXML;
     
    9196            this.short_service_info.appendChild(service);
    9297        }
    93 
     98       
    9499        _GSDM = new GSDocumentModel(this.site_home, this.router);
    95100
     
    445450
    446451                    _GSDM.documentXMLSetText(oid, collection, newContent, userContext);
     452                   
     453                    markDocumentInFlatDatabase("R", collection, oid);
     454
    447455                }
    448456
     
    454462        }
    455463        return result;
     464       
     465    }
     466    protected void markDocumentInFlatDatabase(String mark, String collection, String oid) {
     467   
     468        Document msg_doc = XMLConverter.newDOM();
     469        Element message = msg_doc.createElement(GSXML.MESSAGE_ELEM);
     470        UserContext userContext = new UserContext();
     471        Element query_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE , collection, userContext);       
     472        message.appendChild(query_request);
     473        Element result = (Element) this.router.process(message);
     474        Element resp_elem = (Element) GSXML.getChildByTagName(result, GSXML.RESPONSE_ELEM);
     475        Element coll_elem = (Element) GSXML.getChildByTagName(resp_elem, GSXML.COLLECTION_ELEM);
     476        String dbtype = coll_elem.getAttribute(GSXML.DB_TYPE_ATT);
     477       
     478        SimpleCollectionDatabase coll_db = new SimpleCollectionDatabase(dbtype);
     479        if (!coll_db.databaseOK())
     480        {
     481            logger.error("Couldn't create the collection database of type " + dbtype);
     482            return;
     483        }
     484       
     485        // Open database for reading
     486        String coll_db_file = GSFile.archivesDatabaseFile(this.site_home, collection, dbtype);
     487        if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ))
     488        {
     489            logger.error("Could not open collection archives database. Somebody already using this database!");
     490        }
     491        String old_value = coll_db.getValue(oid);
     492        String new_value = old_value.replace("<index-status>B", "<index-status>" + mark);
     493        // Close database for reading
     494        coll_db.closeDatabase();
     495        if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.WRITE))
     496        {
     497            logger.error("Could not open collection archives database. Somebody already using this database!");
     498        }
     499        coll_db.setValue(oid, new_value);
     500        coll_db.closeDatabase();
     501       
    456502    }
    457503}
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r29947 r30516  
    3838import org.greenstone.gsdl3.util.GSStatus;
    3939import org.greenstone.gsdl3.util.GSXML;
     40import org.greenstone.gsdl3.util.SimpleCollectionDatabase;
    4041import org.greenstone.gsdl3.util.UserContext;
    4142import org.greenstone.gsdl3.util.XMLConverter;
     
    7980    private static final String BUILDTYPE_MGPP = "mgpp";
    8081
     82    protected static String DATABASE_TYPE = null;
     83    protected SimpleCollectionDatabase coll_db = null;
     84   
    8185    // the list of the collections - store between some method calls
    8286    private String[] collection_list = null;
     
    710714            Set<Map.Entry<String, Serializable>> entries = params.entrySet();
    711715            Iterator<Map.Entry<String, Serializable>> i = entries.iterator();
    712             while(i.hasNext()) {
    713716           
    714             Map.Entry<String, Serializable> entry = i.next();
    715             String paramname = entry.getKey();
    716             paramname = paramname.replace("s1.", ""); // replaces all occurrences
    717             if(paramname.equals("collection")) {
    718                 paramname = "c";
    719             }
    720             String paramvalue = (String)entry.getValue();
    721 
    722             querystring.append(paramname + "=" + paramvalue);
    723             if(i.hasNext()) {
    724                 querystring.append("&");
    725             }
     717            String oid = null;
     718           
     719            while (i.hasNext()) {
     720
     721                Map.Entry<String, Serializable> entry = i.next();
     722                String paramname = entry.getKey();
     723                paramname = paramname.replace("s1.", ""); // replaces all
     724                                                            // occurrences
     725                if (paramname.equals("collection")) {
     726                    paramname = "c";
     727                }
     728                if (paramname.equals("d")){
     729                    oid = (String) entry.getValue();
     730                }
     731                String paramvalue = (String) entry.getValue();
     732
     733                querystring.append(paramname + "=" + paramvalue);
     734                if (i.hasNext()) {
     735                    querystring.append("&");
     736                }
    726737            }
     738           
     739            markDocumentInFlatDatabase("R", coll_name, oid);
     740           
    727741            constructor.setQueryString(querystring.toString());
    728742        }
     
    940954   
    941955  }
     956    protected void markDocumentInFlatDatabase(String mark, String collection, String oid) {
     957       
     958        Document msg_doc = XMLConverter.newDOM();
     959        Element message = msg_doc.createElement(GSXML.MESSAGE_ELEM);
     960        UserContext userContext = new UserContext();
     961        Element query_request = GSXML.createBasicRequest(msg_doc, GSXML.REQUEST_TYPE_DESCRIBE , collection, userContext);       
     962        message.appendChild(query_request);
     963        Element result = (Element) this.router.process(message);
     964        Element resp_elem = (Element) GSXML.getChildByTagName(result, GSXML.RESPONSE_ELEM);
     965        Element coll_elem = (Element) GSXML.getChildByTagName(resp_elem, GSXML.COLLECTION_ELEM);
     966        String dbtype = coll_elem.getAttribute(GSXML.DB_TYPE_ATT);
     967       
     968        SimpleCollectionDatabase coll_db = new SimpleCollectionDatabase(dbtype);
     969        if (!coll_db.databaseOK())
     970        {
     971            logger.error("Couldn't create the collection database of type " + dbtype);
     972            return;
     973        }
     974       
     975        // Open database for reading
     976        String coll_db_file = GSFile.archivesDatabaseFile(this.site_home, collection, dbtype);
     977        if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.READ))
     978        {
     979            logger.error("Could not open collection archives database. Somebody already using this database!");
     980        }
     981        String old_value = coll_db.getValue(oid);
     982        String new_value = old_value.replace("<index-status>B", "<index-status>" + mark);
     983        // Close database for reading
     984        coll_db.closeDatabase();
     985        if (!coll_db.openDatabase(coll_db_file, SimpleCollectionDatabase.WRITE))
     986        {
     987            logger.error("Could not open collection archives database. Somebody already using this database!");
     988        }
     989        coll_db.setValue(oid, new_value);
     990        coll_db.closeDatabase();
     991       
     992    }
    942993}
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSFile.java

    r30262 r30516  
    356356    }
    357357
     358    /** the archives database file - */
     359    static public String archivesDatabaseFile(String site_home, String collection_name, String database_type)
     360    {
     361    String db_ext = DBHelper.getDBExtFromDBType(database_type);
     362    if (null == db_ext || db_ext.equals("")) {
     363        logger.warn("Could not recognise database type \"" + database_type + "\", defaulting to GDBM and extension \".gdb\"");
     364        // assume gdbm
     365        db_ext = ".gdb";
     366    }
     367    return site_home + File.separatorChar + "collect" + File.separatorChar + collection_name + File.separatorChar + "archives" + File.separatorChar + "archiveinf-doc" + db_ext;
     368    }
    358369    // some file utility methods
    359370
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/JDBMWrapper.java

    r30264 r30516  
    4444
    4545    RecordManager recman_ = null;
    46     HTree hashtable_;
     46    HTree hashtable_ = null;
    4747
    4848    String db_filename_;
     
    159159    public String getValue(String key)
    160160    {
    161 
     161        if (hashtable_ == null) {
     162            logger.error("Database was not opened or not exist!");
     163            return null;
     164        }
     165       
    162166        String val;
    163167
Note: See TracChangeset for help on using the changeset viewer.