Package org.cyclos.security.marketplace
Class OrderServiceSecurity
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.security.BaseServiceSecurity
-
- org.cyclos.security.CRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams>
-
- org.cyclos.security.marketplace.OrderServiceSecurity
-
- All Implemented Interfaces:
CRUDService<OrderDTO,OrderData,OrderDataParams>,CRUDWithConfirmationPasswordService<OrderDTO,OrderData,OrderDataParams>,OrderService,Service
@Security public class OrderServiceSecurity extends CRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams> implements OrderService
Security forOrderService
-
-
Field Summary
-
Fields inherited from class org.cyclos.security.CRUDServiceSecurity
entityClass
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description OrderServiceSecurity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OrderStatusaccept(AcceptOrderParams params)Accepts the given order, which should be in eitherOrderStatus.PENDING_BUYERorOrderStatus.PENDING_SELLERstatus, and needs the delivery price to be already set.intaddToCart(BasicAdVO ad, BigDecimal quantity)Adds the given product to the logged user's shopping cart, returning the total count of ads in the cart.
When the given quantity is null, the minimum allowed quantity on the shopping cart for the given product is assumedShoppingCartDTOadjustAndGetMyCart()Returns the current logged user's shopping cart, adjusting all quantitiesOrderDataadjustShoppingCartAndGetData(OrderVO vo)Perform adjustments to the shopping cart quantities and returns the data for itvoidcheckCartStock(UserLocatorVO sellerVO, CurrencyVO currencyVO)Checks that all items on the given cart are still on stockprotected voidcheckCreateNew(OrderDataParams params)Checks whether creating new entities with the given context parameters is allowed, throwingPermissionDeniedExceptionif notShoppingCartCheckoutResultcheckout(ShoppingCartCheckoutParams params)Checks out the logged user's shopping cart with the given seller and currency, checking the confirmation password (if any), and reserving the amount when the delivery price is previously known (otherwise, the buyer still needs to confirm before the payment is done).intcountCartItems()Returns the total number of items in the logged user's shopping cartprotected voidcustomizeData(OrderData data)Can be overridden in order to process the returned data object for the given entitybooleandoHasManageAccess(Order order)Should be implemented in order to return whether the caller is allowed to manage the given entity, for the given operationbooleandoHasViewAccess(Order order)Should be implemented in order to return whether the caller is allowed to view the given entity.FileInfoexportOrder(ExportFormatVO format, OrderVO vo)Exports the given order to fileOrderDatagetCheckoutData(UserLocatorVO sellerVO, CurrencyVO currencyVO)Returns data for checkout the cart items of the given seller and currencyprotected OrderServiceLocalgetImplementation()Should be implemented in order to return the actual implementation of the serviceShoppingCartDTOgetMyCart()Returns the current logged user's shopping cart, without adjusting any quantityOrderDatagetOrderData(OrderVO vo)Returns data of an orderlonggetOrderId(OrderVO order)Return the id of the given order only if the logged user can see the order.OrderSearchDatagetSearchData(@NotNull UserLocatorVO locator, boolean sales)Returns data for searching orders / salesbooleanisAccessible(SessionData sessionData, Order entity)Must be implemented in order to determine whether the given entity is accessible for the given session data.intmodifyQuantityOnCart(BasicAdVO ad, BigDecimal quantity)Updates the quantity for the given product on the logged user's shopping cart returning the total count of ads in the cart.voidreject(RejectOrderParams params)Rejects the given orderintremoveCart(UserLocatorVO sellerVO, CurrencyVO currencyVO)Removes the logged user's shopping cart for the given seller and currency returning the remaining count of ads in the cartintremoveCartById(Long id)Same asCRUDService.remove(Long)but returning the total count of items present the whole shopping cartintremoveCartItem(BasicAdVO ad)Removes the given product from the logged user's shopping cart returning the remaining count of ads in the cart.Page<OrderVO>search(OrderQuery query)Searches for orders based onOrderQueryvoidsetDeliveryMethod(SetDeliveryMethodParams deliveryInfo)Updates the delivery method information of an order when it is on theOrderStatus.PENDING_SELLERstatus and there is no delivery information yet.LongsubmitToBuyer(OrderDTO order)Submits the given order for buyer approval-
Methods inherited from class org.cyclos.security.CRUDServiceSecurity
canPerformOperation, canViewData, checkManageAccess, checkOperation, checkSave, checkViewAccess, find, getConfirmationPasswordInputForRemove, getData, getDataForNew, getEntityClass, hasManageAccess, hasViewAccess, load, onBeforeSave, remove, removeAll, removeAllWithConfirmationPassword, removeWithConfirmationPassword, resolveEntityCheck, save, saveWithConfirmationPassword
-
Methods inherited from class org.cyclos.security.BaseServiceSecurity
checkGuest, checkId, checkIds, checkInternalName, checkLoggedIn, checkManagesUser, checkRelatesToUser, checkScope, checkVO, checkVOs, doInitialize, getEntityCheckRegistry, getUser, initialize
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.services.CRUDService
getData, getDataForNew, load, remove, removeAll, save
-
-
-
-
Method Detail
-
accept
public OrderStatus accept(AcceptOrderParams params) throws FrameworkException, TransferException, PasswordException
Description copied from interface:OrderServiceAccepts the given order, which should be in eitherOrderStatus.PENDING_BUYERorOrderStatus.PENDING_SELLERstatus, and needs the delivery price to be already set. When the buyer hasn't yet chosen a payment type, it is required now. Also, when no amount was reserved, the confirmation password will be checked before performing the actual payment.- Specified by:
acceptin interfaceOrderService- Throws:
PasswordException- The given confirmation password is invalidIllegalActionException- The given order is not in eitherOrderStatus.PENDING_BUYERorOrderStatus.PENDING_SELLERstatusTransferException- When there was a problem while reserving the amount, like there is no available balanceFrameworkException
-
addToCart
public int addToCart(BasicAdVO ad, BigDecimal quantity) throws FrameworkException, OutOfStockException
Description copied from interface:OrderServiceAdds the given product to the logged user's shopping cart, returning the total count of ads in the cart.
When the given quantity is null, the minimum allowed quantity on the shopping cart for the given product is assumed- Specified by:
addToCartin interfaceOrderService- Throws:
OutOfStockException- When the given quantity is greater than the available stockFrameworkException
-
adjustAndGetMyCart
public ShoppingCartDTO adjustAndGetMyCart() throws FrameworkException
Description copied from interface:OrderServiceReturns the current logged user's shopping cart, adjusting all quantities- Specified by:
adjustAndGetMyCartin interfaceOrderService- Throws:
FrameworkException
-
adjustShoppingCartAndGetData
public OrderData adjustShoppingCartAndGetData(OrderVO vo) throws FrameworkException
Description copied from interface:OrderServicePerform adjustments to the shopping cart quantities and returns the data for it- Specified by:
adjustShoppingCartAndGetDatain interfaceOrderService- Throws:
FrameworkException
-
checkCartStock
public void checkCartStock(UserLocatorVO sellerVO, CurrencyVO currencyVO) throws FrameworkException, OutOfStockException
Description copied from interface:OrderServiceChecks that all items on the given cart are still on stock- Specified by:
checkCartStockin interfaceOrderService- Throws:
FrameworkExceptionOutOfStockException
-
checkout
public ShoppingCartCheckoutResult checkout(ShoppingCartCheckoutParams params) throws FrameworkException, EntityNotFoundException, OutOfStockException, TransferException, PasswordException
Description copied from interface:OrderServiceChecks out the logged user's shopping cart with the given seller and currency, checking the confirmation password (if any), and reserving the amount when the delivery price is previously known (otherwise, the buyer still needs to confirm before the payment is done).- Specified by:
checkoutin interfaceOrderService- Returns:
- A result containing the order and the remaining webshop ads added to the shopping cart.
- Throws:
EntityNotFoundException- When there is no current shopping cart order with the given seller and currencyPasswordException- The given confirmation password is invalidOutOfStockException- When at least one of the expected items exceeds the available stockInsufficientBalanceException- When there was a problem while reserving the amountFrameworkExceptionTransferException
-
countCartItems
public int countCartItems() throws FrameworkExceptionDescription copied from interface:OrderServiceReturns the total number of items in the logged user's shopping cart- Specified by:
countCartItemsin interfaceOrderService- Throws:
FrameworkException
-
doHasManageAccess
public boolean doHasManageAccess(Order order)
Description copied from class:CRUDServiceSecurityShould be implemented in order to return whether the caller is allowed to manage the given entity, for the given operation- Specified by:
doHasManageAccessin classCRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams>
-
doHasViewAccess
public boolean doHasViewAccess(Order order)
Description copied from class:CRUDServiceSecurityShould be implemented in order to return whether the caller is allowed to view the given entity.- Specified by:
doHasViewAccessin classCRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams>
-
exportOrder
public FileInfo exportOrder(ExportFormatVO format, OrderVO vo) throws FrameworkException
Description copied from interface:OrderServiceExports the given order to file- Specified by:
exportOrderin interfaceOrderService- Throws:
FrameworkException
-
getCheckoutData
public OrderData getCheckoutData(UserLocatorVO sellerVO, CurrencyVO currencyVO)
Description copied from interface:OrderServiceReturns data for checkout the cart items of the given seller and currency- Specified by:
getCheckoutDatain interfaceOrderService
-
getMyCart
public ShoppingCartDTO getMyCart()
Description copied from interface:OrderServiceReturns the current logged user's shopping cart, without adjusting any quantity- Specified by:
getMyCartin interfaceOrderService
-
getOrderData
public OrderData getOrderData(OrderVO vo) throws FrameworkException
Description copied from interface:OrderServiceReturns data of an order- Specified by:
getOrderDatain interfaceOrderService- Throws:
FrameworkException
-
getOrderId
public long getOrderId(OrderVO order) throws FrameworkException
Description copied from interface:OrderServiceReturn the id of the given order only if the logged user can see the order.- Specified by:
getOrderIdin interfaceOrderService- Throws:
FrameworkException
-
getSearchData
public OrderSearchData getSearchData(@NotNull @NotNull UserLocatorVO locator, boolean sales) throws FrameworkException
Description copied from interface:OrderServiceReturns data for searching orders / sales- Specified by:
getSearchDatain interfaceOrderService- Throws:
FrameworkException
-
isAccessible
public boolean isAccessible(SessionData sessionData, Order entity)
Description copied from class:CRUDServiceSecurityMust be implemented in order to determine whether the given entity is accessible for the given session data. This method shouldn't check the same condition asCRUDServiceSecurity.hasViewAccess(BaseEntity). If the only condition for an entity isCRUDServiceSecurity.hasViewAccess(BaseEntity), this method should return false.- Specified by:
isAccessiblein classCRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams>
-
modifyQuantityOnCart
public int modifyQuantityOnCart(BasicAdVO ad, BigDecimal quantity) throws FrameworkException, IllegalActionException, OutOfStockException
Description copied from interface:OrderServiceUpdates the quantity for the given product on the logged user's shopping cart returning the total count of ads in the cart.- Specified by:
modifyQuantityOnCartin interfaceOrderService- Throws:
IllegalActionException- When the given ad is not in the logged user's shopping cartOutOfStockException- When the new quantity is greater than the available stockFrameworkException
-
reject
public void reject(RejectOrderParams params) throws FrameworkException
Description copied from interface:OrderServiceRejects the given order- Specified by:
rejectin interfaceOrderService- Throws:
IllegalActionException- When the given order is not in eitherOrderStatus.PENDING_BUYERorOrderStatus.PENDING_SELLERstatuses.FrameworkException
-
removeCart
public int removeCart(UserLocatorVO sellerVO, CurrencyVO currencyVO)
Description copied from interface:OrderServiceRemoves the logged user's shopping cart for the given seller and currency returning the remaining count of ads in the cart- Specified by:
removeCartin interfaceOrderService
-
removeCartById
public int removeCartById(Long id) throws FrameworkException
Description copied from interface:OrderServiceSame asCRUDService.remove(Long)but returning the total count of items present the whole shopping cart- Specified by:
removeCartByIdin interfaceOrderService- Throws:
FrameworkException- See Also:
CRUDService.remove(java.lang.Long)
-
removeCartItem
public int removeCartItem(BasicAdVO ad) throws FrameworkException
Description copied from interface:OrderServiceRemoves the given product from the logged user's shopping cart returning the remaining count of ads in the cart.- Specified by:
removeCartItemin interfaceOrderService- Throws:
IllegalActionException- When the given ad is not in the logged user's shopping cartFrameworkException
-
search
public Page<OrderVO> search(OrderQuery query)
Description copied from interface:OrderServiceSearches for orders based onOrderQuery- Specified by:
searchin interfaceOrderService
-
setDeliveryMethod
public void setDeliveryMethod(SetDeliveryMethodParams deliveryInfo) throws FrameworkException
Description copied from interface:OrderServiceUpdates the delivery method information of an order when it is on theOrderStatus.PENDING_SELLERstatus and there is no delivery information yet. Afterwards, the new status will beOrderStatus.PENDING_BUYERfor final approval.- Specified by:
setDeliveryMethodin interfaceOrderService- Throws:
IllegalActionException- When the referenced order is not on theOrderStatus.PENDING_SELLERstatus or already has delivery informationFrameworkException
-
submitToBuyer
public Long submitToBuyer(OrderDTO order) throws FrameworkException, OutOfStockException
Description copied from interface:OrderServiceSubmits the given order for buyer approval- Specified by:
submitToBuyerin interfaceOrderService- Throws:
OutOfStockException- When any of the order products have ran out of stock right before processingFrameworkException
-
checkCreateNew
protected void checkCreateNew(OrderDataParams params)
Description copied from class:CRUDServiceSecurityChecks whether creating new entities with the given context parameters is allowed, throwingPermissionDeniedExceptionif not- Specified by:
checkCreateNewin classCRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams>
-
customizeData
protected void customizeData(OrderData data)
Description copied from class:CRUDServiceSecurityCan be overridden in order to process the returned data object for the given entity- Overrides:
customizeDatain classCRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams>
-
getImplementation
protected OrderServiceLocal getImplementation()
Description copied from class:CRUDServiceSecurityShould be implemented in order to return the actual implementation of the service- Specified by:
getImplementationin classCRUDServiceSecurity<OrderDTO,Order,OrderData,OrderDataParams>
-
-