Changeset 568

Show
Ignore:
Timestamp:
06/09/06 16:50:37
Author:
douglm
Message:

Change processing of the onlyusers restore option and add use to the dump/restore script

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/deployment/dumprestore/shellscr/resources/dumpres.sh

    r492 r568  
    2323    echo $RESTORECMD -appname $APPNAME -f $2 $3 $4 $5 $6 $7 $8 $9 
    2424    $RESTORECMD -appname $APPNAME -f $2 $3 $4 $5 $6 $7 $8 $9 
     25    ;; 
     26  restore-for-quickstart) 
     27    echo $RESTORECMD -appname $APPNAME -onlyusers "public-user,caladmin,douglm,agrp_*" -f $2 $3 $4 $5 $6 $7 $8 $9 
     28    $RESTORECMD -appname $APPNAME -onlyusers "public-user,caladmin,douglm,agrp_*" -f $2 $3 $4 $5 $6 $7 $8 $9 
    2529    ;; 
    2630  backup) 
  • trunk/calendar3/dumprestore/build.xml

    r463 r568  
    103103          description="Run bedework db restore app to initialise db"> 
    104104    <property name="org.bedework.onlyusers" 
    105               value="public-user,caladmin,douglm,agrp_cct,agrp_arc,agrp_Admissions,agrp_HSS,agrp_IACS,agrp_Arch,agrp_OoC,agrp_MANE,agrp_health,agrp_ccc,agrp_hr,agrp_physics,agrp_advance,agrp_provost,agrp_empac,agrp_it,agrp_soe,agrp_lally,agrp_CogSci,agrp_alum,agrp_parking,agrp_Athletics,agrp_construct,agrp_union,agrp_Library,agrp_chemistry,agrp_ItOps,agrp_Arts,agrp_President,agrp_facilities,agrp_CDC,agrp_fye,agrp_ECSE,agrp_NetTel,agrp_Math,agrp_dses,agrp_compsci,agrp_Economics,agrp_govrel,agrp_CHME,agrp_Bookstore,agrp_mse,agrp_Diversity,agrp_OriginsOfLife,agrp_doso,agrp_CEE,agrp_SoS,agrp_CreditUnion,agrp_ResLife,agrp_Purchasing,agrp_LRC,agrp_STS,agrp_ComputerStore,agrp_catering,agrp_CIUE,agrp_Biology,agrp_PublicSafety,agrp_UnionClubs,agrp_cpfd,agrp_FYS,agrp_SRFS,agrp_EES,agrp_ALAC,agrp_SCOREC,agrp_CFES,agrp_CATS,agrp_LLC,agrp_Archer,agrp_OMSA,agrp_Nanotech,agrp_BioMed,agrp_CBIS" /> 
     105              value="public-user,caladmin,douglm,agrp_*" /> 
    106106    <antcall target="restoredb" inheritrefs="true" /> 
    107107  </target> 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/HibRestore.java

    r534 r568  
    182182   */ 
    183183  public void restoreUser(BwUser o) throws Throwable { 
    184     if (globals.onlyUsers && 
    185         (globals.onlyUsersMap.get(o.getAccount()) == null)) { 
     184    if (!globals.onlyUsersMap.check(o)) { 
    186185      return; 
    187186    } 
     
    206205   */ 
    207206  public void restoreUserInfo(BwUserInfo o) throws Throwable { 
    208     if (globals.onlyUsers && 
    209         (globals.onlyUsersMap.get(o.getUser().getAccount()) == null)) { 
     207    if (!globals.onlyUsersMap.check(o.getUser())) { 
    210208      return; 
    211209    } 
     
    219217 
    220218  public void restoreTimezone(BwTimeZone o) throws Throwable { 
    221     if (!checkOnlyUser(o)) { 
     219    if (!globals.onlyUsersMap.check(o)) { 
    222220      return; 
    223221    } 
     
    253251    } 
    254252 
    255     if (globals.onlyUsers) { 
    256       if (globals.onlyUsersMap.get(o.getGroupOwner().getAccount()) == null) { 
    257         o.setGroupOwner(globals.getPublicUser()); 
    258       } 
     253    if (!globals.onlyUsersMap.check(o.getGroupOwner())) { 
     254      o.setGroupOwner(globals.getPublicUser()); 
    259255    } 
    260256 
     
    272268      BwPrincipal pr = (BwPrincipal)it.next(); 
    273269 
    274       if (globals.onlyUsers && 
    275           (pr instanceof BwUser) && 
    276           (globals.onlyUsersMap.get(((BwUser)pr).getAccount()) == null)) { 
     270      if ((pr instanceof BwUser) && !globals.onlyUsersMap.check(pr)) { 
    277271        continue; 
    278272      } 
     
    306300   */ 
    307301  public void restoreAuthUser(BwAuthUser o) throws Throwable { 
    308     if (globals.onlyUsers && 
    309         (globals.onlyUsersMap.get(o.getUser().getAccount()) == null)) { 
     302    if (!globals.onlyUsersMap.check(o.getUser())) { 
    310303      return; 
    311304    } 
     
    326319   */ 
    327320  public void restoreEvent(BwEvent o) throws Throwable { 
    328     if (!checkOnlyUser(o)) { 
     321    if (!globals.onlyUsersMap.check(o)) { 
    329322      return; 
    330323    } 
     
    339332   */ 
    340333  public void update(BwEvent o) throws Throwable { 
    341     if (!checkOnlyUser(o)) { 
     334    if (!globals.onlyUsersMap.check(o)) { 
    342335      return; 
    343336    } 
     
    354347   */ 
    355348  public void restoreCategory(BwCategory o) throws Throwable { 
    356     if (!checkOnlyUser(o)) { 
     349    if (!globals.onlyUsersMap.check(o)) { 
    357350      return; 
    358351    } 
     
    376369   */ 
    377370  public Integer restoreLocation(BwLocation o) throws Throwable { 
    378     if (!checkOnlyUser(o)) { 
     371    if (!globals.onlyUsersMap.check(o)) { 
    379372      return null; 
    380373    } 
     
    405398 
    406399  public Integer restoreSponsor(BwSponsor o) throws Throwable { 
    407     if (!checkOnlyUser(o)) { 
     400    if (!globals.onlyUsersMap.check(o)) { 
    408401      return null; 
    409402    } 
     
    453446 
    454447  public void restoreUserPrefs(BwPreferences o) throws Throwable { 
    455     if (!checkOnlyUser(o)) { 
     448    if (!globals.onlyUsersMap.check(o)) { 
    456449      return; 
    457450    } 
     
    485478 
    486479  public void restoreAlarm(BwAlarm o) throws Throwable { 
    487     if (!checkOnlyUser(o)) { 
     480    if (!globals.onlyUsersMap.check(o)) { 
    488481      return; 
    489482    } 
     
    497490 
    498491  public void update(BwUser user) throws Throwable { 
    499     if (globals.onlyUsers && 
    500         (globals.onlyUsersMap.get(user.getAccount()) == null)) { 
     492    if (!globals.onlyUsersMap.check(user)) { 
    501493      return; 
    502494    } 
     
    554546   */ 
    555547  public void restoreCalendars(BwCalendar o) throws Throwable { 
    556     if (!checkOnlyUser(o)) { 
     548    if (!globals.onlyUsersMap.check(o)) { 
    557549      return; 
    558550    } 
     
    579571 
    580572  public void saveRootCalendar(BwCalendar val) throws Throwable { 
    581     if (!checkOnlyUser(val)) { 
     573    if (!globals.onlyUsersMap.check(val)) { 
    582574      return; 
    583575    } 
     
    600592   */ 
    601593  public void addCalendar(BwCalendar o) throws Throwable { 
    602     if (!checkOnlyUser(o)) { 
     594    if (!globals.onlyUsersMap.check(o)) { 
    603595      return; 
    604596    } 
     
    623615 
    624616  private void restoreCalendars(BwCalendar val, Connection conn) throws Throwable { 
    625     if (!checkOnlyUser(val)) { 
     617    if (!globals.onlyUsersMap.check(val)) { 
    626618      return; 
    627619    } 
     
    649641   */ 
    650642  private void restoreCalendar(BwCalendar val, Connection conn) throws Throwable { 
    651     if (!checkOnlyUser(val)) { 
     643    if (!globals.onlyUsersMap.check(val)) { 
    652644      return; 
    653645    } 
     
    779771  }*/ 
    780772 
    781   private boolean checkOnlyUser(BwOwnedDbentity ent) { 
    782     if (!globals.onlyUsers) { 
    783       return true; 
    784     } 
    785  
    786     if (globals.onlyUsersMap.get(ent.getOwner().getAccount()) == null) { 
    787       return false; 
    788     } 
    789  
    790     return true; 
    791   } 
    792  
    793   private boolean checkOnlyUser(BwShareableDbentity ent) { 
    794     if (!globals.onlyUsers) { 
    795       return true; 
    796     } 
    797  
    798     if (globals.onlyUsersMap.get(ent.getOwner().getAccount()) == null) { 
    799       return false; 
    800     } 
    801  
    802     if (globals.onlyUsersMap.get(ent.getCreator().getAccount()) == null) { 
    803       ent.setCreator(ent.getOwner()); 
    804     } 
    805  
    806     return true; 
    807   } 
    808  
    809773  private String boolVal(boolean val) { 
    810774    if (val) { 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/Restore.java

    r544 r568  
    323323          // means ignore this par 
    324324        } else { 
    325           globals.onlyUsers = true
     325          globals.onlyUsersMap.setOnlyUsers(true)
    326326          String[] users = args[i].split(","); 
    327327          for (int oui = 0; oui < users.length; oui++) { 
    328             info("Only user: " + users[oui]); 
    329             globals.onlyUsersMap.put(users[oui], users[oui]); 
     328            String ou = users[oui]; 
     329            info("Only user: " + ou); 
     330 
     331            globals.onlyUsersMap.add(ou); 
    330332          } 
    331333        } 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/RestoreGlobals.java

    r556 r568  
    223223  public int alarms; 
    224224 
    225   /** If true we should discard all but users in onlyUsers 
    226    * This helps when building demo data 
    227    */ 
    228   public boolean onlyUsers; 
    229  
    230   /** Users we preserve */ 
    231   public HashMap onlyUsersMap = new HashMap(); 
     225  /** Only Users mapping */ 
     226  public OnlyUsersMap onlyUsersMap = new OnlyUsersMap(); 
    232227 
    233228  // 3.0