Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String submitProducts()
- throws Exception {
- String resultValue = "";
- /* Algorithm: */
- // 1. Read the Vector object from Session.
- // 2. Check whether the size of the Vector matches the Total Product windows count.
- // 3. If yes, call the Save operation and remove the list from session.
- // 4. If not, copy the values from current Action instance to VO.
- // 5. Add to List object and place in session.
- synchronized (productVOsInVector) {
- productVOsInVector = getProductVOVectorFromSession();
- if (productVOsInVector == null) {
- productVOsInVector = new Vector <ProductVO>();
- }
- log.info("Window Number is " + activeWindowNumber + ". List size is " + productVOsInVector.size());
- if (productVOsInVector.size() == (prodWindowCount - 1)) {
- productVOsInVector = mapActionToVO(productVOsInVector);
- resultValue = saveOperation(productVOsInVector);
- if (resultValue.equalsIgnoreCase(SUCCESS)) {
- session.put("OperationStatus", SUCCESS);
- }
- session.remove("productVOMapData");
- }
- else {
- if (quoteSaveStatus) {
- quoteSaveStatus = false;
- }
- session.put("OperationStatus", "");
- productVOsInVector = mapActionToVO(productVOsInVector);
- session.put("productVOMapData", productVOsInVector);
- }
- waitForOperationStatus();
- }
- System.out.println("Came out of sync block");
- System.out.println("Action Instance" + activeWindowNumber + " is resuming.");
- // Code to display the Error messages
- return resultValue;
- }
- public void waitForOperationStatus() {
- String opStatus = getOperationStatusFromSession();
- synchronized (productVOsInVector) {
- if (!opStatus.equalsIgnoreCase(SUCCESS)) {
- try {
- System.out.println("Window # " + activeWindowNumber + " Waiting");
- productVOsInVector.wait();
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- opStatus = getOperationStatusFromSession();
- }
- productVOsInVector.notifyAll();
- }
- }
- synchronized (productVOsInVector) {
- productVOsInVector = getProductVOVectorFromSession();
- if (productVOsInVector == null) {
- productVOsInVector = new Vector <ProductVO>();
- }
- ...
- }
Add Comment
Please, Sign In to add comment