List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:org.yes.cart.service.domain.aspect.impl.ManagerRegistrationAspect.java
License:Apache License
@Around("execution(* org.yes.cart.service.domain.impl.ManagerServiceImpl.create(..))") public Object doCreateManager(final ProceedingJoinPoint pjp) throws Throwable { final Manager manager = (Manager) pjp.getArgs()[0]; setNewPassword(manager);// w w w . j a v a 2s.c o m return pjp.proceed(); }
From source file:org.yes.cart.service.domain.aspect.impl.ManagerRegistrationAspect.java
License:Apache License
/** Handle reset password operation. * * @param pjp {@link ProceedingJoinPoint} * @return Object//ww w. ja va 2 s .c om * @throws Throwable in case of target method errors */ @Around("execution(* org.yes.cart.service.domain.impl.ManagerServiceImpl.resetPassword(..))") public Object doResetPassword(final ProceedingJoinPoint pjp) throws Throwable { final Manager manager = (Manager) pjp.getArgs()[0]; setNewPassword(manager); return pjp.proceed(); }
From source file:org.yes.cart.service.domain.aspect.impl.OrderStateChangeListenerAspect.java
License:Apache License
/** * Perform shopper notification, about payment authorize. * * @param pjp {@link org.aspectj.lang.ProceedingJoinPoint} * @return result of original operation. * @throws Throwable re throws exception *//*from w w w . ja va 2 s . c o m*/ @Around("execution(* org.yes.cart.service.order.impl.OrderStateManagerImpl.fireTransition(..))") public Object performNotifications(final ProceedingJoinPoint pjp) throws Throwable { final Object[] args = pjp.getArgs(); final OrderEvent orderEvent = (OrderEvent) args[0]; final boolean mastered = orderEvent.getCustomerOrder().getShop().getMaster() != null; final Shop emailShop = mastered ? orderEvent.getCustomerOrder().getShop().getMaster() : orderEvent.getCustomerOrder().getShop(); final String adminEmail = emailShop.getAttributeValueByCode(AttributeNamesKeys.Shop.SHOP_ADMIN_EMAIL); final String subAdminEmail = mastered ? orderEvent.getCustomerOrder().getShop() .getAttributeValueByCode(AttributeNamesKeys.Shop.SHOP_ADMIN_EMAIL) : null; try { Object rez = pjp.proceed(); if ((Boolean) rez) { final String templateKey = getTemplateKey(orderEvent); fillNotificationParameters(orderEvent, shopperTemplates.get(templateKey), orderEvent.getCustomerOrder().getEmail()); if (mastered) { if (StringUtils.isBlank(subAdminEmail)) { LOG.error("Cant get sub-admin email address for shop " + orderEvent.getCustomerOrder().getShop().getCode()); } else { fillNotificationParameters(orderEvent, shopperTemplates.get(templateKey), subAdminEmail); } } if (StringUtils.isBlank(adminEmail)) { LOG.error("Cant get admin email address for shop " + orderEvent.getCustomerOrder().getShop().getCode()); } else { fillNotificationParameters(orderEvent, adminTemplates.get(templateKey), adminEmail); } } return rez; } catch (final OrderItemAllocationException th) { LOG.warn("Cant allocation quantity for product " + th.getProductSkuCode()); if (StringUtils.isBlank(adminEmail)) { LOG.error("Cant get admin email address for shop " + orderEvent.getCustomerOrder().getShop().getCode()); } else { final ProductSku sku = productSkuService.getProductSkuBySkuCode(th.getProductSkuCode()); fillNotificationParameters(orderEvent, "adm-cant-allocate-product-qty", new HashMap<String, Object>() { { put("sku", sku); } }, adminEmail); } throw th; } catch (Throwable th) { throw th; } }
From source file:org.yes.cart.service.domain.aspect.impl.PaymentAspect.java
License:Apache License
/** * Perform generic notification regarding payment. * * @param pjp {@link org.aspectj.lang.ProceedingJoinPoint} * @param rez payment result {@link org.yes.cart.payment.dto.Payment} * @param shopperTemplates shopper templates mapping * @param adminTemplates admin templates mapping *///from w w w . j a va 2 s . co m protected void doNotify(final ProceedingJoinPoint pjp, final String rez, final Map<String, String> shopperTemplates, final Map<String, String> adminTemplates) { final CustomerOrder order = (CustomerOrder) pjp.getArgs()[0]; final Shop pgShop = order.getShop().getMaster() != null ? order.getShop().getMaster() : order.getShop(); final PaymentGateway gateway = paymentModulesManager.getPaymentGateway(order.getPgLabel(), pgShop.getCode()); if (gateway == null) { LOG.error("Cannot send payment email because gateway {} is not resolved for {}, could it be disabled?", order.getPgLabel(), order.getShop().getCode()); return; } final String shopperTemplate = shopperTemplates.get(rez); final String adminTemplate = adminTemplates.get(rez); final HashMap<String, Object> map = new HashMap<String, Object>(); fillParameters(pjp, map); fillPaymentParameters(pjp, order, gateway, rez, map); final PaymentGatewayFeature feature = gateway.getPaymentGatewayFeatures(); // We only report online PG result to shoppers, as offline would be made by contacting shopper directly if (feature.isOnlineGateway() && StringUtils.isNotBlank(shopperTemplate)) { final HashMap<String, Object> userMap = new HashMap<String, Object>(map); userMap.put(StandardMessageListener.TEMPLATE_NAME, shopperTemplate); sendNotification(userMap); } // We notify admin with all PG results for audit purposes if (StringUtils.isNotBlank(adminTemplate)) { final String adminEmail = pgShop.getAttributeValueByCode(AttributeNamesKeys.Shop.SHOP_ADMIN_EMAIL); if (StringUtils.isNotBlank(adminEmail)) { final HashMap<String, Object> adminMap = new HashMap<String, Object>(map); adminMap.put(StandardMessageListener.TEMPLATE_NAME, adminTemplate); adminMap.put(StandardMessageListener.CUSTOMER_EMAIL, adminEmail); List<CustomerOrderPayment> payments = customerOrderPaymentService.findBy(order.getOrdernum(), null, (String) null, (String) null); adminMap.put(StandardMessageListener.PAYMENTS, payments); sendNotification(adminMap); } else { LOG.warn("Shop admin e-mail is not setup for: {}", order.getShop().getCode()); } } }
From source file:org.yes.cart.service.dto.impl.TestManagerRegistrationAspect.java
License:Apache License
/** Handle reset password operation. * * @param pjp {@link ProceedingJoinPoint} * @return Object/*from w ww. j a v a2s . c o m*/ * @throws Throwable in case of target method errors */ @Around("execution(* org.yes.cart.service.domain.impl.ManagerServiceImpl.resetPassword(..))") public Object doResetPassword(final ProceedingJoinPoint pjp) throws Throwable { final Manager manager = (Manager) pjp.getArgs()[0]; final String generatedPassword = phrazeGenerator.getNextPassPhrase(); final String passwordHash = hashHelper.getHash(generatedPassword); manager.setPassword(passwordHash); return pjp.proceed(); }
From source file:org.yes.cart.service.mail.impl.TestCustomerRegistrationAspect.java
License:Apache License
/** * Handle reset password operation./*ww w . j ava 2s. com*/ * * @param pjp {@link org.aspectj.lang.ProceedingJoinPoint} * @return Object * @throws Throwable in case of target method errors */ @Around("execution(* org.yes.cart.service.domain.impl.CustomerServiceImpl.create(..))") public Object doSetPassword(final ProceedingJoinPoint pjp) throws Throwable { setPassword((Customer) pjp.getArgs()[0]); return pjp.proceed(); }
From source file:org.yes.cart.service.mail.impl.TestCustomerRegistrationAspect.java
License:Apache License
/** * Handle reset password operation.//from www. j av a2 s . c o m * * @param pjp {@link org.aspectj.lang.ProceedingJoinPoint} * @return Object * @throws Throwable in case of target method errors */ @Around("execution(* org.yes.cart.service.domain.impl.CustomerServiceImpl.resetPassword(..))") public Object doResetPassword(final ProceedingJoinPoint pjp) throws Throwable { setPassword((Customer) pjp.getArgs()[0]); return pjp.proceed(); }
From source file:org.yes.cart.service.mail.impl.TestManagerRegistrationAspect.java
License:Apache License
/** * Handle reset password operation.//from ww w . j a v a2 s. c o m * * @param pjp {@link ProceedingJoinPoint} * @return Object * @throws Throwable in case of target method errors */ @Around("execution(* org.yes.cart.service.domain.impl.ManagerServiceImpl.create(..))") public Object doSetPassword(final ProceedingJoinPoint pjp) throws Throwable { setPassword((Manager) pjp.getArgs()[0]); return pjp.proceed(); }
From source file:org.yes.cart.service.mail.impl.TestManagerRegistrationAspect.java
License:Apache License
/** * Handle reset password operation./*from www .java 2 s .c o m*/ * * @param pjp {@link ProceedingJoinPoint} * @return Object * @throws Throwable in case of target method errors */ @Around("execution(* org.yes.cart.service.domain.impl.ManagerServiceImpl.resetPassword(..))") public Object doResetPassword(final ProceedingJoinPoint pjp) throws Throwable { setPassword((Manager) pjp.getArgs()[0]); return pjp.proceed(); }
From source file:org.yes.cart.web.aspect.ContactFormAspect.java
License:Apache License
/** * Perform notification about contact us message. * * @param pjp join point/*from w w w. j a v a 2 s. c o m*/ * * @return inherited return * * @throws Throwable in case it was in underlying method */ protected Object notifyInternal(final ProceedingJoinPoint pjp) throws Throwable { final Object[] args = pjp.getArgs(); final Shop shop = (Shop) args[0]; final String email = (String) args[1]; final Map<String, Object> registrationData = (Map<String, Object>) args[2]; registrationData.put("email", email); final RegistrationMessage registrationMessage = new RegistrationMessageImpl(); final ShoppingCart cart = ApplicationDirector.getShoppingCart(); if (cart != null) { registrationMessage.setLocale(cart.getCurrentLocale()); } registrationMessage.setMailTemplatePathChain(themeService.getMailTemplateChainByShopId(shop.getShopId())); registrationMessage.setTemplateName("adm-contactform-request"); final String emailTo = determineFromEmail(shop); // contact request to admin registrationMessage.setEmail(emailTo); registrationMessage.setShopMailFrom(emailTo); registrationMessage.setShopId(shop.getShopId()); registrationMessage.setShopCode(shop.getCode()); registrationMessage.setShopName(shop.getName()); registrationMessage.setShopUrl(transformShopUrls(shop)); registrationMessage.setAdditionalData(registrationData); sendNotification(registrationMessage); LOG.info("ContactUs message was send to queue {}", registrationMessage); return pjp.proceed(); }