Guest User

Untitled

a guest
Jan 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. public String submitProducts()
  2. throws Exception {
  3.  
  4. String resultValue = "";
  5. /* Algorithm: */
  6. // 1. Read the Vector object from Session.
  7. // 2. Check whether the size of the Vector matches the Total Product windows count.
  8. // 3. If yes, call the Save operation and remove the list from session.
  9. // 4. If not, copy the values from current Action instance to VO.
  10. // 5. Add to List object and place in session.
  11.  
  12. synchronized (productVOsInVector) {
  13. productVOsInVector = getProductVOVectorFromSession();
  14. if (productVOsInVector == null) {
  15. productVOsInVector = new Vector <ProductVO>();
  16. }
  17. log.info("Window Number is " + activeWindowNumber + ". List size is " + productVOsInVector.size());
  18. if (productVOsInVector.size() == (prodWindowCount - 1)) {
  19. productVOsInVector = mapActionToVO(productVOsInVector);
  20. resultValue = saveOperation(productVOsInVector);
  21. if (resultValue.equalsIgnoreCase(SUCCESS)) {
  22. session.put("OperationStatus", SUCCESS);
  23. }
  24. session.remove("productVOMapData");
  25. }
  26. else {
  27. if (quoteSaveStatus) {
  28. quoteSaveStatus = false;
  29. }
  30. session.put("OperationStatus", "");
  31. productVOsInVector = mapActionToVO(productVOsInVector);
  32. session.put("productVOMapData", productVOsInVector);
  33. }
  34. waitForOperationStatus();
  35. }
  36. System.out.println("Came out of sync block");
  37. System.out.println("Action Instance" + activeWindowNumber + " is resuming.");
  38. // Code to display the Error messages
  39. return resultValue;
  40. }
  41.  
  42. public void waitForOperationStatus() {
  43.  
  44. String opStatus = getOperationStatusFromSession();
  45. synchronized (productVOsInVector) {
  46. if (!opStatus.equalsIgnoreCase(SUCCESS)) {
  47. try {
  48. System.out.println("Window # " + activeWindowNumber + " Waiting");
  49. productVOsInVector.wait();
  50. }
  51. catch (InterruptedException e) {
  52. e.printStackTrace();
  53. }
  54. opStatus = getOperationStatusFromSession();
  55. }
  56. productVOsInVector.notifyAll();
  57. }
  58. }
  59.  
  60. synchronized (productVOsInVector) {
  61. productVOsInVector = getProductVOVectorFromSession();
  62. if (productVOsInVector == null) {
  63. productVOsInVector = new Vector <ProductVO>();
  64. }
  65. ...
  66. }
Add Comment
Please, Sign In to add comment