Changeset 5038
- Timestamp:
- Aug 7, 2009, 12:50:01 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 16 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/config/dist/base.config
r5023 r5038 140 140 # secondary.storage.time = 18:15,07:30 141 141 142 # ========================= 143 # Change history section 144 # ========================= 145 146 # Class name of the changelog factory; leave empty to disable the changelog 147 # changelog.factory = net.sf.basedb.core.log.db.DbLogManagerFactory 148 142 149 # =============== 143 150 # General section -
trunk/src/core/net/sf/basedb/core/Application.java
r5023 r5038 28 28 import net.sf.basedb.core.data.SchemaVersionData; 29 29 import net.sf.basedb.core.hibernate.JdbcWork; 30 import net.sf.basedb.core.log.LogManagerFactory; 30 31 import net.sf.basedb.core.authentication.Authenticator; 32 import net.sf.basedb.util.ClassUtil; 31 33 import net.sf.basedb.util.FileUtil; 32 34 import net.sf.basedb.util.RegexpFileFilter; … … 187 189 188 190 /** 191 The name of the log manager factory class, if any. 192 */ 193 private static String logManagerFactoryDriver; 194 195 /** 196 The log manager factory currently in use (may be null) 197 */ 198 private static LogManagerFactory logManagerFactory; 199 200 /** 189 201 Get the major version. 190 202 */ … … 401 413 secondaryStorageDriver = Config.getString("secondary.storage.driver"); 402 414 log.info("secondary.storage.driver = " + secondaryStorageDriver); 415 416 logManagerFactoryDriver = Config.getString("changelog.factory"); 417 log.info("changelog.factory = " + logManagerFactoryDriver); 403 418 404 419 sessionCacheTimeout = Config.getInt("cache.timeout", 20); // minutes … … 502 517 RawDataTypes.initPlatforms(); 503 518 519 // Initialise log manager factory 520 if (logManagerFactoryDriver != null) 521 { 522 Class factoryClass = ClassUtil.checkAndLoadClass(null, 523 logManagerFactoryDriver, true, LogManagerFactory.class); 524 logManagerFactory = (LogManagerFactory)factoryClass.newInstance(); 525 } 526 504 527 // Adding a task that cleans the session control cache at regular intervals 505 528 long milliSeconds = 60 * 1000 * sessionCacheTimeout; … … 678 701 679 702 /** 703 Get the log manager factory, or null if not enabled. 704 @since 2.13 705 */ 706 static LogManagerFactory getLogManagerFactory() 707 { 708 return logManagerFactory; 709 } 710 711 /** 680 712 Get the maximum number of minutes permission information for 681 713 a logged in user is kept in memory before beeing reloaded. … … 944 976 @param parent The parent session control 945 977 @param plugin The plugin to execute 978 @param job The job that executes the plug-in, or null 946 979 @return The new plugin session control 947 980 */ 948 static synchronized PluginSessionControl newPluginSessionControl(SessionControl parent, PluginDefinition plugin) 981 static synchronized PluginSessionControl newPluginSessionControl(SessionControl parent, 982 PluginDefinition plugin, Job job) 949 983 { 950 984 String sessionControlId = null; … … 953 987 sessionControlId = generateRandomId(8); 954 988 } while (sessionCache.containsKey(sessionControlId)); 955 return new PluginSessionControl(sessionControlId, parent, plugin );989 return new PluginSessionControl(sessionControlId, parent, plugin, job); 956 990 } 957 991 -
trunk/src/core/net/sf/basedb/core/DbControl.java
r5014 r5038 32 32 import net.sf.basedb.core.data.GroupData; 33 33 import net.sf.basedb.core.data.UserData; 34 import net.sf.basedb.core.log.LogManagerFactory; 35 import net.sf.basedb.core.log.LoggingInterceptor; 34 36 import net.sf.basedb.util.ClassUtil; 35 37 … … 74 76 75 77 /** 78 Handles logging of changes to items. 79 */ 80 private LogControl logControl; 81 82 /** 76 83 The Hibernate session. 77 84 */ … … 132 139 { 133 140 this.sc = sc; 134 hSession = HibernateUtil.newSession(); 141 LogManagerFactory logManagerFactory = Application.getLogManagerFactory(); 142 LoggingInterceptor interceptor = null; 143 if (logManagerFactory != null) 144 { 145 logControl = new LogControl(this); 146 interceptor = new LoggingInterceptor(logControl, logManagerFactory); 147 } 148 hSession = HibernateUtil.newSession(interceptor); 135 149 hTransaction = HibernateUtil.newTransaction(hSession); 136 150 itemCache = new IdentityHashMap<BasicData, BasicItem>(); … … 162 176 { 163 177 return sc; 178 } 179 180 /** 181 Get the log controller for this db control. May be null if 182 logging has been disabled. 183 @since 2.13 184 */ 185 LogControl getLogControl() 186 { 187 return logControl; 164 188 } 165 189 … … 989 1013 if (item.hasPermission(Permission.RESTRICTED_WRITE)) 990 1014 { 991 HibernateUtil.updateData(hSession, item.getData()); 1015 HibernateUtil.lockData(hSession, item.getData(), org.hibernate.LockMode.NONE); 1016 // HibernateUtil.updateData(hSession, item.getData()); 992 1017 } 993 1018 else if (item.hasPermission(Permission.READ)) -
trunk/src/core/net/sf/basedb/core/HibernateUtil.java
r5037 r5038 70 70 71 71 import org.hibernate.Hibernate; 72 import org.hibernate.Interceptor; 72 73 import org.hibernate.SessionFactory; 73 74 import org.hibernate.Session; … … 904 905 throws BaseException 905 906 { 907 return newSession(null); 908 } 909 910 /** 911 Create a new Hibernate session, optionally with an interceptor. 912 @since 2.13 913 */ 914 static Session newSession(Interceptor interceptor) 915 throws BaseException 916 { 906 917 assert sf != null : "HibernateUtil has not been initialised"; 907 918 try 908 919 { 909 Session session = sf.openSession( );920 Session session = sf.openSession(interceptor); 910 921 // FlushMode.COMMIT means that all changes 911 922 // are automatically flushed before a commit is performed -
trunk/src/core/net/sf/basedb/core/Install.java
r5015 r5038 114 114 method. 115 115 */ 116 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(7 2).intValue();116 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(73).intValue(); 117 117 118 118 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
trunk/src/core/net/sf/basedb/core/PluginDefinition.java
r4889 r5038 1159 1159 } 1160 1160 if (sc == null) sc = getSessionControl(); 1161 p.init(sc.getPluginSessionControl(this ),1161 p.init(sc.getPluginSessionControl(this, job), 1162 1162 configuration == null ? new ParameterValuesImpl(this) : configuration.getParameterValuesImpl(configuration.getParameterVersion()), 1163 1163 job == null ? new ParameterValuesImpl(this) : job.getParameterValuesImpl() -
trunk/src/core/net/sf/basedb/core/PluginRequest.java
r4889 r5038 87 87 this.requestParameters = new HashMap<String, List<?>>(); 88 88 this.parameterInfo = new HashMap<String, PluginParameter<?>>(); 89 plugin.init(sc.getPluginSessionControl(pluginDefinition ), configurationParameters, jobParameters);89 plugin.init(sc.getPluginSessionControl(pluginDefinition, job), configurationParameters, jobParameters); 90 90 } 91 91 -
trunk/src/core/net/sf/basedb/core/PluginSessionControl.java
r4517 r5038 45 45 @param plugin The plugin that is executing 46 46 */ 47 PluginSessionControl(String id, SessionControl parent, PluginDefinition plugin )47 PluginSessionControl(String id, SessionControl parent, PluginDefinition plugin, Job job) 48 48 { 49 super(id, parent, plugin );49 super(id, parent, plugin, job); 50 50 this.parent = parent; 51 51 } … … 102 102 parent as this session control has. 103 103 */ 104 PluginSessionControl getPluginSessionControl(PluginDefinition plugin )104 PluginSessionControl getPluginSessionControl(PluginDefinition plugin, Job job) 105 105 { 106 return Application.newPluginSessionControl(parent, plugin );106 return Application.newPluginSessionControl(parent, plugin, job); 107 107 } 108 108 -
trunk/src/core/net/sf/basedb/core/SessionControl.java
r5016 r5038 134 134 private final Map<ContextKey, ItemContext> currentContexts; 135 135 136 private int pluginId; 137 138 private int jobId; 139 136 140 /** 137 141 Create a new session control object using another one as the template. … … 144 148 @param plugin The plugin that is executing 145 149 */ 146 SessionControl(String id, SessionControl parent, PluginDefinition plugin )150 SessionControl(String id, SessionControl parent, PluginDefinition plugin, Job job) 147 151 { 148 152 this.id = id; … … 152 156 this.dbControlCache = Collections.synchronizedMap(new WeakHashMap<DbControl,String>()); 153 157 this.currentContexts = parent.currentContexts; 158 this.pluginId = plugin.getId(); 159 if (job != null) this.jobId = job.getId(); 154 160 LoginInfo li = new LoginInfo(parent.loginInfo); 155 li.keyring = new Keyring(li.keyring, plugin .getId(), plugin.getUsePermissions());161 li.keyring = new Keyring(li.keyring, pluginId, plugin.getUsePermissions()); 156 162 this.loginInfo = li; 157 163 } … … 729 735 730 736 /** 737 Get the id of the current user session, or 0 if no user is logged in. 738 Use {@link Session#getById(DbControl, int)} to the {@link Session} 739 object. 740 @return The session id, or 0 if no user is logged in 741 @since 2.13 742 */ 743 public int getCurrentSessionId() 744 { 745 updateLastAccess(); 746 return loginInfo == null ? 0 : loginInfo.sessionId; 747 } 748 749 /** 750 Get the id of the plug-in that is currently running with this 751 session control. 752 @return The plug-in id, or 0 if not running by a plug-in 753 @since 2.13 754 */ 755 public int getPluginId() 756 { 757 updateLastAccess(); 758 return pluginId; 759 } 760 761 /** 762 Get the id of the job that is currently running with this 763 session control. 764 @return The job id, or 0 if not running by a job 765 @since 2.13 766 */ 767 public int getJobId() 768 { 769 updateLastAccess(); 770 return jobId; 771 } 772 773 /** 731 774 Check if the logged in user was impersonated by another user. 732 775 @return TRUE or FALSE … … 853 896 Create a new session control for executing a plugin. 854 897 @param plugin The plugin to execute 898 @param job The job that executes the plug-in, or null 855 899 @return A plugin session control 856 900 */ 857 PluginSessionControl getPluginSessionControl(PluginDefinition plugin )858 { 859 return Application.newPluginSessionControl(this, plugin );901 PluginSessionControl getPluginSessionControl(PluginDefinition plugin, Job job) 902 { 903 return Application.newPluginSessionControl(this, plugin, job); 860 904 } 861 905 -
trunk/src/core/net/sf/basedb/core/Update.java
r4938 r5038 36 36 37 37 import net.sf.basedb.core.data.ArrayDesignData; 38 import net.sf.basedb.core.data.ChangeHistoryData; 39 import net.sf.basedb.core.data.ChangeHistoryDetailData; 38 40 import net.sf.basedb.core.data.DataCubeData; 39 41 import net.sf.basedb.core.data.ExperimentData; … … 814 816 </td> 815 817 </tr> 818 <tr> 819 <td>73</td> 820 <td> 821 Added {@link ChangeHistoryData} and {@link ChangeHistoryDetailData}. 822 No special update is needed. Only increase the schema version. 823 </td> 824 </tr> 816 825 </table> 817 826 … … 1096 1105 } 1097 1106 1098 if (schemaVersion < 63) 1099 { 1100 if (progress != null) progress.display((int)(62*progress_factor), "--Updating schema version: " + schemaVersion + " -> 63..."); 1101 schemaVersion = setSchemaVersionInTransaction(session, 63); 1102 } 1103 // Schemaversion 64-72 only updates the version number 1104 if (schemaVersion < 72) 1105 { 1106 if (progress != null) progress.display((int)(71*progress_factor), "--Updating schema version: " + schemaVersion + " -> 72..."); 1107 schemaVersion = setSchemaVersionInTransaction(session, 72); 1107 // Schemaversion 61-73 only updates the version number 1108 if (schemaVersion < 73) 1109 { 1110 if (progress != null) progress.display((int)(72*progress_factor), "--Updating schema version: " + schemaVersion + " -> 73..."); 1111 schemaVersion = setSchemaVersionInTransaction(session, 73); 1108 1112 } 1109 1113 -
trunk/src/core/net/sf/basedb/core/data/AnnotatedData.java
r4889 r5038 36 36 public abstract class AnnotatedData 37 37 extends CommonData 38 implements AnnotatableData 38 implements AnnotatableData, LoggableData 39 39 { 40 40
Note: See TracChangeset
for help on using the changeset viewer.