51 |
51 |
|
52 |
52 |
import edu.ucsb.nceas.metacat.MetacatVersion;
|
53 |
53 |
import edu.ucsb.nceas.metacat.admin.upgrade.UpgradeUtilityInterface;
|
|
54 |
import edu.ucsb.nceas.metacat.admin.upgrade.solr.SolrSchemaModificationException;
|
54 |
55 |
import edu.ucsb.nceas.metacat.database.DBConnection;
|
55 |
56 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
|
56 |
57 |
import edu.ucsb.nceas.metacat.database.DBVersion;
|
... | ... | |
90 |
91 |
private HashSet<String> sqlCommandSet = new HashSet<String>();
|
91 |
92 |
private Map<String, String> scriptSuffixMap = new HashMap<String, String>();
|
92 |
93 |
private static DBVersion databaseVersion = null;
|
|
94 |
private SolrSchemaModificationException solrSchemaException = null;
|
93 |
95 |
|
94 |
96 |
/**
|
95 |
97 |
* private constructor since this is a singleton
|
... | ... | |
145 |
147 |
String processForm = request.getParameter("processForm");
|
146 |
148 |
String formErrors = (String) request.getAttribute("formErrors");
|
147 |
149 |
HttpSession session = request.getSession();
|
|
150 |
String supportEmail = null;
|
148 |
151 |
|
149 |
152 |
if (processForm == null || !processForm.equals("true") || formErrors != null) {
|
150 |
153 |
// The servlet configuration parameters have not been set, or there
|
... | ... | |
174 |
177 |
request.setAttribute("databaseVersion", dbVersionString);
|
175 |
178 |
Vector<String> updateScriptList = getUpdateScripts();
|
176 |
179 |
request.setAttribute("updateScriptList", updateScriptList);
|
177 |
|
String supportEmail = PropertyService.getProperty("email.recipient");
|
|
180 |
supportEmail = PropertyService.getProperty("email.recipient");
|
178 |
181 |
request.setAttribute("supportEmail", supportEmail);
|
179 |
182 |
|
180 |
183 |
// Forward the request to the JSP page
|
... | ... | |
204 |
207 |
// there is no other easy way to go back to the configure form
|
205 |
208 |
// and
|
206 |
209 |
// preserve their entries.
|
|
210 |
supportEmail = PropertyService.getProperty("email.recipient");
|
207 |
211 |
validationErrors.addAll(validateOptions(request));
|
208 |
|
|
|
212 |
|
|
213 |
|
209 |
214 |
upgradeDatabase();
|
|
215 |
|
|
216 |
|
210 |
217 |
|
211 |
218 |
// Now that the options have been set, change the
|
212 |
219 |
// 'databaseConfigured' option to 'true' so that normal metacat
|
213 |
220 |
// requests will go through
|
214 |
221 |
PropertyService.setProperty("configutil.databaseConfigured",
|
215 |
222 |
PropertyService.CONFIGURED);
|
|
223 |
PropertyService.persistMainBackupProperties();
|
|
224 |
if(solrSchemaException != null) {
|
|
225 |
//Show the warning message
|
|
226 |
Vector<String> errorVector = new Vector<String>();
|
|
227 |
errorVector.add(solrSchemaException.getMessage());
|
|
228 |
RequestUtil.clearRequestMessages(request);
|
|
229 |
request.setAttribute("supportEmail", supportEmail);
|
|
230 |
RequestUtil.setRequestErrors(request, errorVector);
|
|
231 |
RequestUtil.forwardRequest(request, response,
|
|
232 |
"/admin/solr-schema-warn.jsp", null);
|
|
233 |
} else {
|
|
234 |
// Reload the main metacat configuration page
|
|
235 |
processingSuccess.add("Database successfully upgraded");
|
|
236 |
RequestUtil.clearRequestMessages(request);
|
|
237 |
RequestUtil.setRequestSuccess(request, processingSuccess);
|
|
238 |
RequestUtil.forwardRequest(request, response,
|
|
239 |
"/admin?configureType=configure&processForm=false", null);
|
|
240 |
// Write out the configurable properties to a backup file
|
|
241 |
// outside the install directory.
|
216 |
242 |
|
217 |
|
// Reload the main metacat configuration page
|
218 |
|
processingSuccess.add("Database successfully upgraded");
|
219 |
|
RequestUtil.clearRequestMessages(request);
|
220 |
|
RequestUtil.setRequestSuccess(request, processingSuccess);
|
221 |
|
RequestUtil.forwardRequest(request, response,
|
222 |
|
"/admin?configureType=configure&processForm=false", null);
|
223 |
|
// Write out the configurable properties to a backup file
|
224 |
|
// outside the install directory.
|
225 |
|
|
226 |
|
PropertyService.persistMainBackupProperties();
|
|
243 |
|
|
244 |
}
|
|
245 |
|
227 |
246 |
} catch (GeneralPropertyException gpe) {
|
228 |
247 |
throw new AdminException("DBAdmin.configureDatabase - Problem getting or setting " +
|
229 |
248 |
"property while upgrading database: " + gpe.getMessage());
|
... | ... | |
803 |
822 |
try {
|
804 |
823 |
utility = (UpgradeUtilityInterface) Class.forName(className).newInstance();
|
805 |
824 |
utility.upgrade();
|
|
825 |
} catch (SolrSchemaModificationException e) {
|
|
826 |
//don't throw the exception and continue
|
|
827 |
solrSchemaException = e;
|
|
828 |
continue;
|
806 |
829 |
} catch (Exception e) {
|
807 |
830 |
throw new AdminException("DBAdmin.upgradeDatabase - error getting utility class: "
|
808 |
831 |
+ className + ". Error message: "
|
Add code the display the SchemaModification exception.