Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Removed code duplication

  • Loading branch information...
commit 2b5ca046e139b7883355c0837a85bdc3a0d6c0c9 1 parent 7fbc918
@alexbiehl alexbiehl authored
View
12 src/main/java/org/fhw/asta/kasse/server/service/CheckoutServiceEndpoint.java
@@ -20,6 +20,8 @@
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = Logger.getLogger(CheckoutServiceEndpoint.class);
+ private static final String DEFAULT_RECIPIENT = "default";
+
@Inject
private UserDao userDao;
@@ -33,11 +35,11 @@ public Integer doCheckout(List<BasketItem> items, int discount, String receipien
final Optional<String> issuerLdapName = new UserLdapNameProvider(this.getThreadLocalRequest()).get();
if (issuerLdapName.isPresent() && this.userDao.exists(issuerLdapName.get())) {
- if(this.userDao.exists(receipientLdapName)) {
- return this.billOrderDao.saveBillOrder(items, discount, receipientLdapName, issuerLdapName.get(), orderState);
- } else {
- return this.billOrderDao.saveBillOrder(items, discount, "default", issuerLdapName.get(), orderState);
- }
+
+ String receipient = this.userDao.exists(receipientLdapName) ? receipientLdapName : DEFAULT_RECIPIENT;
+
+ return this.billOrderDao.saveBillOrder(items, discount, receipient, issuerLdapName.get(), orderState);
+
} else {
LOGGER.info("A non registered user tried to checkout");
throw new CheckoutException("No issuer for checkout given. Are you logged in?");
Please sign in to comment.
Something went wrong with that request. Please try again.