summaryrefslogtreecommitdiffstats
path: root/idrop-web/grails-app/services
diff options
context:
space:
mode:
authorMike Conway <michael.c.conway@gmail.com>2011-12-15 16:43:31 (GMT)
committer Mike Conway <michael.c.conway@gmail.com>2011-12-15 16:43:31 (GMT)
commit16bd0e0ae62fbe89fc7bae532859b4de5b79bd43 (patch)
treea28f472770f45ea237d2d64ed71c77a2375d54a2 /idrop-web/grails-app/services
parenta2c98c74f8f40d4610fdce8720f65828a530c644 (diff)
downloadQCG-Data-16bd0e0ae62fbe89fc7bae532859b4de5b79bd43.zip
QCG-Data-16bd0e0ae62fbe89fc7bae532859b4de5b79bd43.tar.gz
QCG-Data-16bd0e0ae62fbe89fc7bae532859b4de5b79bd43.tar.bz2
[#535] shopping cart capability in idrop web and idrop lite
Diffstat (limited to 'idrop-web/grails-app/services')
-rw-r--r--idrop-web/grails-app/services/org/irods/mydrop/service/ShoppingCartSessionService.groovy (renamed from idrop-web/grails-app/services/org/irods/mydrop/service/ShoppingCartService.groovy)35
1 files changed, 17 insertions, 18 deletions
diff --git a/idrop-web/grails-app/services/org/irods/mydrop/service/ShoppingCartService.groovy b/idrop-web/grails-app/services/org/irods/mydrop/service/ShoppingCartSessionService.groovy
index 5025bf2..d2e7aa1 100644
--- a/idrop-web/grails-app/services/org/irods/mydrop/service/ShoppingCartService.groovy
+++ b/idrop-web/grails-app/services/org/irods/mydrop/service/ShoppingCartSessionService.groovy
@@ -1,14 +1,13 @@
package org.irods.mydrop.service
import javax.servlet.http.HttpSession
-import org.irods.jargon.core.connection.IRODSAccount
import org.irods.jargon.datautils.shoppingcart.FileShoppingCart
import org.irods.jargon.datautils.shoppingcart.ShoppingCartEntry
import org.springframework.web.context.request.RequestContextHolder
-class ShoppingCartService {
+class ShoppingCartSessionService {
- static transactional = false
+ static transactional = false
//static scope = "session"
static final String CART_ATTRIBUTE = "shoppingCart"
@@ -18,11 +17,11 @@ class ShoppingCartService {
* @param irodsAccount <code>IRODSAccount</code> for which the cart will be associated
* @return
*/
- public void addToCart(String irodsFileAbsolutePath, IRODSAccount irodsAccount) {
- FileShoppingCart fileShoppingCart = getCartFromSessionAndCreateIfNotThere(irodsAccount)
+ public void addToCart(String irodsFileAbsolutePath) {
+ FileShoppingCart fileShoppingCart = getCartFromSessionAndCreateIfNotThere()
fileShoppingCart.addAnItem(new ShoppingCartEntry(irodsFileAbsolutePath))
- }
-
+ }
+
/**
* List the contents of the cart as a list of file names
* @return
@@ -35,7 +34,7 @@ class ShoppingCartService {
}
return results
}
-
+
/**
* Clear the files in the cart
*/
@@ -45,15 +44,15 @@ class ShoppingCartService {
fileShoppingCart.clearCart()
}
}
-
+
public void deleteFromCart(String fileName) {
FileShoppingCart shoppingCart = getSession().shoppingCart
if (shoppingCart) {
log.info("have a shopping cart, delete ${fileName}")
- shoppingCart.removeAnItem(fileName);
+ shoppingCart.removeAnItem(fileName)
}
}
-
+
/**
* Get shopping cart from session if present, but don't create one if not present (saves storing unnecesary session state)
* @return {@link FileShoppingCart} if stored in session, or <code>null</code> if not stored
@@ -62,20 +61,20 @@ class ShoppingCartService {
FileShoppingCart shoppingCart = getSession().shoppingCart
return shoppingCart
}
-
- private FileShoppingCart getCartFromSessionAndCreateIfNotThere(IRODSAccount irodsAccount) {
+
+ private FileShoppingCart getCartFromSessionAndCreateIfNotThere() {
FileShoppingCart shoppingCart = getSession().shoppingCart
if (!shoppingCart) {
log.info("no shopping cart, create one")
- shoppingCart = new FileShoppingCart(irodsAccount)
+ shoppingCart = new FileShoppingCart()
getSession().shoppingCart = shoppingCart
}
return shoppingCart
-
+
}
-
+
private HttpSession getSession() {
return RequestContextHolder.currentRequestAttributes().getSession()
- }
-
+ }
+
}