__PACKAGE__->register_method(
- method => 'validate_session',
- api_name => 'open-ils.url_verify.session.validate',
+ method => 'verify_session',
+ api_name => 'open-ils.url_verify.session.verify',
stream => 1,
signature => {
desc => q/
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'Session ID (url_verify.session.id)', type => 'number'},
- {desc => 'URL ID list (optional). An empty list will result in no URLs being processed', type => 'array'},
+ {desc => 'URL ID list (optional). An empty list will result in no URLs being processed, but null will result in all the URLs for the session being processed', type => 'array'},
{
desc => q/
Options (optional).
}
);
-# "validate_session" sounds like something to do with authentication, but it
-# actually means for a given session, validate all the URLs associated with
+# "verify_session" sounds like something to do with authentication, but it
+# actually means for a given session, verify all the URLs associated with
# that session.
-sub validate_session {
+sub verify_session {
my ($self, $client, $auth, $session_id, $url_ids, $options) = @_;
$options ||= {};
$e->create_url_verify_verification_attempt($attempt)
or return $e->die_event;
+ $attempt = $e->data;
$e->commit;
}
$session->owning_lib,
'url_verify.verification_batch_size', $e) || 5;
- my $num_processed = 0; # total number processed, including redirects
+ my $total_excluding_redirects = 0;
+ my $total_processed = 0; # total number processed, including redirects
my $resp_window = 1;
# before we start the real work, let the caller know
$client->respond({
url_count => $url_count,
- total_processed => $num_processed,
+ total_processed => $total_processed,
+ total_excluding_redirects => $total_excluding_redirects,
attempt => $attempt
});
if ($content) {
- $num_processed++;
+ $total_processed++;
- if ($options->{report_all} or ($num_processed % $resp_window == 0)) {
+ if ($options->{report_all} or ($total_processed % $resp_window == 0)) {
$client->respond({
url_count => $url_count,
current_verification => $content,
- total_processed => $num_processed
+ total_excluding_redirects => $total_excluding_redirects,
+ total_processed => $total_processed
});
}
# start off responding quickly, then throttle
# back to only relaying every 256 messages.
- $resp_window *= 2 unless $resp_window == 256;
+ $resp_window *= 2 unless $resp_window >= 256;
}
}
},
}
);
- sort_and_fire_domains($e, $auth, $attempt, $url_ids, $multises);
+ sort_and_fire_domains(
+ $e, $auth, $attempt, $url_ids, $multises, \$total_excluding_redirects
+ );
# Wait for all requests to be completed
$multises->session_wait(1);
$attempt->finish_time('now');
$e->xact_begin;
- $e->update_url_verify_verification_attempt($attempt) or return $e->die_event;
+ $e->update_url_verify_verification_attempt($attempt) or
+ return $e->die_event;
+
$e->xact_commit;
+ # This way the caller gets an actual timestamp in the "finish_time" field
+ # instead of the string "now".
+ $attempt = $e->retrieve_url_verify_verification_attempt($e->data) or
+ return $e->die_event;
+
+ $e->disconnect;
+
return {
url_count => $url_count,
- total_processed => $num_processed,
+ total_processed => $total_processed,
+ total_excluding_redirects => $total_excluding_redirects,
attempt => $attempt
};
}
#
# * local data structures, not container.* buckets
sub sort_and_fire_domains {
- my ($e, $auth, $attempt, $url_ids, $multises) = @_;
+ my ($e, $auth, $attempt, $url_ids, $multises, $count) = @_;
# there is potential here for data sets to be too large
# for delivery, but it's not likely, since we're only
$multises->request(
'open-ils.url_verify.verify_url',
$auth, $attempt->id, $url_id);
+
+ $$count++; # sic, a reference to a scalar
}
}
}
<script type="text/javascript">
dojo.require("dijit.form.Button");
dojo.require("openils.widget.FlattenerGrid");
+ dojo.require("openils.widget.ProgressDialog");
dojo.require("openils.Util");
dojo.require("openils.CGI");
dojo.require("openils.URLVerify.SelectURLs");
openils.Util.addOnLoad(
function() {
- var cgi = new openils.CGI();
-
- module.setup(grid);
+ module.setup(grid, progress_dialog);
}
);
</script>
+<style type="text/css">
+ .url-verify-attempt-info { font-style: italic; }
+</style>
<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
<div dojoType="dijit.layout.ContentPane"
layoutAlign="top" class="oils-header-panel">
<div>[% ctx.page_title %]</div>
<div>
<button dojoType="dijit.form.Button"
- onClick="module.validate_selected();">[%
- l("Validate selected")
+ onClick="module.verify_selected();">[%
+ l("Verify Selected URLs")
%]</button>
</div>
</div>
- <!-- <div class="oils-acq-basic-roomy">
- XXX Controls that should go below the title but above the grid
- could be placed here.
- </div> -->
+ <div class="oils-acq-basic-roomy url-verify-attempt-info">
+ <div id="url-verify-attempt-id"></div>
+ <div id="url-verify-attempt-start"></div>
+ <div id="url-verify-attempt-finish"></div>
+ </div>
<table
jsid="grid"
dojoType="openils.widget.FlattenerGrid"
fetchLock="true"
mapExtras="{session_id: {path: 'item.session.id', filter: true}}"
showLoadFilter="true"
- query="initial_query"
fmClass="'uvu'">
<thead>
<tr>
</thead>
</table>
</div>
+<div class="hidden">
+ <div dojoType="openils.widget.ProgressDialog" jsId="progress_dialog"></div>
+</div>
[% END %]
if (!dojo._hasResource["openils.URLVerify.SelectURLs"]) {
+ dojo.require("dojo.string");
dojo.require("openils.CGI");
+ dojo.require("openils.Util");
dojo.requireLocalization("openils.URLVerify", "URLVerify");
var localeStrings =
dojo.i18n.getLocalization("openils.URLVerify", "URLVerify");
- module.setup = function(grid) {
+ module.setup = function(grid, progress_dialog) {
var cgi = new openils.CGI();
+ module.session_id = cgi.param("session_id");
+
module.grid = grid;
- module.grid.attr("query", {"session_id": cgi.param("session_id")});
+ module.grid.attr("query", {"session_id": module.session_id});
module.grid.refresh();
// Alternative to grid.refresh() once filter is set up
//module.grid.fetchLock = false;
//module.grid.filterUi.doApply();
};
- module.validate_selected = function() {
- if (module.grid.everythingSeemsSelected()) {
- if (confirm(localeStrings.VALIDATE_ALL)) {
- return module.validate_all();
+ module.verify_selected = function() {
+ var really_everything = false;
+
+ if (module.grid.everythingSeemsSelected())
+ really_everything = confirm(localeStrings.VERIFY_ALL);
+
+ module.clear_attempt_display();
+ progress_dialog.attr("title", localeStrings.VERIFICATION_BEGIN);
+ progress_dialog.show();
+
+ fieldmapper.standardRequest(
+ ["open-ils.url_verify", "open-ils.url_verify.session.verify"], {
+ "params": [
+ openils.User.authtoken,
+ module.session_id,
+ really_everything ? null : module.grid.getSelectedIDs()
+ ],
+ "async": true,
+ "onresponse": function(r) {
+ if (r = openils.Util.readResponse(r)) {
+ progress_dialog.attr(
+ "title",
+ dojo.string.substitute(
+ localeStrings.VERIFICATION_PROGRESS,
+ [r.total_processed]
+ )
+ );
+ progress_dialog.update({
+ "maximum": r.url_count,
+ "progress": r.total_excluding_redirects
+ });
+
+ if (r.attempt)
+ module.update_attempt_display(r.attempt);
+ }
+ }
}
- }
+ )
+
+ module.grid.getSelectedIDs();
+ };
- console.info("module.validate_selected() sees IDs: " + dojo.toJson(module.grid.getSelectedIDs()));
+ module.clear_attempt_display = function() {
+ dojo.empty(dojo.byId("url-verify-attempt-id"));
+ dojo.empty(dojo.byId("url-verify-attempt-start"));
+ dojo.empty(dojo.byId("url-verify-attempt-finish"));
};
- module.validate_all = function() {
- console.info("module.validate_all() called");
+ module.update_attempt_display = function(attempt) {
+ dojo.byId("url-verify-attempt-id").innerHTML =
+ dojo.string.substitute(
+ localeStrings.VERIFICATION_ATTEMPT_ID,
+ [attempt.id()]
+ );
+ dojo.byId("url-verify-attempt-start").innerHTML =
+ dojo.string.substitute(
+ localeStrings.VERIFICATION_ATTEMPT_START,
+ [attempt.start_time()]
+ );
+
+ if (attempt.finish_time()) {
+ dojo.byId("url-verify-attempt-finish").innerHTML =
+ dojo.string.substitute(
+ localeStrings.VERIFICATION_ATTEMPT_FINISH,
+ [attempt.finish_time()]
+ );
+ }
};
}());
"EXTRACTING_URLS": "Extracting URLs ...",
"NEED_UVUS": "You must add some tag and subfield combinations",
"REDIRECTING": "Loading next interface ...",
- "INTERFACE_SETUP": "Setting up interface ..."
+ "INTERFACE_SETUP": "Setting up interface ...",
+ "VERIFY_ALL": "Click 'OK' to verify ALL the URLs found in this session. Click 'Cancel' if the selected, visible URLs are the only ones you want verified.",
+ "VERIFICATION_BEGIN": "Verifying URLs. This can take a moment ...",
+ "VERIFICATION_PROGRESS": "Verifying URLs: ${0} URLs processed ...",
+ "VERIFICATION_ATTEMPT_ID": "Last verification attempt ID: ${0}",
+ "VERIFICATION_ATTEMPT_START": "Attempt start time: ${0}",
+ "VERIFICATION_ATTEMPT_FINISH": "Attempt finish time: ${0}"
}