-
-
Notifications
You must be signed in to change notification settings - Fork 12
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 1 commit
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.Enumeration; | ||
import java.util.HashMap; | ||
|
@@ -137,7 +138,10 @@ | |
* | ||
* MNReplication | ||
* replicate() - POST /d1/mn/replicate | ||
* getReplica() - GET /d1/mn/replica | ||
* getReplica() - GET /d1/mn/replica | ||
* | ||
* MNAdmin | ||
* reindex() - GET /d1/mn/reindex | ||
* | ||
* ****************** | ||
* @author leinfelder | ||
|
@@ -159,6 +163,7 @@ public class MNResourceHandler extends D1ResourceHandler { | |
protected static final String RESOURCE_WHOAMI = "whoami"; | ||
//make the status of identifier (e.g. DOI) public | ||
protected static final String RESOURCE_PUBLISH_IDENTIFIER = "publishIdentifier"; | ||
protected static final String RESOURCE_REINDEX = "reindex"; | ||
|
||
|
||
|
||
|
@@ -527,6 +532,14 @@ public void handle(byte httpVerb) { | |
publishIdentifier(extra); | ||
status = true; | ||
} | ||
} else if (resource.startsWith(RESOURCE_REINDEX)) { | ||
logMetacat.debug("Using resource: " + RESOURCE_REINDEX); | ||
// GET | ||
if (httpVerb == GET) { | ||
// after the command | ||
reindex(); | ||
status = true; | ||
} | ||
} else { | ||
throw new InvalidRequest("0000", "No resource matched for " + resource); | ||
} | ||
|
@@ -1845,5 +1858,47 @@ protected void updateSystemMetadata() throws ServiceFailure, InvalidRequest, | |
MNodeService.getInstance(request).updateSystemMetadata(session, pid, systemMetadata); | ||
} | ||
|
||
/** | ||
* Handle the reindex request | ||
* @throws InvalidRequest | ||
* @throws ServiceFailure | ||
* @throws NotAuthorized | ||
* @throws NotImplemented | ||
*/ | ||
protected void reindex() throws InvalidRequest, ServiceFailure, NotAuthorized, NotImplemented { | ||
boolean all = false; | ||
List<Identifier> identifiers = new ArrayList<Identifier>(); | ||
String[] allValueArray = params.get("all"); | ||
logMetacat.debug("MNResourceHandler.reindex - the allValueArray in the request is " | ||
+ allValueArray); | ||
if (allValueArray != null) { | ||
if (allValueArray.length != 1) { | ||
throw new InvalidRequest("5903", "The \"all\" should only have one vaule"); | ||
taojing2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
String allValue = allValueArray[0]; | ||
if (allValue != null && allValue.equalsIgnoreCase("true")) { | ||
all = true; | ||
} | ||
} | ||
} | ||
if (!all) { | ||
String[] ids = params.get("pid"); | ||
logMetacat.debug("MNResourceHandler.reindex - the pid list in the request is " + ids); | ||
if (ids != null) { | ||
for (String id : ids) { | ||
if (id != null && !id.trim().equals("")) { | ||
Identifier identifier = new Identifier(); | ||
identifier.setValue(id); | ||
identifiers.add(identifier); | ||
} | ||
} | ||
} else { | ||
throw new InvalidRequest("5903", "Users should specify the \"pid\" vaule " | ||
taojing2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ "for reindexing"); | ||
} | ||
} | ||
MNodeService.getInstance(request).reindex(session, identifiers, all); | ||
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. It's almost always bad practice to have a boolean parameter in a public method if that method is not a setter. When reading this calling code, it's not obvious what the boolean stands for without looking at the source or documentation. (also known as the boolean trap). I think it would be much clearer if this code called the |
||
} | ||
|
||
} | ||
|
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.
see review comment on MNResourceHandler line 1900