Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 3.65 KB  |  views: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. docway.Transfer.requestContentOperation = function(oObject, sCmd, sFormat, nPage, sPageModifier, oWindow)
  2. {
  3.         //we used to "defer" the content operation here, and hit the UI to get tickets and an ajax payload.
  4.         //now we do everything inline, because reentrant setTimeout blows everything up
  5.         if (wsptIsNull(docway.TransferManager.getSharedControl()))
  6.         {
  7.                 if (docway.TransferManager.MustHaveControl)
  8.                 {
  9.                         wspt.alertWarning("${transfer.js.operationdisallowed}");
  10.                         return;
  11.                 }
  12.                 oTransfer = new docway.BrowserTransfer();
  13.         }
  14.         else
  15.         {
  16.                 oTransfer = new docway.Transfer();
  17.         }
  18.        
  19.         //do all ticket-getting right here, because we need a centralized spot
  20.         //to piggy-back onto the request
  21.        
  22.         var oRequestedOperation = {
  23.                 sCmd:sCmd
  24.                 ,sFormat:sFormat
  25.                 ,nPage:nPage
  26.                 ,sPageModifier:sPageModifier
  27.         };
  28.        
  29.         var requestParams = {}
  30.         Ext.applyIf(requestParams, oTransfer.prepareContentOperationHook(oObject, oRequestedOperation));
  31.         Ext.applyIf(requestParams, oTransfer.prepareContentOperation(oObject, oRequestedOperation));
  32.  
  33.         //if (requestParams.keys.length === 0) return;
  34.        
  35.         //execute
  36.         var url = wspt.getDhtmlClient().getDynamicResourceRoot() + 'raw/';
  37.         var qs = wspt.getDhtmlClient().createQueryString();
  38.         for (var key in requestParams)
  39.         {
  40.                 qs.add(key, requestParams[key]);
  41.         }
  42.         var sJson = wspt.getDhtmlClient().executeSynchronousRequest('dwuiOverrideContentOperation', url, qs);
  43.         if (wsptIsNull(sJson))
  44.         {
  45.                 throw new Error('${transfer.js.getticketfailed}'); //where does this get caught
  46.         }
  47.         var oResponse = Ext.util.JSON.decode(sJson);
  48.         //fix up oObject--which might need a full-blown ajax component stack to reproject
  49.         oTransfer.executeContentOperation(oObject, oResponse, oWindow);
  50. };
  51.  
  52. docway.Transfer.prototype.prepareContentOperationHook = function(oObject, op)
  53. //signal that content operation should be deferred, so the UI has a chance
  54. //to intercept and override how the operation happens
  55. //they can also modify the operation inline right here
  56. {
  57.         //return request parameters to be added to query
  58.         if (docway.CONTENTOPERATION_VIEW === op.sCmd)
  59.         {
  60.                 //give UI a chance to override view operations
  61.                 op.sSystemID = oObject.getID();
  62.                 return op; //{ overrideRequest:true };
  63.         }
  64.         return null;
  65. };
  66.  
  67. docway.Transfer.prototype.prepareContentOperation = function(oObject, op)
  68. {
  69.         //all control-based transfer operations except CancelCheckout need a ticket
  70.         if (docway.CONTENTOPERATION_CANCELCHECKOUT !== op.sCmd)
  71.         {
  72.                 return { needTicket: true };
  73.         }
  74.         return null;
  75. }
  76.  
  77. docway.BrowserTransfer.prototype.prepareContentOperation = function(oObject, op)
  78. {
  79.         //which browser-based operations need a ticket?
  80.         if (docway.CONTENTOPERATION_CANCELCHECKOUT !== op.sCmd)
  81.         {
  82.                 return { needTicket: true };
  83.         }
  84.         return null;
  85. }
  86.  
  87. docway.Transfer.prototype.executeContentOperation = function(oObject, oResponse, oWindow)
  88. {
  89.         var op = oResponse.oActualOperation;
  90.         var oTicket = oResponse.oTicket;
  91.         try
  92.         {
  93.                 switch (op.sCmd)
  94.                 {
  95.                 case docway.CONTENTOPERATION_VIEW:
  96.                         this.view(oObject, oTicket, oWindow);
  97.                         break;
  98.                 case docway.CONTENTOPERATION_VIEWRENDITION:
  99.                         this.viewRendition(oObject, oTicket, op.sFormat, op.nPage, op.sPageModifier, oWindow);
  100.                         break;
  101.                 case docway.CONTENTOPERATION_EDIT:
  102.                         this.edit(oObject, oTicket, oWindow);
  103.                         break;
  104.                 case docway.CONTENTOPERATION_EXPORT:
  105.                         this.exportContent(oObject, oWindow);
  106.                         break;
  107.                 case docway.CONTENTOPERATION_CHECKOUT:
  108.                         this.checkout(oObject, oTicket, oWindow);
  109.                         break;
  110.                 case docway.CONTENTOPERATION_CANCELCHECKOUT:
  111.                         this.cancelCheckout(oObject);
  112.                         break;
  113.                 default:
  114.                         throw new Error(wspt.formatString('${transfer.js.executecontentop}', [ op.sCmd ]));
  115.                 }
  116.         }
  117.         catch (e)
  118.         {
  119.                 if(wspt.getDhtmlClient().getDisableExceptionLogging())
  120.                 {
  121.                         throw e;
  122.                 }
  123.                 wspt.alertError(wsptGetErrorMessage(e));
  124.         }
  125. };
clone this paste RAW Paste Data