-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature 1716-mn-reindex #1738
Feature 1716-mn-reindex #1738
Changes from 4 commits
f5abbdb
4bcc056
9b9023f
24a642d
842d923
ea8a8aa
b18f2fc
1a398c7
3801a39
57d400a
52039ad
b998542
c74c522
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3514,7 +3514,7 @@ public boolean reindex(Session session, List<Identifier> identifiers, boolean al | |
String notAuthorizedError ="The provided identity does not have permission to reindex " | ||
+ "objects on the Node: "; | ||
if (session == null) { | ||
throw new NotAuthorized(notAuthorizedCode,notAuthorizedError + "public"); | ||
throw new NotAuthorized(notAuthorizedCode, notAuthorizedError + "public"); | ||
} | ||
try { | ||
Identifier identifier = null; | ||
|
@@ -3523,10 +3523,10 @@ public boolean reindex(Session session, List<Identifier> identifiers, boolean al | |
authDel.doAdminAuthorization(session); | ||
} catch (NotAuthorized na) { | ||
if (session.getSubject() != null) { | ||
throw new NotAuthorized(notAuthorizedCode,notAuthorizedError | ||
throw new NotAuthorized(notAuthorizedCode, notAuthorizedError | ||
+ session.getSubject().getValue()); | ||
} else { | ||
throw new NotAuthorized(notAuthorizedCode,notAuthorizedError + "public"); | ||
throw new NotAuthorized(notAuthorizedCode, notAuthorizedError + "public"); | ||
} | ||
} | ||
|
||
|
@@ -3547,8 +3547,7 @@ protected void handleReindexAction(List<Identifier> pids) { | |
if (pids == null) { | ||
return; | ||
} | ||
for (int i = 0; i < pids.size(); i++) { | ||
Identifier identifier = pids.get(i); | ||
for (Identifier identifier : pids) { | ||
if (identifier != null) { | ||
logMetacat.debug("MNodeService.handleReindexAction: queueing doc index for pid " | ||
+ identifier.getValue()); | ||
|
@@ -3564,7 +3563,6 @@ protected void handleReindexAction(List<Identifier> pids) { | |
} catch (Exception e) { | ||
logMetacat.info("MNodeService.handleReindexAction: Error submitting to " | ||
+ "index for pid " + identifier.getValue()); | ||
continue; | ||
} | ||
} | ||
} | ||
|
@@ -3577,7 +3575,7 @@ protected void handleReindexAction(List<Identifier> pids) { | |
protected void handleReindexAllAction() { | ||
// Process all of the documents | ||
logMetacat.debug("MNodeService.handleReindexAllAction - " | ||
+ "reindexl all objects in this Metacat instance"); | ||
+ "reindex all objects in this Metacat instance"); | ||
Runnable indexAll = new Runnable() { | ||
public void run() { | ||
List<String> resourceMapFormats = ResourceMapNamespaces.getNamespaces(); | ||
|
@@ -3595,23 +3593,24 @@ public void run() { | |
*/ | ||
private void buildAllNonResourceMapIndex(List<String> resourceMapFormatList) { | ||
boolean firstTime = true; | ||
String sql = "select guid from systemmetadata"; | ||
StringBuilder sql = new StringBuilder("select guid from systemmetadata"); | ||
if (resourceMapFormatList != null && resourceMapFormatList.size() > 0) { | ||
for (String format : resourceMapFormatList) { | ||
if (format != null && !format.trim().equals("")) { | ||
if (firstTime) { | ||
sql = sql + " where object_format !='" + format + "'"; | ||
sql.append(" where object_format !='" + format + "'"); | ||
firstTime = false; | ||
} else { | ||
sql = sql + " and object_format !='" + format + "'"; | ||
sql.append(" and object_format !='" + format + "'"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still has string concatenation |
||
} | ||
} | ||
} | ||
sql = sql + " order by date_uploaded asc"; | ||
sql.append(" order by date_uploaded asc"); | ||
} | ||
logMetacat.debug("MNodeService.buildAllNonResourceMapIndex - the final query is " + sql); | ||
logMetacat.debug("MNodeService.buildAllNonResourceMapIndex - the final query is " | ||
+ sql.toString()); | ||
try { | ||
long size = buildIndexFromQuery(sql); | ||
long size = buildIndexFromQuery(sql.toString()); | ||
logMetacat.info( | ||
"MNodeService.buildAllNonResourceMapIndex - the number of non-resource map " | ||
+ "objects is " | ||
|
@@ -3628,24 +3627,25 @@ private void buildAllNonResourceMapIndex(List<String> resourceMapFormatList) { | |
* @param resourceMapFormatList | ||
*/ | ||
private void buildAllResourceMapIndex(List<String> resourceMapFormatList) { | ||
String sql = "select guid from systemmetadata"; | ||
StringBuilder sql = new StringBuilder("select guid from systemmetadata"); | ||
if (resourceMapFormatList != null && resourceMapFormatList.size() > 0) { | ||
boolean firstTime = true; | ||
for (String format : resourceMapFormatList) { | ||
if (format != null && !format.trim().equals("")) { | ||
if (firstTime) { | ||
sql = sql + " where object_format ='" + format + "'"; | ||
sql.append(" where object_format ='" + format + "'"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still has string concatenation |
||
firstTime = false; | ||
} else { | ||
sql = sql + " or object_format ='" + format + "'"; | ||
sql.append(" or object_format ='" + format + "'"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still has string concatenation |
||
} | ||
} | ||
} | ||
sql = sql + " order by date_uploaded asc"; | ||
sql.append(" order by date_uploaded asc"); | ||
} | ||
logMetacat.info("MNodeService.buildAllResourceMapIndex - the final query is " + sql); | ||
logMetacat.info("MNodeService.buildAllResourceMapIndex - the final query is " | ||
+ sql.toString()); | ||
try { | ||
long size = buildIndexFromQuery(sql); | ||
long size = buildIndexFromQuery(sql.toString()); | ||
logMetacat.info( | ||
"MNodeService.buildAllResourceMapIndex - the number of resource map objects is " | ||
+ size + " being submitted to the index queue."); | ||
|
@@ -3699,8 +3699,6 @@ private long buildIndexFromQuery(String sql) throws SQLException { | |
} | ||
rs.close(); | ||
stmt.close(); | ||
} catch (SQLException e) { | ||
throw e; | ||
} finally { | ||
// Return database connection to the pool | ||
DBConnectionPool.returnDBConnection(dbConn, serialNumber); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still has string concatenation