[23446] | 1 |
|
---|
[27318] | 2 | function GSAjaxAPI(gwcgi,collect,un,ky)
|
---|
[23446] | 3 | {
|
---|
| 4 | var gwcgi_ = gwcgi;
|
---|
| 5 | var collect_ = collect;
|
---|
[27318] | 6 | var un_ = un;
|
---|
| 7 | var ky_ = ky;
|
---|
[23446] | 8 |
|
---|
[23806] | 9 |
|
---|
| 10 | this.fullDomainURL = function(localURL)
|
---|
| 11 | {
|
---|
| 12 | return window.location.protocol+'//'+window.location.host+localURL;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
[23446] | 15 | this.apiURL = function(apiProg)
|
---|
| 16 | {
|
---|
| 17 | //get the location of the cgi program
|
---|
| 18 | splitpos = gwcgi_.lastIndexOf("/");
|
---|
| 19 |
|
---|
| 20 | var mdserver;
|
---|
| 21 | if (splitpos >= 0) {
|
---|
| 22 | mdserver = gwcgi.substring(0,(splitpos+1)) + apiProg;
|
---|
| 23 | }
|
---|
| 24 | else {
|
---|
| 25 | mdserver = apiProg;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | return mdserver;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | this.metadataserverURL = function()
|
---|
| 32 | {
|
---|
| 33 | return this.apiURL("metadata-server.pl");
|
---|
| 34 | }
|
---|
| 35 |
|
---|
[23740] | 36 | this.indexserverURL = function()
|
---|
| 37 | {
|
---|
| 38 | return this.apiURL("index-server.pl");
|
---|
| 39 | }
|
---|
[23446] | 40 |
|
---|
[24072] | 41 | this.buildserverURL = function()
|
---|
| 42 | {
|
---|
| 43 | return this.apiURL("build-server.pl");
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[23740] | 46 | this.explodeserverURL = function()
|
---|
[23446] | 47 | {
|
---|
[23740] | 48 | return this.apiURL("explode-server.pl");
|
---|
| 49 | }
|
---|
| 50 |
|
---|
[23806] | 51 | this.myspaceserverURL = function()
|
---|
| 52 | {
|
---|
| 53 | return this.apiURL("myspace-server.pl");
|
---|
| 54 | }
|
---|
[23740] | 55 |
|
---|
[23806] | 56 |
|
---|
[23740] | 57 | this.urlGetAsync = function(url,callback)
|
---|
| 58 | {
|
---|
[23446] | 59 | var xmlHttp;
|
---|
| 60 | try {
|
---|
| 61 | // Firefox, Opera 8.0+, Safari
|
---|
| 62 | xmlHttp=new XMLHttpRequest();
|
---|
| 63 | }
|
---|
| 64 | catch (e) {
|
---|
| 65 | // Internet Explorer
|
---|
| 66 | try {
|
---|
| 67 | xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
|
---|
| 68 | }
|
---|
| 69 | catch (e) {
|
---|
| 70 | try {
|
---|
| 71 | xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 72 | }
|
---|
| 73 | catch (e) {
|
---|
| 74 | alert("Your browser does not support AJAX!");
|
---|
| 75 | return false;
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
[23740] | 79 |
|
---|
| 80 | var typeof_callback = typeof(callback);
|
---|
| 81 | if ((typeof_callback == "string") || (typeof_callback == "number") || (typeof_callback == "boolean")) {
|
---|
| 82 | var locid = callback;
|
---|
| 83 |
|
---|
| 84 | xmlHttp.onreadystatechange=function() {
|
---|
| 85 | if(xmlHttp.readyState==4) {
|
---|
| 86 | if (locelem != null) {
|
---|
| 87 | var locelem = document.getElementById(locid);
|
---|
| 88 |
|
---|
| 89 | locelem.innerHTML = xmlHttp.responseText;
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | else if (typeof_callback == "function") {
|
---|
| 95 | xmlHttp.onreadystatechange=function() {
|
---|
| 96 | if(xmlHttp.readyState==4) {
|
---|
| 97 | callback(xmlHttp);
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 | else {
|
---|
| 102 | alert("Unrecognized type of callback value: " + typeof_callback);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[31528] | 105 | if(un_ != null) {
|
---|
| 106 | url += "&un=" + un_;
|
---|
| 107 | }
|
---|
| 108 | if(ky_ != null) {
|
---|
| 109 | url += "&ky=" + ky_;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
[23740] | 112 | xmlHttp.open("GET",url,true);
|
---|
| 113 | xmlHttp.send(null);
|
---|
[23446] | 114 | }
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | this.urlGetSync = function(url)
|
---|
| 118 | {
|
---|
| 119 | // alert("url = " + url);
|
---|
| 120 |
|
---|
| 121 | var xmlHttp;
|
---|
| 122 | try {
|
---|
| 123 | // Firefox, Opera 8.0+, Safari
|
---|
| 124 | xmlHttp=new XMLHttpRequest();
|
---|
| 125 | }
|
---|
| 126 | catch (e) {
|
---|
| 127 | // Internet Explorer
|
---|
| 128 | try {
|
---|
| 129 | xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
|
---|
| 130 | }
|
---|
| 131 | catch (e) {
|
---|
| 132 | try {
|
---|
| 133 | xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 134 | }
|
---|
| 135 | catch (e) {
|
---|
| 136 | alert("Your browser does not support AJAX!");
|
---|
| 137 | return false;
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
[27318] | 141 |
|
---|
| 142 | if(un_ != null) {
|
---|
| 143 | url += "&un=" + un_;
|
---|
| 144 | }
|
---|
| 145 | if(ky_ != null) {
|
---|
| 146 | url += "&ky=" + ky_;
|
---|
| 147 | }
|
---|
[31528] | 148 |
|
---|
[23446] | 149 | xmlHttp.open("GET",url,false);
|
---|
| 150 | xmlHttp.send(null);
|
---|
| 151 |
|
---|
| 152 | // alert("response = '" + xmlHttp.responseText + "'");
|
---|
| 153 |
|
---|
| 154 | return xmlHttp.responseText;
|
---|
| 155 | }
|
---|
[27277] | 156 |
|
---|
[31528] | 157 | // New, an Ajax Synchronous Post method.
|
---|
[27277] | 158 | // http://www.degraeve.com/reference/simple-ajax-example.php
|
---|
| 159 | // Async vs Sync: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
|
---|
| 160 | // Also:
|
---|
| 161 | // http://stackoverflow.com/questions/6312447/in-an-ajax-post-do-i-need-to-urlencode-parameters-before-sending
|
---|
| 162 | // http://api.jquery.com/jQuery.post/
|
---|
| 163 | // http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
|
---|
| 164 | this.urlPostSync = function(scriptURL, params) {
|
---|
| 165 | var xmlHttp=false;
|
---|
| 166 | try {
|
---|
| 167 | // Firefox, Opera 8.0+, Safari
|
---|
| 168 | xmlHttp=new XMLHttpRequest();
|
---|
| 169 | }
|
---|
| 170 | catch (e) {
|
---|
| 171 | // Internet Explorer
|
---|
| 172 | try {
|
---|
| 173 | xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
|
---|
| 174 | }
|
---|
| 175 | catch (e) {
|
---|
| 176 | try {
|
---|
| 177 | xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 178 | }
|
---|
| 179 | catch (e) {
|
---|
| 180 | alert("Your browser does not support AJAX!");
|
---|
| 181 | return false;
|
---|
| 182 | }
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | // e.g. scriptURL: /greenstone/cgi-bin/metadata-server.pl
|
---|
| 187 | xmlHttp.open('POST', scriptURL, false); // false means synchronous
|
---|
| 188 | xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
---|
[23446] | 189 |
|
---|
[27318] | 190 | if(un_ != null) {
|
---|
| 191 | params += "&un=" + un_;
|
---|
| 192 | }
|
---|
| 193 | if(ky_ != null) {
|
---|
| 194 | params += "&ky=" + ky_;
|
---|
| 195 | }
|
---|
[27277] | 196 |
|
---|
| 197 | xmlHttp.send(params); // needs to be escaped/encoded
|
---|
| 198 |
|
---|
[27318] | 199 | //alert(scriptURL + "?" + params);
|
---|
[27277] | 200 | //alert(xmlHttp.responseText); // if synchronous, process xmlHttp.responseText AFTER send() call
|
---|
| 201 | return xmlHttp.responseText;
|
---|
| 202 | }
|
---|
| 203 |
|
---|
[27322] | 204 | // New, an Ajax Asynchronous Post method.
|
---|
| 205 | // For helpful links, see the urlPostSync() method above
|
---|
| 206 | this.urlPostAsync = function(scriptURL, params, callback) {
|
---|
| 207 | var xmlHttp=false;
|
---|
| 208 | try {
|
---|
| 209 | // Firefox, Opera 8.0+, Safari
|
---|
| 210 | xmlHttp=new XMLHttpRequest();
|
---|
| 211 | }
|
---|
| 212 | catch (e) {
|
---|
| 213 | // Internet Explorer
|
---|
| 214 | try {
|
---|
| 215 | xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
|
---|
| 216 | }
|
---|
| 217 | catch (e) {
|
---|
| 218 | try {
|
---|
| 219 | xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 220 | }
|
---|
| 221 | catch (e) {
|
---|
| 222 | alert("Your browser does not support AJAX!");
|
---|
| 223 | return false;
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 | // e.g. scriptURL: /greenstone/cgi-bin/metadata-server.pl
|
---|
| 231 | xmlHttp.open('POST', scriptURL, true); // true means asynchronous
|
---|
| 232 | xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
---|
| 233 |
|
---|
| 234 |
|
---|
| 235 | // If asynchronous:
|
---|
| 236 | // If the callback param is a function, we will set it up to get called when
|
---|
| 237 | // the async post has finished (is ready)
|
---|
| 238 | // if the callback parameter isn't a function, the param represents a field
|
---|
| 239 | // that we want to dynamically update when the async post process has finished
|
---|
| 240 |
|
---|
| 241 | var typeof_callback = typeof(callback);
|
---|
| 242 | if ((typeof_callback == "string") || (typeof_callback == "number") || (typeof_callback == "boolean")) {
|
---|
| 243 | var locid = callback;
|
---|
| 244 |
|
---|
| 245 | xmlHttp.onreadystatechange=function() {
|
---|
| 246 | if(xmlHttp.readyState==4) {
|
---|
| 247 | if (locelem != null) {
|
---|
| 248 | var locelem = document.getElementById(locid);
|
---|
| 249 |
|
---|
| 250 | locelem.innerHTML = xmlHttp.responseText;
|
---|
| 251 | }
|
---|
| 252 | }
|
---|
| 253 | }
|
---|
| 254 | }
|
---|
| 255 | else if (typeof_callback == "function") {
|
---|
| 256 | xmlHttp.onreadystatechange=function() {
|
---|
| 257 | if(xmlHttp.readyState==4) {
|
---|
| 258 | callback(xmlHttp); // e.g. this might do: updatepage(xmlHttp.responseText);
|
---|
| 259 | }
|
---|
| 260 | }
|
---|
| 261 | }
|
---|
| 262 | else {
|
---|
| 263 | alert("Unrecognized type of callback value: " + typeof_callback);
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | if(un_ != null) {
|
---|
| 267 | params += "&un=" + un_;
|
---|
| 268 | }
|
---|
| 269 | if(ky_ != null) {
|
---|
| 270 | params += "&ky=" + ky_;
|
---|
| 271 | }
|
---|
| 272 | //alert("Posting Async: " + scriptURL + "?" + params);
|
---|
| 273 |
|
---|
| 274 | xmlHttp.send(params); // needs to be escaped/encoded
|
---|
| 275 | // if synchronous, would process xmlHttp AFTER send() call, such as by
|
---|
| 276 | // accessing xmlHttp.responseText to return that to the caller at this point.
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 |
|
---|
[27257] | 280 | // New
|
---|
| 281 | // The where parameter can be specified as one or more of: import, archives, index, live
|
---|
| 282 | // separated by |. If null, it is assumed to be index which is the original default
|
---|
[27277] | 283 | // behaviour of calling set-metadata. E.g. where=import|archives|index
|
---|
[27257] | 284 | this.setMetadata = function(docid,metaname,metapos,metavalue,metamode,where)
|
---|
| 285 | {
|
---|
| 286 | var mdserver = this.metadataserverURL();
|
---|
[23446] | 287 |
|
---|
[27257] | 288 | var params = "a=set-metadata";
|
---|
| 289 | if(where != null) {
|
---|
| 290 | params += "&where=" + where; // if where not specified, meta-server will default to setting index meta
|
---|
| 291 | //} else {
|
---|
| 292 | // params += "&where=import|archives|index";
|
---|
| 293 | }
|
---|
| 294 | params += "&c="+collect_;
|
---|
| 295 | params += "&d="+docid;
|
---|
| 296 | params += "&metaname=" + metaname;
|
---|
| 297 | if (metapos!=null) {
|
---|
| 298 | params += "&metapos=" + metapos;
|
---|
| 299 | }
|
---|
| 300 | params += "&metavalue=" + metavalue;
|
---|
| 301 | if (metamode!=null) {
|
---|
| 302 | params += "&metamode=" + metamode;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
[27277] | 305 | //this.urlGetSync(mdserver + "?" + params);
|
---|
| 306 | this.urlPostSync(mdserver,params);
|
---|
[27257] | 307 | }
|
---|
| 308 |
|
---|
| 309 | // New
|
---|
| 310 | // The where parameter can be specified as one or more of: import, archives, index, live
|
---|
| 311 | // separated by |. If null, it is assumed to be index which is the original default
|
---|
| 312 | // behaviour of calling set-metadata-array). E.g. where=import|archives|index
|
---|
| 313 | this.setMetadataArray = function(docArray,metamode,where)
|
---|
| 314 | {
|
---|
| 315 | docArrayJSON = JSON.stringify(docArray);
|
---|
| 316 |
|
---|
| 317 | var mdserver = this.metadataserverURL();
|
---|
| 318 |
|
---|
[27277] | 319 | var params = "a=" + escape("set-metadata-array"); //"a=set-metadata-array";
|
---|
[27257] | 320 | if(where != null) {
|
---|
[27277] | 321 | params += "&where=" + escape(where); // if where not specified, meta-server will default to setting index meta
|
---|
[27257] | 322 | //} else {
|
---|
| 323 | // params += "&where=import|archives|index";
|
---|
| 324 | }
|
---|
[27277] | 325 | params += "&c="+escape(collect_);
|
---|
| 326 | params += "&json="+escape(docArrayJSON);
|
---|
[27257] | 327 |
|
---|
| 328 | if (metamode!=null) {
|
---|
[27277] | 329 | params += "&metamode=" + escape(metamode);
|
---|
[27257] | 330 | }
|
---|
| 331 |
|
---|
[27277] | 332 | //this.urlGetSync(mdserver + "?" + params);
|
---|
[27365] | 333 | return this.urlPostSync(mdserver,params);
|
---|
[27257] | 334 | }
|
---|
| 335 |
|
---|
[27281] | 336 | // New
|
---|
| 337 | this.getArchivesMetadata = function(docoid,metaname,metapos)
|
---|
| 338 | {
|
---|
| 339 | var mdserver = this.metadataserverURL();
|
---|
| 340 |
|
---|
| 341 | var url = mdserver + "?a=get-archives-metadata";
|
---|
| 342 | url += "&c="+collect_;
|
---|
| 343 | url += "&d="+docoid;
|
---|
| 344 | url += "&metaname=" + metaname;
|
---|
| 345 | if (metapos!=null) {
|
---|
| 346 | url += "&metapos=" + metapos;
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | //alert("In getArchivesMeta. URL: " + url)
|
---|
| 350 | return this.urlGetSync(url); //Once this works, make it POST
|
---|
| 351 | }
|
---|
| 352 |
|
---|
[27313] | 353 | this.getMetadataArray = function(docArray,where)
|
---|
| 354 | {
|
---|
| 355 | docArrayJSON = JSON.stringify(docArray);
|
---|
| 356 |
|
---|
| 357 | var mdserver = this.metadataserverURL();
|
---|
| 358 |
|
---|
| 359 | var params = "a=" + escape("get-metadata-array"); //"a=set-metadata-array";
|
---|
| 360 | if(where != null) {
|
---|
| 361 | params += "&where=" + escape(where); // if where not specified, meta-server will default to setting index meta
|
---|
| 362 | //} else {
|
---|
| 363 | // params += "&where=import|archives|index";
|
---|
| 364 | }
|
---|
| 365 | params += "&c="+escape(collect_);
|
---|
| 366 | params += "&json="+escape(docArrayJSON);
|
---|
| 367 |
|
---|
| 368 | //this.urlGetSync(mdserver + "?" + params);
|
---|
| 369 | return this.urlPostSync(mdserver,params);
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 |
|
---|
[31528] | 373 | this.setLiveMetadata = function(id,metaname,metavalue)
|
---|
| 374 | {
|
---|
| 375 | var mdserver = this.metadataserverURL();
|
---|
| 376 |
|
---|
| 377 | var url = mdserver + "?a=set-live-metadata";
|
---|
| 378 | url += "&c="+collect_;
|
---|
| 379 | url += "&d="+id;
|
---|
| 380 | url += "&metaname=" + metaname;
|
---|
| 381 | url += "&metavalue=" + metavalue;
|
---|
| 382 |
|
---|
| 383 | this.urlGetSync(url);
|
---|
| 384 | }
|
---|
| 385 |
|
---|
[23740] | 386 | this._setMetadata = function(mode,docid,metaname,metapos,metavalue,metamode)
|
---|
[23446] | 387 | {
|
---|
| 388 | var mdserver = this.metadataserverURL();
|
---|
| 389 |
|
---|
[23740] | 390 | var params = "a=set" + mode + "-metadata";
|
---|
| 391 | params += "&c="+collect_;
|
---|
| 392 | params += "&d="+docid;
|
---|
| 393 | params += "&metaname=" + metaname;
|
---|
[23446] | 394 | if (metapos!=null) {
|
---|
[23740] | 395 | params += "&metapos=" + metapos;
|
---|
[23446] | 396 | }
|
---|
[23740] | 397 | params += "&metavalue=" + metavalue;
|
---|
[27257] | 398 | if (metamode!=null) {
|
---|
[23740] | 399 | params += "&metamode=" + metamode;
|
---|
[27257] | 400 | }
|
---|
[23740] | 401 |
|
---|
| 402 | this.urlGetSync(mdserver + "?" + params);
|
---|
| 403 | //this.urlPostSync(mdserver,params);
|
---|
[23446] | 404 | }
|
---|
| 405 |
|
---|
[24072] | 406 |
|
---|
[27257] | 407 | this._setDocumentArrayMetadata = function(mode,docArray,metamode)
|
---|
| 408 | {
|
---|
| 409 | docArrayJSON = JSON.stringify(docArray);
|
---|
[24072] | 410 |
|
---|
[27257] | 411 | var mdserver = this.metadataserverURL();
|
---|
| 412 |
|
---|
| 413 | var params = "a=set" + mode + "-metadata-array";
|
---|
| 414 | params += "&c="+collect_;
|
---|
| 415 | params += "&json="+docArrayJSON;
|
---|
| 416 |
|
---|
| 417 | if (metamode!=null) {
|
---|
| 418 | params += "&metamode=" + metamode;
|
---|
[24072] | 419 | }
|
---|
| 420 |
|
---|
[27257] | 421 | this.urlGetSync(mdserver + "?" + params);
|
---|
[24072] | 422 |
|
---|
[27257] | 423 | }
|
---|
| 424 |
|
---|
| 425 |
|
---|
[23446] | 426 | this.setDocumentMetadata = function(docid,metaname,metapos,metavalue)
|
---|
| 427 | {
|
---|
[23740] | 428 | // Allow for three param call to function, where metapos is missed out
|
---|
[23446] | 429 | if (metavalue==null) {
|
---|
| 430 | // 4 param case
|
---|
| 431 | metavalue = metapos;
|
---|
| 432 | metapos = null;
|
---|
[24072] | 433 | }
|
---|
[23446] | 434 |
|
---|
[24072] | 435 | this._setMetadata("",docid,metaname,metapos,metavalue);
|
---|
| 436 | this._setMetadata("-archives",docid,metaname,metapos,metavalue,"override");
|
---|
| 437 |
|
---|
[23446] | 438 | }
|
---|
| 439 |
|
---|
[31528] | 440 | this.setDocumentArrayMetadata = function(docArray,metamode)
|
---|
| 441 | {
|
---|
| 442 | //showDialog('Greenstone Javascript API','This sequence of changes has been commited into the system.','success', 2);
|
---|
[24072] | 443 |
|
---|
[31528] | 444 | this._setDocumentArrayMetadata("",docArray,metamode);
|
---|
| 445 | this._setDocumentArrayMetadata("-archives",docArray,metamode);
|
---|
| 446 | }
|
---|
[24072] | 447 |
|
---|
[23740] | 448 | this.setNewDocumentMetadata = function(docid,metaname,metavalue)
|
---|
[23446] | 449 | {
|
---|
[24072] | 450 | this._setMetadata("",docid,metaname,null,metavalue);
|
---|
| 451 | this._setMetadata("-archives",docid,metaname,null,metavalue,"accumulate");
|
---|
[23446] | 452 | }
|
---|
| 453 |
|
---|
[23740] | 454 | this.setImportMetadata = function(docid,metaname,metapos,metavalue)
|
---|
[23446] | 455 | {
|
---|
[24072] | 456 | this._setMetadata("-import",docid,metaname,metapos,metavalue,"override");
|
---|
[23446] | 457 | }
|
---|
| 458 |
|
---|
| 459 |
|
---|
[23740] | 460 | this.explodeDocument = function(docid)
|
---|
| 461 | {
|
---|
| 462 | var exserver = this.explodeserverURL();
|
---|
| 463 |
|
---|
[24072] | 464 | var url = exserver + "?a=explode-document";
|
---|
[23740] | 465 | url += "&c="+collect_;
|
---|
| 466 | url += "&d="+docid;
|
---|
[24072] | 467 |
|
---|
| 468 | this.urlGetSync(url);
|
---|
| 469 | }
|
---|
[23740] | 470 |
|
---|
[24072] | 471 | this.deleteDocument = function(docid,onlyAdd)
|
---|
| 472 | {
|
---|
| 473 | var exserver = this.explodeserverURL();
|
---|
| 474 |
|
---|
| 475 | var url = exserver + "?a=delete-document";
|
---|
| 476 | url += "&c="+collect_;
|
---|
| 477 | params += "&onlyadd="+onlyAdd;
|
---|
| 478 | url += "&d="+docid;
|
---|
[23740] | 479 |
|
---|
| 480 | this.urlGetSync(url);
|
---|
| 481 | }
|
---|
[23806] | 482 |
|
---|
[24072] | 483 | this.deleteDocumentArray = function(docArray,onlyAdd)
|
---|
| 484 | {
|
---|
| 485 | docArrayJSON = JSON.stringify(docArray);
|
---|
| 486 |
|
---|
| 487 | var exserver = this.explodeserverURL();
|
---|
| 488 |
|
---|
| 489 | var params = "a=delete-document-array";
|
---|
| 490 | params += "&c="+collect_;
|
---|
| 491 | params += "&onlyadd="+onlyAdd;
|
---|
| 492 | params += "&json="+docArrayJSON;
|
---|
| 493 |
|
---|
| 494 | this.urlGetSync(exserver + "?" + params);
|
---|
| 495 |
|
---|
| 496 | }
|
---|
| 497 |
|
---|
[23806] | 498 |
|
---|
| 499 | this.cloneDocument = function(docid,toCollect)
|
---|
| 500 | {
|
---|
| 501 | var msserver = this.myspaceserverURL();
|
---|
| 502 |
|
---|
| 503 | var url = msserver + "?a=clone";
|
---|
| 504 | url += "&c="+collect_;
|
---|
| 505 | url += "&d="+docid;
|
---|
| 506 | url += "&toCollect="+toCollect;
|
---|
| 507 |
|
---|
| 508 | this.urlGetSync(url);
|
---|
| 509 | }
|
---|
[23740] | 510 |
|
---|
| 511 | // consider name change to reindexDocument
|
---|
[23446] | 512 | this.documentReindex = function(docid)
|
---|
| 513 | {
|
---|
| 514 | var mdserver = this.metadataserverURL();
|
---|
| 515 |
|
---|
| 516 | var url = mdserver + "?a=reindex-document";
|
---|
| 517 | url += "&c="+collect_;
|
---|
| 518 | url += "&d="+docid;
|
---|
| 519 |
|
---|
| 520 | this.urlGetSync(url);
|
---|
| 521 | }
|
---|
[23740] | 522 |
|
---|
| 523 |
|
---|
| 524 | this.reindexCollection = function(mode,callback)
|
---|
| 525 | {
|
---|
| 526 | if (mode==null) {
|
---|
[24072] | 527 | mode = "incremental";
|
---|
| 528 | }
|
---|
[23740] | 529 |
|
---|
| 530 | var idserver = this.indexserverURL();
|
---|
[23446] | 531 |
|
---|
[23740] | 532 | var url = idserver + "?a=" + mode + "-rebuild";
|
---|
| 533 | url += "&c="+collect_;
|
---|
| 534 |
|
---|
| 535 | this.urlGetAsync(url,callback);
|
---|
| 536 | }
|
---|
| 537 |
|
---|
| 538 |
|
---|
[24072] | 539 | this.buildByManifestGeneral = function(hashargs)
|
---|
| 540 | {
|
---|
| 541 | var idserver = this.buildserverURL();
|
---|
| 542 |
|
---|
| 543 | var url = idserver + "?a=build-by-manifest";
|
---|
| 544 | url += "&c="+collect_;
|
---|
| 545 |
|
---|
| 546 | if (hashargs["index-files"] != undefined) {
|
---|
| 547 | url += "&index-files=" + JSON.stringify(hashargs["index-files"]);
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | if (hashargs["reindex-files"] != undefined) {
|
---|
| 551 | url += "&reindex-files=" + JSON.stringify(hashargs["reindex-files"]);
|
---|
| 552 | }
|
---|
| 553 | if (hashargs["delete-OIDs"] != undefined) {
|
---|
| 554 | url += "&delete-OIDs=" + JSON.stringify(hashargs["delete-OIDs"]);
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | this.urlGetSync(url);
|
---|
| 558 | }
|
---|
| 559 |
|
---|
| 560 | this.indexByManifest = function(docidArray)
|
---|
| 561 | {
|
---|
| 562 | var hashargs = {};
|
---|
| 563 | hashargs["index-files"] = docidArray;
|
---|
| 564 | this.buildByManifestGeneral(hashargs);
|
---|
| 565 | }
|
---|
| 566 |
|
---|
| 567 | this.reindexByManifest = function(docidArray)
|
---|
| 568 | {
|
---|
| 569 | var hashargs = {};
|
---|
| 570 | hashargs["reindex-files"] = docidArray;
|
---|
| 571 | this.buildByManifestGeneral(hashargs);
|
---|
| 572 | }
|
---|
| 573 | this.deleteByManifest = function(docidArray)
|
---|
| 574 | {
|
---|
| 575 | var hashargs = {};
|
---|
| 576 | hashargs["delete-OIDs"] = docidArray;
|
---|
| 577 | this.buildByManifestGeneral(hashargs);
|
---|
| 578 | }
|
---|
| 579 |
|
---|
[23446] | 580 | this.getLiveMetadata = function(id,metaname)
|
---|
| 581 | {
|
---|
| 582 | var mdserver = this.metadataserverURL();
|
---|
| 583 |
|
---|
| 584 | var url = mdserver + "?a=get-live-metadata";
|
---|
| 585 | url += "&c="+collect_;
|
---|
| 586 | url += "&d="+id;
|
---|
| 587 | url += "&metaname=" + metaname;
|
---|
| 588 |
|
---|
| 589 | var metavalue = this.urlGetSync(url);
|
---|
[24072] | 590 |
|
---|
[23446] | 591 | return metavalue;
|
---|
| 592 | }
|
---|
| 593 |
|
---|
| 594 | this.getDocumentMetadata = function(docoid,metaname,metapos)
|
---|
| 595 | {
|
---|
| 596 | var mdserver = this.metadataserverURL();
|
---|
| 597 |
|
---|
| 598 | var url = mdserver + "?a=get-metadata";
|
---|
| 599 | url += "&c="+collect_;
|
---|
| 600 | url += "&d="+docoid;
|
---|
| 601 | url += "&metaname=" + metaname;
|
---|
| 602 | if (metapos!=null) {
|
---|
| 603 | url += "&metapos=" + metapos;
|
---|
| 604 | }
|
---|
| 605 |
|
---|
| 606 | return this.urlGetSync(url);
|
---|
| 607 | }
|
---|
| 608 |
|
---|
| 609 | this.removeLiveMetadata = function(id,metaname)
|
---|
| 610 | {
|
---|
| 611 | var mdserver = this.metadataserverURL();
|
---|
| 612 |
|
---|
| 613 | var url = mdserver + "?a=remove-live-metadata";
|
---|
| 614 | url += "&c="+collect_;
|
---|
| 615 | url += "&d="+id;
|
---|
| 616 | url += "&metaname=" + metaname;
|
---|
| 617 |
|
---|
| 618 | this.urlGetSync(url);
|
---|
| 619 | }
|
---|
| 620 |
|
---|
| 621 | this.removeDocumentMetadata = function(docid,metaname,metapos)
|
---|
| 622 | {
|
---|
| 623 | var mdserver = this.metadataserverURL();
|
---|
| 624 |
|
---|
| 625 | var url = mdserver + "?a=remove-metadata";
|
---|
| 626 | url += "&c="+collect_;
|
---|
| 627 | url += "&d="+docid;
|
---|
| 628 | url += "&metaname=" + metaname;
|
---|
| 629 | if (metapos!=null) {
|
---|
| 630 | url += "&metapos=" + metapos;
|
---|
| 631 | }
|
---|
| 632 |
|
---|
| 633 | this.urlGetSync(url);
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | return true;
|
---|
| 637 |
|
---|
| 638 | } |
---|