Subversion Repositories SmartDukaan

Rev

Rev 37764 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.service.user;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * Who may extend a store's billing grace date. Shared by the fofo RetailerController and the web
 * V2FofoRetailerController. Store status changes are authorised by StoreStatusService instead.
 */
public final class StoreAccess {

        public static final List<String> EXTEND_BILLING = Collections.unmodifiableList(Arrays.asList(
                        "kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com"));

        private StoreAccess() {
        }

        /**
         * @param action the verb shown in the error, e.g. "close store"
         */
        public static void check(List<String> allowed, String emailId, String action) throws ProfitMandiBusinessException {
                if (emailId == null || !allowed.contains(emailId)) {
                        throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
                                        "You are not authorise to " + action);
                }
        }
}