if(customer != null){
CustomerMarketArea customerMarketArea = customer.getCurrentCustomerMarketArea(marketArea.getId());
if(customerMarketArea != null){
CustomerOptin customerOptin = customerMarketArea.getOptins(CustomerOptin.OPTIN_TYPE_WWW_NEWSLETTER);
if(customerOptin != null){
throw new UniqueNewsletterSubscriptionException();
}
}
}
CustomerOptin customerOptin = new CustomerOptin();