Changeset 5864


Ignore:
Timestamp:
Nov 10, 2011, 9:15:24 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

Merged patch release 3.0.1 to the trunk.

Location:
trunk
Files:
1 deleted
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/credits.txt

    r5805 r5864  
    11$Id$
    22
    3 The current BASE team is (at BASE 3.0-beta release)
     3The current BASE team is (at BASE 3.0.1 release)
    44{{{
    55Jari Häkkinen
  • trunk/doc/src/docbook/overview/resources.xml

    r5782 r5864  
    135135        contains information about the plans for future development, including
    136136        the tickets that should be fixed for each milestone. Usually, only
    137         the next upcoming release has a date set. The <guilabel>BASE 2.x</guilabel>
     137        the next upcoming release has a date set. The <guilabel>BASE Future Release</guilabel>
    138138        milestone is used to collected tickets that we think should be fixed
    139139        but are less important or require too much work. Contributions are welcome.
     
    191191      </para>
    192192    </sect2>
    193   </sect1>
    194   <sect1 id="resources.coreplugins">
    195     <title>Core plug-in configurations</title>
    196     <para>
    197       In the section called <guilabel>Plug-ins</guilabel> on the home page, is a
    198       link to
    199       <ulink
    200         url="http://base.thep.lu.se/chrome/site/doc/historical/admin/plugin_configuration/coreplugins.html">
    201         a page that lists the core plug-ins</ulink>.
    202       All plug-ins that are included in the installation of
    203       BASE are listed on this page, some together with one or several examples of suitable
    204       configuration files. These configuration files can be downloaded and imported with the
    205       plug-in configuration importer in BASE.
    206     </para>
    207193  </sect1>
    208194  <sect1 id="resources.plugins">
  • trunk/src/core/net/sf/basedb/core/Install.java

    r5853 r5864  
    118118    method.
    119119  */
    120   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(100).intValue();
     120  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(102).intValue();
    121121 
    122122  public static synchronized int createTables(SchemaGenerator.Mode mode, ProgressReporter progress,
  • trunk/src/core/net/sf/basedb/core/Update.java

    r5837 r5864  
    9595    </td>
    9696  </tr>
    97  
     97  <tr>
     98    <td>101 and 102</td>
     99    <td>
     100      Fixes an issue with duplicate {@link FileSetMemberData} entries
     101      due to a bug in the upgrade program. Make sure that the unique
     102      constraint that should prevent duplicates exists.
     103    </td>
     104  </tr>
     105
    98106  </table>
    99107
     
    122130    throws BaseException
    123131  {
    124     final int total_progress_steps = Install.NEW_SCHEMA_VERSION;
    125     final float progress_factor = 100F / total_progress_steps;
    126132    if (progress != null) progress.display(0, "Updating database...");
    127133    org.hibernate.Session session = null;
     
    141147      session = HibernateUtil.newSession();
    142148      int schemaVersion = getSchemaVersion(session);
     149      final int total_progress_steps = 1 + Install.NEW_SCHEMA_VERSION - schemaVersion;
     150      final float progress_step = 100F / total_progress_steps;
     151      float progress_current = progress_step;
    143152     
    144153      if (schemaVersion == 99)
    145154      {
    146155        // Final update to BASE 3
    147         if (progress != null) progress.display((int)(1*progress_factor), "--Updating schema version: " + schemaVersion + " -> 100...");
     156        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 100...");
    148157        schemaVersion = updateToSchemaVersion100(session);
    149 
     158        progress_current += progress_step;
     159       
     160        // Skipping directly to 102 since the updateToBase3()
     161        // has already fixed those issues
     162        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 102...");
     163        schemaVersion = setSchemaVersionInTransaction(session, 102);
     164        progress_current += 2 * progress_step;
     165      }
     166
     167      // The 101 and 102 updates are only needed when updating from a BASE 3.0.0 installation
     168      if (schemaVersion < 101)
     169      {
     170        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 101...");
     171        schemaVersion = updateToSchemaVersion101(session);
     172        progress_current += progress_step;
     173      }
     174     
     175      if (schemaVersion < 102)
     176      {
     177        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 102...");
     178        schemaVersion = updateToSchemaVersion102(session);
     179        progress_current += progress_step;
    150180      }
    151181     
     
    435465  }
    436466
     467  /**
     468    Remove duplicate file set members.
     469   
     470    @return The new schema version (=101)
     471  */
     472  private static int updateToSchemaVersion101(org.hibernate.Session session)
     473    throws BaseException
     474  {
     475    final int schemaVersion = 101;
     476    org.hibernate.Transaction tx = null;
     477    try
     478    {
     479      tx = HibernateUtil.newTransaction(session);
     480
     481      org.hibernate.Query query = HibernateUtil.createQuery(session,
     482        "SELECT fsm FROM FileSetMemberData fsm");
     483      List<FileSetMemberData> members = HibernateUtil.loadList(FileSetMemberData.class, query, null);
     484      Set<String> allMembers = new HashSet<String>();
     485      for (FileSetMemberData member : members)
     486      {
     487        int fileSetId = member.getFileSet().getId();
     488        int fileTypeId = member.getDataFileType().getId();
     489        int fileId = member.getFile().getId();
     490        String unique = fileSetId + "." + fileTypeId + "." + fileId;
     491        if (!allMembers.add(unique))
     492        {
     493          // This combination has been seen before
     494          session.delete(member);
     495        }
     496      }
     497     
     498      // Update the schema version number
     499      setSchemaVersion(session, schemaVersion);
     500 
     501      // Commit the changes
     502      HibernateUtil.commit(tx);
     503      log.info("updateToSchemaVersion101: OK");
     504    }
     505    catch (BaseException ex)
     506    {
     507      if (tx != null) HibernateUtil.rollback(tx);
     508      log.error("updateToSchemaVersion101: FAILED", ex);
     509      throw ex;
     510    }
     511    return schemaVersion;
     512  }
     513
     514  /**
     515    Add unique index on FileSetMembers(fileset_id,datafiletype_id,file_id)
     516   
     517    @return The new schema version (=102)
     518  */
     519  private static int updateToSchemaVersion102(org.hibernate.Session session)
     520    throws BaseException
     521  {
     522    final int schemaVersion = 102;
     523    try
     524    {
     525 
     526      // Try to drop just to make sure that we don't create duplicated indexes
     527      dropIndex(session, true, "FileSetMembers", "fileset_id", "datafiletype_id", "file_id");
     528      // Create the index
     529      createIndex(session, true, "FileSetMembers_uniquefile", "FileSetMembers", "fileset_id", "datafiletype_id", "file_id");
     530     
     531      // Update the schema version number
     532      setSchemaVersionInTransaction(session, schemaVersion);
     533 
     534      log.info("updateToSchemaVersion102: OK");
     535    }
     536    catch (SQLException ex)
     537    {
     538      log.error("updateToSchemaVersion102: FAILED", ex);
     539      throw new BaseException(ex);
     540    }
     541    catch (BaseException ex)
     542    {
     543      log.error("updateToSchemaVersion102: FAILED", ex);
     544      throw ex;
     545    }
     546    return schemaVersion;
     547  }
     548 
    437549  // Item type codes for item types that was removed since BASE 2
    438550  private static final int LABELEDEXTRACT = 204;
     
    491603      progress.display(15, "--Removing unique constraint on FileSetMembers");
    492604      dropIndex(session, true, "FileSetMembers", "fileset_id", "datafiletype_id");
     605      createIndex(session, true, "FileSetMembers_uniquefile", "FileSetMembers", "fileset_id", "datafiletype_id", "file_id");
    493606      fixPlatformFileTypes(session);
    494607     
     
    11661279        FileSetData fileSet = null;
    11671280       
     1281        // Keep track of duplicate files (since more than one image may reference the same fileId)
     1282        Set<Integer> files = new HashSet<Integer>();
     1283       
    11681284        while (it2.hasNext())
    11691285        {
    11701286          Object[] imgRow = (Object[])it2.next();
    11711287          Integer fileId = (Integer)imgRow[2];
    1172           if (fileId != null)
     1288          if (fileId != null && files.add(fileId))
    11731289          {
    11741290            if (fileSet == null)
  • trunk/src/test/TestFile.java

    r5758 r5864  
    8282        "data/base2.thep.lu.se.crt", null, null);
    8383    int extId1 = test_create("http://base.thep.lu.se/robots.txt", false, false);
    84     int extId2 = test_create("https://base2.thep.lu.se/base/base-2.15.0.tar.gz.MD5", false, false);
     84    int extId2 = test_create("https://base2.thep.lu.se/base/base-2.17.2.tar.gz.MD5", false, false);
    8585    int extId3 = test_create("http://base.thep.lu.se/login", false, false);
    8686    test_load(id1);
     
    9696    test_download(id1, "data/test.upload.txt");
    9797    test_download(extId1, "data/test.download.robots.txt");
    98     test_download(extId2, "data/test.download.base-2.15.0.MD5");
     98    test_download(extId2, "data/test.download.base-2.17.2.md5");
    9999    test_download(extId3, null);
    100100   
Note: See TracChangeset for help on using the changeset viewer.