Changeset 4113
- Timestamp:
- Jan 31, 2008, 11:21:59 AM (15 years ago)
- Location:
- trunk/src/core/net/sf/basedb/core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/DataFileType.java
r4112 r4113 519 519 public String getValidatorJarPath() 520 520 { 521 return getData().getValidatorJarPath();521 return PluginDefinition.convertToAbsolute(getData().getValidatorJarPath()); 522 522 } 523 523 … … 533 533 { 534 534 checkPermission(Permission.WRITE); 535 validatorJarPath = PluginDefinition.convertToRelative(validatorJarPath); 535 536 getData().setValidatorJarPath(StringUtil.setNullableString(validatorJarPath, 536 537 "validatorJarPath", MAX_JARPATH_LENGTH)); … … 546 547 public DataFileValidator getValidator() 547 548 { 548 String validatorClass = get Data().getValidatorClass();549 String validatorClass = getValidatorClass(); 549 550 if (validatorClass == null) return null; 550 551 DataFileValidator validator = null; … … 596 597 public String getMetadataReaderJarPath() 597 598 { 598 return getData().getMetadataReaderJarPath();599 return PluginDefinition.convertToAbsolute(getData().getMetadataReaderJarPath()); 599 600 } 600 601 … … 610 611 { 611 612 checkPermission(Permission.WRITE); 613 metadataReaderJarPath = PluginDefinition.convertToRelative(metadataReaderJarPath); 612 614 getData().setMetadataReaderJarPath(StringUtil.setNullableString(metadataReaderJarPath, 613 615 "metadataReaderJarPath", MAX_JARPATH_LENGTH)); … … 622 624 public DataFileMetadataReader getMetadataReader() 623 625 { 624 String readerClass = get Data().getMetadataReaderClass();626 String readerClass = getMetadataReaderClass(); 625 627 if (readerClass == null) return null; 626 628 DataFileMetadataReader reader = null; 627 629 try 628 630 { 629 String jarPath = get ValidatorJarPath();631 String jarPath = getMetadataReaderJarPath(); 630 632 ClassLoader loader = jarPath == null ? null : JarClassLoader.getInstance(jarPath); 631 633 reader = (DataFileMetadataReader)ClassUtil.checkAndLoadClass( -
trunk/src/core/net/sf/basedb/core/Install.java
r4112 r4113 107 107 method. 108 108 */ 109 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(5 0).intValue();109 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(51).intValue(); 110 110 111 111 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
trunk/src/core/net/sf/basedb/core/JobAgentSettings.java
r3675 r4113 222 222 if (jarPath == null) 223 223 { 224 jarPath = data.getPluginDefinition().getJarPath();224 jarPath = PluginDefinition.convertToAbsolute(data.getPluginDefinition().getJarPath()); 225 225 } 226 226 return jarPath; -
trunk/src/core/net/sf/basedb/core/PluginDefinition.java
r4040 r4113 122 122 public static final int MAX_URL_LENGTH = PluginDefinitionData.MAX_URL_LENGTH; 123 123 124 /** 125 Convert a plug-in path to a path relative to the <code>plugins.dir</code> 126 setting in <code>base.config</code>. If no plug-in directory has been 127 specified or if the path is null nothing is done. If the given path is 128 a subpath to the <code>plugins.dir</code> path the common path is replaced 129 with <code>%plugins.dir%</code> For example: 130 <pre class="code>" 131 path = /usr/local/base/plugins/myplugin.jar 132 plugins.dir = /usr/local/base/plugins 133 relative path = %plugins.dir%/myplugin.jar 134 </pre> 135 136 @param path The absolute path 137 @return The relative path 138 @since 2.6 139 @see #convertToAbsolute(String) 140 */ 141 public static String convertToRelative(String path) 142 { 143 if (path == null) return null; 144 String pluginsDir = Config.getString("plugins.dir"); 145 if (pluginsDir == null) return path; 146 if (path.startsWith(pluginsDir)) 147 { 148 path = "%plugins.dir%" + path.substring(pluginsDir.length()); 149 } 150 return path; 151 } 152 153 /** 154 Convert a relative plug-in path to an absolute path. This is the 155 reverse of the {@link #convertToRelative(String)} method. 156 157 @param path The relative path 158 @return The absolute path 159 @since 2.6 160 */ 161 public static String convertToAbsolute(String path) 162 { 163 if (path == null) return path; 164 String pluginsDir = Config.getString("plugins.dir"); 165 if (pluginsDir == null) return path; 166 if (path.startsWith("%plugins.dir%")) 167 { 168 path = pluginsDir + path.substring("%plugins.dir%".length()); 169 } 170 return path; 171 } 172 124 173 /** 125 174 Create a new <code>PluginDefinition</code> item. … … 551 600 public String getJarPath() 552 601 { 553 return getData().getJarPath();602 return convertToAbsolute(getData().getJarPath()); 554 603 } 555 604 /** … … 559 608 throws InvalidDataException 560 609 { 561 getData().setJarPath(StringUtil.setNullableString(jarPath, "jarPath", MAX_JARPATH_LENGTH)); 610 getData().setJarPath(StringUtil.setNullableString(convertToRelative(jarPath), 611 "jarPath", MAX_JARPATH_LENGTH)); 562 612 } 563 613 … … 1058 1108 { 1059 1109 checkPermission(Permission.USE); 1060 return newInstance(get Data().getJarPath(), getData().getClassName(), false);1110 return newInstance(getJarPath(), getClassName(), false); 1061 1111 } 1062 1112 … … 1065 1115 { 1066 1116 checkPermission(Permission.USE); 1067 return newInstance(jarPath == null ? get Data().getJarPath() : jarPath, getData().getClassName(), false);1117 return newInstance(jarPath == null ? getJarPath() : jarPath, getClassName(), false); 1068 1118 } 1069 1119 -
trunk/src/core/net/sf/basedb/core/Update.java
r4112 r4113 584 584 </td> 585 585 </tr> 586 <tr> 587 <td>51</td> 588 <td> 589 External plug-in paths should be relative to the plugins.dir setting 590 in base.config. The update loads all PluginDefinitions with a JAR path 591 and convert the path with {@link PluginDefinition#convertToRelative(String)}. 592 </td> 593 </tr> 586 594 587 595 </table> … … 828 836 if (progress != null) progress.display((int)(49*progress_factor), "Updating schema version: " + schemaVersion + " -> 50..."); 829 837 schemaVersion = setSchemaVersionInTransaction(session, 50); 838 } 839 840 if (schemaVersion < 51) 841 { 842 if (progress != null) progress.display((int)(50*progress_factor), "--Updating schema version: " + schemaVersion + " -> 51..."); 843 schemaVersion = updateToSchemaVersion51(session); 830 844 } 831 845 … … 2072 2086 return schemaVersion; 2073 2087 } 2088 2089 /** 2090 Change all plug-ins with an absolute JAR path to relative 2091 paths. 2092 2093 @return The new schema version (=51) 2094 */ 2095 private static int updateToSchemaVersion51(org.hibernate.Session session) 2096 throws BaseException 2097 { 2098 final int schemaVersion = 51; 2099 org.hibernate.Transaction tx = null; 2100 try 2101 { 2102 tx = HibernateUtil.newTransaction(session); 2103 2104 // Change property values 2105 org.hibernate.Query query = HibernateUtil.createQuery(session, 2106 "SELECT pd FROM PluginDefinitionData pd WHERE NOT pd.jarPath IS NULL"); 2107 List<PluginDefinitionData> plugins = 2108 HibernateUtil.loadList(PluginDefinitionData.class, query, null); 2109 2110 for (PluginDefinitionData pd : plugins) 2111 { 2112 pd.setJarPath(PluginDefinition.convertToRelative(pd.getJarPath())); 2113 } 2114 2115 // Update the schema version number 2116 setSchemaVersion(session, schemaVersion); 2117 2118 // Commit the changes 2119 HibernateUtil.commit(tx); 2120 log.info("updateToSchemaVersion51: OK"); 2121 } 2122 catch (BaseException ex) 2123 { 2124 if (tx != null) HibernateUtil.rollback(tx); 2125 log.error("updateToSchemaVersion51: FAILED", ex); 2126 throw ex; 2127 } 2128 return schemaVersion; 2129 } 2074 2130 2075 2131 /**
Note: See TracChangeset
for help on using the changeset viewer.